diff options
author | Karel Zak <kzak@redhat.com> | 2010-04-08 15:02:32 +0200 |
---|---|---|
committer | Karel Zak <kzak@redhat.com> | 2010-06-03 15:20:12 +0200 |
commit | ac808156cb45a6ae6696563991eb7e8811982f3c (patch) | |
tree | 6dc4a480ccc3fec20199d763d4b8e4fe176187aa /misc-utils/findmnt.c | |
parent | 3ef87248bf6567651af96bf49a77f177a4a29621 (diff) | |
download | util-linux-old-ac808156cb45a6ae6696563991eb7e8811982f3c.tar.gz |
findmnt: don't swap source and target for tags
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'misc-utils/findmnt.c')
-rw-r--r-- | misc-utils/findmnt.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/misc-utils/findmnt.c b/misc-utils/findmnt.c index 70678235..6ce1ec8a 100644 --- a/misc-utils/findmnt.c +++ b/misc-utils/findmnt.c @@ -358,6 +358,7 @@ static mnt_tab *parse_tabfile(const char *path) mnt_tab_strerror(tb, buf, sizeof(buf)); warnx(_("%s: parse error: %s"), path, buf); } + return tb; } @@ -582,7 +583,7 @@ int main(int argc, char *argv[]) if (tabfile) errx_mutually_exclusive("--{fstab,mtab,kernel}"); tabfile = _PATH_MNTTAB; - flags &= ~TT_FL_TREE; + tt_flags &= ~TT_FL_TREE; break; case 'k': /* kernel (mountinfo) */ if (tabfile) @@ -593,10 +594,6 @@ int main(int argc, char *argv[]) set_match(COL_FSTYPE, optarg); break; case 'r': - if (!(tt_flags & TT_FL_TREE) && - !(tt_flags & TT_FL_RAW)) - errx_mutually_exclusive("--{raw,list}"); - tt_flags &= ~TT_FL_TREE; /* disable the default */ tt_flags |= TT_FL_RAW; /* enable raw */ break; @@ -644,9 +641,23 @@ int main(int argc, char *argv[]) if (!is_listall_mode() || (flags & FL_FIRSTONLY)) tt_flags &= ~TT_FL_TREE; + if (!(flags & FL_NOSWAPMATCH) && + !get_match(COL_TARGET) && get_match(COL_SOURCE)) { + /* + * Check if we can swap source and target, it's + * not possible if the source is LABEL=/UUID= + */ + const char *x = get_match(COL_SOURCE); + + if (!strncmp(x, "LABEL=", 6) || !strncmp(x, "UUID=", 5)) + flags |= FL_NOSWAPMATCH; + } + /* * initialize libmount */ + mnt_init_debug(0); + tb = parse_tabfile(tabfile); if (!tb) goto leave; @@ -656,6 +667,7 @@ int main(int argc, char *argv[]) warn(_("failed to initialize libmount iterator")); goto leave; } + cache = mnt_new_cache(); if (!cache) { warn(_("failed to initialize libmount cache")); @@ -671,6 +683,7 @@ int main(int argc, char *argv[]) warn(_("failed to initialize output table")); goto leave; } + for (i = 0; i < ncolumns; i++) { int fl = get_column_truncate(i) ? TT_FL_TRUNCATE : 0; |