Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

syscalls: switch to rustix for most of our syscalls #92

Merged
merged 1 commit into from
Oct 17, 2024

Conversation

cyphar
Copy link
Member

@cyphar cyphar commented Oct 17, 2024

Using libc leads to several issues when dealing with multiarch that make things quite frustrating, and rustix does provide nicer APIs (for the most part -- some are a little wonky). One major annoyance is that building for musl leads to annoying build failures because musl uses differently-sized or differently-signed types, which we don't want to care about because we just want to use the actual kernel APIs. Also, musl is missing wrappers for things like statx(2) which we need to use.

We still need syscall wrappers to provide nice error information, but we can remove most of the internal-only bitflags and unsafe blocks. The only syscall wrapper we don't switch to rustix is openat2 because rustix's API is not designed to be extensible and so we can stick with libc for now.

In the future we might want to consider migrating away from libc entirely (to linux_raw_sys) to reduce the code bloat of having two different syscall wrappers.

Fixes #1
Signed-off-by: Aleksa Sarai [email protected]


I hit two issues while working on this, but have applied workarounds so we can merge this without fixing those issues:

@cyphar cyphar force-pushed the rustix-syscalls branch 2 times, most recently from 802a413 to 5499641 Compare October 17, 2024 07:24
Using libc leads to several issues when dealing with multiarch that make
things quite frustrating, and rustix does provide nicer APIs (for the
most part -- some are a little wonky). One major annoyance is that
building for musl leads to annoying build failures because musl uses
differently-sized or differently-signed types, which we don't want to
care about because we just want to use the actual kernel APIs. Also,
musl is missing wrappers for things like statx(2) which we need to use.

We still need syscall wrappers to provide nice error information, but we
can remove most of the internal-only bitflags and unsafe blocks. The
only syscall wrapper we don't switch to rustix is openat2 because
rustix's API is not designed to be extensible and so we can stick with
libc for now.

In the future we might want to consider migrating away from libc
entirely (to linux_raw_sys) to reduce the code bloat of having two
different syscall wrappers.

Signed-off-by: Aleksa Sarai <[email protected]>
@cyphar cyphar merged commit 55226a9 into openSUSE:main Oct 17, 2024
35 checks passed
@cyphar cyphar deleted the rustix-syscalls branch October 17, 2024 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

move to using rustix instead of custom syscall wrappers
1 participant