CVS commit: src/bin/df

2024-08-02 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sat Aug  3 05:27:58 UTC 2024

Modified Files:
src/bin/df: df.1 df.c

Log Message:
Add -M and -q options to df(1).

-q suppresses warning output (rather than redirecting stderr, which
also buries error messages, which -q does not).

-M requires each arg given to be the name of a mount point, and
issues a warning, and ignores the arg, if it is not.   This allows
scripts (etc) to have a whole list of places for which to produce df
output, while only listing the ones that are actually mounted (rather
than simply listing the filesystem containing the mount point instead -
perhaps several times).  (If there are no args, -M is a no-op).

If the options aren't given, nothing alters.


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/bin/df/df.1
cvs rdiff -u -r1.102 -r1.103 src/bin/df/df.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/bin/df

2024-08-02 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sat Aug  3 05:27:58 UTC 2024

Modified Files:
src/bin/df: df.1 df.c

Log Message:
Add -M and -q options to df(1).

-q suppresses warning output (rather than redirecting stderr, which
also buries error messages, which -q does not).

-M requires each arg given to be the name of a mount point, and
issues a warning, and ignores the arg, if it is not.   This allows
scripts (etc) to have a whole list of places for which to produce df
output, while only listing the ones that are actually mounted (rather
than simply listing the filesystem containing the mount point instead -
perhaps several times).  (If there are no args, -M is a no-op).

If the options aren't given, nothing alters.


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/bin/df/df.1
cvs rdiff -u -r1.102 -r1.103 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.59 src/bin/df/df.1:1.60
--- src/bin/df/df.1:1.59	Sat Aug  3 04:04:54 2024
+++ src/bin/df/df.1	Sat Aug  3 05:27:58 2024
@@ -1,4 +1,4 @@
-.\" $NetBSD: df.1,v 1.59 2024/08/03 04:04:54 kre Exp $
+.\" $NetBSD: df.1,v 1.60 2024/08/03 05:27:58 kre 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 8, 2022
+.Dd August 3, 2024
 .Dt DF 1
 .Os
 .Sh NAME
@@ -37,7 +37,7 @@
 .Nd display free disk space
 .Sh SYNOPSIS
 .Nm
-.Op Fl aclnW
+.Op Fl aclMnqW
 .Op Fl G | Fl bkP | Fl bfgHhikmN
 .Op Fl t Ar type
 .Oo Ar file | Ar file_system Oc Ns ...
@@ -173,6 +173,23 @@ Display statistics only about mounted fi
 flag set.
 If a non-local file system is given as an argument, a
 warning is issued and no information is given on that file system.
+.It Fl M
+Each
+.Ar file
+.Pq or Ar file_system
+specified as an argument must give a path to a mount point
+in the tree, at which a file system is currently mounted.
+Information for that mounted file system is, if not otherwise
+excluded, provided.
+If a
+.Ar file
+which does not name a mount point is specified,
+a warning is issued,
+and no information is given for the file system on which that
+.Ar file
+resides (unless some other
+.Ar file
+names its mount point).
 .It Fl m
 The
 .Fl m
@@ -217,6 +234,8 @@ option may not be specified with
 and the
 .Ar blksize
 is required to be 512 or 1024.
+.It Fl q
+Suppress all warning output.
 .It Fl t Ar type
 Is used to indicate the actions should only be taken on
 file systems of the specified type.

Index: src/bin/df/df.c
diff -u src/bin/df/df.c:1.102 src/bin/df/df.c:1.103
--- src/bin/df/df.c:1.102	Mon Dec 18 08:27:24 2023
+++ src/bin/df/df.c	Sat Aug  3 05:27:58 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: df.c,v 1.102 2023/12/18 08:27:24 kre Exp $ */
+/*	$NetBSD: df.c,v 1.103 2024/08/03 05:27:58 kre 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.102 2023/12/18 08:27:24 kre Exp $");
+__RCSID("$NetBSD: df.c,v 1.103 2024/08/03 05:27:58 kre Exp $");
 #endif
 #endif /* not lint */
 
@@ -77,7 +77,7 @@ static void	 prthumanval(int64_t, int);
 static void	 prthuman(const struct statvfs *, int64_t, int64_t);
 
 static int	 aflag, cflag, fflag, gflag, hflag, iflag, lflag;
-static int	 Nflag, nflag, Pflag, Wflag;
+static int	 Mflag, Nflag, nflag, Pflag, qflag, Wflag;
 static long	 usize;
 static char	**typelist;
 static size_t	 mntcount;
