]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
findmnt: add -D, --df option to imitate df(1)
authorDave Reisner <d@falconindy.com>
Sun, 18 Mar 2012 03:36:33 +0000 (23:36 -0400)
committerKarel Zak <kzak@redhat.com>
Tue, 20 Mar 2012 08:53:47 +0000 (09:53 +0100)
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
misc-utils/findmnt.8
misc-utils/findmnt.c

index 9dc5301e420c095978523cefefd5ddd8364b0257..e98233009d5a7a6ecd9641fd73946b5e9241b52a 100644 (file)
@@ -49,6 +49,9 @@ Search in
 The output is in the tree-like format.  This is the default.
 .IP "\fB\-c, \-\-canonicalize\fP"
 Canonicalize all printed paths.
+.IP "\fB\-D, \-\-df\fP"
+Imitate the output of df(1). This option is equivalent to
+"-o SOURCE,FSTYPE,SIZE,USED,AVAIL,USE%,TARGET".
 .IP "\fB\-d, \-\-direction \fIword\fP"
 The search direction -
 .IR forward
index 6bec6866dfc15681ea8a2b96d7d6df232938c29b..acaedfc569db3eecc23fac56b9da4b7b12b72f22 100644 (file)
@@ -885,6 +885,7 @@ static void __attribute__((__noreturn__)) usage(FILE *out)
        fprintf(out, _(
        " -a, --ascii            use ASCII chars for tree formatting\n"
        " -c, --canonicalize     canonicalize printed paths\n"
+       " -D, --df               imitate the output of df(1)\n"
        " -d, --direction <word> direction of search, 'forward' or 'backward'\n"
        " -e, --evaluate         convert tags (LABEL/UUID) to device names\n"
        " -F, --tab-file <path>  alternative file for --fstab, --mtab or --kernel options\n"
@@ -931,7 +932,7 @@ int main(int argc, char *argv[])
        struct libmnt_table *tb = NULL;
        char **tabfiles = NULL;
        int direction = MNT_ITER_FORWARD;
-       int i, c, rc = -1, timeout = -1;
+       int i, c, rc = -1, timeout = -1, df_output = 0;
        int ntabfiles = 0, tabtype = 0;
 
        /* table.h */
@@ -941,6 +942,7 @@ int main(int argc, char *argv[])
            { "ascii",        0, 0, 'a' },
            { "canonicalize", 0, 0, 'c' },
            { "direction",    1, 0, 'd' },
+           { "df",           0, 0, 'D' },
            { "evaluate",     0, 0, 'e' },
            { "first-only",   0, 0, 'f' },
            { "fstab",        0, 0, 's' },
@@ -977,7 +979,7 @@ int main(int argc, char *argv[])
        tt_flags |= TT_FL_TREE;
 
        while ((c = getopt_long(argc, argv,
-                               "acd:ehifF:o:O:p::Pklmnrst:uvRS:T:w:",
+                               "acDd:ehifF:o:O:p::Pklmnrst:uvRS:T:w:",
                                longopts, NULL)) != -1) {
                switch(c) {
                case 'a':
@@ -986,6 +988,10 @@ int main(int argc, char *argv[])
                case 'c':
                        flags |= FL_CANONICALIZE;
                        break;
+               case 'D':
+                       tt_flags &= ~TT_FL_TREE;
+                       df_output = 1;
+                       break;
                case 'd':
                        if (!strcmp(optarg, "forward"))
                                direction = MNT_ITER_FORWARD;
@@ -1095,6 +1101,16 @@ int main(int argc, char *argv[])
                }
        }
 
+       if (df_output) {
+               columns[ncolumns++] = COL_SOURCE;
+               columns[ncolumns++] = COL_FSTYPE;
+               columns[ncolumns++] = COL_SIZE;
+               columns[ncolumns++] = COL_USED;
+               columns[ncolumns++] = COL_AVAIL;
+               columns[ncolumns++] = COL_USEPERC;
+               columns[ncolumns++] = COL_TARGET;
+       }
+
        /* default columns */
        if (!ncolumns) {
                if (flags & FL_POLL)