Page MenuHomeFreeBSD

stat: fix use of devname(3)
ClosedPublic

Authored by kevans on Wed, Apr 22, 1:02 AM.
Tags
None
Referenced Files
F157089707: D56565.id176047.diff
Mon, May 18, 9:23 AM
F157089142: D56565.id176047.diff
Mon, May 18, 9:20 AM
F156956073: D56565.id176975.diff
Sun, May 17, 3:25 PM
F156955149: D56565.id176975.diff
Sun, May 17, 3:17 PM
Unknown Object (File)
Sun, May 17, 12:12 PM
Unknown Object (File)
Sun, May 17, 12:07 PM
Unknown Object (File)
Sat, May 16, 7:49 PM
Unknown Object (File)
Fri, May 15, 10:29 PM
Subscribers

Details

Summary

Besides being a little hard to parse through visually, this had its own
bug of inspecting st->st_mode to determine what to pass to devname(3),
which is only correct for st_rdev.

For st_dev, you're likely to be looking at files or directories and
attempting to assess what device they're located on, so the mode is
meaningless- we just have to assume that our filesystems are on
character devices and attempt to resolve st_dev as such.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 72457
Build 69340: arc lint + arc unit

Event Timeline

This revision is now accepted and ready to land.Wed, Apr 22, 1:38 AM

Do we even need HAVE_DEVNAME at all? This was originally imported from OpenBSD via NetBSD, but we haven't pulled anything from upstream in 15 years and the diff is now massive. We may as well drop the pretense that we will ever want to build this code on a platform that doesn't have devname().

usr.bin/stat/tests/stat_test.sh
313

I would move this to right before mount, because of how you wrote the cleanup function.

324

rm

kevans marked 2 inline comments as done.

Small test cleanup:

  • mkdir mnt later, since we use it to signal that we need to try unmounting
  • use a local for the path to check as a portability aid, other systems may be able to make different asssumptions about their filesystem layout and avoid needing to mount anything
This revision now requires review to proceed.Thu, Apr 23, 2:51 AM
usr.bin/stat/tests/stat_test.sh
313

This should be at a global since we need it in cleanup

kevans marked an inline comment as done.

Lift chkpath out and actually use it in cleanup, rather than inlining its value

des added inline comments.
usr.bin/stat/tests/stat_test.sh
28

I generally prefer uppercase for globals but that's a matter of taste, this is gtg

This revision is now accepted and ready to land.Wed, Apr 29, 2:34 PM
This revision was automatically updated to reflect the committed changes.
kevans marked an inline comment as done.