Commit f72f3824 authored by Saied Kazemi's avatar Saied Kazemi Committed by Pavel Emelyanov

Do not fail if /tmp does not exist

Currently if /tmp does not exist, CRIU fails because it will not be
able to create a temporary directory there.  But when checkpointing
and restoring containers, we cannot rely on the existence of /tmp.
For such containers, we should use root (/).  The temporary directory
will be removed after CRIU is done.
Signed-off-by: 's avatarSaied Kazemi <saied@google.com>
Acked-by: 's avatarAndrew Vagin <avagin@odin.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent ad03d67a
...@@ -774,7 +774,9 @@ int open_mount(unsigned int s_dev) ...@@ -774,7 +774,9 @@ int open_mount(unsigned int s_dev)
static int open_mountpoint(struct mount_info *pm) static int open_mountpoint(struct mount_info *pm)
{ {
int fd = -1, ns_old = -1; int fd = -1, ns_old = -1;
char mnt_path[] = "/tmp/cr-tmpfs.XXXXXX"; char mnt_path_tmp[] = "/tmp/cr-tmpfs.XXXXXX";
char mnt_path_root[] = "/cr-tmpfs.XXXXXX";
char *mnt_path = mnt_path_tmp;
int cwd_fd; int cwd_fd;
/* /*
...@@ -803,7 +805,10 @@ static int open_mountpoint(struct mount_info *pm) ...@@ -803,7 +805,10 @@ static int open_mountpoint(struct mount_info *pm)
if (switch_ns(root_item->pid.real, &mnt_ns_desc, &ns_old) < 0) if (switch_ns(root_item->pid.real, &mnt_ns_desc, &ns_old) < 0)
goto out; goto out;
if (mkdtemp(mnt_path) == NULL) { mnt_path = mkdtemp(mnt_path_tmp);
if (mnt_path == NULL && errno == ENOENT)
mnt_path = mkdtemp(mnt_path_root);
if (mnt_path == NULL) {
pr_perror("Can't create a temporary directory"); pr_perror("Can't create a temporary directory");
goto out; goto out;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment