summaryrefslogtreecommitdiffstats
path: root/misc-utils/findmnt.c
diff options
context:
space:
mode:
authorKarel Zak2013-01-14 14:50:50 +0100
committerKarel Zak2013-01-14 14:50:50 +0100
commit3e373967ec06d246ffede78fd78d078df3b770ff (patch)
treef52e479fbddd1d930830ea21f682dedb59760179 /misc-utils/findmnt.c
parentfindmnt: add PROPAGATION column (diff)
downloadkernel-qcow2-util-linux-3e373967ec06d246ffede78fd78d078df3b770ff.tar.gz
kernel-qcow2-util-linux-3e373967ec06d246ffede78fd78d078df3b770ff.tar.xz
kernel-qcow2-util-linux-3e373967ec06d246ffede78fd78d078df3b770ff.zip
findmnt: make --target usable with bind mounts
The --target <non-mount-point> functionality should be enabled only if previous regular search found nothing to avoid collisions with bind mounts, because to detect mountpoint we use traditional child / parent stat.st_dev comparison which does not work for bind mounts (--bind /A /A). Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'misc-utils/findmnt.c')
-rw-r--r--misc-utils/findmnt.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/misc-utils/findmnt.c b/misc-utils/findmnt.c
index fed1a3c20..358082a91 100644
--- a/misc-utils/findmnt.c
+++ b/misc-utils/findmnt.c
@@ -1335,13 +1335,6 @@ int main(int argc, char *argv[])
}
mnt_table_set_cache(tb, cache);
- if (tabtype == TABTYPE_KERNEL
- && (flags & FL_NOSWAPMATCH)
- && get_match(COL_TARGET))
- /*
- * enable extra functionality for target match
- */
- enable_extra_target_match();
/*
* initialize output formatting (tt.h)
@@ -1381,10 +1374,24 @@ int main(int argc, char *argv[])
} else if ((tt_flags & TT_FL_TREE) && is_listall_mode())
/* whole tree */
rc = create_treenode(tt, tb, NULL, NULL);
- else
+ else {
/* whole lits of sub-tree */
rc = add_matching_lines(tb, tt, direction);
+ if (rc != 0
+ && tabtype == TABTYPE_KERNEL
+ && (flags & FL_NOSWAPMATCH)
+ && get_match(COL_TARGET)) {
+ /*
+ * Found nothing, maybe the --target is regular file,
+ * try it again with extra functionality for target
+ * match
+ */
+ enable_extra_target_match();
+ rc = add_matching_lines(tb, tt, direction);
+ }
+ }
+
/*
* Print the output table for non-poll modes
*/