summaryrefslogtreecommitdiffstats
path: root/misc-utils/fincore.c
diff options
context:
space:
mode:
authorKarel Zak2017-03-27 13:08:40 +0200
committerKarel Zak2017-03-27 13:08:40 +0200
commite4e8b57be2b63fed82647e4d5efd0e0eaf36b19e (patch)
tree975d521370af1a87bd93f0fd2e4a8a385e08577a /misc-utils/fincore.c
parenttests: remove status=none dd(1) from fincore (diff)
downloadkernel-qcow2-util-linux-e4e8b57be2b63fed82647e4d5efd0e0eaf36b19e.tar.gz
kernel-qcow2-util-linux-e4e8b57be2b63fed82647e4d5efd0e0eaf36b19e.tar.xz
kernel-qcow2-util-linux-e4e8b57be2b63fed82647e4d5efd0e0eaf36b19e.zip
fincore: add column RES
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'misc-utils/fincore.c')
-rw-r--r--misc-utils/fincore.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/misc-utils/fincore.c b/misc-utils/fincore.c
index a2fc1d111..b867c2d06 100644
--- a/misc-utils/fincore.c
+++ b/misc-utils/fincore.c
@@ -53,11 +53,13 @@ struct colinfo {
enum {
COL_PAGES,
COL_SIZE,
- COL_FILE
+ COL_FILE,
+ COL_RES
};
static struct colinfo infos[] = {
- [COL_PAGES] = { "PAGES", 1, SCOLS_FL_RIGHT, N_("number of memory page")},
+ [COL_PAGES] = { "PAGES", 1, SCOLS_FL_RIGHT, N_("file data residend in memory in pages")},
+ [COL_RES] = { "RES", 5, SCOLS_FL_RIGHT, N_("file data residend in memory in bytes")},
[COL_SIZE] = { "SIZE", 5, SCOLS_FL_RIGHT, N_("size of the file")},
[COL_FILE] = { "FILE", 4, 0, N_("file name")},
};
@@ -129,6 +131,17 @@ static int add_output_data(struct fincore_control *ctl,
xasprintf(&tmp, "%jd", (intmax_t) count_incore);
scols_line_refer_data(ln, i, tmp);
break;
+ case COL_RES:
+ {
+ uintmax_t res = (uintmax_t) count_incore * ctl->pagesize;
+
+ if (ctl->bytes)
+ xasprintf(&tmp, "%ju", res);
+ else
+ tmp = size_to_human_string(SIZE_SUFFIX_1LETTER, res);
+ scols_line_refer_data(ln, i, tmp);
+ break;
+ }
case COL_SIZE:
if (ctl->bytes)
xasprintf(&tmp, "%jd", (intmax_t) file_size);
@@ -327,6 +340,7 @@ int main(int argc, char ** argv)
}
if (!ncolumns) {
+ columns[ncolumns++] = COL_RES;
columns[ncolumns++] = COL_PAGES;
columns[ncolumns++] = COL_SIZE;
columns[ncolumns++] = COL_FILE;