FreeBSD Bugzilla – Attachment 9618 Details for
Bug 19635
add -c for grand total to df(1), like du(1) does
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
file.diff
file.diff (text/plain), 3.95 KB, created by
clefevre
on 2000-07-02 07:00:01 UTC
(
hide
)
Description:
file.diff
Filename:
MIME Type:
Creator:
clefevre
Created:
2000-07-02 07:00:01 UTC
Size:
3.95 KB
patch
obsolete
>Index: /usr/src/bin/df/df.1 >=================================================================== >RCS file: /home/ncvs/src/bin/df/df.1,v >retrieving revision 1.18.2.2 >diff -u -b -r1.18.2.2 df.1 >--- /usr/src/bin/df/df.1 2000/07/01 03:02:08 1.18.2.2 >+++ /usr/src/bin/df/df.1 2000/07/02 05:38:45 >@@ -44,7 +44,7 @@ > .Fl b | h | H | k | > .Fl m | P > .Oc >-.Op Fl ain >+.Op Fl acin > .Op Fl t Ar type > .Op Ar file | Ar filesystem ... > .Sh DESCRIPTION >@@ -71,6 +71,8 @@ > this overrides the > .Ev BLOCKSIZE > specification from the environment. >+.It Fl c >+Display a grand total. > .It Fl g > Use 1073741824-byte (1-Gbyte) blocks rather than the default. Note that > this overrides the >Index: /usr/src/bin/df/df.c >=================================================================== >RCS file: /home/ncvs/src/bin/df/df.c,v >retrieving revision 1.23.2.1 >diff -u -b -r1.23.2.1 df.c >--- /usr/src/bin/df/df.c 2000/06/13 03:19:40 1.23.2.1 >+++ /usr/src/bin/df/df.c 2000/07/02 05:38:40 >@@ -103,11 +103,12 @@ > void prthuman __P((struct statfs *, long)); > void prthumanval __P((double)); > void prtstat __P((struct statfs *, int)); >+void addstat __P((struct statfs *, struct statfs *)); > int ufs_df __P((char *, int)); > unit_t unit_adjust __P((double *)); > void usage __P((void)); > >-int aflag = 0, hflag, iflag, nflag; >+int aflag = 0, cflag = 0, hflag, iflag, nflag; > struct ufs_args mdev; > > int >@@ -116,17 +117,22 @@ > char *argv[]; > { > struct stat stbuf; >- struct statfs statfsbuf, *mntbuf; >+ struct statfs statfsbuf, *mntbuf, totalbuf = { 0 }; > long mntsize; > int ch, err, i, maxwidth, rv, width; > char *mntpt, *mntpath, **vfslist; > >+ totalbuf.f_bsize = DEV_BSIZE; >+ strncpy (totalbuf.f_mntfromname, "total", MNAMELEN); > vfslist = NULL; >- while ((ch = getopt(argc, argv, "abgHhikmnPt:")) != -1) >+ while ((ch = getopt(argc, argv, "abcgHhikmnPt:")) != -1) > switch (ch) { > case 'a': > aflag = 1; > break; >+ case 'c': >+ cflag = 1; >+ break; > case 'b': > /* FALLTHROUGH */ > case 'P': >@@ -191,9 +197,14 @@ > } > } > for (i = 0; i < mntsize; i++) { >- if (aflag || (mntbuf[i].f_flags & MNT_IGNORE) == 0) >+ if (aflag || (mntbuf[i].f_flags & MNT_IGNORE) == 0) { > prtstat(&mntbuf[i], maxwidth); >+ if (cflag) >+ addstat(&totalbuf, &mntbuf[i]); >+ } > } >+ if (cflag) >+ prtstat(&totalbuf, maxwidth); > exit(rv); > } > >@@ -256,7 +267,11 @@ > if (argc == 1) > maxwidth = strlen(statfsbuf.f_mntfromname) + 1; > prtstat(&statfsbuf, maxwidth); >+ if (cflag) >+ addstat(&totalbuf, &statfsbuf); > } >+ if (cflag) >+ prtstat(&totalbuf, maxwidth); > return (rv); > } > >@@ -380,6 +395,7 @@ > static int headerlen, timesthrough; > static char *header; > long used, availblks, inodes; >+ int total; > > if (maxwidth < 11) > maxwidth = 11; >@@ -411,14 +427,32 @@ > } > (void)printf(" %5.0f%%", > availblks == 0 ? 100.0 : (double)used / (double)availblks * 100.0); >+ total = !*sfsp->f_mntonname && >+ !strncmp(sfsp->f_mntfromname, "total", MNAMELEN); > if (iflag) { > inodes = sfsp->f_files; > used = inodes - sfsp->f_ffree; > (void)printf(" %7ld %7ld %5.0f%% ", used, sfsp->f_ffree, > inodes == 0 ? 100.0 : (double)used / (double)inodes * 100.0); >- } else >+ } else if (!total) > (void)printf(" "); >- (void)printf(" %s\n", sfsp->f_mntonname); >+ if (!total) >+ (void)printf(" %s", sfsp->f_mntonname); >+ (void)printf("\n"); >+} >+ >+void >+addstat(totalfsp, statfsp) >+ struct statfs *totalfsp, *statfsp; >+{ >+ totalfsp->f_blocks += (statfsp->f_blocks * statfsp->f_bsize) / >+ totalfsp->f_bsize; >+ totalfsp->f_bfree += (statfsp->f_bfree * statfsp->f_bsize) / >+ totalfsp->f_bsize; >+ totalfsp->f_bavail += (statfsp->f_bavail * statfsp->f_bsize) / >+ totalfsp->f_bsize; >+ totalfsp->f_files += statfsp->f_files; >+ totalfsp->f_ffree += statfsp->f_ffree; > } > > /* >@@ -506,6 +540,6 @@ > { > > (void)fprintf(stderr, >- "usage: df [-b | -H | -h | -k | -m | -P] [-ain] [-t type] [file | filesystem ...]\n"); >+ "usage: df [-b | -H | -h | -k | -m | -P] [-acin] [-t type] [file | filesystem ...]\n"); > exit(EX_USAGE); > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 19635
: 9618