diff options
author | Karel Zak | 2008-07-02 14:26:51 +0200 |
---|---|---|
committer | Karel Zak | 2008-07-02 15:01:28 +0200 |
commit | e84feaecfdf44a33ef9eccc5a56c8a6999466140 (patch) | |
tree | 29d8c5744a3dbd7129c8f5518b08cd43409b2214 /mount/umount.c | |
parent | selinux: is_selinux_enabled() returns 0, 1 and -1 (diff) | |
download | kernel-qcow2-util-linux-e84feaecfdf44a33ef9eccc5a56c8a6999466140.tar.gz kernel-qcow2-util-linux-e84feaecfdf44a33ef9eccc5a56c8a6999466140.tar.xz kernel-qcow2-util-linux-e84feaecfdf44a33ef9eccc5a56c8a6999466140.zip |
umount: improve "-d" option for autoclear loops
The new loop auto-destruct feature detaches automatically loop devices
when no longer used. This means they are detached with the umount()
call. But when we call umount with -d, del_loop() is called and fails
because the ioctl() returns ENXIO. We have to check for autoclear
loop devices rather than blindly call del_loop().
Reported-by: Matthias Koenig <mkoenig@suse.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'mount/umount.c')
-rw-r--r-- | mount/umount.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/mount/umount.c b/mount/umount.c index 65c8622b5..b2bbdae3c 100644 --- a/mount/umount.c +++ b/mount/umount.c @@ -190,6 +190,7 @@ umount_one (const char *spec, const char *node, const char *type, int res; int status; const char *loopdev; + int myloop = 0; /* Special case for root. As of 0.99pl10 we can (almost) unmount root; the kernel will remount it readonly so that we can carry on running @@ -201,7 +202,7 @@ umount_one (const char *spec, const char *node, const char *type, || streq (node, "rootfs")); if (isroot) nomtab++; - + /* * Call umount.TYPE for types that require a separate umount program. * All such special things must occur isolated in the types string. @@ -209,6 +210,13 @@ umount_one (const char *spec, const char *node, const char *type, if (check_special_umountprog(spec, node, type, &status)) return status; + /* + * Ignore the option "-d" for non-loop devices and loop devices with + * LO_FLAGS_AUTOCLEAR flag. + */ + if (delloop && is_loop_device(spec) && !is_loop_autoclear(spec)) + myloop = 1; + umnt_err = umnt_err2 = 0; if (lazy) { res = umount2 (node, MNT_DETACH); @@ -310,7 +318,7 @@ umount_one (const char *spec, const char *node, const char *type, } /* Also free loop devices when -d flag is given */ - if (delloop && is_loop_device(spec)) + if (myloop) loopdev = spec; } gotloop: |