diff options
author | Harald Hoyer | 2011-11-14 14:11:01 +0100 |
---|---|---|
committer | Karel Zak | 2011-11-14 14:49:37 +0100 |
commit | 944de78b5d83e548f7c428ef5c08c69e6984cc4f (patch) | |
tree | f2b17cd168dfb5f0dac081e95135f0b3f3d6356d /sys-utils/switch_root.c | |
parent | fdisk: enable expert menu with SGI label (diff) | |
download | kernel-qcow2-util-linux-944de78b5d83e548f7c428ef5c08c69e6984cc4f.tar.gz kernel-qcow2-util-linux-944de78b5d83e548f7c428ef5c08c69e6984cc4f.tar.xz kernel-qcow2-util-linux-944de78b5d83e548f7c428ef5c08c69e6984cc4f.zip |
switch_root: umount mount points we cannot move with MNT_DETACH
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>
Diffstat (limited to 'sys-utils/switch_root.c')
-rw-r--r-- | sys-utils/switch_root.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/sys-utils/switch_root.c b/sys-utils/switch_root.c index e50f3101a..1c7375dbe 100644 --- a/sys-utils/switch_root.c +++ b/sys-utils/switch_root.c @@ -40,6 +40,10 @@ #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; } |