]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
mount: (old) check for LD_FLAGS_AUTOCLEAR more carefully
authorKarel Zak <kzak@redhat.com>
Mon, 2 Apr 2012 15:34:07 +0000 (17:34 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 2 Apr 2012 15:34:07 +0000 (17:34 +0200)
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=803799
Signed-off-by: Karel Zak <kzak@redhat.com>
mount/umount.c

index a6fcd333ccc32c203f62ad1c9a4b79840591a25c..71cc0ee58c1887ed491c0f4a996b282badcf684e 100644 (file)
@@ -276,7 +276,6 @@ umount_one (const char *spec, const char *node, const char *type,
        int extra_flags = 0;
        const char *loopdev, *target = node;
        char *targetbuf = NULL;
-       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
@@ -301,12 +300,6 @@ umount_one (const char *spec, const char *node, const char *type,
        /* Skip the actual umounting for --fake */
        if (fake)
                goto writemtab;
-       /*
-        * Ignore the option "-d" for non-loop devices and loop devices with
-        * LO_FLAGS_AUTOCLEAR flag.
-        */
-       if (delloop && is_loopdev(spec))
-               myloop = 1;
 
        if (restricted) {
                if (umount_nofollow_support())
@@ -409,12 +402,21 @@ umount_one (const char *spec, const char *node, const char *type,
                }
 
                /* Also free loop devices when -d flag is given */
-               if (myloop)
+               if (delloop)
                        loopdev = spec;
        }
  gotloop:
-       if (loopdev && !loopdev_is_autoclear(loopdev))
-               loopdev_delete(loopdev);
+       if (loopdev) {
+               struct loopdev_cxt lc;
+
+               loopcxt_init(&lc, 0);
+               loopcxt_set_device(&lc, loopdev);
+
+               if (loopcxt_get_backing_file(&lc)
+                   && loopcxt_is_autoclear(&lc) == 0)
+                       loopcxt_delete_device(&lc);
+               loopcxt_deinit(&lc);
+       }
 
  writemtab:
        if (!nomtab &&