Page MenuHomeFreeBSD

directory.3: add a STANDARDS section
ClosedPublic

Authored by asomers on Apr 30 2019, 6:09 PM.
Tags
None
Referenced Files
Unknown Object (File)
Jan 23 2024, 9:47 AM
Unknown Object (File)
Dec 27 2023, 4:15 PM
Unknown Object (File)
Dec 24 2023, 7:29 AM
Unknown Object (File)
Dec 24 2023, 7:28 AM
Unknown Object (File)
Dec 20 2023, 12:26 AM
Unknown Object (File)
Dec 15 2023, 10:28 PM
Unknown Object (File)
Dec 11 2023, 3:08 AM
Unknown Object (File)
Aug 7 2023, 6:38 AM
Subscribers

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

This revision is now accepted and ready to land.Apr 30 2019, 6:31 PM

Not so fast! I just discovered a serious footgun: Linux's struct dirent has a
d_off field, but it's meaning is different than FreeBSD's. That's worth
mentioning.

This revision now requires review to proceed.Apr 30 2019, 10:28 PM

Not so fast! I just discovered a serious footgun: Linux's struct dirent has a
d_off field, but it's meaning is different than FreeBSD's. That's worth
mentioning.

As far as I understand, d_off on FreeBSD is supposed to work the same as on Linux once it is implemented completely. Recent head and stable/12 seems to have most of the kernel part of this (SVN r340431, r340721). However, telldir() and seekdir() in libc still use their old partially broken implementation.

Perhaps we can also mention here that readdir_r()'s API is broken by design since it cannot work if NAME_MAX is not defined as a constant, and http://austingroupbugs.net/view.php?id=696 proposes to deprecate readdir_r() in POSIX and allow readdir() to be thread-safe under some conditions.

lib/libc/gen/directory.3
291 ↗(On Diff #56891)

Hmm, why does "should not be used in portable programs" only apply to the fields and not to the function?

Not so fast! I just discovered a serious footgun: Linux's struct dirent has a
d_off field, but it's meaning is different than FreeBSD's. That's worth
mentioning.

As far as I understand, d_off on FreeBSD is supposed to work the same as on Linux once it is implemented completely. Recent head and stable/12 seems to have most of the kernel part of this (SVN r340431, r340721). However, telldir() and seekdir() in libc still use their old partially broken implementation.

Interesting. I didn't know that. Is the intent then to change telldir() to return a file offset instead of the weird thing it does now?

Perhaps we can also mention here that readdir_r()'s API is broken by design since it cannot work if NAME_MAX is not defined as a constant, and http://austingroupbugs.net/view.php?id=696 proposes to deprecate readdir_r() in POSIX and allow readdir() to be thread-safe under some conditions.

readdir_r already has a prominent shoutout at the top of the man page.

asomers marked an inline comment as done.

Address jilles' feedback

Not so fast! I just discovered a serious footgun: Linux's struct dirent has a
d_off field, but it's meaning is different than FreeBSD's. That's worth
mentioning.

As far as I understand, d_off on FreeBSD is supposed to work the same as on Linux once it is implemented completely. Recent head and stable/12 seems to have most of the kernel part of this (SVN r340431, r340721). However, telldir() and seekdir() in libc still use their old partially broken implementation.

Interesting. I didn't know that. Is the intent then to change telldir() to return a file offset instead of the weird thing it does now?

telldir() will still return a cookie, but it will come from d_off rather than the value returned by getdirentries() in *basep with libc magic.

In the case of UFS, d_off contains a file offset but in more modern filesystems it generally contains a cookie that cannot be interpreted by the application.

This revision is now accepted and ready to land.May 2 2019, 7:51 PM
This revision was automatically updated to reflect the committed changes.