Support the 1003.2-92 -P flag for a `portable output format'; based on
Ben Harris' patch in standards/11208 but extended about output alignment and documentation.
This commit is contained in:
parent
e26a7ce86b
commit
bd6b91bddb
33
bin/df/df.1
33
bin/df/df.1
@ -1,4 +1,4 @@
|
|||||||
.\" $NetBSD: df.1,v 1.18 2000/06/26 21:16:15 christos Exp $
|
.\" $NetBSD: df.1,v 1.19 2000/10/15 17:50:10 kleink Exp $
|
||||||
.\"
|
.\"
|
||||||
.\" Copyright (c) 1989, 1990, 1993
|
.\" Copyright (c) 1989, 1990, 1993
|
||||||
.\" The Regents of the University of California. All rights reserved.
|
.\" The Regents of the University of California. All rights reserved.
|
||||||
@ -41,7 +41,7 @@
|
|||||||
.Nd display free disk space
|
.Nd display free disk space
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.Nm
|
.Nm
|
||||||
.Op Fl aikln
|
.Op Fl aiklnP
|
||||||
.Op Fl t Ar type
|
.Op Fl t Ar type
|
||||||
.Op Ar file | Ar file_system ...
|
.Op Ar file | Ar file_system ...
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
@ -95,6 +95,35 @@ When this option is specified,
|
|||||||
.Nm
|
.Nm
|
||||||
will not request new statistics from the file systems, but will respond
|
will not request new statistics from the file systems, but will respond
|
||||||
with the possibly stale statistics that were previously obtained.
|
with the possibly stale statistics that were previously obtained.
|
||||||
|
.It Fl P
|
||||||
|
Produce output in the following portable format:
|
||||||
|
.Pp
|
||||||
|
If both the
|
||||||
|
.Fl P
|
||||||
|
and
|
||||||
|
.Fl k
|
||||||
|
option are specified, the output will be preceeded by the following header
|
||||||
|
line, formatted to match the data following it:
|
||||||
|
.Bd -literal
|
||||||
|
"Filesystem 1024-blocks Used Available Capacity Mounted on\\n"
|
||||||
|
.Ed
|
||||||
|
.Pp
|
||||||
|
If the
|
||||||
|
.Fl P
|
||||||
|
option is specified without the
|
||||||
|
.Fl k
|
||||||
|
options, the output will be preceeded by the following header line,
|
||||||
|
formatted to matche the data following it:
|
||||||
|
.Bd -literal
|
||||||
|
"Filesystem <blksize>-blocks Used Available Capacity Mounted on\\n"
|
||||||
|
.Ed
|
||||||
|
.Pp
|
||||||
|
The header line is followed by data formatted as follows:
|
||||||
|
.Bd -literal
|
||||||
|
"%s %d %d %d %d%% %s\\n", <file system name>, <total space>,
|
||||||
|
<space used>, <space free>, <percentage used>,
|
||||||
|
<file system root>
|
||||||
|
.Ed
|
||||||
.It Fl t Ar type
|
.It Fl t Ar type
|
||||||
Is used to indicate the actions should only be taken on
|
Is used to indicate the actions should only be taken on
|
||||||
filesystems of the specified type.
|
filesystems of the specified type.
|
||||||
|
24
bin/df/df.c
24
bin/df/df.c
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: df.c,v 1.34 2000/06/26 21:16:16 christos Exp $ */
|
/* $NetBSD: df.c,v 1.35 2000/10/15 17:50:10 kleink Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1980, 1990, 1993, 1994
|
* Copyright (c) 1980, 1990, 1993, 1994
|
||||||
@ -49,7 +49,7 @@ __COPYRIGHT(
|
|||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)df.c 8.7 (Berkeley) 4/2/94";
|
static char sccsid[] = "@(#)df.c 8.7 (Berkeley) 4/2/94";
|
||||||
#else
|
#else
|
||||||
__RCSID("$NetBSD: df.c,v 1.34 2000/06/26 21:16:16 christos Exp $");
|
__RCSID("$NetBSD: df.c,v 1.35 2000/10/15 17:50:10 kleink Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ void maketypelist __P((char *));
|
|||||||
long regetmntinfo __P((struct statfs **, long));
|
long regetmntinfo __P((struct statfs **, long));
|
||||||
void usage __P((void));
|
void usage __P((void));
|
||||||
|
|
||||||
int aflag, iflag, kflag, lflag, nflag;
|
int aflag, iflag, kflag, lflag, nflag, Pflag;
|
||||||
char **typelist = NULL;
|
char **typelist = NULL;
|
||||||
struct ufs_args mdev;
|
struct ufs_args mdev;
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ main(argc, argv)
|
|||||||
int ch, i, maxwidth, width;
|
int ch, i, maxwidth, width;
|
||||||
char *mntpt;
|
char *mntpt;
|
||||||
|
|
||||||
while ((ch = getopt(argc, argv, "aiklnt:")) != -1)
|
while ((ch = getopt(argc, argv, "aiklnPt:")) != -1)
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case 'a':
|
case 'a':
|
||||||
aflag = 1;
|
aflag = 1;
|
||||||
@ -111,6 +111,9 @@ main(argc, argv)
|
|||||||
case 'n':
|
case 'n':
|
||||||
nflag = 1;
|
nflag = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'P':
|
||||||
|
Pflag = 1;
|
||||||
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
if (typelist != NULL)
|
if (typelist != NULL)
|
||||||
errx(1, "only one -t option may be specified.");
|
errx(1, "only one -t option may be specified.");
|
||||||
@ -345,12 +348,13 @@ prtstat(sfsp, maxwidth)
|
|||||||
if (++timesthrough == 1) {
|
if (++timesthrough == 1) {
|
||||||
if (kflag) {
|
if (kflag) {
|
||||||
blocksize = 1024;
|
blocksize = 1024;
|
||||||
header = "1K-blocks";
|
header = Pflag ? "1024-blocks" : "1K-blocks";
|
||||||
headerlen = strlen(header);
|
headerlen = strlen(header);
|
||||||
} else
|
} else
|
||||||
header = getbsize(&headerlen, &blocksize);
|
header = getbsize(&headerlen, &blocksize);
|
||||||
(void)printf("%-*.*s %s Used Avail Capacity",
|
(void)printf("%-*.*s %s Used %9s Capacity",
|
||||||
maxwidth, maxwidth, "Filesystem", header);
|
maxwidth, maxwidth, "Filesystem", header,
|
||||||
|
Pflag ? "Available" : "Avail");
|
||||||
if (iflag)
|
if (iflag)
|
||||||
(void)printf(" iused ifree %%iused");
|
(void)printf(" iused ifree %%iused");
|
||||||
(void)printf(" Mounted on\n");
|
(void)printf(" Mounted on\n");
|
||||||
@ -358,11 +362,11 @@ prtstat(sfsp, maxwidth)
|
|||||||
(void)printf("%-*.*s", maxwidth, maxwidth, sfsp->f_mntfromname);
|
(void)printf("%-*.*s", maxwidth, maxwidth, sfsp->f_mntfromname);
|
||||||
used = sfsp->f_blocks - sfsp->f_bfree;
|
used = sfsp->f_blocks - sfsp->f_bfree;
|
||||||
availblks = sfsp->f_bavail + used;
|
availblks = sfsp->f_bavail + used;
|
||||||
(void)printf(" %*ld %8ld %8ld", headerlen,
|
(void)printf(" %*ld %8ld %9ld", headerlen,
|
||||||
fsbtoblk(sfsp->f_blocks, sfsp->f_bsize, blocksize),
|
fsbtoblk(sfsp->f_blocks, sfsp->f_bsize, blocksize),
|
||||||
fsbtoblk(used, sfsp->f_bsize, blocksize),
|
fsbtoblk(used, sfsp->f_bsize, blocksize),
|
||||||
fsbtoblk(sfsp->f_bavail, sfsp->f_bsize, blocksize));
|
fsbtoblk(sfsp->f_bavail, sfsp->f_bsize, blocksize));
|
||||||
(void)printf(" %6s",
|
(void)printf("%9s",
|
||||||
availblks == 0 ? full : strpct((u_long)used, (u_long)availblks, 0));
|
availblks == 0 ? full : strpct((u_long)used, (u_long)availblks, 0));
|
||||||
if (iflag) {
|
if (iflag) {
|
||||||
inodes = sfsp->f_files;
|
inodes = sfsp->f_files;
|
||||||
@ -459,7 +463,7 @@ usage()
|
|||||||
extern char *__progname;
|
extern char *__progname;
|
||||||
|
|
||||||
(void)fprintf(stderr,
|
(void)fprintf(stderr,
|
||||||
"Usage: %s [-aikln] [-t type] [file | file_system ...]\n",
|
"Usage: %s [-aiklnP] [-t type] [file | file_system ...]\n",
|
||||||
__progname);
|
__progname);
|
||||||
exit(1);
|
exit(1);
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user