FreeBSD Bugzilla – Attachment 230685 Details for
Bug 260921
/bin/df: make -l and -t nonexclusive
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Allow -l and -t to be used together
df.diff (text/plain), 3.51 KB, created by
Stefan Eßer
on 2022-01-04 13:12:49 UTC
(
hide
)
Description:
Allow -l and -t to be used together
Filename:
MIME Type:
Creator:
Stefan Eßer
Created:
2022-01-04 13:12:49 UTC
Size:
3.51 KB
patch
obsolete
>diff --git a/bin/df/df.c b/bin/df/df.c >index 5a96eb9d58c4..01c0564ca0d7 100644 >--- a/bin/df/df.c >+++ b/bin/df/df.c >@@ -88,7 +88,7 @@ static void prthuman(const struct statfs *, int64_t); > static void prthumanval(const char *, int64_t); > static intmax_t fsbtoblk(int64_t, uint64_t, u_long); > static void prtstat(struct statfs *, struct maxwidths *); >-static size_t regetmntinfo(struct statfs **, long, const char **); >+static size_t regetmntinfo(struct statfs **, long, const char **, const char **); > static void update_maxwidths(struct maxwidths *, const struct statfs *); > static void usage(void); > >@@ -115,7 +115,7 @@ main(int argc, char *argv[]) > struct maxwidths maxwidths; > struct statfs *mntbuf; > char *mntpt; >- const char **vfslist; >+ const char **vfslist_l, **vfslist_t; > int i, mntsize; > int ch, rv; > >@@ -124,7 +124,8 @@ main(int argc, char *argv[]) > memset(&totalbuf, 0, sizeof(totalbuf)); > totalbuf.f_bsize = DEV_BSIZE; > strlcpy(totalbuf.f_mntfromname, "total", MNAMELEN); >- vfslist = NULL; >+ vfslist_l = NULL; >+ vfslist_t = NULL; > > argc = xo_parse_args(argc, argv); > if (argc < 0) >@@ -175,9 +176,7 @@ main(int argc, char *argv[]) > /* Ignore duplicate -l */ > if (lflag) > break; >- if (vfslist != NULL) >- xo_errx(1, "-l and -t are mutually exclusive."); >- vfslist = makevfslist(makenetvfslist()); >+ vfslist_l = makevfslist(makenetvfslist()); > lflag = 1; > break; > case 'm': >@@ -188,11 +187,7 @@ main(int argc, char *argv[]) > nflag = 1; > break; > case 't': >- if (lflag) >- xo_errx(1, "-l and -t are mutually exclusive."); >- if (vfslist != NULL) >- xo_errx(1, "only one -t option may be specified"); >- vfslist = makevfslist(optarg); >+ vfslist_t = makevfslist(optarg); > break; > case 'T': > Tflag = 1; >@@ -211,7 +206,7 @@ main(int argc, char *argv[]) > if (!*argv) { > /* everything (modulo -t) */ > mntsize = getmntinfo(&mntbuf, MNT_NOWAIT); >- mntsize = regetmntinfo(&mntbuf, mntsize, vfslist); >+ mntsize = regetmntinfo(&mntbuf, mntsize, vfslist_l, vfslist_t); > } else { > /* just the filesystems specified on the command line */ > mntbuf = malloc(argc * sizeof(*mntbuf)); >@@ -259,7 +254,8 @@ main(int argc, char *argv[]) > * list a mount point that does not match the other args > * we've been given (-l, -t, etc.). > */ >- if (checkvfsname(statfsbuf.f_fstypename, vfslist)) { >+ if (checkvfsname(statfsbuf.f_fstypename, vfslist_l) || >+ checkvfsname(statfsbuf.f_fstypename, vfslist_t)) { > rv = 1; > continue; > } >@@ -309,21 +305,24 @@ getmntpt(const char *name) > > /* > * Make a pass over the file system info in ``mntbuf'' filtering out >- * file system types not in vfslist and possibly re-stating to get >+ * file system types not in vfslist_{l,t} and possibly re-stating to get > * current (not cached) info. Returns the new count of valid statfs bufs. > */ > static size_t >-regetmntinfo(struct statfs **mntbufp, long mntsize, const char **vfslist) >+regetmntinfo(struct statfs **mntbufp, long mntsize, const char **vfslist_l, >+ const char **vfslist_t) > { > int error, i, j; > struct statfs *mntbuf; > >- if (vfslist == NULL) >+ if (vfslist_l == NULL && vfslist_t == NULL) > return (nflag ? mntsize : getmntinfo(mntbufp, MNT_WAIT)); > > mntbuf = *mntbufp; > for (j = 0, i = 0; i < mntsize; i++) { >- if (checkvfsname(mntbuf[i].f_fstypename, vfslist)) >+ if (vfslist_l && checkvfsname(mntbuf[i].f_fstypename, vfslist_l)) >+ continue; >+ if (vfslist_t && checkvfsname(mntbuf[i].f_fstypename, vfslist_t)) > continue; > /* > * XXX statfs(2) can fail for various reasons. It may be
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 260921
: 230685