Page MenuHomeFreeBSD

Fix getmntpoint(3) to operate as it is documented in its manual page.
Needs ReviewPublic

Authored by mckusick on Sat, Oct 18, 7:11 AM.
Tags
None
Referenced Files
F132618022: D53185.diff
Sat, Oct 18, 11:42 AM
F132613534: D53185.id.diff
Sat, Oct 18, 10:41 AM
F132613432: D53185.id164486.diff
Sat, Oct 18, 10:39 AM
F132608369: D53185.id164486.diff
Sat, Oct 18, 9:35 AM
F132608324: D53185.id.diff
Sat, Oct 18, 9:34 AM
F132605289: D53185.diff
Sat, Oct 18, 8:55 AM
Restricted File
Sat, Oct 18, 7:11 AM
Subscribers

Details

Reviewers
des
olce
Summary

Dag-Erling Smørgrav <des@FreeBSD.org> reoprts:
While working on quot(8), I noticed that getmntpoint(3) does not actually accept a device name “with or without /dev/ prepended to it” as the manual page and code comments claim.

This patch corrects the problem by prepending /dev/ to names that do not begin with a '/'.

Since there are now two places in the code that want to prepend /dev/ the code to do this is broken out into a separate function.

Test Plan

Note that this fix cannot be tested with the df(1) command as it does not use getmntpoint(3).

This program can be used to test getmntpoit(3): {F132597285}

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

des requested changes to this revision.Sat, Oct 18, 7:36 AM
des added inline comments.
lib/libutil/mntopts.c
151

Please use a caller-provided buffer instead

179

Missing a null check here

This revision now requires changes to proceed.Sat, Oct 18, 7:36 AM
mckusick marked 2 inline comments as done.

Respond to Dag-Erling's comments.

Responding to Dag-Erling's comments.

lib/libutil/mntopts.c
151

It takes more parameters, more lines of code, and generally makes the code harder to follow. That said, I have made the change.

179

stat(NULL, &statbuf) returns -1 (EBADF) which will have the correct response here. It seems pointless to add an explicit test for NULL.