diff options
author | Karel Zak | 2013-01-17 12:02:03 +0100 |
---|---|---|
committer | Karel Zak | 2013-01-17 12:08:09 +0100 |
commit | 31f67453a39bd8b7ce957adc8bcb246d7d4c4bd0 (patch) | |
tree | 60bd5b6213d11605e9855ce6e3b02fb6b4dacf42 /misc-utils/findmnt.c | |
parent | mount: make --verbose more verbose about propagation (diff) | |
download | kernel-qcow2-util-linux-31f67453a39bd8b7ce957adc8bcb246d7d4c4bd0.tar.gz kernel-qcow2-util-linux-31f67453a39bd8b7ce957adc8bcb246d7d4c4bd0.tar.xz kernel-qcow2-util-linux-31f67453a39bd8b7ce957adc8bcb246d7d4c4bd0.zip |
findmnt: use tree output in more cases
It seems that we can create the tree also if output is restricted by
fstype or options filter, for example
$ findmnt -t cgroups
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'misc-utils/findmnt.c')
-rw-r--r-- | misc-utils/findmnt.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/misc-utils/findmnt.c b/misc-utils/findmnt.c index 358082a91..f6c864fc4 100644 --- a/misc-utils/findmnt.c +++ b/misc-utils/findmnt.c @@ -146,6 +146,9 @@ static int nactions; /* libmount cache */ static struct libmnt_cache *cache; +static int match_func(struct libmnt_fs *fs, void *data __attribute__ ((__unused__))); + + static int get_column_id(int num) { assert(num < ncolumns); @@ -639,9 +642,12 @@ static int create_treenode(struct tt *tt, struct libmnt_table *tb, if (!itr) goto leave; - line = add_line(tt, fs, parent_line); - if (!line) - goto leave; + if ((flags & FL_SUBMOUNTS) || match_func(fs, NULL)) { + line = add_line(tt, fs, parent_line); + if (!line) + goto leave; + } else + line = parent_line; /* * add all children to the output table @@ -835,6 +841,10 @@ again: return fs; } +/* + * Filter out unwanted lines for --list output or top level lines for + * --submounts tree output. + */ static int add_matching_lines(struct libmnt_table *tb, struct tt *tt, int direction) { @@ -1299,8 +1309,10 @@ int main(int argc, char *argv[]) /* don't care about submounts if list all mounts */ flags &= ~FL_SUBMOUNTS; - if (!(flags & FL_SUBMOUNTS) && - (!is_listall_mode() || (flags & FL_FIRSTONLY))) + if (!(flags & FL_SUBMOUNTS) && ((flags & FL_FIRSTONLY) + || get_match(COL_TARGET) + || get_match(COL_SOURCE) + || get_match(COL_MAJMIN))) tt_flags &= ~TT_FL_TREE; if (!(flags & FL_NOSWAPMATCH) && @@ -1371,10 +1383,10 @@ int main(int argc, char *argv[]) /* poll mode (accept the first tabfile only) */ rc = poll_table(tb, tabfiles ? *tabfiles : _PATH_PROC_MOUNTINFO, timeout, tt, direction); - } else if ((tt_flags & TT_FL_TREE) && is_listall_mode()) + } else if ((tt_flags & TT_FL_TREE) && !(flags & FL_SUBMOUNTS)) { /* whole tree */ rc = create_treenode(tt, tb, NULL, NULL); - else { + } else { /* whole lits of sub-tree */ rc = add_matching_lines(tb, tt, direction); |