From d88857d6805f38355b8ad4fb029972a31db175fe Mon Sep 17 00:00:00 2001 From: phk Date: Wed, 2 Jun 2004 07:09:34 +0000 Subject: Give du(1) a -m option to report in megabytes. Submitted by: Vasily Korytov PR: 66976 --- usr.bin/du/du.1 | 11 +++-------- usr.bin/du/du.c | 8 ++++++-- 2 files changed, 9 insertions(+), 10 deletions(-) (limited to 'usr.bin') diff --git a/usr.bin/du/du.1 b/usr.bin/du/du.1 index edbe569..e8f36b1 100644 --- a/usr.bin/du/du.1 +++ b/usr.bin/du/du.1 @@ -44,7 +44,7 @@ .Op Fl I Ar mask .Op Fl a | s | d Ar depth .Op Fl c -.Op Fl h | k +.Op Fl h | k | m .Op Fl x .Op Ar .Sh DESCRIPTION @@ -55,13 +55,6 @@ and for each directory in the file hierarchy rooted in each directory argument. If no file is specified, the block usage of the hierarchy rooted in the current directory is displayed. -If the -.Fl k -flag is specified, the number of 1024-byte -blocks used by the file is displayed, otherwise -.Xr getbsize 3 -is used to determine the preferred block size. -Partial numbers of blocks are rounded up. .Pp The options are as follows: .Bl -tag -width indent @@ -98,6 +91,8 @@ directories deep. Display a grand total. .It Fl k Display block counts in 1024-byte (1-Kbyte) blocks. +.It Fl m +Display block counts in 104857-byte (1-Mbyte) blocks. .It Fl x File system mount points are not traversed. .El diff --git a/usr.bin/du/du.c b/usr.bin/du/du.c index f2010f1..6b85e17 100644 --- a/usr.bin/du/du.c +++ b/usr.bin/du/du.c @@ -96,7 +96,7 @@ main(int argc, char *argv[]) depth = INT_MAX; SLIST_INIT(&ignores); - while ((ch = getopt(argc, argv, "HI:LPasd:chkrx")) != -1) + while ((ch = getopt(argc, argv, "HI:LPasd:chkmrx")) != -1) switch (ch) { case 'H': Hflag = 1; @@ -140,6 +140,10 @@ main(int argc, char *argv[]) hflag = 0; putenv("BLOCKSIZE=1024"); break; + case 'm': + hflag = 0; + putenv("BLOCKSIZE=1048576"); + break; case 'r': /* Compatibility. */ break; case 'x': @@ -430,7 +434,7 @@ static void usage(void) { (void)fprintf(stderr, - "usage: du [-H | -L | -P] [-a | -s | -d depth] [-c] [-h | -k] [-x] [-I mask] [file ...]\n"); + "usage: du [-H | -L | -P] [-a | -s | -d depth] [-c] [-h | -k | -m] [-x] [-I mask] [file ...]\n"); exit(EX_USAGE); } -- cgit v1.1