Page MenuHomeFreeBSD

libc: Remove readdir_r(3)
ClosedPublic

Authored by des on Sep 10 2025, 3:51 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Nov 5, 10:03 AM
Unknown Object (File)
Fri, Oct 31, 1:05 AM
Unknown Object (File)
Tue, Oct 28, 5:27 PM
Unknown Object (File)
Sun, Oct 26, 1:02 AM
Unknown Object (File)
Oct 12 2025, 5:47 AM
Unknown Object (File)
Oct 10 2025, 12:47 PM
Unknown Object (File)
Oct 10 2025, 12:47 PM
Unknown Object (File)
Oct 10 2025, 12:47 PM

Details

Reviewers
kib
Group Reviewers
srcmgr
Commits
rGd549de769055: libc: Remove readdir_r(3)
Summary

Relnotes: yes

Diff Detail

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

Event Timeline

des requested review of this revision.Sep 10 2025, 3:51 PM

Commit message should include the reason for the removal

This revision is now accepted and ready to land.Sep 10 2025, 4:15 PM

Commit message should include the reason for the removal

That was in the deprecation commit (2bd157bc732a1939cb71314e48de6118b91e0ad0).

This revision was automatically updated to reflect the committed changes.

This broke building rust 1.88 via poudriere-devel :

  = note: ld: error: undefined symbol: readdir_r
          >>> referenced by std.d8968a002452916e-cgu.07
          >>>               std-de94806a57729acc.std.d8968a002452916e-cgu.07.rcgu.o:(std::sys::fs::unix::remove_dir_impl::remove_dir_all_recursive::hbe1160129d2c5f7c) in archive /wrkdirs/usr/ports/lan
g/rust/work/bootstrap/lib/rustlib/x86_64-unknown-freebsd/lib/libstd-de94806a57729acc.rlib
          >>> did you mean: readdir_r@FBSD_1.5
          >>> defined in: /lib/libc.so.7
          cc: error: linker command failed with exit code 1 (use -v to see invocation)

This broke building rust 1.88 via poudriere-devel :

That's a bug in rust. Two bugs, actually: using readdir_r() in the first place, and using it despite the lack of a prototype.

Small suggestion for when/if this gets recommitted.

By the way, I think the current warning message about readdir_r() in the man page is likely wrong. Looking at all implementations of VOP_PATHCONF() in sys/fs, UFS and ZFS, I only see constants being returned except for the NFS client, where that entirely depends on the server (which is actually wrong given our implementation of namei()). While I can easily conceive that different directories may have different values (e.g., if not backed by the same FS), I have a harder time imagining that this value would change *while* a directory is in use, and some POSIX wording implies this cannot be the case. The reason for deprecating readdir_r() seems to be that it cannot be used on systems where {NAME_MAX} is indeterminate (pathconf() returning -1 on _SC_NAME_MAX), which is not the case on FreeBSD.

Based on this, I do not think that readdir_r() poses any actual security problems on FreeBSD, and thus see no hurry in removing this function (even if less efficient). Do you agree?

lib/libc/gen/gen-compat.h
40–43

Suggested alphabetical/version ordering.