Skip to content

feat: add missing lch* syscalls to *BSD platforms - #5400

Merged
tgross35 merged 1 commit into
rust-lang:mainfrom
ngie-eign:add-lch-functions
Aug 12, 2026
Merged

feat: add missing lch* syscalls to *BSD platforms#5400
tgross35 merged 1 commit into
rust-lang:mainfrom
ngie-eign:add-lch-functions

Conversation

@ngie-eign

@ngie-eign ngie-eign commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

This change adds the following system calls to various 4.4BSD derivatives:

  • FreeBSD(-like)
    • lchmod ([DragonFlyBSD][1], [FreeBSD][2])
  • macOS
    • [lchflags][3]
    • [lchmod][4]
  • NetBSD
    • [lchmod][5]

These system calls are available on all ancient versions of *BSD (4.4BSD, FreeBSD 3.0, etc). More specific historical information about when the functions were added is available in the manpages and headers referenced.

1: https://leaf.dragonflybsd.org/cgi/web-man?command=lchmod
2: https://man.freebsd.org/cgi/man.cgi?query=lchmod
3: https://github.com/apple-oss-distributions/xnu/blob/f6217f891ac0bb64f3d375211650a4c1ff8ca1ea/bsd/sys/stat.h#L597
4: https://github.com/apple-oss-distributions/xnu/blob/f6217f891ac0bb64f3d375211650a4c1ff8ca1ea/bsd/sys/stat.h#L598
5: https://man.netbsd.org/lchmod.2

@rustbot

rustbot commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in a NetBSD-like module

cc @semarie

@tgross35

Copy link
Copy Markdown
Member

Diff looks reasonable but could you please add source permalinks to the commit message? https://github.com/rust-lang/libc/blob/main/CONTRIBUTING.md#source-links

@ngie-eign

ngie-eign commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

Diff looks reasonable but could you please add source permalinks to the commit message? https://github.com/rust-lang/libc/blob/main/CONTRIBUTING.md#source-links

