|
Lines 88-94
static void prthuman(const struct statfs *, int64_t);
Link Here
|
| 88 |
static void prthumanval(const char *, int64_t); |
88 |
static void prthumanval(const char *, int64_t); |
| 89 |
static intmax_t fsbtoblk(int64_t, uint64_t, u_long); |
89 |
static intmax_t fsbtoblk(int64_t, uint64_t, u_long); |
| 90 |
static void prtstat(struct statfs *, struct maxwidths *); |
90 |
static void prtstat(struct statfs *, struct maxwidths *); |
| 91 |
static size_t regetmntinfo(struct statfs **, long, const char **); |
91 |
static size_t regetmntinfo(struct statfs **, long, const char **, const char **); |
| 92 |
static void update_maxwidths(struct maxwidths *, const struct statfs *); |
92 |
static void update_maxwidths(struct maxwidths *, const struct statfs *); |
| 93 |
static void usage(void); |
93 |
static void usage(void); |
| 94 |
|
94 |
|
|
Lines 115-121
main(int argc, char *argv[])
Link Here
|
| 115 |
struct maxwidths maxwidths; |
115 |
struct maxwidths maxwidths; |
| 116 |
struct statfs *mntbuf; |
116 |
struct statfs *mntbuf; |
| 117 |
char *mntpt; |
117 |
char *mntpt; |
| 118 |
const char **vfslist; |
118 |
const char **vfslist_l, **vfslist_t; |
| 119 |
int i, mntsize; |
119 |
int i, mntsize; |
| 120 |
int ch, rv; |
120 |
int ch, rv; |
| 121 |
|
121 |
|
|
Lines 124-130
main(int argc, char *argv[])
Link Here
|
| 124 |
memset(&totalbuf, 0, sizeof(totalbuf)); |
124 |
memset(&totalbuf, 0, sizeof(totalbuf)); |
| 125 |
totalbuf.f_bsize = DEV_BSIZE; |
125 |
totalbuf.f_bsize = DEV_BSIZE; |
| 126 |
strlcpy(totalbuf.f_mntfromname, "total", MNAMELEN); |
126 |
strlcpy(totalbuf.f_mntfromname, "total", MNAMELEN); |
| 127 |
vfslist = NULL; |
127 |
vfslist_l = NULL; |
|
|
128 |
vfslist_t = NULL; |
| 128 |
|
129 |
|
| 129 |
argc = xo_parse_args(argc, argv); |
130 |
argc = xo_parse_args(argc, argv); |
| 130 |
if (argc < 0) |
131 |
if (argc < 0) |
|
Lines 175-183
main(int argc, char *argv[])
Link Here
|
| 175 |
/* Ignore duplicate -l */ |
176 |
/* Ignore duplicate -l */ |
| 176 |
if (lflag) |
177 |
if (lflag) |
| 177 |
break; |
178 |
break; |
| 178 |
if (vfslist != NULL) |
179 |
vfslist_l = makevfslist(makenetvfslist()); |
| 179 |
xo_errx(1, "-l and -t are mutually exclusive."); |
|
|
| 180 |
vfslist = makevfslist(makenetvfslist()); |
| 181 |
lflag = 1; |
180 |
lflag = 1; |
| 182 |
break; |
181 |
break; |
| 183 |
case 'm': |
182 |
case 'm': |
|
Lines 188-198
main(int argc, char *argv[])
Link Here
|
| 188 |
nflag = 1; |
187 |
nflag = 1; |
| 189 |
break; |
188 |
break; |
| 190 |
case 't': |
189 |
case 't': |
| 191 |
if (lflag) |
190 |
vfslist_t = makevfslist(optarg); |
| 192 |
xo_errx(1, "-l and -t are mutually exclusive."); |
|
|
| 193 |
if (vfslist != NULL) |
| 194 |
xo_errx(1, "only one -t option may be specified"); |
| 195 |
vfslist = makevfslist(optarg); |
| 196 |
break; |
191 |
break; |
| 197 |
case 'T': |
192 |
case 'T': |
| 198 |
Tflag = 1; |
193 |
Tflag = 1; |
|
Lines 211-217
main(int argc, char *argv[])
Link Here
|
| 211 |
if (!*argv) { |
206 |
if (!*argv) { |
| 212 |
/* everything (modulo -t) */ |
207 |
/* everything (modulo -t) */ |
| 213 |
mntsize = getmntinfo(&mntbuf, MNT_NOWAIT); |
208 |
mntsize = getmntinfo(&mntbuf, MNT_NOWAIT); |
| 214 |
mntsize = regetmntinfo(&mntbuf, mntsize, vfslist); |
209 |
mntsize = regetmntinfo(&mntbuf, mntsize, vfslist_l, vfslist_t); |
| 215 |
} else { |
210 |
} else { |
| 216 |
/* just the filesystems specified on the command line */ |
211 |
/* just the filesystems specified on the command line */ |
| 217 |
mntbuf = malloc(argc * sizeof(*mntbuf)); |
212 |
mntbuf = malloc(argc * sizeof(*mntbuf)); |
|
Lines 259-265
main(int argc, char *argv[])
Link Here
|
| 259 |
* list a mount point that does not match the other args |
254 |
* list a mount point that does not match the other args |
| 260 |
* we've been given (-l, -t, etc.). |
255 |
* we've been given (-l, -t, etc.). |
| 261 |
*/ |
256 |
*/ |
| 262 |
if (checkvfsname(statfsbuf.f_fstypename, vfslist)) { |
257 |
if (checkvfsname(statfsbuf.f_fstypename, vfslist_l) || |
|
|
258 |
checkvfsname(statfsbuf.f_fstypename, vfslist_t)) { |
| 263 |
rv = 1; |
259 |
rv = 1; |
| 264 |
continue; |
260 |
continue; |
| 265 |
} |
261 |
} |
|
Lines 309-329
getmntpt(const char *name)
Link Here
|
| 309 |
|
305 |
|
| 310 |
/* |
306 |
/* |
| 311 |
* Make a pass over the file system info in ``mntbuf'' filtering out |
307 |
* Make a pass over the file system info in ``mntbuf'' filtering out |
| 312 |
* file system types not in vfslist and possibly re-stating to get |
308 |
* file system types not in vfslist_{l,t} and possibly re-stating to get |
| 313 |
* current (not cached) info. Returns the new count of valid statfs bufs. |
309 |
* current (not cached) info. Returns the new count of valid statfs bufs. |
| 314 |
*/ |
310 |
*/ |
| 315 |
static size_t |
311 |
static size_t |
| 316 |
regetmntinfo(struct statfs **mntbufp, long mntsize, const char **vfslist) |
312 |
regetmntinfo(struct statfs **mntbufp, long mntsize, const char **vfslist_l, |
|
|
313 |
const char **vfslist_t) |
| 317 |
{ |
314 |
{ |
| 318 |
int error, i, j; |
315 |
int error, i, j; |
| 319 |
struct statfs *mntbuf; |
316 |
struct statfs *mntbuf; |
| 320 |
|
317 |
|
| 321 |
if (vfslist == NULL) |
318 |
if (vfslist_l == NULL && vfslist_t == NULL) |
| 322 |
return (nflag ? mntsize : getmntinfo(mntbufp, MNT_WAIT)); |
319 |
return (nflag ? mntsize : getmntinfo(mntbufp, MNT_WAIT)); |
| 323 |
|
320 |
|
| 324 |
mntbuf = *mntbufp; |
321 |
mntbuf = *mntbufp; |
| 325 |
for (j = 0, i = 0; i < mntsize; i++) { |
322 |
for (j = 0, i = 0; i < mntsize; i++) { |
| 326 |
if (checkvfsname(mntbuf[i].f_fstypename, vfslist)) |
323 |
if (vfslist_l && checkvfsname(mntbuf[i].f_fstypename, vfslist_l)) |
|
|
324 |
continue; |
| 325 |
if (vfslist_t && checkvfsname(mntbuf[i].f_fstypename, vfslist_t)) |
| 327 |
continue; |
326 |
continue; |
| 328 |
/* |
327 |
/* |
| 329 |
* XXX statfs(2) can fail for various reasons. It may be |
328 |
* XXX statfs(2) can fail for various reasons. It may be |