Replace libc in Linux with rustix#41
Conversation
| N: AsRef<OsStr>, | ||
| { | ||
| util::extract_noattr(sys::get_fd(self.as_raw_fd(), name.as_ref())) | ||
| // SAFETY: Implement I/O safety later. |
There was a problem hiding this comment.
Note: this should be safe as-is as we don't keep the file descriptor around. I.e., the API is unsafe, but the usage is safe.
|
Could you rebase on master? That should cause CI to run. |
|
It looks like we're going to need to do some casting on macos: https://github.com/Stebalien/xattr/actions/runs/6991478958/job/19022083927. |
rustix is a crate which provides I/O-safe wrappers around raw system calls on Linux and libc on other Unixes. This PR makes it so the functions in this crate call the rustix functions. This has a number of benefits. It removes a substantial amount of unsafe code from this crate. In addition, raw syscalls are often more efficient than libc calls; sometimes they can even be inlined into their calling functions. Two compromises were made in this PR: - This crate does not have I/O safety yet, while rustix does. So I borrow the raw file descriptor for now to avoid a breaking change. - The BSD equivalents to the Xattr functions are not yet exposed in Rustix. So I still use libc in the BSD backend. Closes Stebalien#40 Signed-off-by: John Nunley <dev@notgull.net>
Signed-off-by: John Nunley <dev@notgull.net>
I've fixed this issue. |
src/sys/linux_macos.rs
Outdated
|
|
||
| // Convert an `&mut [u8]` to an `&mut [c_char]` | ||
| #[inline] | ||
| fn as_list_buffer(buf: &mut [u8]) -> &mut [c_char] { |
There was a problem hiding this comment.
(I'm just not sure what "list buffer" means here).
There was a problem hiding this comment.
The buffer is for listxattr, I've renamed it accordingly.
|
Not sure what the errors on BSD/MacOS mean. I'll investigate this later. |
Signed-off-by: John Nunley <dev@notgull.net>
Signed-off-by: John Nunley <dev@notgull.net>
Signed-off-by: John Nunley <dev@notgull.net>
|
It's later now, I've investigated this. Both macOS and FreeBSD looks good to me, at least when I try them in a VM. |
|
@Stebalien When do you think you can review this PR? |
|
Thanks for the reminder! |
|
And released as v1.1.0. |
This reverts commit 2cf71bc.
This reverts commit 2cf71bc. Signed-off-by: John Nunley <dev@notgull.net>
rustix is a crate which provides I/O-safe wrappers around raw system
calls on Linux and libc on other Unixes. This PR makes it so the
functions in this crate call the rustix functions.
This has a number of benefits. It removes a substantial amount of
unsafe code from this crate. In addition, raw syscalls are often more
efficient than libc calls; sometimes they can even be inlined into
their calling functions.
Two compromises were made in this PR:
borrow the raw file descriptor for now to avoid a breaking change.
Rustix. So I still use libc in the BSD backend.
Closes #40