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)
{
static int __attribute__((__noreturn__)) usage(FILE *out)
{
+ int i;
+
fprintf(out, _(
"\nUsage:\n"
" %1$s [options]\n"
" -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);
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':
}
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;