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
}
}
- *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);
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;
}
if (!tb || !itr || !parent)
return -EINVAL;
- DBG(TAB, mnt_debug_h(tb, "lookup next child of %s",
+ DBG(TAB, mnt_debug_h(tb, "lookup next child of '%s'",
mnt_fs_get_target(parent)));
parent_id = mnt_fs_get_id(parent);
{
char *mnt;
- if (!tb || !path)
+ if (!tb || !path || !*path)
return NULL;
if (direction != MNT_ITER_FORWARD && direction != MNT_ITER_BACKWARD)
return NULL;
- DBG(TAB, mnt_debug_h(tb, "lookup MOUNTPOINT: %s", path));
+ DBG(TAB, mnt_debug_h(tb, "lookup MOUNTPOINT: '%s'", path));
mnt = strdup(path);
if (!mnt)
assert(tb);
assert(path);
- if (!tb || !path)
+ if (!tb || !path || !*path)
return NULL;
if (direction != MNT_ITER_FORWARD && direction != MNT_ITER_BACKWARD)
return NULL;
- DBG(TAB, mnt_debug_h(tb, "lookup TARGET: %s", path));
+ DBG(TAB, mnt_debug_h(tb, "lookup TARGET: '%s'", path));
/* native @target */
mnt_reset_iter(&itr, direction);
if (!tb->cache || !(cn = mnt_resolve_path(path, tb->cache)))
return NULL;
+ DBG(TAB, mnt_debug_h(tb, "lookup canonical TARGET: '%s'", cn));
+
/* canonicalized paths in struct libmnt_table */
mnt_reset_iter(&itr, direction);
while(mnt_table_next_fs(tb, &itr, &fs) == 0) {
const char *p;
assert(tb);
- if (!tb || !path)
+ if (!tb || !path || !*path)
return NULL;
if (direction != MNT_ITER_FORWARD && direction != MNT_ITER_BACKWARD)
return NULL;
- DBG(TAB, mnt_debug_h(tb, "lookup srcpath: %s", path));
+ DBG(TAB, mnt_debug_h(tb, "lookup SRCPATH: '%s'", path));
/* native paths */
mnt_reset_iter(&itr, direction);
if (!path || !tb->cache || !(cn = mnt_resolve_path(path, tb->cache)))
return NULL;
+ DBG(TAB, mnt_debug_h(tb, "lookup canonical SRCPATH: '%s'", cn));
+
/* canonicalized paths in struct libmnt_table */
if (ntags < mnt_table_get_nents(tb)) {
mnt_reset_iter(&itr, direction);
assert(tag);
assert(val);
- if (!tb || !tag || !val)
+ if (!tb || !tag || !*tag || !val)
return NULL;
if (direction != MNT_ITER_FORWARD && direction != MNT_ITER_BACKWARD)
return NULL;
if (direction != MNT_ITER_FORWARD && direction != MNT_ITER_BACKWARD)
return NULL;
- DBG(TAB, mnt_debug_h(tb, "lookup SOURCE: %s", source));
+ DBG(TAB, mnt_debug_h(tb, "lookup SOURCE: '%s'", source));
- if (source && strchr(source, '=')) {
+ if (source && *source && strchr(source, '=')) {
char *tag, *val;
if (blkid_parse_tag_string(source, &tag, &val) == 0) {
assert(tb);
assert(target);
- if (!tb || !target)
+ if (!tb || !target || !*target || !source || !*source)
return NULL;
if (direction != MNT_ITER_FORWARD && direction != MNT_ITER_BACKWARD)
return NULL;
assert(fs);
assert(fsroot);
- DBG(TAB, mnt_debug("lookup fs-root for %s", mnt_fs_get_source(fs)));
+ DBG(TAB, mnt_debug("lookup fs-root for '%s'", mnt_fs_get_source(fs)));
fstype = mnt_fs_get_fstype(fs);