mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-30 22:05:36 +00:00
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: Saied Kazemi <saied@google.com> Acked-by: Andrew Vagin <avagin@odin.com> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
committed by
Pavel Emelyanov
parent
ad03d67a4b
commit
f72f3824f4
9
mount.c
9
mount.c
@@ -774,7 +774,9 @@ int open_mount(unsigned int s_dev)
|
||||
static int open_mountpoint(struct mount_info *pm)
|
||||
{
|
||||
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;
|
||||
|
||||
/*
|
||||
@@ -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)
|
||||
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");
|
||||
goto out;
|
||||
}
|
||||
|
Reference in New Issue
Block a user