diff options
author | jhb <jhb@FreeBSD.org> | 2017-02-08 18:32:35 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2017-02-08 18:32:35 +0000 |
commit | 35b15de17b53838c6a73dcbb7af21c1d3cac3c11 (patch) | |
tree | 132262bb0c2f8d194e47f5c0f818a8e361c9e4af /lib | |
parent | 9921ea670c139b76859e2dfa7110c594cb0b355e (diff) | |
download | FreeBSD-src-35b15de17b53838c6a73dcbb7af21c1d3cac3c11.zip FreeBSD-src-35b15de17b53838c6a73dcbb7af21c1d3cac3c11.tar.gz |
MFC 310638:
Rename the 'flags' argument to getfsstat() to 'mode' and validate it.
This argument is not a bitmask of flags, but only accepts a single value.
Fail with EINVAL if an invalid value is passed to 'flag'. Rename the
'flags' argument to getmntinfo(3) to 'mode' as well to match.
This is a followup to r308088.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/gen/getmntinfo.3 | 6 | ||||
-rw-r--r-- | lib/libc/gen/getmntinfo.c | 6 | ||||
-rw-r--r-- | lib/libc/sys/getfsstat.2 | 14 |
3 files changed, 16 insertions, 10 deletions
diff --git a/lib/libc/gen/getmntinfo.3 b/lib/libc/gen/getmntinfo.3 index dc83e37..0e9601c 100644 --- a/lib/libc/gen/getmntinfo.3 +++ b/lib/libc/gen/getmntinfo.3 @@ -28,7 +28,7 @@ .\" @(#)getmntinfo.3 8.1 (Berkeley) 6/9/93 .\" $FreeBSD$ .\" -.Dd June 9, 1993 +.Dd December 27, 2016 .Dt GETMNTINFO 3 .Os .Sh NAME @@ -41,7 +41,7 @@ .In sys/ucred.h .In sys/mount.h .Ft int -.Fn getmntinfo "struct statfs **mntbufp" "int flags" +.Fn getmntinfo "struct statfs **mntbufp" "int mode" .Sh DESCRIPTION The .Fn getmntinfo @@ -55,7 +55,7 @@ The .Fn getmntinfo function passes its -.Fa flags +.Fa mode argument transparently to .Xr getfsstat 2 . .Sh RETURN VALUES diff --git a/lib/libc/gen/getmntinfo.c b/lib/libc/gen/getmntinfo.c index 606fea7..692d8f1 100644 --- a/lib/libc/gen/getmntinfo.c +++ b/lib/libc/gen/getmntinfo.c @@ -42,7 +42,7 @@ __FBSDID("$FreeBSD$"); * Return information about mounted filesystems. */ int -getmntinfo(struct statfs **mntbufp, int flags) +getmntinfo(struct statfs **mntbufp, int mode) { static struct statfs *mntbuf; static int mntsize; @@ -50,7 +50,7 @@ getmntinfo(struct statfs **mntbufp, int flags) if (mntsize <= 0 && (mntsize = getfsstat(0, 0, MNT_NOWAIT)) < 0) return (0); - if (bufsize > 0 && (mntsize = getfsstat(mntbuf, bufsize, flags)) < 0) + if (bufsize > 0 && (mntsize = getfsstat(mntbuf, bufsize, mode)) < 0) return (0); while (bufsize <= mntsize * sizeof(struct statfs)) { if (mntbuf) @@ -58,7 +58,7 @@ getmntinfo(struct statfs **mntbufp, int flags) bufsize = (mntsize + 1) * sizeof(struct statfs); if ((mntbuf = malloc(bufsize)) == NULL) return (0); - if ((mntsize = getfsstat(mntbuf, bufsize, flags)) < 0) + if ((mntsize = getfsstat(mntbuf, bufsize, mode)) < 0) return (0); } *mntbufp = mntbuf; diff --git a/lib/libc/sys/getfsstat.2 b/lib/libc/sys/getfsstat.2 index 9d13280..08cdf49 100644 --- a/lib/libc/sys/getfsstat.2 +++ b/lib/libc/sys/getfsstat.2 @@ -28,7 +28,7 @@ .\" @(#)getfsstat.2 8.3 (Berkeley) 5/25/95 .\" $FreeBSD$ .\" -.Dd November 6, 2016 +.Dd December 27, 2016 .Dt GETFSSTAT 2 .Os .Sh NAME @@ -41,7 +41,7 @@ .In sys/ucred.h .In sys/mount.h .Ft int -.Fn getfsstat "struct statfs *buf" "long bufsize" "int flags" +.Fn getfsstat "struct statfs *buf" "long bufsize" "int mode" .Sh DESCRIPTION The .Fn getfsstat @@ -74,11 +74,11 @@ is given as NULL, returns just the number of mounted file systems. .Pp Normally -.Fa flags +.Fa mode should be specified as .Dv MNT_WAIT . If -.Fa flags +.Fa mode is set to .Dv MNT_NOWAIT , .Fn getfsstat @@ -108,6 +108,12 @@ The .Fa buf argument points to an invalid address. +.It Bq Er EINVAL +.Fa mode +is set to a value other than +.Dv MNT_WAIT +or +.Dv MNT_NOWAIT . .It Bq Er EIO An .Tn I/O |