Commit b7ed4bf0 by Christian Seiler Committed by Serge Hallyn

Change rootfs pinning mechnism

Chane pinning mechanism: Use $rootfs/lxc.hold instead of $rootfs.hold (in case $rootfs is a mountpoint itself), but delete the file immediately after creating it (but keep it open). This will keep the root filesystem busy but does not leave any unnecessary files lying around. Signed-off-by: 's avatarChristian Seiler <christian@iwakd.de> Signed-off-by: 's avatarSerge Hallyn <serge.hallyn@ubuntu.com>
parent 368bbc02
...@@ -671,9 +671,10 @@ static int mount_rootfs_block(const char *rootfs, const char *target) ...@@ -671,9 +671,10 @@ static int mount_rootfs_block(const char *rootfs, const char *target)
/* /*
* pin_rootfs * pin_rootfs
* if rootfs is a directory, then open ${rootfs}.hold for writing for the * if rootfs is a directory, then open ${rootfs}/lxc.hold for writing for
* duration of the container run, to prevent the container from marking the * the duration of the container run, to prevent the container from marking
* underlying fs readonly on shutdown. * the underlying fs readonly on shutdown. unlink the file immediately so
* no name pollution is happens
* return -1 on error. * return -1 on error.
* return -2 if nothing needed to be pinned. * return -2 if nothing needed to be pinned.
* return an open fd (>=0) if we pinned it. * return an open fd (>=0) if we pinned it.
...@@ -700,11 +701,14 @@ int pin_rootfs(const char *rootfs) ...@@ -700,11 +701,14 @@ int pin_rootfs(const char *rootfs)
if (!S_ISDIR(s.st_mode)) if (!S_ISDIR(s.st_mode))
return -2; return -2;
ret = snprintf(absrootfspin, MAXPATHLEN, "%s%s", absrootfs, ".hold"); ret = snprintf(absrootfspin, MAXPATHLEN, "%s/lxc.hold", absrootfs);
if (ret >= MAXPATHLEN) if (ret >= MAXPATHLEN)
return -1; return -1;
fd = open(absrootfspin, O_CREAT | O_RDWR, S_IWUSR|S_IRUSR); fd = open(absrootfspin, O_CREAT | O_RDWR, S_IWUSR|S_IRUSR);
if (fd < 0)
return fd;
(void)unlink(absrootfspin);
return fd; return fd;
} }
......
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