Add -m option, similar to -k, but display output in 1024*1024 byte units.

Patch submitted by Chris Pinnock <C.J.E.Pinnock@qmw.ac.uk> in PR 11849,
adjusted for NetBSD-current by me.
This commit is contained in:
hubertf 2000-12-30 16:20:58 +00:00
parent eb24c4857c
commit 69939b09cd
2 changed files with 22 additions and 9 deletions

View File

@ -1,4 +1,4 @@
.\" $NetBSD: df.1,v 1.19 2000/10/15 17:50:10 kleink Exp $
.\" $NetBSD: df.1,v 1.20 2000/12/30 16:20:58 hubertf Exp $
.\"
.\" Copyright (c) 1989, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@ -41,7 +41,7 @@
.Nd display free disk space
.Sh SYNOPSIS
.Nm
.Op Fl aiklnP
.Op Fl aiklmnP
.Op Fl t Ar type
.Op Ar file | Ar file_system ...
.Sh DESCRIPTION
@ -80,7 +80,11 @@ Include statistics on the number of free inodes.
By default, all sizes are reported in 512-byte block counts.
The
.Fl k
option causes the numbers to be reported in kilobyte counts.
option causes the numbers to be reported in kilobyte (1024 bytes) counts.
.It Fl m
The
.Fl m
option causes the numbers to be reported in megabyte (1024*1024 bytes) counts.
.It Fl l
Display statistics only about mounted file systems with the
.Dv MNT_LOCAL
@ -143,7 +147,9 @@ If the environment variable
.Ev BLOCKSIZE
is set, and the
.Fl k
option is not specified, the block counts will be displayed in units of that
and
.Fl m
options are not specified, the block counts will be displayed in units of that
size block.
.El
.Sh SEE ALSO

View File

@ -1,4 +1,4 @@
/* $NetBSD: df.c,v 1.35 2000/10/15 17:50:10 kleink Exp $ */
/* $NetBSD: df.c,v 1.36 2000/12/30 16:20:58 hubertf Exp $ */
/*
* Copyright (c) 1980, 1990, 1993, 1994
@ -49,7 +49,7 @@ __COPYRIGHT(
#if 0
static char sccsid[] = "@(#)df.c 8.7 (Berkeley) 4/2/94";
#else
__RCSID("$NetBSD: df.c,v 1.35 2000/10/15 17:50:10 kleink Exp $");
__RCSID("$NetBSD: df.c,v 1.36 2000/12/30 16:20:58 hubertf Exp $");
#endif
#endif /* not lint */
@ -79,7 +79,7 @@ void maketypelist __P((char *));
long regetmntinfo __P((struct statfs **, long));
void usage __P((void));
int aflag, iflag, kflag, lflag, nflag, Pflag;
int aflag, iflag, kflag, lflag, mflag, nflag, Pflag;
char **typelist = NULL;
struct ufs_args mdev;
@ -94,7 +94,7 @@ main(argc, argv)
int ch, i, maxwidth, width;
char *mntpt;
while ((ch = getopt(argc, argv, "aiklnPt:")) != -1)
while ((ch = getopt(argc, argv, "aiklmnPt:")) != -1)
switch (ch) {
case 'a':
aflag = 1;
@ -108,6 +108,9 @@ main(argc, argv)
case 'l':
lflag = 1;
break;
case 'm':
mflag = 1;
break;
case 'n':
nflag = 1;
break;
@ -350,6 +353,10 @@ prtstat(sfsp, maxwidth)
blocksize = 1024;
header = Pflag ? "1024-blocks" : "1K-blocks";
headerlen = strlen(header);
} else if (mflag) {
blocksize = 1024 * 1024;
header = Pflag ? "1048576-blocks" : "1M-blocks";
headerlen = strlen(header);
} else
header = getbsize(&headerlen, &blocksize);
(void)printf("%-*.*s %s Used %9s Capacity",
@ -463,7 +470,7 @@ usage()
extern char *__progname;
(void)fprintf(stderr,
"Usage: %s [-aiklnP] [-t type] [file | file_system ...]\n",
"Usage: %s [-aiklmnP] [-t type] [file | file_system ...]\n",
__progname);
exit(1);
/* NOTREACHED */