Sun Aug 26 23:34:52 2018 UTC ()
-G cannot be specified alongside -i or -P.

Heads up by <leot>


(sevan)
diff -r1.48 -r1.49 src/bin/df/df.1
diff -r1.92 -r1.93 src/bin/df/df.c

cvs diff -r1.48 -r1.49 src/bin/df/df.1 (switch to unified diff)

--- src/bin/df/df.1 2018/08/26 22:25:37 1.48
+++ src/bin/df/df.1 2018/08/26 23:34:52 1.49
@@ -1,206 +1,206 @@ @@ -1,206 +1,206 @@
1.\" $NetBSD: df.1,v 1.48 2018/08/26 22:25:37 sevan Exp $ 1.\" $NetBSD: df.1,v 1.49 2018/08/26 23:34:52 sevan Exp $
2.\" 2.\"
3.\" Copyright (c) 1989, 1990, 1993 3.\" Copyright (c) 1989, 1990, 1993
4.\" The Regents of the University of California. All rights reserved. 4.\" The Regents of the University of California. All rights reserved.
5.\" 5.\"
6.\" Redistribution and use in source and binary forms, with or without 6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions 7.\" modification, are permitted provided that the following conditions
8.\" are met: 8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright 9.\" 1. Redistributions of source code must retain the above copyright
10.\" notice, this list of conditions and the following disclaimer. 10.\" notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright 11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the 12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution. 13.\" documentation and/or other materials provided with the distribution.
14.\" 3. Neither the name of the University nor the names of its contributors 14.\" 3. Neither the name of the University nor the names of its contributors
15.\" may be used to endorse or promote products derived from this software 15.\" may be used to endorse or promote products derived from this software
16.\" without specific prior written permission. 16.\" without specific prior written permission.
17.\" 17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28.\" SUCH DAMAGE. 28.\" SUCH DAMAGE.
29.\" 29.\"
30.\" @(#)df.1 8.2 (Berkeley) 1/13/92 30.\" @(#)df.1 8.2 (Berkeley) 1/13/92
31.\" 31.\"
32.Dd August 26, 2018 32.Dd August 27, 2018
33.Dt DF 1 33.Dt DF 1
34.Os 34.Os
35.Sh NAME 35.Sh NAME
36.Nm df 36.Nm df
37.Nd display free disk space 37.Nd display free disk space
38.Sh SYNOPSIS 38.Sh SYNOPSIS
39.Nm 39.Nm
40.Op Fl aGgln 40.Op Fl agln
41.Op Fl hkm | Fl ihkm | Fl Pk 41.Op Fl Ghkm | Fl ihkm | Fl Pk
42.Op Fl t Ar type 42.Op Fl t Ar type
43.Op Ar file | Ar file_system ... 43.Op Ar file | Ar file_system ...
44.Sh DESCRIPTION 44.Sh DESCRIPTION
45.Nm 45.Nm
46displays statistics about the amount of free disk space on the specified 46displays statistics about the amount of free disk space on the specified
47.Ar file_system 47.Ar file_system
48or on the file system of which 48or on the file system of which
49.Ar file 49.Ar file
50is a part. 50is a part.
51By default, all sizes are reported in 512-byte block counts. 51By default, all sizes are reported in 512-byte block counts.
52If neither a file or a 52If neither a file or a
53.Ar file_system 53.Ar file_system
54operand is specified, 54operand is specified,
55statistics for all mounted file systems are displayed 55statistics for all mounted file systems are displayed
56(subject to the 56(subject to the
57.Fl l 57.Fl l
58and 58and
59.Fl t 59.Fl t
60options below). 60options below).
61.Pp 61.Pp
62Note that the printed count of available blocks takes 62Note that the printed count of available blocks takes
63.Va minfree 63.Va minfree
64into account, and thus will be negative when the number of free blocks 64into account, and thus will be negative when the number of free blocks
65on the filesystem is less than 65on the filesystem is less than
66.Va minfree . 66.Va minfree .
67.Pp 67.Pp
68The following options are available: 68The following options are available:
69.Bl -tag -width Ds 69.Bl -tag -width Ds
70.It Fl a 70.It Fl a
71Show all mount points, 71Show all mount points,
72including those that were mounted with the 72including those that were mounted with the
73.Dv MNT_IGNORE 73.Dv MNT_IGNORE
74flag. 74flag.
75.It Fl G 75.It Fl G
76Display all the fields of the structure(s) returned by 76Display all the fields of the structure(s) returned by
77.Xr statvfs 2 . 77.Xr statvfs 2 .
78This option cannot be used with the 78This option cannot be used with the
79.Fl i 79.Fl i
80or 80or
81.Fl P 81.Fl P
82options, and it is modelled after the Solaris 82options, and it is modelled after the Solaris
83.Fl g 83.Fl g
84option. 84option.
85This option will override the 85This option will override the
86.Fl g , 86.Fl g ,
87.Fl h , 87.Fl h ,
88.Fl k , 88.Fl k ,
89and 89and
90.Fl m 90.Fl m
91options, as well as any setting of 91options, as well as any setting of
92.Ev BLOCKSIZE . 92.Ev BLOCKSIZE .
93.It Fl g 93.It Fl g
94The 94The
95.Fl g 95.Fl g
96option causes the numbers to be reported in gigabytes (1024*1024*1024 96option causes the numbers to be reported in gigabytes (1024*1024*1024
97bytes). 97bytes).
98.It Fl h 98.It Fl h
99"Human-readable" output. 99"Human-readable" output.
100Use unit suffixes: Byte, Kilobyte, Megabyte, 100Use unit suffixes: Byte, Kilobyte, Megabyte,
101Gigabyte, Terabyte, Petabyte, Exabyte in order to reduce the number of 101Gigabyte, Terabyte, Petabyte, Exabyte in order to reduce the number of
102digits to four or less. 102digits to four or less.
103.It Fl i 103.It Fl i
104Include statistics on the number of free inodes. 104Include statistics on the number of free inodes.
105.It Fl k 105.It Fl k
106By default, all sizes are reported in 512-byte block counts. 106By default, all sizes are reported in 512-byte block counts.
107The 107The
108.Fl k 108.Fl k
109option causes the numbers to be reported in kilobytes (1024 bytes). 109option causes the numbers to be reported in kilobytes (1024 bytes).
110.It Fl l 110.It Fl l
111Display statistics only about mounted file systems with the 111Display statistics only about mounted file systems with the
112.Dv MNT_LOCAL 112.Dv MNT_LOCAL
113flag set. 113flag set.
114If a non-local file system is given as an argument, a 114If a non-local file system is given as an argument, a
115warning is issued and no information is given on that file system. 115warning is issued and no information is given on that file system.
116.It Fl m 116.It Fl m
117The 117The
118.Fl m 118.Fl m
119option causes the numbers to be reported in megabytes (1024*1024 bytes). 119option causes the numbers to be reported in megabytes (1024*1024 bytes).
120.It Fl n 120.It Fl n
121Print out the previously obtained statistics from the file systems. 121Print out the previously obtained statistics from the file systems.
122This option should be used if it is possible that one or more 122This option should be used if it is possible that one or more
123file systems are in a state such that they will not be able to provide 123file systems are in a state such that they will not be able to provide
124statistics without a long delay. 124statistics without a long delay.
125When this option is specified, 125When this option is specified,
126.Nm 126.Nm
127will not request new statistics from the file systems, but will respond 127will not request new statistics from the file systems, but will respond
128with the possibly stale statistics that were previously obtained. 128with the possibly stale statistics that were previously obtained.
129.It Fl P 129.It Fl P
130Produce output in the following portable format: 130Produce output in the following portable format:
131.Pp 131.Pp
132If both the 132If both the
133.Fl P 133.Fl P
134and 134and
135.Fl k 135.Fl k
136option are specified, the output will be preceded by the following header 136option are specified, the output will be preceded by the following header
137line, formatted to match the data following it: 137line, formatted to match the data following it:
138.Bd -literal 138.Bd -literal
139"Filesystem 1024-blocks Used Available Capacity Mounted on\en" 139"Filesystem 1024-blocks Used Available Capacity Mounted on\en"
140.Ed 140.Ed
141.Pp 141.Pp
142If the 142If the
143.Fl P 143.Fl P
144option is specified without the 144option is specified without the
145.Fl k 145.Fl k
146options, the output will be preceded by the following header line, 146options, the output will be preceded by the following header line,
147formatted to match the data following it: 147formatted to match the data following it:
148.Bd -literal 148.Bd -literal
149"Filesystem <blksize>-blocks Used Available Capacity Mounted on\en" 149"Filesystem <blksize>-blocks Used Available Capacity Mounted on\en"
150.Ed 150.Ed
151.Pp 151.Pp
152The header line is followed by data formatted as follows: 152The header line is followed by data formatted as follows:
153.Bd -literal 153.Bd -literal
154"%s %d %d %d %d%% %s\en", <file system name>, <total space>, 154"%s %d %d %d %d%% %s\en", <file system name>, <total space>,
155 <space used>, <space free>, <percentage used>, 155 <space used>, <space free>, <percentage used>,
156 <file system root> 156 <file system root>
157.Ed 157.Ed
158.Pp 158.Pp
159Note that the 159Note that the
160.Fl i 160.Fl i
161option may not be specified with 161option may not be specified with
162.Fl P . 162.Fl P .
163.It Fl t Ar type 163.It Fl t Ar type
164Is used to indicate the actions should only be taken on 164Is used to indicate the actions should only be taken on
165filesystems of the specified type. 165filesystems of the specified type.
166More than one type may be specified in a comma-separated list. 166More than one type may be specified in a comma-separated list.
167The list of filesystem types can be prefixed with 167The list of filesystem types can be prefixed with
168.Dq no 168.Dq no
169to specify the filesystem types for which action should 169to specify the filesystem types for which action should
170.Em not 170.Em not
171be taken. 171be taken.
172If a file system is given on the command line that is not of 172If a file system is given on the command line that is not of
173the specified type, a warning is issued and no information is given on 173the specified type, a warning is issued and no information is given on
174that file system. 174that file system.
175.El 175.El
176.Sh ENVIRONMENT 176.Sh ENVIRONMENT
177.Bl -tag -width BLOCKSIZE 177.Bl -tag -width BLOCKSIZE
178.It Ev BLOCKSIZE 178.It Ev BLOCKSIZE
179If the environment variable 179If the environment variable
180.Ev BLOCKSIZE 180.Ev BLOCKSIZE
181is set, and the 181is set, and the
182.Fl g , 182.Fl g ,
183.Fl h , 183.Fl h ,
184.Fl k 184.Fl k
185and 185and
186.Fl m 186.Fl m
187options are not specified, the block counts will be displayed in units of that 187options are not specified, the block counts will be displayed in units of that
188size block. 188size block.
189.El 189.El
190.Sh SEE ALSO 190.Sh SEE ALSO
191.Xr quota 1 , 191.Xr quota 1 ,
192.Xr fstatvfs 2 , 192.Xr fstatvfs 2 ,
193.Xr getvfsstat 2 , 193.Xr getvfsstat 2 ,
194.Xr statvfs 2 , 194.Xr statvfs 2 ,
195.Xr getbsize 3 , 195.Xr getbsize 3 ,
196.Xr getmntinfo 3 , 196.Xr getmntinfo 3 ,
197.Xr fs 5 , 197.Xr fs 5 ,
198.Xr fstab 5 , 198.Xr fstab 5 ,
199.Xr mount 8 , 199.Xr mount 8 ,
200.Xr quot 8 , 200.Xr quot 8 ,
201.Xr tunefs 8 201.Xr tunefs 8
202.Sh HISTORY 202.Sh HISTORY
203A 203A
204.Nm 204.Nm
205utility appeared in 205utility appeared in
206.At v1 . 206.At v1 .

