Page MenuHomeFreeBSD

Rename the 'flags' argument to getfsstat() to 'flag' and validate it.
ClosedPublic

Authored by jhb on Dec 19 2016, 4:40 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Nov 23, 1:58 AM
Unknown Object (File)
Tue, Nov 12, 6:00 PM
Unknown Object (File)
Sep 20 2024, 6:25 AM
Unknown Object (File)
Sep 19 2024, 7:38 PM
Unknown Object (File)
Sep 18 2024, 5:36 PM
Unknown Object (File)
Sep 15 2024, 6:26 AM
Unknown Object (File)
Sep 15 2024, 6:26 AM
Unknown Object (File)
Sep 15 2024, 6:25 AM
Subscribers

Details

Summary

Rename the 'flags' argument to getfsstat() to 'flag' 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'.

This is a followup to r308088. I will include the regen'd bits in a
separate followup. Will also bump .Dd on manpage when I actually
commit.

Test Plan
  • compiled and booted, but we do not have an existing test for getfsstat

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

jhb retitled this revision from to Rename the 'flags' argument to getfsstat() to 'flag' and validate it..
jhb updated this object.
jhb edited the test plan for this revision. (Show Details)
jhb added reviewers: trasz, kib.

As we discussed this with trasz, the callers must be inspected.

lib/libc/sys/getfsstat.2
44 ↗(On Diff #23094)

flag->mode or wait_mode.

sys/kern/vfs_syscalls.c
455 ↗(On Diff #23094)

What about MNT_LAZY ? Either it should be enabled there, or check for != MNT_LAZY removed below ?

As discussed, the callers have been inspected :-)

MNT_LAZY is an invalid flag there, and other BSDs don't allow anything other than MNT_WAIT, MNT_NOWAIT, or 0.

sys/kern/vfs_syscalls.c
455 ↗(On Diff #23094)

I'm guessing it needs removing as it has never been documented. I looked in history and MNT_LAZY was added long ago in rS34266 which has a completely useless commit message.

Hmm, there is a followup e-mail saying that this was added for soft-updates:

https://docs.freebsd.org/cgi/getmsg.cgi?fetch=8550+0+archive/1998/cvs-sys/19980308.cvs-sys

Nothing in the rest of that commit (i.e. the userland bits) uses MNT_LAZY with getfsstat(). It seems to primarily be required for fsync(), so I wonder if it's addition to getfsstat() was an error to begin with?

sys/kern/vfs_syscalls.c
455 ↗(On Diff #23094)

I am fine with the removal, but removal must be done in the same commit which adds the flags check for MNT_WAIT/NOWAIT, IMO.

I did some sleuthing through BSDI sources and the addition of the MNT_LAZY flag check was put into getfsstat by one of the BSDI engineers apparently in response to a customer request. From there it got carried over to FreeBSD when I made the diffs for Julian who did the import.

I do not think that it is wrong to treat MNT_LAZY the same as MNT_NOWAIT, but I agree that there is nothing to be gained from doing that other than possibly keeping some programs from breaking.

jhb edited edge metadata.
  • Don't check for MNT_LAZY in getfsstat().
  • Rename 'flag' to 'mode'.
  • Regen.
kib edited edge metadata.
This revision is now accepted and ready to land.Dec 24 2016, 10:33 PM
jhb edited edge metadata.
  • Rename flags argument to getmntinfo to mode to match getfsstat.
This revision now requires review to proceed.Dec 26 2016, 7:04 PM

While doing a check via grep for all callers of getfsstat I found getmntinfo. All the in-tree callers pass either MNT_WAIT or MNT_NOWAIT.

kib edited edge metadata.
This revision is now accepted and ready to land.Dec 26 2016, 7:25 PM
This revision was automatically updated to reflect the committed changes.