From: Karel Zak Date: Fri, 5 Oct 2012 18:35:34 +0000 (+0200) Subject: libmount: fix umount file.img X-Git-Tag: v2.23-rc1~653 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dc3ea1335696434863c9ef4376858dcd4df6ec1b;p=thirdparty%2Futil-linux.git libmount: fix umount file.img The umount optimization (commit 9cc03553f7b8494c7193024eec6e13b903eb2eec) has to be disabled if the umount argument is not a directory. Reported-by: Milan Broz Signed-off-by: Karel Zak --- diff --git a/libmount/src/context_umount.c b/libmount/src/context_umount.c index 92663a218a..ce095bff17 100644 --- a/libmount/src/context_umount.c +++ b/libmount/src/context_umount.c @@ -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);