[CRIU] [PATCH] Do not fail if /tmp does not exist
Saied Kazemi
saied at google.com
Fri Apr 3 18:02:56 PDT 2015
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 at google.com>
---
mount.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/mount.c b/mount.c
index 079430a..4ae1150 100644
--- a/mount.c
+++ b/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[] = "/tmp2/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;
}
--
1.9.1
More information about the CRIU
mailing list