diff options
author | Karel Zak | 2018-04-18 14:32:39 +0200 |
---|---|---|
committer | Karel Zak | 2018-04-18 14:32:39 +0200 |
commit | 8945d9dc63ae0f2a3824d2d69b7979761b391a14 (patch) | |
tree | f8d961f693ffbd5fa0050f52d3c44fbd3916e540 /misc-utils/fincore.c | |
parent | libmount: fix mnt_table_is_fs_mounted() for NFS bind mounts. (diff) | |
download | kernel-qcow2-util-linux-8945d9dc63ae0f2a3824d2d69b7979761b391a14.tar.gz kernel-qcow2-util-linux-8945d9dc63ae0f2a3824d2d69b7979761b391a14.tar.xz kernel-qcow2-util-linux-8945d9dc63ae0f2a3824d2d69b7979761b391a14.zip |
fincore: use scols_column_set_json_type()
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'misc-utils/fincore.c')
-rw-r--r-- | misc-utils/fincore.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/misc-utils/fincore.c b/misc-utils/fincore.c index f9534e85b..6bad2c040 100644 --- a/misc-utils/fincore.c +++ b/misc-utils/fincore.c @@ -368,9 +368,29 @@ int main(int argc, char ** argv) for (i = 0; i < ncolumns; i++) { const struct colinfo *col = get_column_info(i); + struct libscols_column *cl; - if (!scols_table_new_column(ctl.tb, col->name, col->whint, col->flags)) + cl = scols_table_new_column(ctl.tb, col->name, col->whint, col->flags); + if (!cl) err(EXIT_FAILURE, _("failed to allocate output column")); + + if (ctl.json) { + int id = get_column_id(i); + + switch (id) { + case COL_FILE: + scols_column_set_json_type(cl, SCOLS_JSON_STRING); + break; + case COL_SIZE: + case COL_RES: + if (!ctl.bytes) + break; + /* fallthrough */ + default: + scols_column_set_json_type(cl, SCOLS_JSON_NUMBER); + break; + } + } } for(; optind < argc; optind++) { |