summaryrefslogtreecommitdiffstats
path: root/libmount/src/context_umount.c
diff options
context:
space:
mode:
authorKarel Zak2013-06-17 13:02:15 +0200
committerKarel Zak2013-06-17 13:02:15 +0200
commit7ba207e781c7af3945d3a718651b87425685131e (patch)
treed8edf4afc0d81a68f94a68c5421b4446677e70c2 /libmount/src/context_umount.c
parentlibblkid: support pseudo PARTUUID= for MBR (diff)
downloadkernel-qcow2-util-linux-7ba207e781c7af3945d3a718651b87425685131e.tar.gz
kernel-qcow2-util-linux-7ba207e781c7af3945d3a718651b87425685131e.tar.xz
kernel-qcow2-util-linux-7ba207e781c7af3945d3a718651b87425685131e.zip
libmount: be robust for empty target/source strings
* lib/canonicalize.c: don't interpret empty strings as relative paths * libmount: more robust libmnt_table find function and debug messages References: https://bugzilla.novell.com/show_bug.cgi?id=825150 Signed-off-by: Karel Zak <kzak@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src/context_umount.c')
-rw-r--r--libmount/src/context_umount.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/libmount/src/context_umount.c b/libmount/src/context_umount.c
index 4a8659c9c..7707991eb 100644
--- a/libmount/src/context_umount.c
+++ b/libmount/src/context_umount.c
@@ -71,11 +71,17 @@ int mnt_context_find_umount_fs(struct libmnt_context *cxt,
struct libmnt_cache *cache = NULL;
char *cn_tgt = NULL, *loopdev = NULL;
+ if (pfs)
+ *pfs = NULL;
+
if (!cxt || !tgt || !pfs)
return -EINVAL;
DBG(CXT, mnt_debug_h(cxt, "umount: lookup FS for '%s'", tgt));
+ if (!*tgt)
+ return 1; /* empty string is not error */
+
/*
* The mtab file maybe huge and on systems with utab we have to merge
* userspace mount options into /proc/self/mountinfo. This all is
@@ -169,9 +175,12 @@ try_loopdev:
}
}
- *pfs = fs;
+ if (pfs)
+ *pfs = fs;
free(loopdev);
+ DBG(CXT, mnt_debug_h(cxt, "umount fs: %s", fs ? mnt_fs_get_target(fs) :
+ "<not found>"));
return fs ? 0 : 1;
err:
free(loopdev);
@@ -197,7 +206,7 @@ static int lookup_umount_fs(struct libmnt_context *cxt)
if (rc < 0)
return rc;
if (rc == 1 || !fs) {
- DBG(CXT, mnt_debug_h(cxt, "umount: cannot find %s in mtab", tgt));
+ DBG(CXT, mnt_debug_h(cxt, "umount: cannot find '%s' in mtab", tgt));
return 0;
}