Page MenuHomeFreeBSD

linsysfs: error check device-directory creation
ClosedPublic

Authored by kevans on Aug 20 2025, 2:38 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Oct 12, 12:31 AM
Unknown Object (File)
Sat, Oct 11, 3:00 PM
Unknown Object (File)
Sat, Oct 11, 6:35 AM
Unknown Object (File)
Sat, Oct 11, 6:35 AM
Unknown Object (File)
Sat, Oct 11, 6:35 AM
Unknown Object (File)
Sat, Oct 11, 6:34 AM
Unknown Object (File)
Fri, Oct 10, 11:17 PM
Unknown Object (File)
Wed, Oct 8, 6:07 AM
Subscribers

Details

Summary

This one in particular is ripe with opportunities to trigger a duplicate
node error in pfs_create_dir(), so we do actually want to error-check
it. The rest, more or less, should be expected not to fail. We'll
propagate the error from pfs_create_dir() up through linsysfs_run_bus
and complain about the device node that caused the error. Note that we
avoid failing vfs_init() since a partially-constructed linsysfs with
missing devices is probably more useful than missing linsysfs entirely.

While we're here, convert two malloc() that weren't being error checked
to M_WAITOK -- we already wait in the rest of the function, might as
well do the same here.

Add a missing newline to the pseudofs error mesage.

Diff Detail

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

Event Timeline

Why all this stuff is done in the vfs_init() context, at all? vfs_init() should be limited to just that, initialization of the vfs glue. Real fs structure creation should be done on the (first) mount.

An incomplete linsysfs would frequently be more useful than no linsysfs at all. Would it be possible to change the behaviour such that if there are homonymous siblings, we just drop one of them and put a warning into the dmesg log?

In D52038#1188847, @kib wrote:

Why all this stuff is done in the vfs_init() context, at all? vfs_init() should be limited to just that, initialization of the vfs glue. Real fs structure creation should be done on the (first) mount.

I went to make this change, but I understand why it does this now- we don't expose any way for pseudofs' to do that. They get init/uninit, but vfs_mount() doesn't get exposed to them in any useful way at the moment.

My proposal is to change this review to just ignore the pfs_create_dir error (maybe with some diagnostic output) and I'll do some follow-up work on pseudofs. I guess I'd specifically aim to add a pi_create that we run once on the first pfs_mount(), and we don't really need a pi_destroy to pair with it since unload will pfs_destroy() the structure.

Print a warning when we fail to add a directory just to give the admin some
expectation of what devices might be missing from the tree, but don't propagate
the error back upward so that the rest of the sysfs is still usable.

kib added inline comments.
sys/compat/linsysfs/linsysfs.c
297

Consider changing the pfs_create_dir() interface to return an error.
(In the other patch, of course).

This revision is now accepted and ready to land.Aug 22 2025, 11:25 AM

Kernel now boots on the Windows ARM Dev Kit. LGTM.