summaryrefslogtreecommitdiffstats
path: root/libmount/src/context.c
diff options
context:
space:
mode:
authorKarel Zak2017-06-07 11:35:26 +0200
committerKarel Zak2017-06-07 11:35:26 +0200
commitf8416301c195d50a21cb54d9ea9abeccc40f9ee7 (patch)
tree9c55ab36703691d74d0b674f99631d2001e59acc /libmount/src/context.c
parentrename: add -o to the man page (diff)
downloadkernel-qcow2-util-linux-f8416301c195d50a21cb54d9ea9abeccc40f9ee7.tar.gz
kernel-qcow2-util-linux-f8416301c195d50a21cb54d9ea9abeccc40f9ee7.tar.xz
kernel-qcow2-util-linux-f8416301c195d50a21cb54d9ea9abeccc40f9ee7.zip
libmount: use mount table filter on --no-canonicalize
The umount command option --no-canonicalize means that the path is already canonical. So, we can use mount table filter in this case too. Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src/context.c')
-rw-r--r--libmount/src/context.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/libmount/src/context.c b/libmount/src/context.c
index 3620f6525..5725ab1ad 100644
--- a/libmount/src/context.c
+++ b/libmount/src/context.c
@@ -1124,7 +1124,10 @@ int mnt_context_get_mtab_for_target(struct libmnt_context *cxt,
char *cn_tgt = NULL;
int rc;
- if (mnt_stat_mountpoint(tgt, &st) == 0 && S_ISDIR(st.st_mode)) {
+ if (mnt_context_is_nocanonicalize(cxt))
+ mnt_context_set_tabfilter(cxt, mtab_filter, (void *) tgt);
+
+ else if (mnt_stat_mountpoint(tgt, &st) == 0 && S_ISDIR(st.st_mode)) {
cache = mnt_context_get_cache(cxt);
cn_tgt = mnt_resolve_path(tgt, cache);
if (cn_tgt)
@@ -1132,12 +1135,10 @@ int mnt_context_get_mtab_for_target(struct libmnt_context *cxt,
}
rc = mnt_context_get_mtab(cxt, mtab);
+ mnt_context_set_tabfilter(cxt, NULL, NULL);
- if (cn_tgt) {
- mnt_context_set_tabfilter(cxt, NULL, NULL);
- if (!cache)
- free(cn_tgt);
- }
+ if (cn_tgt && !cache)
+ free(cn_tgt);
return rc;
}