summaryrefslogtreecommitdiffstats
path: root/bin/df
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2008-11-23 13:03:44 +0000
committerpjd <pjd@FreeBSD.org>2008-11-23 13:03:44 +0000
commit1142201df8c0741d9b787f4dbd27031ab5f93e60 (patch)
treed7734a042b6043823c0a3658df4d2251eeba19a7 /bin/df
parent70a61d9b8a30f8ae702fc97e2d7668c9d7df305f (diff)
downloadFreeBSD-src-1142201df8c0741d9b787f4dbd27031ab5f93e60.zip
FreeBSD-src-1142201df8c0741d9b787f4dbd27031ab5f93e60.tar.gz
Implement -T option as found in Linux df(1). When given, file system type
will be included in output. Reviewed and tested by: keramida MFC after: 2 weeks
Diffstat (limited to 'bin/df')
-rw-r--r--bin/df/df.16
-rw-r--r--bin/df/df.c20
2 files changed, 19 insertions, 7 deletions
diff --git a/bin/df/df.1 b/bin/df/df.1
index 8cdff7d..7d4253d 100644
--- a/bin/df/df.1
+++ b/bin/df/df.1
@@ -29,7 +29,7 @@
.\" @(#)df.1 8.3 (Berkeley) 5/8/95
.\" $FreeBSD$
.\"
-.Dd April 22, 2004
+.Dd November 23, 2008
.Dt DF 1
.Os
.Sh NAME
@@ -38,7 +38,7 @@
.Sh SYNOPSIS
.Nm
.Op Fl b | g | H | h | k | m | P
-.Op Fl aciln
+.Op Fl acilnT
.Op Fl t Ar type
.Op Ar file | filesystem ...
.Sh DESCRIPTION
@@ -140,6 +140,8 @@ The
.Xr lsvfs 1
command can be used to find out the types of file systems
that are available on the system.
+.It Fl T
+Include file system type.
.El
.Sh ENVIRONMENT
.Bl -tag -width BLOCKSIZE
diff --git a/bin/df/df.c b/bin/df/df.c
index f48c8c9..465f65b 100644
--- a/bin/df/df.c
+++ b/bin/df/df.c
@@ -68,6 +68,7 @@ __FBSDID("$FreeBSD$");
/* Maximum widths of various fields. */
struct maxwidths {
int mntfrom;
+ int fstype;
int total;
int used;
int avail;
@@ -93,7 +94,7 @@ imax(int a, int b)
return (a > b ? a : b);
}
-static int aflag = 0, cflag, hflag, iflag, kflag, lflag = 0, nflag;
+static int aflag = 0, cflag, hflag, iflag, kflag, lflag = 0, nflag, Tflag;
static struct ufs_args mdev;
int
@@ -115,7 +116,7 @@ main(int argc, char *argv[])
totalbuf.f_bsize = DEV_BSIZE;
strlcpy(totalbuf.f_mntfromname, "total", MNAMELEN);
vfslist = NULL;
- while ((ch = getopt(argc, argv, "abcgHhiklmnPt:")) != -1)
+ while ((ch = getopt(argc, argv, "abcgHhiklmnPt:T")) != -1)
switch (ch) {
case 'a':
aflag = 1;
@@ -176,6 +177,9 @@ main(int argc, char *argv[])
fstype = optarg;
vfslist = makevfslist(optarg);
break;
+ case 'T':
+ Tflag = 1;
+ break;
case '?':
default:
usage();
@@ -391,6 +395,7 @@ prtstat(struct statfs *sfsp, struct maxwidths *mwp)
if (++timesthrough == 1) {
mwp->mntfrom = imax(mwp->mntfrom, (int)strlen("Filesystem"));
+ mwp->fstype = imax(mwp->fstype, (int)strlen("Type"));
if (hflag) {
header = " Size";
mwp->total = mwp->used = mwp->avail =
@@ -402,8 +407,10 @@ prtstat(struct statfs *sfsp, struct maxwidths *mwp)
mwp->used = imax(mwp->used, (int)strlen("Used"));
mwp->avail = imax(mwp->avail, (int)strlen("Avail"));
- (void)printf("%-*s %-*s %*s %*s Capacity",
- mwp->mntfrom, "Filesystem", mwp->total, header,
+ (void)printf("%-*s", mwp->mntfrom, "Filesystem");
+ if (Tflag)
+ (void)printf(" %-*s", mwp->fstype, "Type");
+ (void)printf(" %-*s %*s %*s Capacity", mwp->total, header,
mwp->used, "Used", mwp->avail, "Avail");
if (iflag) {
mwp->iused = imax(mwp->iused, (int)strlen(" iused"));
@@ -414,6 +421,8 @@ prtstat(struct statfs *sfsp, struct maxwidths *mwp)
(void)printf(" Mounted on\n");
}
(void)printf("%-*s", mwp->mntfrom, sfsp->f_mntfromname);
+ if (Tflag)
+ (void)printf(" %-*s", mwp->fstype, sfsp->f_fstypename);
used = sfsp->f_blocks - sfsp->f_bfree;
availblks = sfsp->f_bavail + used;
if (hflag) {
@@ -468,6 +477,7 @@ update_maxwidths(struct maxwidths *mwp, const struct statfs *sfsp)
getbsize(&dummy, &blocksize);
mwp->mntfrom = imax(mwp->mntfrom, (int)strlen(sfsp->f_mntfromname));
+ mwp->fstype = imax(mwp->fstype, (int)strlen(sfsp->f_fstypename));
mwp->total = imax(mwp->total, int64width(
fsbtoblk((int64_t)sfsp->f_blocks, sfsp->f_bsize, blocksize)));
mwp->used = imax(mwp->used,
@@ -505,7 +515,7 @@ usage(void)
{
(void)fprintf(stderr,
-"usage: df [-b | -g | -H | -h | -k | -m | -P] [-aciln] [-t type] [file | filesystem ...]\n");
+"usage: df [-b | -g | -H | -h | -k | -m | -P] [-acilnT] [-t type] [file | filesystem ...]\n");
exit(EX_USAGE);
}
OpenPOWER on IntegriCloud