From a405d25b6056b92a4fde525ce4cb752f0e0140d9 Mon Sep 17 00:00:00 2001 From: Mike Rapoport Date: Sun, 7 Aug 2016 17:22:51 +0300 Subject: [PATCH] criu/lazy-pages: fix socket creation with relative images-dir The UNIX sockets do not like relative paths. Assuming both lazy-pages daemon and restore use the same opts.work_dir, their working directory full path will be the same. Signed-off-by: Mike Rapoport Signed-off-by: Pavel Emelyanov --- criu/uffd.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/criu/uffd.c b/criu/uffd.c index b81947293..a55a69d72 100644 --- a/criu/uffd.c +++ b/criu/uffd.c @@ -119,16 +119,22 @@ static void lpi_hash_fini(void) static int prepare_sock_addr(struct sockaddr_un *saddr) { + char cwd[PATH_MAX]; int len; + if (!getcwd(cwd, PATH_MAX)) { + pr_perror("Cannot get CWD\n"); + return -1; + } + memset(saddr, 0, sizeof(struct sockaddr_un)); saddr->sun_family = AF_UNIX; len = snprintf(saddr->sun_path, sizeof(saddr->sun_path), - "%s/%s", opts.work_dir, LAZY_PAGES_SOCK_NAME); + "%s/%s", cwd, LAZY_PAGES_SOCK_NAME); if (len >= sizeof(saddr->sun_path)) { pr_err("Wrong UNIX socket name: %s/%s\n", - opts.work_dir, LAZY_PAGES_SOCK_NAME); + cwd, LAZY_PAGES_SOCK_NAME); return -1; }