I added links to the BSD manpages (they have historical notes for when syscalls were added) instead of source on GitHub--which may or may not change in the future or might be pointing to out-of-date or unofficial readonly mirrors. macOS ... is another beast entirely (partly because they don't publish their documentation as much), so I've linked the actual header source as mentioned in CONTRIBUTING.md .

@ngie-eign
ngie-eign force-pushed the add-lch-functions branch 3 times, most recently from 332fdda to ee9a957 Compare August 12, 2026 04:30
Comment thread src/unix/bsd/apple/mod.rs Outdated
Comment thread src/unix/bsd/apple/mod.rs
@tgross35

Copy link
Copy Markdown
Member

I added links to the BSD manpages (they have historical notes for when syscalls were added) instead of source on GitHub--which may or may not change in the future or might be pointing to out-of-date or unofficial readonly mirrors. macOS ... is another beast entirely (partly because they don't publish their documentation as much), so I've linked the actual header source as mentioned in CONTRIBUTING.md .

Manpages are of course fine to include but I always need to check against headers (since sometimes they show more details or don't actually line up), so linking them is really just a way to save me from going hunting. I'll make that more clear in the docs.

As far as I'm aware, the BSD mirrors are official, and asking specifically for permalinks is how we know they're accurate at some point of time. If there's a non-mirror web viewer then that's fine too but they seem to often give problems (e.g. sourceware is flaky, https://svnweb.freebsd.org/ is currently a 503 for me, I'm not even sure if DragonFly has a viewer for their repo...).

Anyway, I already peeked so:

Comment thread libc-test/semver/macos.txt Outdated
@ngie-eign

Copy link
Copy Markdown
Contributor Author

I added links to the BSD manpages (they have historical notes for when syscalls were added) instead of source on GitHub--which may or may not change in the future or might be pointing to out-of-date or unofficial readonly mirrors. macOS ... is another beast entirely (partly because they don't publish their documentation as much), so I've linked the actual header source as mentioned in CONTRIBUTING.md .

Manpages are of course fine to include but I always need to check against headers (since sometimes they show more details or don't actually line up), so linking them is really just a way to save me from going hunting. I'll make that more clear in the docs.

As far as I'm aware, the BSD mirrors are official, and asking specifically for permalinks is how we know they're accurate at some point of time. If there's a non-mirror web viewer then that's fine too but they seem to often give problems (e.g. sourceware is flaky, https://svnweb.freebsd.org/ is currently a 503 for me, I'm not even sure if DragonFly has a viewer for their repo...).

FreeBSD moved to cgit over a year ago [1]. There was recent discussion about shutting down svnweb on the internal developers list, but there's no timeframe for when that might happen.

Anyway, I already peeked so:

  1. https://docs.freebsd.org/en/books/handbook/mirrors/

This change adds the following system calls to various 4.4BSD
derivatives:

* FreeBSD(-like)
    * lchmod ([DragonFlyBSD][1], [FreeBSD][2])
* macOS
    * [lchflags][3]
    * [lchmod][4]
* NetBSD
    * [lchmod][5]

These system calls are available on all ancient versions of *BSD
(4.4BSD, FreeBSD 3.0, etc). More specific historical information
about when the functions were added is available in the manpages
and headers referenced.

This change also adds *chflags and *chmod to macos' semver file
(additional syscalls are missing from that file).

1: https://leaf.dragonflybsd.org/cgi/web-man?command=lchmod
2: https://man.freebsd.org/cgi/man.cgi?query=lchmod
3: https://github.com/apple-oss-distributions/xnu/blob/f6217f891ac0bb64f3d375211650a4c1ff8ca1ea/bsd/sys/stat.h#L597
4: https://github.com/apple-oss-distributions/xnu/blob/f6217f891ac0bb64f3d375211650a4c1ff8ca1ea/bsd/sys/stat.h#L598
5: https://man.netbsd.org/lchmod.2

Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
@ngie-eign

ngie-eign commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author
  • DragonFly hosts their primary git mirror.
  • NetBSD uses cvsweb as their primary source of truth.
    • I use the readonly GitHub mirror for my own sanity, but doublecheck against my CVS checkout when upstreaming changes and vendoring changes from NetBSD in FreeBSD.
  • OpenBSD uses cvsweb as their primary source of truth, but they also advertise their git mirrors on the front page.

PS My FreeBSD.org handle is: ngie, FYI.
PPS I'm working on this in order to get the pjdfstest rust rewrite done by a GSoC 2022 student into mainline.

@tgross35

Copy link
Copy Markdown
Member

Thanks for all the info, I'll pull that all into our docs at the next update. Also looks like a rather cool project.

@tgross35 tgross35 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM as well, thanks!

View changes since this review

@tgross35
tgross35 added this pull request to the merge queue Aug 12, 2026
@tgross35 tgross35 added the stable-nominated This PR should be considered for cherry-pick to libc's stable release branch label Aug 12, 2026
Merged via the queue into rust-lang:main with commit 8b4ebdc Aug 12, 2026
57 checks passed
@ngie-eign
ngie-eign deleted the add-lch-functions branch August 12, 2026 05:35
@ngie-eign

ngie-eign commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

(I see @tgross35 already added the stable-nominated label; whoops -- heh)

Ad hoc libc-0.2 GHA CI/CD run.
More info:

@ngie-eign

ngie-eign commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author
  • NetBSD uses cvsweb as their primary source of truth.
    • I use the readonly GitHub mirror for my own sanity, but doublecheck against my CVS checkout when upstreaming changes and vendoring changes from NetBSD in FreeBSD.

I just compared my GitHub fork against NetBSD's, and it look like they rewrote their history sometime in the not so distant past (my trunk has different hashes from their's). So, I would strongly advise not using their GitHub readonly mirror as a valid source of truth :/...

@tgross35 tgross35 mentioned this pull request Sep 4, 2026
@tgross35 tgross35 added stable-applied This PR has been cherry-picked to libc's stable release branch and removed stable-nominated This PR should be considered for cherry-pick to libc's stable release branch labels Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

O-bsd O-freebsd O-macos O-unix stable-applied This PR has been cherry-picked to libc's stable release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants