CVS commit: src/bin/df
Module Name:src Committed By: ginsbach Date: Wed Jan 6 20:38:09 UTC 2021 Modified Files: src/bin/df: df.1 Log Message: df: bump man page date To generate a diff of this commit: cvs rdiff -u -r1.55 -r1.56 src/bin/df/df.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/df/df.1 diff -u src/bin/df/df.1:1.55 src/bin/df/df.1:1.56 --- src/bin/df/df.1:1.55 Sun Jan 3 01:43:12 2021 +++ src/bin/df/df.1 Wed Jan 6 20:38:09 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: df.1,v 1.55 2021/01/03 01:43:12 ginsbach Exp $ +.\" $NetBSD: df.1,v 1.56 2021/01/06 20:38:09 ginsbach Exp $ .\" .\" Copyright (c) 1989, 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)df.1 8.2 (Berkeley) 1/13/92 .\" -.Dd September 23, 2019 +.Dd January 2, 2021 .Dt DF 1 .Os .Sh NAME
CVS commit: src/bin/df
Module Name:src Committed By: ginsbach Date: Sun Jan 3 01:43:13 UTC 2021 Modified Files: src/bin/df: df.1 df.c Log Message: df: add grand total option Add a grand total option, -c, similar to the du(1) -c option. Adapted from the same option (-c) in FreeBSD df(1). To generate a diff of this commit: cvs rdiff -u -r1.54 -r1.55 src/bin/df/df.1 cvs rdiff -u -r1.97 -r1.98 src/bin/df/df.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/df/df.1 diff -u src/bin/df/df.1:1.54 src/bin/df/df.1:1.55 --- src/bin/df/df.1:1.54 Mon Sep 23 15:24:44 2019 +++ src/bin/df/df.1 Sun Jan 3 01:43:12 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: df.1,v 1.54 2019/09/23 15:24:44 christos Exp $ +.\" $NetBSD: df.1,v 1.55 2021/01/03 01:43:12 ginsbach Exp $ .\" .\" Copyright (c) 1989, 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -37,7 +37,7 @@ .Nd display free disk space .Sh SYNOPSIS .Nm -.Op Fl aglnW +.Op Fl acglnW .Op Fl Ghkm | Fl ihkm | Fl Pk .Op Fl t Ar type .Op Ar file | Ar file_system ... @@ -72,6 +72,8 @@ Show all mount points, including those that were mounted with the .Dv MNT_IGNORE flag. +.It Fl c +Display a grand total for all shown mount points. .It Fl G Display all the fields of the structure(s) returned by .Xr statvfs 2 . Index: src/bin/df/df.c diff -u src/bin/df/df.c:1.97 src/bin/df/df.c:1.98 --- src/bin/df/df.c:1.97 Fri Aug 21 16:41:06 2020 +++ src/bin/df/df.c Sun Jan 3 01:43:12 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: df.c,v 1.97 2020/08/21 16:41:06 ryo Exp $ */ +/* $NetBSD: df.c,v 1.98 2021/01/03 01:43:12 ginsbach Exp $ */ /* * Copyright (c) 1980, 1990, 1993, 1994 @@ -45,7 +45,7 @@ __COPYRIGHT( #if 0 static char sccsid[] = "@(#)df.c 8.7 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: df.c,v 1.97 2020/08/21 16:41:06 ryo Exp $"); +__RCSID("$NetBSD: df.c,v 1.98 2021/01/03 01:43:12 ginsbach Exp $"); #endif #endif /* not lint */ @@ -67,6 +67,7 @@ __RCSID("$NetBSD: df.c,v 1.97 2020/08/21 #include static char *getmntpt(const char *); +static void addstat(struct statvfs *, const struct statvfs *); static void prtstat(const struct statvfs *, int); static int selected(const char *, size_t); static void maketypelist(char *); @@ -75,7 +76,7 @@ __dead static void usage(void); static void prthumanval(int64_t, int); static void prthuman(const struct statvfs *, int64_t, int64_t); -static int aflag, gflag, hflag, iflag, lflag, nflag, Pflag, Wflag; +static int aflag, cflag, gflag, hflag, iflag, lflag, nflag, Pflag, Wflag; static long usize; static char **typelist; @@ -87,7 +88,7 @@ int main(int argc, char *argv[]) { struct stat stbuf; - struct statvfs *mntbuf; + struct statvfs *mntbuf, totals; int ch, maxwidth, width; size_t i, mntcount; char *mntpt; @@ -95,11 +96,14 @@ main(int argc, char *argv[]) setprogname(argv[0]); (void)setlocale(LC_ALL, ""); - while ((ch = getopt(argc, argv, "aGghiklmnPt:W")) != -1) + while ((ch = getopt(argc, argv, "acGghiklmnPt:W")) != -1) switch (ch) { case 'a': aflag = 1; break; + case 'c': + cflag = 1; + break; case 'g': hflag = 0; usize = 1024 * 1024 * 1024; @@ -207,15 +211,28 @@ main(int argc, char *argv[]) } } + if (cflag) { + memset(, 0, sizeof(totals)); + totals.f_bsize = DEV_BSIZE; + strlcpy(totals.f_mntfromname, "total", + sizeof(totals.f_mntfromname)); + } + maxwidth = 0; for (i = 0; i < mntcount; i++) { width = (int)strlen(Wflag && mntbuf[i].f_mntfromlabel[0] ? mntbuf[i].f_mntfromlabel : mntbuf[i].f_mntfromname); if (width > maxwidth) maxwidth = width; + if (cflag) + addstat(, [i]); } for (i = 0; i < mntcount; i++) prtstat([i], maxwidth); + + if (cflag) + prtstat(, maxwidth); + return 0; } @@ -361,6 +378,22 @@ prthuman(const struct statvfs *sfsp, int (int64_t)(num) / (int64_t)((bs) / (fsbs)) : \ (int64_t)(num) * (int64_t)((fsbs) / (bs))) +static void +addstat(struct statvfs *totalfsp, const struct statvfs *sfsp) +{ + uint64_t frsize; + + frsize = sfsp->f_frsize / totalfsp->f_frsize; + totalfsp->f_blocks += sfsp->f_blocks * frsize; + totalfsp->f_bfree += sfsp->f_bfree * frsize; + totalfsp->f_bavail += sfsp->f_bavail * frsize; + totalfsp->f_bresvd += sfsp->f_bresvd * frsize; + totalfsp->f_files += sfsp->f_files; + totalfsp->f_ffree += sfsp->f_ffree; + totalfsp->f_favail += sfsp->f_favail; + totalfsp->f_fresvd += sfsp->f_fresvd; +} + /* * Print out status about a filesystem. */
CVS commit: src/bin/df
Module Name:src Committed By: ryo Date: Fri Aug 21 16:41:06 UTC 2020 Modified Files: src/bin/df: df.c Log Message: - Bump Size/Used/Avail from 10 to 12, and iUsed/iAvail from 8 to 10 for double-digit terabyte storage. - set the field width to the optimal, if "-h" is specified. - if blocksize is greater than M or G, reduce the size field width. To generate a diff of this commit: cvs rdiff -u -r1.96 -r1.97 src/bin/df/df.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/df/df.c diff -u src/bin/df/df.c:1.96 src/bin/df/df.c:1.97 --- src/bin/df/df.c:1.96 Fri Aug 21 16:40:02 2020 +++ src/bin/df/df.c Fri Aug 21 16:41:06 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: df.c,v 1.96 2020/08/21 16:40:02 ryo Exp $ */ +/* $NetBSD: df.c,v 1.97 2020/08/21 16:41:06 ryo Exp $ */ /* * Copyright (c) 1980, 1990, 1993, 1994 @@ -45,7 +45,7 @@ __COPYRIGHT( #if 0 static char sccsid[] = "@(#)df.c 8.7 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: df.c,v 1.96 2020/08/21 16:40:02 ryo Exp $"); +__RCSID("$NetBSD: df.c,v 1.97 2020/08/21 16:41:06 ryo Exp $"); #endif #endif /* not lint */ @@ -79,8 +79,9 @@ static int aflag, gflag, hflag, iflag, static long usize; static char **typelist; -#define WIDTH_INODE 8 -#define WIDTH_BLKSIZE 10 +#define WIDTH_INODE 10 +#define WIDTH_BLKSIZE 12 +static int blksize_width = WIDTH_BLKSIZE; int main(int argc, char *argv[]) @@ -346,9 +347,9 @@ static void prthuman(const struct statvfs *sfsp, int64_t used, int64_t bavail) { - prthumanval((int64_t)(sfsp->f_blocks * sfsp->f_frsize), WIDTH_BLKSIZE); - prthumanval((int64_t)(used * sfsp->f_frsize), 1 + WIDTH_BLKSIZE); - prthumanval((int64_t)(bavail * sfsp->f_frsize), 1 + WIDTH_BLKSIZE); + prthumanval((int64_t)(sfsp->f_blocks * sfsp->f_frsize), blksize_width); + prthumanval((int64_t)(used * sfsp->f_frsize), 1 + blksize_width); + prthumanval((int64_t)(bavail * sfsp->f_frsize), 1 + blksize_width); } /* @@ -447,10 +448,19 @@ prtstat(const struct statvfs *sfsp, int if (hflag) { header = "Size"; headerlen = (int)strlen(header); +blksize_width = 6; } else header = getbsize(, ); break; } + + if (blocksize >= 1024 * 1024) + blksize_width -= 3; + if (blocksize >= 1024 * 1024 * 1024) + blksize_width -= 3; + if (blksize_width < headerlen) + blksize_width = headerlen; + if (Pflag) { /* * either: @@ -466,9 +476,9 @@ prtstat(const struct statvfs *sfsp, int } else { (void)printf("%-*.*s %*s %*s %*s %%Cap", maxwidth, maxwidth, "Filesystem", - WIDTH_BLKSIZE, header, - WIDTH_BLKSIZE, "Used", - WIDTH_BLKSIZE, "Avail"); + blksize_width, header, + blksize_width, "Used", + blksize_width, "Avail"); if (iflag) { (void)printf(" %*s %*s %%iCap", WIDTH_INODE, "iUsed", @@ -510,10 +520,10 @@ prtstat(const struct statvfs *sfsp, int prthuman(sfsp, used, bavail); else (void)printf("%*" PRId64 " %*" PRId64 " %*" PRId64, - WIDTH_BLKSIZE, + blksize_width, fsbtoblk(sfsp->f_blocks, sfsp->f_frsize, blocksize), - WIDTH_BLKSIZE, fsbtoblk(used, sfsp->f_frsize, blocksize), - WIDTH_BLKSIZE, fsbtoblk(bavail, sfsp->f_frsize, blocksize)); + blksize_width, fsbtoblk(used, sfsp->f_frsize, blocksize), + blksize_width, fsbtoblk(bavail, sfsp->f_frsize, blocksize)); (void)printf(" %3s%%", availblks == 0 ? full : strspct(pb, sizeof(pb), used, availblks, 0));
CVS commit: src/bin/df
Module Name:src Committed By: ryo Date: Fri Aug 21 16:40:02 UTC 2020 Modified Files: src/bin/df: df.c Log Message: field width of blocksize and inode can be changed by #define To generate a diff of this commit: cvs rdiff -u -r1.95 -r1.96 src/bin/df/df.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/df/df.c diff -u src/bin/df/df.c:1.95 src/bin/df/df.c:1.96 --- src/bin/df/df.c:1.95 Sun Sep 22 22:59:37 2019 +++ src/bin/df/df.c Fri Aug 21 16:40:02 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: df.c,v 1.95 2019/09/22 22:59:37 christos Exp $ */ +/* $NetBSD: df.c,v 1.96 2020/08/21 16:40:02 ryo Exp $ */ /* * Copyright (c) 1980, 1990, 1993, 1994 @@ -45,7 +45,7 @@ __COPYRIGHT( #if 0 static char sccsid[] = "@(#)df.c 8.7 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: df.c,v 1.95 2019/09/22 22:59:37 christos Exp $"); +__RCSID("$NetBSD: df.c,v 1.96 2020/08/21 16:40:02 ryo Exp $"); #endif #endif /* not lint */ @@ -72,13 +72,16 @@ static int selected(const char *, size_ static void maketypelist(char *); static size_t regetmntinfo(struct statvfs **, size_t); __dead static void usage(void); -static void prthumanval(int64_t, const char *); +static void prthumanval(int64_t, int); static void prthuman(const struct statvfs *, int64_t, int64_t); static int aflag, gflag, hflag, iflag, lflag, nflag, Pflag, Wflag; static long usize; static char **typelist; +#define WIDTH_INODE 8 +#define WIDTH_BLKSIZE 10 + int main(int argc, char *argv[]) { @@ -328,7 +331,7 @@ regetmntinfo(struct statvfs **mntbufp, s } static void -prthumanval(int64_t bytes, const char *pad) +prthumanval(int64_t bytes, int width) { char buf[6]; @@ -336,16 +339,16 @@ prthumanval(int64_t bytes, const char *p bytes, "", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL); - (void)printf("%s %6s", pad, buf); + (void)printf("%*s", width, buf); } static void prthuman(const struct statvfs *sfsp, int64_t used, int64_t bavail) { - prthumanval((int64_t)(sfsp->f_blocks * sfsp->f_frsize), " "); - prthumanval((int64_t)(used * sfsp->f_frsize), ""); - prthumanval((int64_t)(bavail * sfsp->f_frsize), ""); + prthumanval((int64_t)(sfsp->f_blocks * sfsp->f_frsize), WIDTH_BLKSIZE); + prthumanval((int64_t)(used * sfsp->f_frsize), 1 + WIDTH_BLKSIZE); + prthumanval((int64_t)(bavail * sfsp->f_frsize), 1 + WIDTH_BLKSIZE); } /* @@ -461,12 +464,16 @@ prtstat(const struct statvfs *sfsp, int (void)printf("Filesystem %s Used Available Capacity " "Mounted on\n", header); } else { - (void)printf("%-*.*s %s Used Avail %%Cap", - maxwidth - (headerlen - 10), - maxwidth - (headerlen - 10), - "Filesystem", header); - if (iflag) -(void)printf("iUsed iAvail %%iCap"); + (void)printf("%-*.*s %*s %*s %*s %%Cap", + maxwidth, maxwidth, "Filesystem", + WIDTH_BLKSIZE, header, + WIDTH_BLKSIZE, "Used", + WIDTH_BLKSIZE, "Avail"); + if (iflag) { +(void)printf(" %*s %*s %%iCap", +WIDTH_INODE, "iUsed", +WIDTH_INODE, "iAvail"); + } (void)printf(" Mounted on\n"); } } @@ -502,18 +509,20 @@ prtstat(const struct statvfs *sfsp, int if (hflag) prthuman(sfsp, used, bavail); else - (void)printf("%10" PRId64 " %10" PRId64 " %10" PRId64, + (void)printf("%*" PRId64 " %*" PRId64 " %*" PRId64, + WIDTH_BLKSIZE, fsbtoblk(sfsp->f_blocks, sfsp->f_frsize, blocksize), - fsbtoblk(used, sfsp->f_frsize, blocksize), - fsbtoblk(bavail, sfsp->f_frsize, blocksize)); + WIDTH_BLKSIZE, fsbtoblk(used, sfsp->f_frsize, blocksize), + WIDTH_BLKSIZE, fsbtoblk(bavail, sfsp->f_frsize, blocksize)); (void)printf(" %3s%%", availblks == 0 ? full : strspct(pb, sizeof(pb), used, availblks, 0)); if (iflag) { inodes = sfsp->f_files; used = inodes - sfsp->f_ffree; - (void)printf(" %8jd %8jd %4s%%", - (intmax_t)used, (intmax_t)sfsp->f_ffree, + (void)printf(" %*jd %*jd %4s%%", + WIDTH_INODE, (intmax_t)used, + WIDTH_INODE, (intmax_t)sfsp->f_ffree, inodes == 0 ? (used == 0 ? empty : full) : strspct(pb, sizeof(pb), used, inodes, 0)); }
CVS commit: src/bin/df
Module Name:src Committed By: sevan Date: Sun Aug 26 23:34:52 UTC 2018 Modified Files: src/bin/df: df.1 df.c Log Message: -G cannot be specified alongside -i or -P. Heads up by To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/bin/df/df.1 cvs rdiff -u -r1.92 -r1.93 src/bin/df/df.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/df/df.1 diff -u src/bin/df/df.1:1.48 src/bin/df/df.1:1.49 --- src/bin/df/df.1:1.48 Sun Aug 26 22:25:37 2018 +++ src/bin/df/df.1 Sun Aug 26 23:34:52 2018 @@ -1,4 +1,4 @@ -.\" $NetBSD: df.1,v 1.48 2018/08/26 22:25:37 sevan Exp $ +.\" $NetBSD: df.1,v 1.49 2018/08/26 23:34:52 sevan Exp $ .\" .\" Copyright (c) 1989, 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)df.1 8.2 (Berkeley) 1/13/92 .\" -.Dd August 26, 2018 +.Dd August 27, 2018 .Dt DF 1 .Os .Sh NAME @@ -37,8 +37,8 @@ .Nd display free disk space .Sh SYNOPSIS .Nm -.Op Fl aGgln -.Op Fl hkm | Fl ihkm | Fl Pk +.Op Fl agln +.Op Fl Ghkm | Fl ihkm | Fl Pk .Op Fl t Ar type .Op Ar file | Ar file_system ... .Sh DESCRIPTION Index: src/bin/df/df.c diff -u src/bin/df/df.c:1.92 src/bin/df/df.c:1.93 --- src/bin/df/df.c:1.92 Sat Mar 5 08:15:01 2016 +++ src/bin/df/df.c Sun Aug 26 23:34:52 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: df.c,v 1.92 2016/03/05 08:15:01 kamil Exp $ */ +/* $NetBSD: df.c,v 1.93 2018/08/26 23:34:52 sevan Exp $ */ /* * Copyright (c) 1980, 1990, 1993, 1994 @@ -45,7 +45,7 @@ __COPYRIGHT( #if 0 static char sccsid[] = "@(#)df.c 8.7 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: df.c,v 1.92 2016/03/05 08:15:01 kamil Exp $"); +__RCSID("$NetBSD: df.c,v 1.93 2018/08/26 23:34:52 sevan Exp $"); #endif #endif /* not lint */ @@ -512,7 +512,7 @@ usage(void) { (void)fprintf(stderr, - "Usage: %s [-aGgln] [-hkm|-ihkm|-Pk] [-t type] [file | " + "Usage: %s [-agln] [-Ghkm|-ihkm|-Pk] [-t type] [file | " "file_system ...]\n", getprogname()); exit(1);
CVS commit: src/bin/df
Module Name:src Committed By: sevan Date: Sun Aug 26 22:25:38 UTC 2018 Modified Files: src/bin/df: df.1 Log Message: Match SYNOPSIS with usage() To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.48 src/bin/df/df.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/df/df.1 diff -u src/bin/df/df.1:1.47 src/bin/df/df.1:1.48 --- src/bin/df/df.1:1.47 Mon Jul 3 21:33:22 2017 +++ src/bin/df/df.1 Sun Aug 26 22:25:37 2018 @@ -1,4 +1,4 @@ -.\" $NetBSD: df.1,v 1.47 2017/07/03 21:33:22 wiz Exp $ +.\" $NetBSD: df.1,v 1.48 2018/08/26 22:25:37 sevan Exp $ .\" .\" Copyright (c) 1989, 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)df.1 8.2 (Berkeley) 1/13/92 .\" -.Dd August 10, 2016 +.Dd August 26, 2018 .Dt DF 1 .Os .Sh NAME @@ -37,8 +37,8 @@ .Nd display free disk space .Sh SYNOPSIS .Nm -.Op Fl agklmn -.Op Fl G | Fl i | Fl P +.Op Fl aGgln +.Op Fl hkm | Fl ihkm | Fl Pk .Op Fl t Ar type .Op Ar file | Ar file_system ... .Sh DESCRIPTION
CVS commit: src/bin/df
Module Name:src Committed By: sevan Date: Wed Aug 10 23:48:14 UTC 2016 Modified Files: src/bin/df: df.1 Log Message: Bump date Reminded by wiz@ To generate a diff of this commit: cvs rdiff -u -r1.45 -r1.46 src/bin/df/df.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/df/df.1 diff -u src/bin/df/df.1:1.45 src/bin/df/df.1:1.46 --- src/bin/df/df.1:1.45 Wed Aug 10 18:58:23 2016 +++ src/bin/df/df.1 Wed Aug 10 23:48:14 2016 @@ -1,4 +1,4 @@ -.\" $NetBSD: df.1,v 1.45 2016/08/10 18:58:23 sevan Exp $ +.\" $NetBSD: df.1,v 1.46 2016/08/10 23:48:14 sevan Exp $ .\" .\" Copyright (c) 1989, 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)df.1 8.2 (Berkeley) 1/13/92 .\" -.Dd March 4, 2008 +.Dd August 10, 2016 .Dt DF 1 .Os .Sh NAME
CVS commit: src/bin/df
Module Name:src Committed By: sevan Date: Wed Aug 10 18:58:23 UTC 2016 Modified Files: src/bin/df: df.1 Log Message: df was there from v1. Confirmed from the TUHS & cat-v.org hosted copies of man pages. To generate a diff of this commit: cvs rdiff -u -r1.44 -r1.45 src/bin/df/df.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/df/df.1 diff -u src/bin/df/df.1:1.44 src/bin/df/df.1:1.45 --- src/bin/df/df.1:1.44 Mon Apr 5 21:17:28 2010 +++ src/bin/df/df.1 Wed Aug 10 18:58:23 2016 @@ -1,4 +1,4 @@ -.\" $NetBSD: df.1,v 1.44 2010/04/05 21:17:28 joerg Exp $ +.\" $NetBSD: df.1,v 1.45 2016/08/10 18:58:23 sevan Exp $ .\" .\" Copyright (c) 1989, 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -203,4 +203,4 @@ size block. A .Nm utility appeared in -.At v6 . +.At v1 .
CVS commit: src/bin/df
Module Name:src Committed By: kamil Date: Sat Mar 5 08:15:01 UTC 2016 Modified Files: src/bin/df: df.c Log Message: Correct display of df(1) with the -i parameter Now the "Mounted on" column should be aligned with /entries. Patch by Michal Mazurek. To generate a diff of this commit: cvs rdiff -u -r1.91 -r1.92 src/bin/df/df.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/df/df.c diff -u src/bin/df/df.c:1.91 src/bin/df/df.c:1.92 --- src/bin/df/df.c:1.91 Thu Nov 12 17:59:21 2015 +++ src/bin/df/df.c Sat Mar 5 08:15:01 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: df.c,v 1.91 2015/11/12 17:59:21 christos Exp $ */ +/* $NetBSD: df.c,v 1.92 2016/03/05 08:15:01 kamil Exp $ */ /* * Copyright (c) 1980, 1990, 1993, 1994 @@ -45,7 +45,7 @@ __COPYRIGHT( #if 0 static char sccsid[] = "@(#)df.c 8.7 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: df.c,v 1.91 2015/11/12 17:59:21 christos Exp $"); +__RCSID("$NetBSD: df.c,v 1.92 2016/03/05 08:15:01 kamil Exp $"); #endif #endif /* not lint */ @@ -499,7 +499,7 @@ prtstat(struct statvfs *sfsp, int maxwid if (iflag) { inodes = sfsp->f_files; used = inodes - sfsp->f_ffree; - (void)printf(" %8jd %8jd %3s%%", + (void)printf(" %8jd %8jd %4s%%", (intmax_t)used, (intmax_t)sfsp->f_ffree, inodes == 0 ? (used == 0 ? empty : full) : strspct(pb, sizeof(pb), used, inodes, 0));
CVS commit: src/bin/df
Module Name:src Committed By: christos Date: Thu Nov 12 17:59:21 UTC 2015 Modified Files: src/bin/df: df.c Log Message: PR/50422: Robert Elz: df -G prints the wrong value for fragsize (+FIX) For df -G, print the block and fragment size instead of the iosize and the blocksize. If we need to print the iosize, it should be done in a different field. Nevertheless printing the blocksize in the fragment size field is just wrong. XXX: pullup-6, pullup-7 To generate a diff of this commit: cvs rdiff -u -r1.90 -r1.91 src/bin/df/df.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/df/df.c diff -u src/bin/df/df.c:1.90 src/bin/df/df.c:1.91 --- src/bin/df/df.c:1.90 Sat Jan 7 13:45:13 2012 +++ src/bin/df/df.c Thu Nov 12 12:59:21 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: df.c,v 1.90 2012/01/07 18:45:13 christos Exp $ */ +/* $NetBSD: df.c,v 1.91 2015/11/12 17:59:21 christos Exp $ */ /* * Copyright (c) 1980, 1990, 1993, 1994 @@ -45,7 +45,7 @@ __COPYRIGHT( #if 0 static char sccsid[] = "@(#)df.c 8.7 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: df.c,v 1.90 2012/01/07 18:45:13 christos Exp $"); +__RCSID("$NetBSD: df.c,v 1.91 2015/11/12 17:59:21 christos Exp $"); #endif #endif /* not lint */ @@ -379,13 +379,13 @@ prtstat(struct statvfs *sfsp, int maxwid */ (void)printf("%10s (%-12s): %7ld block size %12ld frag size\n", sfsp->f_mntonname, sfsp->f_mntfromname, - sfsp->f_iosize, /* On UFS/FFS systems this is + sfsp->f_bsize, /* On UFS/FFS systems this is * also called the "optimal * transfer block size" but it * is of course the file * system's block size too. */ - sfsp->f_bsize); /* not so surprisingly the + sfsp->f_frsize); /* not so surprisingly the * "fundamental file system * block size" is the frag * size.
CVS commit: src/bin/df
Module Name:src Committed By: christos Date: Sat Jan 7 18:45:13 UTC 2012 Modified Files: src/bin/df: df.c Log Message: use strspct. To generate a diff of this commit: cvs rdiff -u -r1.89 -r1.90 src/bin/df/df.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/df/df.c diff -u src/bin/df/df.c:1.89 src/bin/df/df.c:1.90 --- src/bin/df/df.c:1.89 Mon Aug 29 13:30:28 2011 +++ src/bin/df/df.c Sat Jan 7 13:45:13 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: df.c,v 1.89 2011/08/29 17:30:28 gson Exp $ */ +/* $NetBSD: df.c,v 1.90 2012/01/07 18:45:13 christos Exp $ */ /* * Copyright (c) 1980, 1990, 1993, 1994 @@ -45,7 +45,7 @@ __COPYRIGHT( #if 0 static char sccsid[] = @(#)df.c 8.7 (Berkeley) 4/2/94; #else -__RCSID($NetBSD: df.c,v 1.89 2011/08/29 17:30:28 gson Exp $); +__RCSID($NetBSD: df.c,v 1.90 2012/01/07 18:45:13 christos Exp $); #endif #endif /* not lint */ @@ -473,7 +473,7 @@ prtstat(struct statvfs *sfsp, int maxwid fsbtoblk(sfsp-f_blocks, sfsp-f_frsize, blocksize), fsbtoblk(used, sfsp-f_frsize, blocksize), fsbtoblk(bavail, sfsp-f_frsize, blocksize), - availblks == 0 ? full : strpct(pb, sizeof(pb), used, + availblks == 0 ? full : strspct(pb, sizeof(pb), used, availblks, 0), sfsp-f_mntonname); /* * another concession by the structured programming police to @@ -495,15 +495,14 @@ prtstat(struct statvfs *sfsp, int maxwid fsbtoblk(bavail, sfsp-f_frsize, blocksize)); (void)printf( %3s%%, availblks == 0 ? full : - /* We know that these values are never negative */ - strpct(pb, sizeof(pb), used, availblks, 0)); + strspct(pb, sizeof(pb), used, availblks, 0)); if (iflag) { inodes = sfsp-f_files; used = inodes - sfsp-f_ffree; (void)printf( %8jd %8jd %3s%%, (intmax_t)used, (intmax_t)sfsp-f_ffree, inodes == 0 ? (used == 0 ? empty : full) : - strpct(pb, sizeof(pb), used, inodes, 0)); + strspct(pb, sizeof(pb), used, inodes, 0)); } (void)printf( %s\n, sfsp-f_mntonname); }
CVS commit: src/bin/df
Module Name:src Committed By: gson Date: Mon Aug 29 17:30:28 UTC 2011 Modified Files: src/bin/df: df.c Log Message: Use the same column spacing for the -h output as with the normal output, as the same header line format is used in both cases and it can't line up correctly with both of them otherwise. To generate a diff of this commit: cvs rdiff -u -r1.88 -r1.89 src/bin/df/df.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/df/df.c diff -u src/bin/df/df.c:1.88 src/bin/df/df.c:1.89 --- src/bin/df/df.c:1.88 Mon Aug 29 00:36:20 2011 +++ src/bin/df/df.c Mon Aug 29 17:30:28 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: df.c,v 1.88 2011/08/29 00:36:20 enami Exp $ */ +/* $NetBSD: df.c,v 1.89 2011/08/29 17:30:28 gson Exp $ */ /* * Copyright (c) 1980, 1990, 1993, 1994 @@ -45,7 +45,7 @@ #if 0 static char sccsid[] = @(#)df.c 8.7 (Berkeley) 4/2/94; #else -__RCSID($NetBSD: df.c,v 1.88 2011/08/29 00:36:20 enami Exp $); +__RCSID($NetBSD: df.c,v 1.89 2011/08/29 17:30:28 gson Exp $); #endif #endif /* not lint */ @@ -338,7 +338,7 @@ prthuman(struct statvfs *sfsp, int64_t used, int64_t bavail) { - prthumanval((int64_t)(sfsp-f_blocks * sfsp-f_frsize), ); + prthumanval((int64_t)(sfsp-f_blocks * sfsp-f_frsize),); prthumanval((int64_t)(used * sfsp-f_frsize), ); prthumanval((int64_t)(bavail * sfsp-f_frsize), ); }
CVS commit: src/bin/df
Module Name:src Committed By: christos Date: Sun Aug 28 08:20:58 UTC 2011 Modified Files: src/bin/df: Makefile df.c Log Message: - static/__dead - use strpct from libutil - fix off by one in format To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/bin/df/Makefile cvs rdiff -u -r1.86 -r1.87 src/bin/df/df.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/df/Makefile diff -u src/bin/df/Makefile:1.18 src/bin/df/Makefile:1.19 --- src/bin/df/Makefile:1.18 Sun Aug 14 06:53:17 2011 +++ src/bin/df/Makefile Sun Aug 28 04:20:58 2011 @@ -1,11 +1,11 @@ -# $NetBSD: Makefile,v 1.18 2011/08/14 10:53:17 christos Exp $ +# $NetBSD: Makefile,v 1.19 2011/08/28 08:20:58 christos Exp $ # @(#)Makefile 8.3 (Berkeley) 5/8/95 .include bsd.own.mk PROG= df -.PATH: ${NETBSDSRCDIR}/bin/csh -SRCS= df.c strpct.c -COPTS.strpct.c = -Wno-format-nonliteral + +LDADD+=-lutil +DPADD+=${LIBUTIL} .include bsd.prog.mk Index: src/bin/df/df.c diff -u src/bin/df/df.c:1.86 src/bin/df/df.c:1.87 --- src/bin/df/df.c:1.86 Sat Jun 6 05:30:45 2009 +++ src/bin/df/df.c Sun Aug 28 04:20:58 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: df.c,v 1.86 2009/06/06 09:30:45 mlelstv Exp $ */ +/* $NetBSD: df.c,v 1.87 2011/08/28 08:20:58 christos Exp $ */ /* * Copyright (c) 1980, 1990, 1993, 1994 @@ -45,7 +45,7 @@ #if 0 static char sccsid[] = @(#)df.c 8.7 (Berkeley) 4/2/94; #else -__RCSID($NetBSD: df.c,v 1.86 2009/06/06 09:30:45 mlelstv Exp $); +__RCSID($NetBSD: df.c,v 1.87 2011/08/28 08:20:58 christos Exp $); #endif #endif /* not lint */ @@ -63,25 +63,20 @@ #include stdlib.h #include string.h #include unistd.h +#include util.h -extern char *strpct(u_long, u_long, u_int); - -int main(int, char *[]); -int bread(off_t, void *, int); -char *getmntpt(char *); -void prtstat(struct statvfs *, int); -int selected(const char *, size_t); -void maketypelist(char *); -long regetmntinfo(struct statvfs **, long); -void usage(void); -void prthumanval(int64_t, const char *); -void prthuman(struct statvfs *, int64_t, int64_t); -const char * - strpct64(uint64_t, uint64_t, u_int); - -int aflag, gflag, hflag, iflag, lflag, nflag, Pflag; -long usize = 0; -char **typelist = NULL; +static char *getmntpt(const char *); +static void prtstat(struct statvfs *, int); +static int selected(const char *, size_t); +static void maketypelist(char *); +static size_t regetmntinfo(struct statvfs **, size_t); +__dead static void usage(void); +static void prthumanval(int64_t, const char *); +static void prthuman(struct statvfs *, int64_t, int64_t); + +static int aflag, gflag, hflag, iflag, lflag, nflag, Pflag; +static long usize; +static char **typelist; int main(int argc, char *argv[]) @@ -212,44 +207,45 @@ } for (i = 0; i mntsize; i++) prtstat(mntbuf[i], maxwidth); - exit(0); - /* NOTREACHED */ + return 0; } -char * -getmntpt(char *name) +static char * +getmntpt(const char *name) { - long mntsize, i; + size_t mntsize, i; struct statvfs *mntbuf; mntsize = getmntinfo(mntbuf, MNT_NOWAIT); + if (mntsize == 0) + err(EXIT_FAILURE, Can't get mount information); for (i = 0; i mntsize; i++) { if (!strcmp(mntbuf[i].f_mntfromname, name)) - return (mntbuf[i].f_mntonname); + return mntbuf[i].f_mntonname; } - return (0); + return 0; } static enum { IN_LIST, NOT_IN_LIST } which; -int +static int selected(const char *type, size_t len) { char **av; /* If no type specified, it's always selected. */ if (typelist == NULL) - return (1); + return 1; for (av = typelist; *av != NULL; ++av) if (!strncmp(type, *av, len)) - return (which == IN_LIST ? 1 : 0); - return (which == IN_LIST ? 0 : 1); + return which == IN_LIST ? 1 : 0; + return which == IN_LIST ? 0 : 1; } -void +static void maketypelist(char *fslist) { - int i; + size_t i; char *nextcp, **av; if ((fslist == NULL) || (fslist[0] == '\0')) @@ -272,7 +268,7 @@ ++nextcp; /* Build an array of that many types. */ - if ((av = typelist = malloc((i + 1) * sizeof(char *))) == NULL) + if ((av = typelist = malloc((i + 1) * sizeof(*av))) == NULL) err(EXIT_FAILURE, can't allocate type array); av[0] = fslist; for (i = 1, nextcp = fslist; @@ -289,14 +285,14 @@ * filesystem types not in ``fsmask'' and possibly re-stating to get * current (not cached) info. Returns the new count of valid statvfs bufs. */ -long -regetmntinfo(struct statvfs **mntbufp, long mntsize) +static size_t +regetmntinfo(struct statvfs **mntbufp, size_t mntsize) { - int i, j; + size_t i, j; struct statvfs *mntbuf; if (!lflag typelist == NULL aflag) - return (nflag ? mntsize : getmntinfo(mntbufp, MNT_WAIT)); + return nflag ? mntsize : (size_t)getmntinfo(mntbufp, MNT_WAIT); mntbuf = *mntbufp; j = 0; @@ -323,10 +319,10 @@ } j++; } - return (j); + return j; } -void +static void prthumanval(int64_t bytes, const char *pad) { char
CVS commit: src/bin/df
Module Name:src Committed By: enami Date: Mon Aug 29 00:36:20 UTC 2011 Modified Files: src/bin/df: df.c Log Message: No need to print internal state once debug is done. To generate a diff of this commit: cvs rdiff -u -r1.87 -r1.88 src/bin/df/df.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/df/df.c diff -u src/bin/df/df.c:1.87 src/bin/df/df.c:1.88 --- src/bin/df/df.c:1.87 Sun Aug 28 08:20:58 2011 +++ src/bin/df/df.c Mon Aug 29 00:36:20 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: df.c,v 1.87 2011/08/28 08:20:58 christos Exp $ */ +/* $NetBSD: df.c,v 1.88 2011/08/29 00:36:20 enami Exp $ */ /* * Copyright (c) 1980, 1990, 1993, 1994 @@ -45,7 +45,7 @@ #if 0 static char sccsid[] = @(#)df.c 8.7 (Berkeley) 4/2/94; #else -__RCSID($NetBSD: df.c,v 1.87 2011/08/28 08:20:58 christos Exp $); +__RCSID($NetBSD: df.c,v 1.88 2011/08/29 00:36:20 enami Exp $); #endif #endif /* not lint */ @@ -448,7 +448,6 @@ (void)printf(Filesystem %s Used Available Capacity Mounted on\n, header); } else { - printf(%d %d\n, maxwidth, headerlen); (void)printf(%-*.*s %s Used Avail %%Cap, maxwidth - (headerlen - 10), maxwidth - (headerlen - 10),