Page MenuHomeFreeBSD

pseudofs: Simplify pfs_readdir() and set eofflag
ClosedPublic

Authored by markj on Jul 22 2025, 1:31 PM.
Tags
None
Referenced Files
F132313549: D51462.id158907.diff
Wed, Oct 15, 7:27 PM
F132310608: D51462.id158949.diff
Wed, Oct 15, 6:52 PM
Unknown Object (File)
Sat, Oct 11, 7:10 AM
Unknown Object (File)
Sat, Oct 11, 7:10 AM
Unknown Object (File)
Sat, Oct 11, 7:10 AM
Unknown Object (File)
Sat, Oct 11, 7:10 AM
Unknown Object (File)
Sat, Oct 11, 1:35 AM
Unknown Object (File)
Fri, Oct 10, 11:52 PM
Subscribers

Details

Summary

There were two loops, one to skip entries before the requested offset,
and one to populate entries. Merge them and use the return value of
pfs_iterate() to decide whether to set eofflag.

As a side effect, this fixes a small bug: the first loop would decrement
offset to zero, and the second loop would increment it again.
However, offset was used to set d_off, and we should include the
starting offset there.

Diff Detail

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

Event Timeline

markj requested review of this revision.Jul 22 2025, 1:31 PM
kib added inline comments.
sys/fs/pseudofs/pseudofs_vnops.c
888

This line definitely needs a comment that allproc_lock is required for pfs_iterate().
Although it is probably not needed for not-procdir directories.

This revision is now accepted and ready to land.Jul 22 2025, 2:19 PM
markj marked an inline comment as done.

Add a comment noting the reason for acquiring allproc_lock.

For now I did not attempt to make it smarter.

This revision now requires review to proceed.Jul 22 2025, 3:13 PM
This revision is now accepted and ready to land.Jul 22 2025, 3:17 PM