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

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
-

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!