]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
switch_root: umount mount points we cannot move with MNT_DETACH
authorHarald Hoyer <harald@redhat.com>
Mon, 14 Nov 2011 13:11:01 +0000 (14:11 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 14 Nov 2011 13:49:37 +0000 (14:49 +0100)
If a mount point cannot be moved to the new root, umount it with
MNT_DETACH, so that it is lazy umounted and does not show up in
/proc/mounts anymore.

[kzak@redhat.com: - add MNT_DETACH macro fallback]

Signed-off-by: Harald Hoyer <harald@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/switch_root.c

index e50f3101a5c6f7c8773be0028451efda7cd286ee..1c7375dbed51963e44599e8673ce1e11912a2a92 100644 (file)
 #define MS_MOVE 8192
 #endif
 
+#ifndef MNT_DETACH
+#define MNT_DETACH       0x00000002    /* Just detach from the tree */
+#endif
+
 /* remove all files/directories below dirName -- don't cross mountpoints */
 static int recursiveRemove(int fd)
 {
@@ -131,7 +135,7 @@ static int switchroot(const char *newroot)
 
                if ((stat(newmount, &sb) != 0) || (sb.st_dev != newroot_stat.st_dev)) {
                        /* mount point seems to be mounted already or stat failed */
-                       umount(umounts[i]);
+                       umount2(umounts[i], MNT_DETACH);
                        continue;
                }