cvs diff -r1.92 -r1.93 src/bin/df/df.c (switch to unified diff)

--- src/bin/df/df.c 2016/03/05 08:15:01 1.92
+++ src/bin/df/df.c 2018/08/26 23:34:52 1.93
@@ -1,520 +1,520 @@ @@ -1,520 +1,520 @@
1/* $NetBSD: df.c,v 1.92 2016/03/05 08:15:01 kamil Exp $ */ 1/* $NetBSD: df.c,v 1.93 2018/08/26 23:34:52 sevan Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1980, 1990, 1993, 1994 4 * Copyright (c) 1980, 1990, 1993, 1994
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * (c) UNIX System Laboratories, Inc. 6 * (c) UNIX System Laboratories, Inc.
7 * All or some portions of this file are derived from material licensed 7 * All or some portions of this file are derived from material licensed
8 * to the University of California by American Telephone and Telegraph 8 * to the University of California by American Telephone and Telegraph
9 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 9 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
10 * the permission of UNIX System Laboratories, Inc. 10 * the permission of UNIX System Laboratories, Inc.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions 13 * modification, are permitted provided that the following conditions
14 * are met: 14 * are met:
15 * 1. Redistributions of source code must retain the above copyright 15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer. 16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright 17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the 18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution. 19 * documentation and/or other materials provided with the distribution.
20 * 3. Neither the name of the University nor the names of its contributors 20 * 3. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software 21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission. 22 * without specific prior written permission.
23 * 23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE. 34 * SUCH DAMAGE.
35 */ 35 */
36 36
37#include <sys/cdefs.h> 37#include <sys/cdefs.h>
38#ifndef lint 38#ifndef lint
39__COPYRIGHT( 39__COPYRIGHT(
40"@(#) Copyright (c) 1980, 1990, 1993, 1994\ 40"@(#) Copyright (c) 1980, 1990, 1993, 1994\
41 The Regents of the University of California. All rights reserved."); 41 The Regents of the University of California. All rights reserved.");
42#endif /* not lint */ 42#endif /* not lint */
43 43
44#ifndef lint 44#ifndef lint
45#if 0 45#if 0
46static char sccsid[] = "@(#)df.c 8.7 (Berkeley) 4/2/94"; 46static char sccsid[] = "@(#)df.c 8.7 (Berkeley) 4/2/94";
47#else 47#else
48__RCSID("$NetBSD: df.c,v 1.92 2016/03/05 08:15:01 kamil Exp $"); 48__RCSID("$NetBSD: df.c,v 1.93 2018/08/26 23:34:52 sevan Exp $");
49#endif 49#endif
50#endif /* not lint */ 50#endif /* not lint */
51 51
52#include <sys/param.h> 52#include <sys/param.h>
53#include <sys/stat.h> 53#include <sys/stat.h>
54#include <sys/mount.h> 54#include <sys/mount.h>
55 55
56#include <assert.h> 56#include <assert.h>
57#include <err.h> 57#include <err.h>
58#include <errno.h> 58#include <errno.h>
59#include <fcntl.h> 59#include <fcntl.h>
60#include <locale.h> 60#include <locale.h>
61#include <util.h> 61#include <util.h>
62#include <stdio.h> 62#include <stdio.h>
63#include <stdlib.h> 63#include <stdlib.h>
64#include <string.h> 64#include <string.h>
65#include <unistd.h> 65#include <unistd.h>
66#include <util.h> 66#include <util.h>
67 67
68static char *getmntpt(const char *); 68static char *getmntpt(const char *);
69static void prtstat(struct statvfs *, int); 69static void prtstat(struct statvfs *, int);
70static int selected(const char *, size_t); 70static int selected(const char *, size_t);
71static void maketypelist(char *); 71static void maketypelist(char *);
72static size_t regetmntinfo(struct statvfs **, size_t); 72static size_t regetmntinfo(struct statvfs **, size_t);
73__dead static void usage(void); 73__dead static void usage(void);
74static void prthumanval(int64_t, const char *); 74static void prthumanval(int64_t, const char *);
75static void prthuman(struct statvfs *, int64_t, int64_t); 75static void prthuman(struct statvfs *, int64_t, int64_t);
76 76
77static int aflag, gflag, hflag, iflag, lflag, nflag, Pflag; 77static int aflag, gflag, hflag, iflag, lflag, nflag, Pflag;
78static long usize; 78static long usize;
79static char **typelist; 79static char **typelist;
80 80
81int 81int
82main(int argc, char *argv[]) 82main(int argc, char *argv[])
83{ 83{
84 struct stat stbuf; 84 struct stat stbuf;
85 struct statvfs *mntbuf; 85 struct statvfs *mntbuf;
86 long mntsize; 86 long mntsize;
87 int ch, i, maxwidth, width; 87 int ch, i, maxwidth, width;
88 char *mntpt; 88 char *mntpt;
89 89
90 setprogname(argv[0]); 90 setprogname(argv[0]);
91 (void)setlocale(LC_ALL, ""); 91 (void)setlocale(LC_ALL, "");
92 92
93 while ((ch = getopt(argc, argv, "aGghiklmnPt:")) != -1) 93 while ((ch = getopt(argc, argv, "aGghiklmnPt:")) != -1)
94 switch (ch) { 94 switch (ch) {
95 case 'a': 95 case 'a':
96 aflag = 1; 96 aflag = 1;
97 break; 97 break;
98 case 'g': 98 case 'g':
99 hflag = 0; 99 hflag = 0;
100 usize = 1024 * 1024 * 1024; 100 usize = 1024 * 1024 * 1024;
101 break; 101 break;
102 case 'G': 102 case 'G':
103 gflag = 1; 103 gflag = 1;
104 break; 104 break;
105 case 'h': 105 case 'h':
106 hflag = 1; 106 hflag = 1;
107 usize = 0; 107 usize = 0;
108 break; 108 break;
109 case 'i': 109 case 'i':
110 iflag = 1; 110 iflag = 1;
111 break; 111 break;
112 case 'k': 112 case 'k':
113 hflag = 0; 113 hflag = 0;
114 usize = 1024; 114 usize = 1024;
115 break; 115 break;
116 case 'l': 116 case 'l':
117 lflag = 1; 117 lflag = 1;
118 break; 118 break;
119 case 'm': 119 case 'm':
120 hflag = 0; 120 hflag = 0;
121 usize = 1024 * 1024; 121 usize = 1024 * 1024;
122 break; 122 break;
123 case 'n': 123 case 'n':
124 nflag = 1; 124 nflag = 1;
125 break; 125 break;
126 case 'P': 126 case 'P':
127 Pflag = 1; 127 Pflag = 1;
128 break; 128 break;
129 case 't': 129 case 't':
130 if (typelist != NULL) 130 if (typelist != NULL)
131 errx(EXIT_FAILURE, 131 errx(EXIT_FAILURE,
132 "only one -t option may be specified."); 132 "only one -t option may be specified.");
133 maketypelist(optarg); 133 maketypelist(optarg);
134 break; 134 break;
135 case '?': 135 case '?':
136 default: 136 default:
137 usage(); 137 usage();
138 } 138 }
139 139
140 if (gflag && (Pflag || iflag)) 140 if (gflag && (Pflag || iflag))
141 errx(EXIT_FAILURE, 141 errx(EXIT_FAILURE,
142 "only one of -G and -P or -i may be specified"); 142 "only one of -G and -P or -i may be specified");
143 if (Pflag && iflag) 143 if (Pflag && iflag)
144 errx(EXIT_FAILURE, 144 errx(EXIT_FAILURE,
145 "only one of -P and -i may be specified"); 145 "only one of -P and -i may be specified");
146#if 0 146#if 0
147 /* 147 /*
148 * The block size cannot be checked until after getbsize() is called. 148 * The block size cannot be checked until after getbsize() is called.
149 */ 149 */
150 if (Pflag && (hflag || (usize != 1024 && usize != 512))) 150 if (Pflag && (hflag || (usize != 1024 && usize != 512)))
151 errx(EXIT_FAILURE, 151 errx(EXIT_FAILURE,
152 "non-standard block size incompatible with -P"); 152 "non-standard block size incompatible with -P");
153#endif 153#endif
154 argc -= optind; 154 argc -= optind;
155 argv += optind; 155 argv += optind;
156 156
157 mntsize = getmntinfo(&mntbuf, MNT_NOWAIT); 157 mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
158 if (mntsize == 0) 158 if (mntsize == 0)
159 err(EXIT_FAILURE, 159 err(EXIT_FAILURE,
160 "retrieving information on mounted file systems"); 160 "retrieving information on mounted file systems");
161 161
162 if (*argv == NULL) { 162 if (*argv == NULL) {
163 mntsize = regetmntinfo(&mntbuf, mntsize); 163 mntsize = regetmntinfo(&mntbuf, mntsize);
164 } else { 164 } else {
165 if ((mntbuf = malloc(argc * sizeof(*mntbuf))) == NULL) 165 if ((mntbuf = malloc(argc * sizeof(*mntbuf))) == NULL)
166 err(EXIT_FAILURE, "can't allocate statvfs array"); 166 err(EXIT_FAILURE, "can't allocate statvfs array");
167 mntsize = 0; 167 mntsize = 0;
168 for (/*EMPTY*/; *argv != NULL; argv++) { 168 for (/*EMPTY*/; *argv != NULL; argv++) {
169 if (stat(*argv, &stbuf) < 0) { 169 if (stat(*argv, &stbuf) < 0) {
170 if ((mntpt = getmntpt(*argv)) == 0) { 170 if ((mntpt = getmntpt(*argv)) == 0) {
171 warn("%s", *argv); 171 warn("%s", *argv);
172 continue; 172 continue;
173 } 173 }
174 } else if (S_ISBLK(stbuf.st_mode)) { 174 } else if (S_ISBLK(stbuf.st_mode)) {
175 if ((mntpt = getmntpt(*argv)) == 0) 175 if ((mntpt = getmntpt(*argv)) == 0)
176 mntpt = *argv; 176 mntpt = *argv;
177 } else 177 } else
178 mntpt = *argv; 178 mntpt = *argv;
179 /* 179 /*
180 * Statfs does not take a `wait' flag, so we cannot 180 * Statfs does not take a `wait' flag, so we cannot
181 * implement nflag here. 181 * implement nflag here.
182 */ 182 */
183 if (!statvfs(mntpt, &mntbuf[mntsize])) 183 if (!statvfs(mntpt, &mntbuf[mntsize]))
184 if (lflag && 184 if (lflag &&
185 (mntbuf[mntsize].f_flag & MNT_LOCAL) == 0) 185 (mntbuf[mntsize].f_flag & MNT_LOCAL) == 0)
186 warnx("Warning: %s is not a local %s", 186 warnx("Warning: %s is not a local %s",
187 *argv, "file system"); 187 *argv, "file system");
188 else if 188 else if
189 (!selected(mntbuf[mntsize].f_fstypename, 189 (!selected(mntbuf[mntsize].f_fstypename,
190 sizeof(mntbuf[mntsize].f_fstypename))) 190 sizeof(mntbuf[mntsize].f_fstypename)))
191 warnx("Warning: %s mounted as a %s %s", 191 warnx("Warning: %s mounted as a %s %s",
192 *argv, 192 *argv,
193 mntbuf[mntsize].f_fstypename, 193 mntbuf[mntsize].f_fstypename,
194 "file system"); 194 "file system");
195 else 195 else
196 ++mntsize; 196 ++mntsize;
197 else 197 else
198 warn("%s", *argv); 198 warn("%s", *argv);
199 } 199 }
200 } 200 }
201 201
202 maxwidth = 0; 202 maxwidth = 0;
203 for (i = 0; i < mntsize; i++) { 203 for (i = 0; i < mntsize; i++) {
204 width = (int)strlen(mntbuf[i].f_mntfromname); 204 width = (int)strlen(mntbuf[i].f_mntfromname);
205 if (width > maxwidth) 205 if (width > maxwidth)
206 maxwidth = width; 206 maxwidth = width;
207 } 207 }
208 for (i = 0; i < mntsize; i++) 208 for (i = 0; i < mntsize; i++)
209 prtstat(&mntbuf[i], maxwidth); 209 prtstat(&mntbuf[i], maxwidth);
210 return 0; 210 return 0;
211} 211}
212 212
213static char * 213static char *
214getmntpt(const char *name) 214getmntpt(const char *name)
215{ 215{
216 size_t mntsize, i; 216 size_t mntsize, i;
217 struct statvfs *mntbuf; 217 struct statvfs *mntbuf;
218 218
219 mntsize = getmntinfo(&mntbuf, MNT_NOWAIT); 219 mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
220 if (mntsize == 0) 220 if (mntsize == 0)
221 err(EXIT_FAILURE, "Can't get mount information"); 221 err(EXIT_FAILURE, "Can't get mount information");
222 for (i = 0; i < mntsize; i++) { 222 for (i = 0; i < mntsize; i++) {
223 if (!strcmp(mntbuf[i].f_mntfromname, name)) 223 if (!strcmp(mntbuf[i].f_mntfromname, name))
224 return mntbuf[i].f_mntonname; 224 return mntbuf[i].f_mntonname;
225 } 225 }
226 return 0; 226 return 0;
227} 227}
228 228
229static enum { IN_LIST, NOT_IN_LIST } which; 229static enum { IN_LIST, NOT_IN_LIST } which;
230 230
231static int 231static int
232selected(const char *type, size_t len) 232selected(const char *type, size_t len)
233{ 233{
234 char **av; 234 char **av;
235 235
236 /* If no type specified, it's always selected. */ 236 /* If no type specified, it's always selected. */
237 if (typelist == NULL) 237 if (typelist == NULL)
238 return 1; 238 return 1;
239 for (av = typelist; *av != NULL; ++av) 239 for (av = typelist; *av != NULL; ++av)
240 if (!strncmp(type, *av, len)) 240 if (!strncmp(type, *av, len))
241 return which == IN_LIST ? 1 : 0; 241 return which == IN_LIST ? 1 : 0;
242 return which == IN_LIST ? 0 : 1; 242 return which == IN_LIST ? 0 : 1;
243} 243}
244 244
245static void 245static void
246maketypelist(char *fslist) 246maketypelist(char *fslist)
247{ 247{
248 size_t i; 248 size_t i;
249 char *nextcp, **av; 249 char *nextcp, **av;
250 250
251 if ((fslist == NULL) || (fslist[0] == '\0')) 251 if ((fslist == NULL) || (fslist[0] == '\0'))
252 errx(EXIT_FAILURE, "empty type list"); 252 errx(EXIT_FAILURE, "empty type list");
253 253
254 /* 254 /*
255 * XXX 255 * XXX
256 * Note: the syntax is "noxxx,yyy" for no xxx's and 256 * Note: the syntax is "noxxx,yyy" for no xxx's and
257 * no yyy's, not the more intuitive "noyyy,noyyy". 257 * no yyy's, not the more intuitive "noyyy,noyyy".
258 */ 258 */
259 if (fslist[0] == 'n' && fslist[1] == 'o') { 259 if (fslist[0] == 'n' && fslist[1] == 'o') {
260 fslist += 2; 260 fslist += 2;
261 which = NOT_IN_LIST; 261 which = NOT_IN_LIST;
262 } else 262 } else
263 which = IN_LIST; 263 which = IN_LIST;
264 264
265 /* Count the number of types. */ 265 /* Count the number of types. */
266 for (i = 1, nextcp = fslist; 266 for (i = 1, nextcp = fslist;
267 (nextcp = strchr(nextcp, ',')) != NULL; i++) 267 (nextcp = strchr(nextcp, ',')) != NULL; i++)
268 ++nextcp; 268 ++nextcp;
269 269
270 /* Build an array of that many types. */ 270 /* Build an array of that many types. */
271 if ((av = typelist = malloc((i + 1) * sizeof(*av))) == NULL) 271 if ((av = typelist = malloc((i + 1) * sizeof(*av))) == NULL)
272 err(EXIT_FAILURE, "can't allocate type array"); 272 err(EXIT_FAILURE, "can't allocate type array");
273 av[0] = fslist; 273 av[0] = fslist;
274 for (i = 1, nextcp = fslist; 274 for (i = 1, nextcp = fslist;
275 (nextcp = strchr(nextcp, ',')) != NULL; i++) { 275 (nextcp = strchr(nextcp, ',')) != NULL; i++) {
276 *nextcp = '\0'; 276 *nextcp = '\0';
277 av[i] = ++nextcp; 277 av[i] = ++nextcp;
278 } 278 }
279 /* Terminate the array. */ 279 /* Terminate the array. */
280 av[i] = NULL; 280 av[i] = NULL;
281} 281}
282 282
283/* 283/*
284 * Make a pass over the filesystem info in ``mntbuf'' filtering out 284 * Make a pass over the filesystem info in ``mntbuf'' filtering out
285 * filesystem types not in ``fsmask'' and possibly re-stating to get 285 * filesystem types not in ``fsmask'' and possibly re-stating to get
286 * current (not cached) info. Returns the new count of valid statvfs bufs. 286 * current (not cached) info. Returns the new count of valid statvfs bufs.
287 */ 287 */
288static size_t 288static size_t
289regetmntinfo(struct statvfs **mntbufp, size_t mntsize) 289regetmntinfo(struct statvfs **mntbufp, size_t mntsize)
290{ 290{
291 size_t i, j; 291 size_t i, j;
292 struct statvfs *mntbuf; 292 struct statvfs *mntbuf;
293 293
294 if (!lflag && typelist == NULL && aflag) 294 if (!lflag && typelist == NULL && aflag)
295 return nflag ? mntsize : (size_t)getmntinfo(mntbufp, MNT_WAIT); 295 return nflag ? mntsize : (size_t)getmntinfo(mntbufp, MNT_WAIT);
296 296
297 mntbuf = *mntbufp; 297 mntbuf = *mntbufp;
298 j = 0; 298 j = 0;
299 for (i = 0; i < mntsize; i++) { 299 for (i = 0; i < mntsize; i++) {
300 if (!aflag && (mntbuf[i].f_flag & MNT_IGNORE) != 0) 300 if (!aflag && (mntbuf[i].f_flag & MNT_IGNORE) != 0)
301 continue; 301 continue;
302 if (lflag && (mntbuf[i].f_flag & MNT_LOCAL) == 0) 302 if (lflag && (mntbuf[i].f_flag & MNT_LOCAL) == 0)
303 continue; 303 continue;
304 if (!selected(mntbuf[i].f_fstypename, 304 if (!selected(mntbuf[i].f_fstypename,
305 sizeof(mntbuf[i].f_fstypename))) 305 sizeof(mntbuf[i].f_fstypename)))
306 continue; 306 continue;
307 if (nflag) 307 if (nflag)
308 mntbuf[j] = mntbuf[i]; 308 mntbuf[j] = mntbuf[i];
309 else { 309 else {
310 struct statvfs layerbuf = mntbuf[i]; 310 struct statvfs layerbuf = mntbuf[i];
311 (void)statvfs(mntbuf[i].f_mntonname, &mntbuf[j]); 311 (void)statvfs(mntbuf[i].f_mntonname, &mntbuf[j]);
312 /* 312 /*
313 * If the FS name changed, then new data is for 313 * If the FS name changed, then new data is for
314 * a different layer and we don't want it. 314 * a different layer and we don't want it.
315 */ 315 */
316 if (memcmp(layerbuf.f_mntfromname, 316 if (memcmp(layerbuf.f_mntfromname,
317 mntbuf[j].f_mntfromname, MNAMELEN)) 317 mntbuf[j].f_mntfromname, MNAMELEN))
318 mntbuf[j] = layerbuf; 318 mntbuf[j] = layerbuf;
319 } 319 }
320 j++; 320 j++;
321 } 321 }
322 return j; 322 return j;
323} 323}
324 324
325static void 325static void
326prthumanval(int64_t bytes, const char *pad) 326prthumanval(int64_t bytes, const char *pad)
327{ 327{
328 char buf[6]; 328 char buf[6];
329 329
330 (void)humanize_number(buf, sizeof(buf) - (bytes < 0 ? 0 : 1), 330 (void)humanize_number(buf, sizeof(buf) - (bytes < 0 ? 0 : 1),
331 bytes, "", HN_AUTOSCALE, 331 bytes, "", HN_AUTOSCALE,
332 HN_B | HN_NOSPACE | HN_DECIMAL); 332 HN_B | HN_NOSPACE | HN_DECIMAL);
333 333
334 (void)printf("%s %6s", pad, buf); 334 (void)printf("%s %6s", pad, buf);
335} 335}
336 336
337static void 337static void
338prthuman(struct statvfs *sfsp, int64_t used, int64_t bavail) 338prthuman(struct statvfs *sfsp, int64_t used, int64_t bavail)
339{ 339{
340 340
341 prthumanval((int64_t)(sfsp->f_blocks * sfsp->f_frsize), " "); 341 prthumanval((int64_t)(sfsp->f_blocks * sfsp->f_frsize), " ");
342 prthumanval((int64_t)(used * sfsp->f_frsize), " "); 342 prthumanval((int64_t)(used * sfsp->f_frsize), " ");
343 prthumanval((int64_t)(bavail * sfsp->f_frsize), " "); 343 prthumanval((int64_t)(bavail * sfsp->f_frsize), " ");
344} 344}
345 345
346/* 346/*
347 * Convert statvfs returned filesystem size into BLOCKSIZE units. 347 * Convert statvfs returned filesystem size into BLOCKSIZE units.
348 * Attempts to avoid overflow for large filesystems. 348 * Attempts to avoid overflow for large filesystems.
349 */ 349 */
350#define fsbtoblk(num, fsbs, bs) \ 350#define fsbtoblk(num, fsbs, bs) \
351 (((fsbs) != 0 && (uint64_t)(fsbs) < (uint64_t)(bs)) ? \ 351 (((fsbs) != 0 && (uint64_t)(fsbs) < (uint64_t)(bs)) ? \
352 (int64_t)(num) / (int64_t)((bs) / (fsbs)) : \ 352 (int64_t)(num) / (int64_t)((bs) / (fsbs)) : \
353 (int64_t)(num) * (int64_t)((fsbs) / (bs))) 353 (int64_t)(num) * (int64_t)((fsbs) / (bs)))
354 354
355/* 355/*
356 * Print out status about a filesystem. 356 * Print out status about a filesystem.
357 */ 357 */
358static void 358static void
359prtstat(struct statvfs *sfsp, int maxwidth) 359prtstat(struct statvfs *sfsp, int maxwidth)
360{ 360{
361 static long blocksize; 361 static long blocksize;
362 static int headerlen, timesthrough; 362 static int headerlen, timesthrough;
363 static const char *header; 363 static const char *header;
364 static const char full[] = "100"; 364 static const char full[] = "100";
365 static const char empty[] = " 0"; 365 static const char empty[] = " 0";
366 int64_t used, availblks, inodes; 366 int64_t used, availblks, inodes;
367 int64_t bavail; 367 int64_t bavail;
368 char pb[64]; 368 char pb[64];
369 369
370 if (gflag) { 370 if (gflag) {
371 /* 371 /*
372 * From SunOS-5.6: 372 * From SunOS-5.6:
373 * 373 *
374 * /var (/dev/dsk/c0t0d0s3 ): 8192 block size 1024 frag size 374 * /var (/dev/dsk/c0t0d0s3 ): 8192 block size 1024 frag size
375 * 984242 total blocks 860692 free blocks 859708 available 249984 total files 375 * 984242 total blocks 860692 free blocks 859708 available 249984 total files
376 * 248691 free files 8388611 filesys id 376 * 248691 free files 8388611 filesys id
377 * ufs fstype 0x00000004 flag 255 filename length 377 * ufs fstype 0x00000004 flag 255 filename length
378 * 378 *
379 */ 379 */
380 (void)printf("%10s (%-12s): %7ld block size %12ld frag size\n", 380 (void)printf("%10s (%-12s): %7ld block size %12ld frag size\n",
381 sfsp->f_mntonname, sfsp->f_mntfromname, 381 sfsp->f_mntonname, sfsp->f_mntfromname,
382 sfsp->f_bsize, /* On UFS/FFS systems this is 382 sfsp->f_bsize, /* On UFS/FFS systems this is
383 * also called the "optimal 383 * also called the "optimal
384 * transfer block size" but it 384 * transfer block size" but it
385 * is of course the file 385 * is of course the file
386 * system's block size too. 386 * system's block size too.
387 */ 387 */
388 sfsp->f_frsize); /* not so surprisingly the 388 sfsp->f_frsize); /* not so surprisingly the
389 * "fundamental file system 389 * "fundamental file system
390 * block size" is the frag 390 * block size" is the frag
391 * size. 391 * size.
392 */ 392 */
393 (void)printf("%10" PRId64 " total blocks %10" PRId64 393 (void)printf("%10" PRId64 " total blocks %10" PRId64
394 " free blocks %10" PRId64 " available\n", 394 " free blocks %10" PRId64 " available\n",
395 (uint64_t)sfsp->f_blocks, (uint64_t)sfsp->f_bfree, 395 (uint64_t)sfsp->f_blocks, (uint64_t)sfsp->f_bfree,
396 (uint64_t)sfsp->f_bavail); 396 (uint64_t)sfsp->f_bavail);
397 (void)printf("%10" PRId64 " total files %10" PRId64 397 (void)printf("%10" PRId64 " total files %10" PRId64
398 " free files %12lx filesys id\n", 398 " free files %12lx filesys id\n",
399 (uint64_t)sfsp->f_ffree, (uint64_t)sfsp->f_files, 399 (uint64_t)sfsp->f_ffree, (uint64_t)sfsp->f_files,
400 sfsp->f_fsid); 400 sfsp->f_fsid);
401 (void)printf("%10s fstype %#15lx flag %17ld filename " 401 (void)printf("%10s fstype %#15lx flag %17ld filename "
402 "length\n", sfsp->f_fstypename, sfsp->f_flag, 402 "length\n", sfsp->f_fstypename, sfsp->f_flag,
403 sfsp->f_namemax); 403 sfsp->f_namemax);
404 (void)printf("%10lu owner %17" PRId64 " syncwrites %12" PRId64 404 (void)printf("%10lu owner %17" PRId64 " syncwrites %12" PRId64
405 " asyncwrites\n\n", (unsigned long)sfsp->f_owner, 405 " asyncwrites\n\n", (unsigned long)sfsp->f_owner,
406 sfsp->f_syncwrites, sfsp->f_asyncwrites); 406 sfsp->f_syncwrites, sfsp->f_asyncwrites);
407 407
408 /* 408 /*
409 * a concession by the structured programming police to the 409 * a concession by the structured programming police to the
410 * indentation police.... 410 * indentation police....
411 */ 411 */
412 return; 412 return;
413 } 413 }
414 if (maxwidth < 12) 414 if (maxwidth < 12)
415 maxwidth = 12; 415 maxwidth = 12;
416 if (++timesthrough == 1) { 416 if (++timesthrough == 1) {
417 switch (blocksize = usize) { 417 switch (blocksize = usize) {
418 case 1024: 418 case 1024:
419 header = Pflag ? "1024-blocks" : "1K-blocks"; 419 header = Pflag ? "1024-blocks" : "1K-blocks";
420 headerlen = (int)strlen(header); 420 headerlen = (int)strlen(header);
421 break; 421 break;
422 case 1024 * 1024: 422 case 1024 * 1024:
423 header = "1M-blocks"; 423 header = "1M-blocks";
424 headerlen = (int)strlen(header); 424 headerlen = (int)strlen(header);
425 break; 425 break;
426 case 1024 * 1024 * 1024: 426 case 1024 * 1024 * 1024:
427 header = "1G-blocks"; 427 header = "1G-blocks";
428 headerlen = (int)strlen(header); 428 headerlen = (int)strlen(header);
429 break; 429 break;
430 default: 430 default:
431 if (hflag) { 431 if (hflag) {
432 header = "Size"; 432 header = "Size";
433 headerlen = (int)strlen(header); 433 headerlen = (int)strlen(header);
434 } else 434 } else
435 header = getbsize(&headerlen, &blocksize); 435 header = getbsize(&headerlen, &blocksize);
436 break; 436 break;
437 } 437 }
438 if (Pflag) { 438 if (Pflag) {
439 /* 439 /*
440 * either: 440 * either:
441 * "Filesystem 1024-blocks Used Available Capacity Mounted on\n" 441 * "Filesystem 1024-blocks Used Available Capacity Mounted on\n"
442 * or: 442 * or:
443 * "Filesystem 512-blocks Used Available Capacity Mounted on\n" 443 * "Filesystem 512-blocks Used Available Capacity Mounted on\n"
444 */ 444 */
445 if (blocksize != 1024 && blocksize != 512) 445 if (blocksize != 1024 && blocksize != 512)
446 errx(EXIT_FAILURE, 446 errx(EXIT_FAILURE,
447 "non-standard block size incompatible with -P"); 447 "non-standard block size incompatible with -P");
448 (void)printf("Filesystem %s Used Available Capacity " 448 (void)printf("Filesystem %s Used Available Capacity "
449 "Mounted on\n", header); 449 "Mounted on\n", header);
450 } else { 450 } else {
451 (void)printf("%-*.*s %s Used Avail %%Cap", 451 (void)printf("%-*.*s %s Used Avail %%Cap",
452 maxwidth - (headerlen - 10), 452 maxwidth - (headerlen - 10),
453 maxwidth - (headerlen - 10), 453 maxwidth - (headerlen - 10),
454 "Filesystem", header); 454 "Filesystem", header);
455 if (iflag) 455 if (iflag)
456 (void)printf(" iUsed iAvail %%iCap"); 456 (void)printf(" iUsed iAvail %%iCap");
457 (void)printf(" Mounted on\n"); 457 (void)printf(" Mounted on\n");
458 } 458 }
459 } 459 }
460 used = sfsp->f_blocks - sfsp->f_bfree; 460 used = sfsp->f_blocks - sfsp->f_bfree;
461 bavail = sfsp->f_bfree - sfsp->f_bresvd; 461 bavail = sfsp->f_bfree - sfsp->f_bresvd;
462 availblks = bavail + used; 462 availblks = bavail + used;
463 if (Pflag) { 463 if (Pflag) {
464 assert(hflag == 0); 464 assert(hflag == 0);
465 assert(blocksize > 0); 465 assert(blocksize > 0);
466 /* 466 /*
467 * "%s %d %d %d %s %s\n", <file system name>, <total space>, 467 * "%s %d %d %d %s %s\n", <file system name>, <total space>,
468 * <space used>, <space free>, <percentage used>, 468 * <space used>, <space free>, <percentage used>,
469 * <file system root> 469 * <file system root>
470 */ 470 */
471 (void)printf("%s %" PRId64 " %" PRId64 " %" PRId64 " %s%% %s\n", 471 (void)printf("%s %" PRId64 " %" PRId64 " %" PRId64 " %s%% %s\n",
472 sfsp->f_mntfromname, 472 sfsp->f_mntfromname,
473 fsbtoblk(sfsp->f_blocks, sfsp->f_frsize, blocksize), 473 fsbtoblk(sfsp->f_blocks, sfsp->f_frsize, blocksize),
474 fsbtoblk(used, sfsp->f_frsize, blocksize), 474 fsbtoblk(used, sfsp->f_frsize, blocksize),
475 fsbtoblk(bavail, sfsp->f_frsize, blocksize), 475 fsbtoblk(bavail, sfsp->f_frsize, blocksize),
476 availblks == 0 ? full : strspct(pb, sizeof(pb), used, 476 availblks == 0 ? full : strspct(pb, sizeof(pb), used,
477 availblks, 0), sfsp->f_mntonname); 477 availblks, 0), sfsp->f_mntonname);
478 /* 478 /*
479 * another concession by the structured programming police to 479 * another concession by the structured programming police to
480 * the indentation police.... 480 * the indentation police....
481 * 481 *
482 * Note iflag cannot be set when Pflag is set. 482 * Note iflag cannot be set when Pflag is set.
483 */ 483 */
484 return; 484 return;
485 } 485 }
486 486
487 (void)printf("%-*.*s ", maxwidth, maxwidth, sfsp->f_mntfromname); 487 (void)printf("%-*.*s ", maxwidth, maxwidth, sfsp->f_mntfromname);
488 488
489 if (hflag) 489 if (hflag)
490 prthuman(sfsp, used, bavail); 490 prthuman(sfsp, used, bavail);
491 else 491 else
492 (void)printf("%10" PRId64 " %10" PRId64 " %10" PRId64, 492 (void)printf("%10" PRId64 " %10" PRId64 " %10" PRId64,
493 fsbtoblk(sfsp->f_blocks, sfsp->f_frsize, blocksize), 493 fsbtoblk(sfsp->f_blocks, sfsp->f_frsize, blocksize),
494 fsbtoblk(used, sfsp->f_frsize, blocksize), 494 fsbtoblk(used, sfsp->f_frsize, blocksize),
495 fsbtoblk(bavail, sfsp->f_frsize, blocksize)); 495 fsbtoblk(bavail, sfsp->f_frsize, blocksize));
496 (void)printf(" %3s%%", 496 (void)printf(" %3s%%",
497 availblks == 0 ? full : 497 availblks == 0 ? full :
498 strspct(pb, sizeof(pb), used, availblks, 0)); 498 strspct(pb, sizeof(pb), used, availblks, 0));
499 if (iflag) { 499 if (iflag) {
500 inodes = sfsp->f_files; 500 inodes = sfsp->f_files;
501 used = inodes - sfsp->f_ffree; 501 used = inodes - sfsp->f_ffree;
502 (void)printf(" %8jd %8jd %4s%%", 502 (void)printf(" %8jd %8jd %4s%%",
503 (intmax_t)used, (intmax_t)sfsp->f_ffree, 503 (intmax_t)used, (intmax_t)sfsp->f_ffree,
504 inodes == 0 ? (used == 0 ? empty : full) : 504 inodes == 0 ? (used == 0 ? empty : full) :
505 strspct(pb, sizeof(pb), used, inodes, 0)); 505 strspct(pb, sizeof(pb), used, inodes, 0));
506 } 506 }
507 (void)printf(" %s\n", sfsp->f_mntonname); 507 (void)printf(" %s\n", sfsp->f_mntonname);
508} 508}
509 509
510static void 510static void
511usage(void) 511usage(void)
512{ 512{
513 513
514 (void)fprintf(stderr, 514 (void)fprintf(stderr,
515 "Usage: %s [-aGgln] [-hkm|-ihkm|-Pk] [-t type] [file | " 515 "Usage: %s [-agln] [-Ghkm|-ihkm|-Pk] [-t type] [file | "
516 "file_system ...]\n", 516 "file_system ...]\n",
517 getprogname()); 517 getprogname());
518 exit(1); 518 exit(1);
519 /* NOTREACHED */ 519 /* NOTREACHED */
520} 520}