]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: canonicalize for conversion from loopdev backing file
authorKarel Zak <kzak@redhat.com>
Mon, 5 Aug 2013 11:58:01 +0000 (13:58 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 5 Aug 2013 11:58:01 +0000 (13:58 +0200)
  # mount foo.img /mnt
  # umount foo.img
  umount: foo.img: not mounted

The loopdev code (and sysfs backing_file) uses absolute paths, but
libmount does not canonicalize the path before lookup for the backing file.

References: https://bugzilla.redhat.com/show_bug.cgi?id=950497
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/context_umount.c

index 2b791c44d3717248880735f1cbc0fafa89b6872d..b02902c45af1bd04eb55cfb9afe225ed14422312 100644 (file)
@@ -161,7 +161,12 @@ try_loopdev:
                struct stat st;
 
                if (stat(tgt, &st) == 0 && S_ISREG(st.st_mode)) {
-                       int count = loopdev_count_by_backing_file(tgt, &loopdev);
+                       int count;
+
+                       cn_tgt = mnt_resolve_path(tgt, cache);
+                       count = loopdev_count_by_backing_file(cn_tgt, &loopdev);
+                       if (!cache)
+                               free(cn_tgt);
                        if (count == 1) {
                                DBG(CXT, mnt_debug_h(cxt,
                                        "umount: %s --> %s (retry)", tgt, loopdev));