summaryrefslogtreecommitdiffstats
path: root/misc-utils/findmnt.c
diff options
context:
space:
mode:
authorKarel Zak2010-11-18 21:06:27 +0100
committerKarel Zak2010-11-24 17:08:32 +0100
commit9ead000613ea527f047597d2978ca605f1314418 (patch)
treeddab6612d4195d985ea58eb300bbaffbb02bcd5e /misc-utils/findmnt.c
parentlib: [tt] add TT_FL_RIGHT, add columns list parser (diff)
downloadkernel-qcow2-util-linux-9ead000613ea527f047597d2978ca605f1314418.tar.gz
kernel-qcow2-util-linux-9ead000613ea527f047597d2978ca605f1314418.tar.xz
kernel-qcow2-util-linux-9ead000613ea527f047597d2978ca605f1314418.zip
findmnt: apply new changes from tt.c
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'misc-utils/findmnt.c')
-rw-r--r--misc-utils/findmnt.c58
1 files changed, 16 insertions, 42 deletions
diff --git a/misc-utils/findmnt.c b/misc-utils/findmnt.c
index 0e3cc3765..9d3547b1a 100644
--- a/misc-utils/findmnt.c
+++ b/misc-utils/findmnt.c
@@ -190,46 +190,6 @@ static int column_name_to_id(const char *name, size_t namesz)
return -1;
}
-/*
- * parses list of columns from @str and add IDs to columns[]
- */
-static int set_columns(const char *str)
-{
- const char *begin = NULL, *p;
-
- ncolumns = 0;
-
- if (!str || !*str)
- return -1;
-
- ncolumns = 0;
-
- for (p = str; p && *p; p++) {
- const char *end = NULL;
- int id;
-
- if (!begin)
- begin = p; /* begin of the column name */
- if (*p == ',')
- end = p; /* terminate the name */
- if (*(p + 1) == '\0')
- end = p + 1; /* end of string */
- if (!begin || !end)
- continue;
- if (end <= begin)
- return -1;
-
- id = column_name_to_id(begin, end - begin);
- if (id == -1)
- return -1;
- columns[ ncolumns++ ] = id;
- begin = NULL;
- if (end && !*end)
- break;
- }
- return 0;
-}
-
/* Returns LABEL or UUID */
static const char *get_tag(mnt_fs *fs, const char *tagname)
{
@@ -446,6 +406,8 @@ again:
static int __attribute__((__noreturn__)) usage(FILE *out)
{
+ int i;
+
fprintf(out, _(
"\nUsage:\n"
" %1$s [options]\n"
@@ -478,6 +440,17 @@ static int __attribute__((__noreturn__)) usage(FILE *out)
" -S, --source <string> device, LABEL= or UUID=device\n"
" -T, --target <string> mountpoint\n\n"));
+
+ fprintf(out, _("\nAvailable columns:\n"));
+
+ for (i = 0; i < __NCOLUMNS; i++) {
+
+ fprintf(out, " %-12s", infos[i].name);
+ if (i && !((i+1) % 3))
+ fputc('\n', out);
+ }
+ fputc('\n', out);
+
fprintf(out, _("\nFor more information see findmnt(1).\n"));
exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
@@ -577,7 +550,8 @@ int main(int argc, char *argv[])
set_all_columns_truncate(FALSE);
break;
case 'o':
- if (set_columns(optarg))
+ if (tt_parse_columns_list(optarg, columns, &ncolumns,
+ column_name_to_id))
exit(EXIT_FAILURE);
break;
case 'O':
@@ -695,7 +669,7 @@ int main(int argc, char *argv[])
}
for (i = 0; i < ncolumns; i++) {
- int fl = get_column_truncate(i) ? TT_FL_TRUNCATE : 0;
+ int fl = get_column_truncate(i) ? TT_FL_TRUNC : 0;
if (get_column_id(i) == COL_TARGET && (tt_flags & TT_FL_TREE))
fl |= TT_FL_TREE;