]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: fix umount file.img
authorKarel Zak <kzak@redhat.com>
Fri, 5 Oct 2012 18:35:34 +0000 (20:35 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 5 Oct 2012 18:38:49 +0000 (20:38 +0200)
The umount optimization (commit 9cc03553f7b8494c7193024eec6e13b903eb2eec)
has to be disabled if the umount argument is not a directory.

Reported-by: Milan Broz <mbroz@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/context_umount.c

index 92663a218a4abf65be984cbd818347eca72e9feb..ce095bff1732e6a00da2bc6b4ead5c8974e101f8 100644 (file)
@@ -83,12 +83,16 @@ static int lookup_umount_fs(struct libmnt_context *cxt)
         * where LABEL, UUID or symlinks are to canonicalized. It means that
         * it's usable only for canonicalized stuff (e.g. kernel mountinfo).
         */
-       if (!cxt->mtab_writable && *tgt == '/') {
-               /* we'll canonicalized /proc/self/mountinfo */
-               cache = mnt_context_get_cache(cxt);
-               cn_tgt = mnt_resolve_path(tgt, cache);
-               if (cn_tgt)
-                       mnt_context_set_tabfilter(cxt, mtab_filter, cn_tgt);
+       if (!cxt->mtab_writable && *tgt == '/') {
+               struct stat st;
+
+               if (stat(tgt, &st) == 0 && S_ISDIR(st.st_mode)) {
+                       /* we'll canonicalized /proc/self/mountinfo */
+                       cache = mnt_context_get_cache(cxt);
+                       cn_tgt = mnt_resolve_path(tgt, cache);
+                       if (cn_tgt)
+                               mnt_context_set_tabfilter(cxt, mtab_filter, cn_tgt);
+               }
        }
        rc = mnt_context_get_mtab(cxt, &mtab);