public inbox for util-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Reisner <d@falconindy.com>
To: util-linux@vger.kernel.org
Cc: Dave Reisner <dreisner@archlinux.org>
Subject: [PATCH 5/5] findmnt: add -D, --df option to imitate df(1)
Date: Sat, 17 Mar 2012 23:36:33 -0400	[thread overview]
Message-ID: <1332041793-7919-5-git-send-email-dreisner@archlinux.org> (raw)
In-Reply-To: <1332041793-7919-1-git-send-email-dreisner@archlinux.org>

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
---
 misc-utils/findmnt.8 |    3 +++
 misc-utils/findmnt.c |   20 ++++++++++++++++++--
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/misc-utils/findmnt.8 b/misc-utils/findmnt.8
index c1734ca..8ad4432 100644
--- a/misc-utils/findmnt.8
+++ b/misc-utils/findmnt.8
@@ -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
diff --git a/misc-utils/findmnt.c b/misc-utils/findmnt.c
index 547be66..84092d2 100644
--- a/misc-utils/findmnt.c
+++ b/misc-utils/findmnt.c
@@ -890,6 +890,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"
@@ -936,7 +937,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 */
@@ -946,6 +947,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' },
@@ -982,7 +984,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':
@@ -991,6 +993,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;
@@ -1100,6 +1106,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)
-- 
1.7.9.4


  parent reply	other threads:[~2012-03-18  3:36 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-18  3:36 [PATCH 1/5] checkxalloc: nudge regex, fix newfound instances Dave Reisner
2012-03-18  3:36 ` [PATCH 2/5] tunelp: remove old, now unneeded header Dave Reisner
2012-03-20  9:53   ` Karel Zak
2012-03-18  3:36 ` [PATCH 3/5] include/ttyutils.h: add include guards Dave Reisner
2012-03-20  9:53   ` Karel Zak
2012-03-18  3:36 ` [PATCH 4/5] findmnt: add FS size, avail, used, and use% columns Dave Reisner
2012-03-20  9:54   ` Karel Zak
2012-03-18  3:36 ` Dave Reisner [this message]
2012-03-20 10:09   ` [PATCH 5/5] findmnt: add -D, --df option to imitate df(1) Karel Zak
2012-03-18 14:53 ` [PATCH 1/5] checkxalloc: nudge regex, fix newfound instances Davidlohr Bueso
2012-03-20  8:50 ` Karel Zak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1332041793-7919-5-git-send-email-dreisner@archlinux.org \
    --to=d@falconindy.com \
    --cc=dreisner@archlinux.org \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox