]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
fincore: add column RES
authorKarel Zak <kzak@redhat.com>
Mon, 27 Mar 2017 11:08:40 +0000 (13:08 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 27 Mar 2017 11:08:40 +0000 (13:08 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/fincore.1
misc-utils/fincore.c

index 942dd70d1551be87525c4aec1ab64da053b1ec24..1625bf68d522e5d65f488cd6ea02e10ea01a6a6d 100644 (file)
@@ -10,10 +10,9 @@ fincore \- count pages of file contents in core
 .I file ...
 .SH DESCRIPTION
 .B fincore
-counts pages of file contents being resident in memory(in core), and
-reports the numbers.  An output line has 3 columns: the number of
-pages in core, a file size, and a file name.  If an error
-occurs during counting, then an error message is printed to the stderr and
+counts pages of file contents being resident in memory(in core), and reports
+the numbers.  If an error occurs during counting, then an error message is
+printed to the stderr and
 .B fincore
 continues processing the rest of files listed in a command line.
 
index a2fc1d1113514940633f5dd87b38ef11d92c8a0e..b867c2d06671009362563b65a828d35705fc9c97 100644 (file)
@@ -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;