@@ -88,6 +88,9 @@ static int blksize_width = WIDTH_BLKSIZE
 
 static int fudgeunits = 0;
 
+#define	streq(a, b)	(strcmp((a), (b)) == 0)
+#define	warnq(args)	do { if (!qflag) warnx args; } while (0)
+
 int
 main(int argc, char *argv[])
 {
@@ -100,7 +103,7 @@ main(int argc, char *argv[])
 	setprogname(argv[0]);
 	(void)setlocale(LC_ALL, "");
 
-	while ((ch = getopt(argc, argv, "abcfGgHhiklmNnPt:W")) != -1)
+	while ((ch = getopt(argc, argv, "abcfGgHhiklMmNnPqt:W")) != -1)
 		switch (ch) {
 		case 'a':
 			aflag = 1;
@@ -139,6 +142,9 @@ main(int argc, char *argv[])
 		case 'l':
 			lflag = 1;
 			break;
+		case 'M':
+			Mflag = 1;
+			break;
 		case 'm':
 			hflag = 0;
 			usize = 1024 * 1024;
@@ -152,6 +158,9 @@ main(int argc, char *argv[])
 		case 'P':
 			Pflag = 1;
 			break;
+		case 'q':
+			qflag = 1;
+			break;
 		case 'W':
 			Wflag = 1;
 			break;
@@ -203,7 +212,8 @@ main(int argc, char *argv[])
 		for (/*EMPTY*/; *argv != NULL; argv++) {
 			if (stat(*argv, ) < 0) {
 if ((mntpt = getmntpt(*argv)) == 0) {
-	warn("%s", *argv);
+	if (!qflag)
+		warn("%s", *argv);
 	continue;
 }
 			} else if (S_ISBLK(stbuf.st_mode)) {
@@ -211,25 +221,30 @@ main(int argc, char *argv[])
 	mntpt = *argv;
 			} else
 mntpt = *argv;
+
 			/*
 			 * Statfs does not take a `wait' flag, so we cannot
 			 * 

CVS commit: src/bin/df

2024-08-02 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sat Aug  3 04:04:54 UTC 2024

Modified Files:
src/bin/df: df.1

Log Message:
Typo correction: s/givem/given/.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/bin/df/df.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/bin/df

2024-08-02 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sat Aug  3 04:04:54 UTC 2024

Modified Files:
src/bin/df: df.1

Log Message:
Typo correction: s/givem/given/.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 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.58 src/bin/df/df.1:1.59
--- src/bin/df/df.1:1.58	Tue Aug  9 08:13:56 2022
+++ src/bin/df/df.1	Sat Aug  3 04:04:54 2024
@@ -1,4 +1,4 @@
-.\" $NetBSD: df.1,v 1.58 2022/08/09 08:13:56 wiz Exp $
+.\" $NetBSD: df.1,v 1.59 2024/08/03 04:04:54 kre Exp $
 .\"
 .\" Copyright (c) 1989, 1990, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -76,7 +76,7 @@ If no
 .Ar file ,
 or
 .Ar file_system
-arguments are givem, show all mount points,
+arguments are given, show all mount points,
 including those that were mounted with the
 .Dv MNT_IGNORE
 flag.



CVS commit: src/bin/df

2023-12-18 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Mon Dec 18 08:27:24 UTC 2023

Modified Files:
src/bin/df: df.c

Log Message:
Correctly compute the "Filesystem" column with when using -W
(that added "NAME=" occupies space!)

XXX pullup -10


To generate a diff of this commit:
cvs rdiff -u -r1.101 -r1.102 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.101 src/bin/df/df.c:1.102
--- src/bin/df/df.c:1.101	Tue Aug  9 08:14:03 2022
+++ src/bin/df/df.c	Mon Dec 18 08:27:24 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: df.c,v 1.101 2022/08/09 08:14:03 wiz Exp $ */
+/*	$NetBSD: df.c,v 1.102 2023/12/18 08:27:24 kre 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.101 2022/08/09 08:14:03 wiz Exp $");
+__RCSID("$NetBSD: df.c,v 1.102 2023/12/18 08:27:24 kre Exp $");
 #endif
 #endif /* not lint */
 
@@ -243,8 +243,13 @@ main(int argc, char *argv[])
 
 	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);
+		width = 0;
+		if (Wflag && mntbuf[i].f_mntfromlabel[0]) {
+			/* +5 is for "NAME=" added later */
+			width = (int)strlen(mntbuf[i].f_mntfromlabel) + 5;
+		}
+		if (width == 0)
+			width = (int)strlen(mntbuf[i].f_mntfromname);
 		if (width > maxwidth)
 			maxwidth = width;
 		if (cflag)



CVS commit: src/bin/df

2023-12-18 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Mon Dec 18 08:27:24 UTC 2023

Modified Files:
src/bin/df: df.c

Log Message:
Correctly compute the "Filesystem" column with when using -W
(that added "NAME=" occupies space!)

XXX pullup -10


To generate a diff of this commit:
cvs rdiff -u -r1.101 -r1.102 src/bin/df/df.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/bin/df

2022-08-09 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Aug  9 08:14:03 UTC 2022

Modified Files:
src/bin/df: df.c

Log Message:
Sync usage with man page.


To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 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.100 src/bin/df/df.c:1.101
--- src/bin/df/df.c:1.100	Mon Aug  8 16:50:35 2022
+++ src/bin/df/df.c	Tue Aug  9 08:14:03 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: df.c,v 1.100 2022/08/08 16:50:35 kre Exp $ */
+/*	$NetBSD: df.c,v 1.101 2022/08/09 08:14:03 wiz 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.100 2022/08/08 16:50:35 kre Exp $");
+__RCSID("$NetBSD: df.c,v 1.101 2022/08/09 08:14:03 wiz Exp $");
 #endif
 #endif /* not lint */
 
@@ -623,7 +623,7 @@ usage(void)
 {
 
 	(void)fprintf(stderr,
-	"Usage: %s [-alnW] [-G|-Pbk|-bfgHhikm] [-t type] [file | "
+	"Usage: %s [-aclnW] [-G|-bkP|-bfgHhikmN] [-t type] [file | "
 	"file_system]...\n",
 	getprogname());
 	exit(1);



CVS commit: src/bin/df

2022-08-09 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Aug  9 08:14:03 UTC 2022

Modified Files:
src/bin/df: df.c

Log Message:
Sync usage with man page.


To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 src/bin/df/df.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/bin/df

2022-08-09 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Aug  9 08:13:56 UTC 2022

Modified Files:
src/bin/df: df.1

Log Message:
Sort options, fix macro, add RCS Id.


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/bin/df/df.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/bin/df

2022-08-09 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Aug  9 08:13:56 UTC 2022

Modified Files:
src/bin/df: df.1

Log Message:
Sort options, fix macro, add RCS Id.


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 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.57 src/bin/df/df.1:1.58
--- src/bin/df/df.1:1.57	Mon Aug  8 16:50:35 2022
+++ src/bin/df/df.1	Tue Aug  9 08:13:56 2022
@@ -1,3 +1,5 @@
+.\" $NetBSD: df.1,v 1.58 2022/08/09 08:13:56 wiz Exp $
+.\"
 .\" Copyright (c) 1989, 1990, 1993
 .\"	The Regents of the University of California.  All rights reserved.
 .\"
@@ -36,7 +38,7 @@
 .Sh SYNOPSIS
 .Nm
 .Op Fl aclnW
-.Op Fl G | Fl Pbk | Fl bfgHhikmN
+.Op Fl G | Fl bkP | Fl bfgHhikmN
 .Op Fl t Ar type
 .Oo Ar file | Ar file_system Oc Ns ...
 .Sh DESCRIPTION
@@ -246,7 +248,7 @@ If more than one of
 .Fl h ,
 .Fl k
 or
-.FL m
+.Fl m
 is given, the last of those specified is used.
 .Sh ENVIRONMENT
 .Bl -tag -width BLOCKSIZE



CVS commit: src/bin/df

2022-08-08 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Mon Aug  8 16:50:35 UTC 2022

Modified Files:
src/bin/df: df.1 df.c

Log Message:
Add 4 new flags:
-b (from FreeBSD) - set blocksize to blocks (512 bytes)
(overrides a contrary setting in BLOCKSIZE)
-H (from FreeBSD and Linux): -h using SI units (powers of 10).  Ugh.
-N suppress the header line (except with -P which requires it).
-f show only free space (or inodes) in a minimal format (implies -N)
(that is, with one file[system] specified, print 1 number only)
With -c, show only the total.
Intended to be useful for scripting (aka, I needed it.)

While here, improve the usage message (group options where they apply,
there is no reason, for example, that -g should be shown differently
to -k -m ..., and those options aren't at all useful with -G)

Update the man page to match.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/bin/df/df.1
cvs rdiff -u -r1.99 -r1.100 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.56 src/bin/df/df.1:1.57
--- src/bin/df/df.1:1.56	Wed Jan  6 20:38:09 2021
+++ src/bin/df/df.1	Mon Aug  8 16:50:35 2022
@@ -1,5 +1,3 @@
-.\"	$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 +27,7 @@
 .\"
 .\"	@(#)df.1	8.2 (Berkeley) 1/13/92
 .\"
-.Dd January 2, 2021
+.Dd August 8, 2022
 .Dt DF 1
 .Os
 .Sh NAME
@@ -37,10 +35,10 @@
 .Nd display free disk space
 .Sh SYNOPSIS
 .Nm
-.Op Fl acglnW
-.Op Fl Ghkm | Fl ihkm | Fl Pk
+.Op Fl aclnW
+.Op Fl G | Fl Pbk | Fl bfgHhikmN
 .Op Fl t Ar type
-.Op Ar file | Ar file_system ...
+.Oo Ar file | Ar file_system Oc Ns ...
 .Sh DESCRIPTION
 .Nm
 displays statistics about the amount of free disk space on the specified
@@ -52,8 +50,12 @@ By default, all sizes are reported in 51
 If neither a file or a
 .Ar file_system
 operand is specified,
-statistics for all mounted file systems are displayed
+statistics for all mounted,
+and not hidden (i.e.: not mounted with
+.Dv MNT_IGNORE ) ,
+file systems are displayed
 (subject to the
+.Fl a ,
 .Fl l
 and
 .Fl t
@@ -68,26 +70,68 @@ on the file system is less than
 The following options are available:
 .Bl -tag -width Ds
 .It Fl a
-Show all mount points,
+If no
+.Ar file ,
+or
+.Ar file_system
+arguments are givem, show all mount points,
 including those that were mounted with the
 .Dv MNT_IGNORE
 flag.
+Note that for file systems specified on the command
+line, that mount option is never considered.
+.It Fl b
+Show space as units of basic blocks (512 bytes).
+This is normally the default; this option can be used to
+override a conflicting setting in the environment variable
+.Ev BLOCKSIZE .
 .It Fl c
 Display a grand total for all shown mount points.
+When combined with
+.Fl f
+only the total for the mount points which otherwise
+would be included is shown, not the individual entries.
+.It Fl f
+Display only the available free space (or with
+.Fl i ,
+free inodes) in a minimal format.
+When there is to be only one line of output, only the value
+is shown, otherwise the value and the mount point,
+separated by a single space, are printed.
+For free space, the
+.Fl b ,
+.Fl g ,
+.Fl H ,
+.Fl h ,
+.Fl k
+and
+.Fl m
+options, and
+.Ev BLOCKSIZE
+are all used as normal.
+This option implies
+.Fl N
+and is incompatible with
+.Fl P
+and
+.Fl G .
 .It Fl G
 Display all the fields of the structure(s) returned by
 .Xr statvfs 2 .
 This option cannot be used with the
+.Fl f ,
 .Fl i
 or
 .Fl P
-options, and it is modelled after the Solaris
+options, and is modelled after the Solaris
 .Fl g
 option.
 This option will override the
+.Fl b ,
 .Fl g ,
+.Fl H ,
 .Fl h ,
-.Fl k ,
+.Fl k
 and
 .Fl m
 options, as well as any setting of
@@ -95,20 +139,32 @@ options, as well as any setting of
 .It Fl g
 The
 .Fl g
-option causes the numbers to be reported in gigabytes (1024*1024*1024
+option causes size numbers to be reported in gigabytes (1024*1024*1024
 bytes).
 .It Fl h
-"Human-readable" output.
+Use
+.Dq human-readable
+output for space data.
 Use unit suffixes: Byte, Kilobyte, Megabyte,
 Gigabyte, Terabyte, Petabyte, Exabyte in order to reduce the number of
 digits to four or less.
+.It Fl H
+As with
+.Fl h
+but using powers of 10 (1000) rather than 2 (1024).
 .It Fl i
 Include statistics on the number of free inodes.
+When combined with
+.Fl f
+only the number of free inodes is shown.
 .It Fl k
-By default, all sizes are reported in 512-byte block counts.
+By default, all sizes are reported in 512-byte block counts,
+unless the
+.Ev BLOCKSIZE
+environment variable is set.
 The
 .Fl k
-option causes the numbers to be reported in kilobytes (1024 bytes).
+option causes the size numbers to be 

CVS commit: src/bin/df

2022-08-08 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Mon Aug  8 16:50:35 UTC 2022

Modified Files:
src/bin/df: df.1 df.c

Log Message:
Add 4 new flags:
-b (from FreeBSD) - set blocksize to blocks (512 bytes)
(overrides a contrary setting in BLOCKSIZE)
-H (from FreeBSD and Linux): -h using SI units (powers of 10).  Ugh.
-N suppress the header line (except with -P which requires it).
-f show only free space (or inodes) in a minimal format (implies -N)
(that is, with one file[system] specified, print 1 number only)
With -c, show only the total.
Intended to be useful for scripting (aka, I needed it.)

While here, improve the usage message (group options where they apply,
there is no reason, for example, that -g should be shown differently
to -k -m ..., and those options aren't at all useful with -G)

Update the man page to match.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/bin/df/df.1
cvs rdiff -u -r1.99 -r1.100 src/bin/df/df.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/bin/df

2021-11-28 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Mon Nov 29 05:59:58 UTC 2021

Modified Files:
src/bin/df: df.c

Log Message:
Set totals.f_frsize to DEV_BSIZE instead of totals.f_bsize so that
addstat() uses an initialised value for total size calculations.
Fixes core dump for "df -c".


To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.99 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.98 src/bin/df/df.c:1.99
--- src/bin/df/df.c:1.98	Sun Jan  3 01:43:12 2021
+++ src/bin/df/df.c	Mon Nov 29 05:59:58 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: df.c,v 1.98 2021/01/03 01:43:12 ginsbach Exp $ */
+/*	$NetBSD: df.c,v 1.99 2021/11/29 05:59:58 simonb 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.98 2021/01/03 01:43:12 ginsbach Exp $");
+__RCSID("$NetBSD: df.c,v 1.99 2021/11/29 05:59:58 simonb Exp $");
 #endif
 #endif /* not lint */
 
@@ -213,7 +213,7 @@ main(int argc, char *argv[])
 
 	if (cflag) {
 		memset(, 0, sizeof(totals));
-		totals.f_bsize = DEV_BSIZE;
+		totals.f_frsize = DEV_BSIZE;
 		strlcpy(totals.f_mntfromname, "total",
 			sizeof(totals.f_mntfromname));
 	}



CVS commit: src/bin/df

2021-11-28 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Mon Nov 29 05:59:58 UTC 2021

Modified Files:
src/bin/df: df.c

Log Message:
Set totals.f_frsize to DEV_BSIZE instead of totals.f_bsize so that
addstat() uses an initialised value for total size calculations.
Fixes core dump for "df -c".


To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.99 src/bin/df/df.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/bin/df

2021-01-06 Thread Brian Ginsbach
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

2021-01-06 Thread Brian Ginsbach
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.



CVS commit: src/bin/df

2021-01-02 Thread Brian Ginsbach
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

2021-01-02 Thread Brian Ginsbach
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.



CVS commit: src/bin/df

2020-08-21 Thread Ryo Shimizu
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

2020-08-21 Thread Ryo Shimizu
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.



CVS commit: src/bin/df

2020-08-21 Thread Ryo Shimizu
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.



CVS commit: src/bin/df

2020-08-21 Thread Ryo Shimizu
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

2019-09-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Sep 23 15:24:44 UTC 2019

Modified Files:
src/bin/df: df.1

Log Message:
we don't need root anymore.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/bin/df/df.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/bin/df

2019-09-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Sep 23 15:24:44 UTC 2019

Modified Files:
src/bin/df: df.1

Log Message:
we don't need root anymore.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 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.53 src/bin/df/df.1:1.54
--- src/bin/df/df.1:1.53	Fri Sep 20 09:43:47 2019
+++ src/bin/df/df.1	Mon Sep 23 11:24:44 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: df.1,v 1.53 2019/09/20 13:43:47 wiz Exp $
+.\"	$NetBSD: df.1,v 1.54 2019/09/23 15:24:44 christos 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 18, 2019
+.Dd September 23, 2019
 .Dt DF 1
 .Os
 .Sh NAME
@@ -178,12 +178,7 @@ The wedge name is prefixed with
 .Dq NAME=
 as in
 .Xr fstab 5 .
-The .Fl W
-option needs read access on the devices to be able to access
-the wedge information.
-This is available to users with root privileges, and usually to
-members of group operator.
-If the wedge information cannot be obtained, for one or more
+If the wedge information cannot be obtained for one or more
 file systems, the
 .Fl W
 option is silently ignored for those file systems.
@@ -219,10 +214,3 @@ A
 .Nm
 utility appeared in
 .At v1 .
-.Sh BUGS
-The
-.Fl W
-option needs read access to the disk device node to
-get the wedge information.
-Perhaps this information should be exposed via a different mechanism in the
-future.



CVS commit: src/bin/df

2019-09-20 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Fri Sep 20 13:43:47 UTC 2019

Modified Files:
src/bin/df: df.1

Log Message:
file system police. Fix typo. Fix macro use.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 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.52 src/bin/df/df.1:1.53
--- src/bin/df/df.1:1.52	Wed Sep 18 23:43:23 2019
+++ src/bin/df/df.1	Fri Sep 20 13:43:47 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: df.1,v 1.52 2019/09/18 23:43:23 christos Exp $
+.\"	$NetBSD: df.1,v 1.53 2019/09/20 13:43:47 wiz Exp $
 .\"
 .\" Copyright (c) 1989, 1990, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -62,7 +62,7 @@ options below).
 Note that the printed count of available blocks takes
 .Va minfree
 into account, and thus will be negative when the number of free blocks
-on the filesystem is less than
+on the file system is less than
 .Va minfree .
 .Pp
 The following options are available:
@@ -162,11 +162,11 @@ option may not be specified with
 .Fl P .
 .It Fl t Ar type
 Is used to indicate the actions should only be taken on
-filesystems of the specified type.
+file systems of the specified type.
 More than one type may be specified in a comma-separated list.
-The list of filesystem types can be prefixed with
+The list of file system types can be prefixed with
 .Dq no
-to specify the filesystem types for which action should
+to specify the file system types for which action should
 .Em not
 be taken.
 If a file system is given on the command line that is not of
@@ -184,8 +184,9 @@ the wedge information.
 This is available to users with root privileges, and usually to
 members of group operator.
 If the wedge information cannot be obtained, for one or more
-filesystems, the
-.Fl W option is silently ignoresd for those filesystems.
+file systems, the
+.Fl W
+option is silently ignored for those file systems.
 .El
 .Sh ENVIRONMENT
 .Bl -tag -width BLOCKSIZE



CVS commit: src/bin/df

2019-09-20 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Fri Sep 20 13:43:47 UTC 2019

Modified Files:
src/bin/df: df.1

Log Message:
file system police. Fix typo. Fix macro use.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/bin/df/df.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/bin/df

2019-09-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Sep 18 23:43:23 UTC 2019

Modified Files:
src/bin/df: df.1

Log Message:
It is not just root, it is device read access (kre)


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 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.51 src/bin/df/df.1:1.52
--- src/bin/df/df.1:1.51	Wed Sep 18 16:17:46 2019
+++ src/bin/df/df.1	Wed Sep 18 19:43:23 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: df.1,v 1.51 2019/09/18 20:17:46 christos Exp $
+.\"	$NetBSD: df.1,v 1.52 2019/09/18 23:43:23 christos Exp $
 .\"
 .\" Copyright (c) 1989, 1990, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -178,6 +178,14 @@ The wedge name is prefixed with
 .Dq NAME=
 as in
 .Xr fstab 5 .
+The .Fl W
+option needs read access on the devices to be able to access
+the wedge information.
+This is available to users with root privileges, and usually to
+members of group operator.
+If the wedge information cannot be obtained, for one or more
+filesystems, the
+.Fl W option is silently ignoresd for those filesystems.
 .El
 .Sh ENVIRONMENT
 .Bl -tag -width BLOCKSIZE
@@ -213,7 +221,7 @@ utility appeared in
 .Sh BUGS
 The
 .Fl W
-option needs root privileges to run because it needs to open the disk devices
-to get the wedge information.
+option needs read access to the disk device node to
+get the wedge information.
 Perhaps this information should be exposed via a different mechanism in the
 future.



CVS commit: src/bin/df

2019-09-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Sep 18 23:43:23 UTC 2019

Modified Files:
src/bin/df: df.1

Log Message:
It is not just root, it is device read access (kre)


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/bin/df/df.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/bin/df

2019-09-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Sep 18 20:17:46 UTC 2019

Modified Files:
src/bin/df: df.1

Log Message:
mention that -W needs root.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 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.50 src/bin/df/df.1:1.51
--- src/bin/df/df.1:1.50	Wed Sep 18 16:14:44 2019
+++ src/bin/df/df.1	Wed Sep 18 16:17:46 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: df.1,v 1.50 2019/09/18 20:14:44 christos Exp $
+.\"	$NetBSD: df.1,v 1.51 2019/09/18 20:17:46 christos Exp $
 .\"
 .\" Copyright (c) 1989, 1990, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -210,3 +210,10 @@ A
 .Nm
 utility appeared in
 .At v1 .
+.Sh BUGS
+The
+.Fl W
+option needs root privileges to run because it needs to open the disk devices
+to get the wedge information.
+Perhaps this information should be exposed via a different mechanism in the
+future.



CVS commit: src/bin/df

2019-09-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Sep 18 20:17:46 UTC 2019

Modified Files:
src/bin/df: df.1

Log Message:
mention that -W needs root.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/bin/df/df.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/bin/df

2019-09-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Sep 18 20:14:44 UTC 2019

Modified Files:
src/bin/df: df.1 df.c

Log Message:
Print the wedge name with -W instead of mntfrom


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/bin/df/df.1
cvs rdiff -u -r1.93 -r1.94 src/bin/df/df.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/bin/df

2019-09-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Sep 18 20:14:44 UTC 2019

Modified Files:
src/bin/df: df.1 df.c

Log Message:
Print the wedge name with -W instead of mntfrom


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/bin/df/df.1
cvs rdiff -u -r1.93 -r1.94 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.49 src/bin/df/df.1:1.50
--- src/bin/df/df.1:1.49	Sun Aug 26 19:34:52 2018
+++ src/bin/df/df.1	Wed Sep 18 16:14:44 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: df.1,v 1.49 2018/08/26 23:34:52 sevan Exp $
+.\"	$NetBSD: df.1,v 1.50 2019/09/18 20:14:44 christos 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 27, 2018
+.Dd September 18, 2019
 .Dt DF 1
 .Os
 .Sh NAME
@@ -37,7 +37,7 @@
 .Nd display free disk space
 .Sh SYNOPSIS
 .Nm
-.Op Fl agln
+.Op Fl aglnW
 .Op Fl Ghkm | Fl ihkm | Fl Pk
 .Op Fl t Ar type
 .Op Ar file | Ar file_system ...
@@ -172,6 +172,12 @@ be taken.
 If a file system is given on the command line that is not of
 the specified type, a warning is issued and no information is given on
 that file system.
+.It Fl W
+Print the wedge name instead of the mounted from device for wedges.
+The wedge name is prefixed with
+.Dq NAME=
+as in
+.Xr fstab 5 .
 .El
 .Sh ENVIRONMENT
 .Bl -tag -width BLOCKSIZE

Index: src/bin/df/df.c
diff -u src/bin/df/df.c:1.93 src/bin/df/df.c:1.94
--- src/bin/df/df.c:1.93	Sun Aug 26 19:34:52 2018
+++ src/bin/df/df.c	Wed Sep 18 16:14:44 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: df.c,v 1.93 2018/08/26 23:34:52 sevan Exp $ */
+/*	$NetBSD: df.c,v 1.94 2019/09/18 20:14:44 christos Exp $ */
 
 /*
  * Copyright (c) 1980, 1990, 1993, 1994
@@ -45,17 +45,20 @@ __COPYRIGHT(
 #if 0
 static char sccsid[] = "@(#)df.c	8.7 (Berkeley) 4/2/94";
 #else
-__RCSID("$NetBSD: df.c,v 1.93 2018/08/26 23:34:52 sevan Exp $");
+__RCSID("$NetBSD: df.c,v 1.94 2019/09/18 20:14:44 christos Exp $");
 #endif
 #endif /* not lint */
 
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -66,15 +69,17 @@ __RCSID("$NetBSD: df.c,v 1.93 2018/08/26
 #include 
 
 static char	*getmntpt(const char *);
-static void	 prtstat(struct statvfs *, int);
+static void	 prtstat(const struct dkwedge_info *, const 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 struct dkwedge_info *getwedgeinfo(const struct statvfs *, size_t);
 static void	 prthumanval(int64_t, const char *);
-static void	 prthuman(struct statvfs *, int64_t, int64_t);
+static void	 prthuman(const struct statvfs *, int64_t, int64_t);
 
-static int	 aflag, gflag, hflag, iflag, lflag, nflag, Pflag;
+static int	 aflag, gflag, hflag, iflag, lflag, nflag, Pflag, Wflag;
 static long	 usize;
 static char	**typelist;
 
@@ -83,14 +88,15 @@ main(int argc, char *argv[])
 {
 	struct stat stbuf;
 	struct statvfs *mntbuf;
-	long mntsize;
-	int ch, i, maxwidth, width;
+	struct dkwedge_info *wedge_info;
+	int ch, maxwidth, width;
+	size_t i, mntcount;
 	char *mntpt;
 
 	setprogname(argv[0]);
 	(void)setlocale(LC_ALL, "");
 
-	while ((ch = getopt(argc, argv, "aGghiklmnPt:")) != -1)
+	while ((ch = getopt(argc, argv, "aGghiklmnPt:W")) != -1)
 		switch (ch) {
 		case 'a':
 			aflag = 1;
@@ -126,6 +132,9 @@ main(int argc, char *argv[])
 		case 'P':
 			Pflag = 1;
 			break;
+		case 'W':
+			Wflag = 1;
+			break;
 		case 't':
 			if (typelist != NULL)
 errx(EXIT_FAILURE,
@@ -154,17 +163,17 @@ main(int argc, char *argv[])
 	argc -= optind;
 	argv += optind;
 
-	mntsize = getmntinfo(, MNT_NOWAIT);
-	if (mntsize == 0)
+	mntcount = getmntinfo(, MNT_NOWAIT);
+	if (mntcount == 0)
 		err(EXIT_FAILURE,
 		"retrieving information on mounted file systems");
 
 	if (*argv == NULL) {
-		mntsize = regetmntinfo(, mntsize);
+		mntcount = regetmntinfo(, mntcount);
 	} else {
-		if ((mntbuf = malloc(argc * sizeof(*mntbuf))) == NULL)
+		if ((mntbuf = calloc(argc, sizeof(*mntbuf))) == NULL)
 			err(EXIT_FAILURE, "can't allocate statvfs array");
-		mntsize = 0;
+		mntcount = 0;
 		for (/*EMPTY*/; *argv != NULL; argv++) {
 			if (stat(*argv, ) < 0) {
 if ((mntpt = getmntpt(*argv)) == 0) {
@@ -180,46 +189,50 @@ main(int argc, char *argv[])
 			 * Statfs does not take a `wait' flag, so we cannot
 			 * implement nflag here.
 			 */
-			if (!statvfs(mntpt, [mntsize]))
+			if (!statvfs(mntpt, [mntcount]))
 if (lflag &&
-(mntbuf[mntsize].f_flag & MNT_LOCAL) == 0)
+(mntbuf[mntcount].f_flag & MNT_LOCAL) == 0)
 	warnx("Warning: %s is not a local %s",
 	*argv, "file system");
 else if
-

CVS commit: src/bin/df

2018-08-26 Thread Sevan Janiyan
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

2018-08-26 Thread Sevan Janiyan
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.



Re: CVS commit: src/bin/df

2018-08-26 Thread Leonardo Taccari
Hello Sevan,

Sevan Janiyan writes:
> 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()
> [...]

Shouldn't this be:

 df [-agln] [-Ghkm|-ihkm|-Pk] [-t type] [file | file_system ...]

instead? (both in SYNOPSIS and usage())

(i.e. only one of `-G' or `-i' or `-P' can be selected)


Thanks!


CVS commit: src/bin/df

2018-08-26 Thread Sevan Janiyan
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

2018-08-26 Thread Sevan Janiyan
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.



CVS commit: src/bin/df

2016-08-10 Thread Sevan Janiyan
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.



CVS commit: src/bin/df

2016-08-10 Thread Sevan Janiyan
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

2016-08-10 Thread Sevan Janiyan
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

2016-08-10 Thread Sevan Janiyan
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.



CVS commit: src/bin/df

2016-03-05 Thread Kamil Rytarowski
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

2016-03-05 Thread Kamil Rytarowski
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.



CVS commit: src/bin/df

2015-11-12 Thread Christos Zoulas
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.



CVS commit: src/bin/df

2015-11-12 Thread Christos Zoulas
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

2012-01-07 Thread Christos Zoulas
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

2012-01-07 Thread Christos Zoulas
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.



CVS commit: src/bin/df

2011-08-29 Thread Andreas Gustafsson
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

2011-08-29 Thread Andreas Gustafsson
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.



CVS commit: src/bin/df

2011-08-28 Thread Christos Zoulas
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

2011-08-28 Thread enami tsugutomo
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),



CVS commit: src/bin/df

2011-08-28 Thread Christos Zoulas
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.



CVS commit: src/bin/df

2011-08-28 Thread enami tsugutomo
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.