diff options
author | Karel Zak | 2018-04-18 14:45:21 +0200 |
---|---|---|
committer | Karel Zak | 2018-04-18 14:45:21 +0200 |
commit | 3a645e3658095e7e7dbdebbc938ddb85bbbc02bb (patch) | |
tree | b4a4bea92f47836cbfc95c48ffe6713c61765c5b /misc-utils/findmnt.c | |
parent | fincore: use scols_column_set_json_type() (diff) | |
download | kernel-qcow2-util-linux-3a645e3658095e7e7dbdebbc938ddb85bbbc02bb.tar.gz kernel-qcow2-util-linux-3a645e3658095e7e7dbdebbc938ddb85bbbc02bb.tar.xz kernel-qcow2-util-linux-3a645e3658095e7e7dbdebbc938ddb85bbbc02bb.zip |
findmnt: use scols_column_set_json_type()
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, 24 insertions, 2 deletions
diff --git a/misc-utils/findmnt.c b/misc-utils/findmnt.c index 184b6f7d7..4d55cde33 100644 --- a/misc-utils/findmnt.c +++ b/misc-utils/findmnt.c @@ -1606,6 +1606,7 @@ int main(int argc, char *argv[]) scols_table_set_name(table, "filesystems"); for (i = 0; i < ncolumns; i++) { + struct libscols_column *cl; int fl = get_column_flags(i); int id = get_column_id(i); @@ -1617,11 +1618,32 @@ int main(int argc, char *argv[]) "is not enabled"), get_column_name(i)); goto leave; } - if (!scols_table_new_column(table, get_column_name(i), - get_column_whint(i), fl)) { + cl = scols_table_new_column(table, get_column_name(i), + get_column_whint(i), fl); + if (!cl) { warn(_("failed to allocate output column")); goto leave; } + + if (flags & FL_JSON) { + switch (id) { + case COL_SIZE: + case COL_AVAIL: + case COL_USED: + if (!(flags & FL_BYTES)) + break; + /* fallthrough */ + case COL_ID: + case COL_FREQ: + case COL_PASSNO: + case COL_TID: + scols_column_set_json_type(cl, SCOLS_JSON_NUMBER); + break; + default: + scols_column_set_json_type(cl, SCOLS_JSON_STRING); + break; + } + } } /* |