Page MenuHomeFreeBSD

libdevctl: Add devctl_getpath
ClosedPublic

Authored by imp on Oct 30 2021, 12:52 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Jun 17, 10:10 AM
Unknown Object (File)
Mon, Jun 3, 5:20 PM
Unknown Object (File)
May 13 2024, 8:42 PM
Unknown Object (File)
Mar 12 2024, 5:32 PM
Unknown Object (File)
Mar 12 2024, 5:32 PM
Unknown Object (File)
Mar 12 2024, 5:32 PM
Unknown Object (File)
Mar 12 2024, 5:32 PM
Unknown Object (File)
Mar 8 2024, 10:02 AM
Subscribers

Details

Summary

Helper routine to call the kernel to get a path to the named device.
Different path enumeration methods (called locators) can be used
for different path types depending on what the kernel implements.

Sponsored by: Netflix

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

imp requested review of this revision.Oct 30 2021, 12:52 AM
imp added a parent revision: D32745: devctl: Add DEV_GET_PATH.
gbe added a subscriber: gbe.

LGTM for the man page part.

lib/libdevctl/devctl.c
171
185

I don't know that you need this check? The ioctl handler in the kernel already validates the length, and it enforces a much smaller limit (64) anyway?

190
203

Note that this isn't necessarily guaranteed to loop twice if the path "changes" size for some reason (not sure if we have any paths that will ever change size dynamically?) It might be nice to return a more specific error value for the buffer being too short. Other places in the kernel (e.g. sysctl handlers) tend to return ENOMEM for this rather than EINVAL. (The argument wasn't invalid, just too small). That would let you then just loop on the specific errno value without the BUFLEN check. It might still loop more than once, but you would know it wasn't due to some other EINVAL case at least.

imp marked 4 inline comments as done.Nov 5 2021, 11:28 PM
imp added inline comments.
lib/libdevctl/devctl.c
185

Sure.

203

We have no devices that change path today.
It also returns ENAMETOOLONG and I've fixed that.

imp marked 2 inline comments as done.

update with jhb review comments

This revision is now accepted and ready to land.Nov 9 2021, 5:30 PM
This revision was automatically updated to reflect the committed changes.