diff --git a/changelog/2657.changed.md b/changelog/2657.changed.md new file mode 100644 index 0000000000..3b534175f3 --- /dev/null +++ b/changelog/2657.changed.md @@ -0,0 +1 @@ +Changed `renameat2` to use raw syscalls instead of libc functions, enabling support for musl libc and other Linux environments beyond GNU libc. \ No newline at end of file diff --git a/src/fcntl.rs b/src/fcntl.rs index 6504c1dcf2..9c7501198e 100644 --- a/src/fcntl.rs +++ b/src/fcntl.rs @@ -444,22 +444,24 @@ pub fn renameat( old_dirfd: Fd1, old_path: &P1, @@ -483,7 +485,10 @@ pub fn renameat2, len: ssize_t) -> Result { diff --git a/test/test_fcntl.rs b/test/test_fcntl.rs index 693935894e..9b781f20e2 100644 --- a/test/test_fcntl.rs +++ b/test/test_fcntl.rs @@ -8,15 +8,7 @@ use nix::fcntl::{openat, readlinkat, renameat}; #[cfg(target_os = "linux")] use nix::fcntl::{openat2, OpenHow, ResolveFlag}; -#[cfg(all( - target_os = "linux", - target_env = "gnu", - any( - target_arch = "x86_64", - target_arch = "powerpc", - target_arch = "s390x" - ) -))] +#[cfg(target_os = "linux")] use nix::fcntl::{renameat2, RenameFlags}; #[cfg(not(target_os = "redox"))] use nix::sys::stat::Mode; @@ -132,15 +124,7 @@ fn test_renameat() { } #[test] -#[cfg(all( - target_os = "linux", - target_env = "gnu", - any( - target_arch = "x86_64", - target_arch = "powerpc", - target_arch = "s390x" - ) -))] +#[cfg(target_os = "linux")] fn test_renameat2_behaves_like_renameat_with_no_flags() { let old_dir = tempfile::tempdir().unwrap(); let old_dirfd = @@ -161,15 +145,7 @@ fn test_renameat2_behaves_like_renameat_with_no_flags() { } #[test] -#[cfg(all( - target_os = "linux", - target_env = "gnu", - any( - target_arch = "x86_64", - target_arch = "powerpc", - target_arch = "s390x" - ) -))] +#[cfg(target_os = "linux")] fn test_renameat2_exchange() { let old_dir = tempfile::tempdir().unwrap(); let old_dirfd = @@ -206,15 +182,7 @@ fn test_renameat2_exchange() { } #[test] -#[cfg(all( - target_os = "linux", - target_env = "gnu", - any( - target_arch = "x86_64", - target_arch = "powerpc", - target_arch = "s390x" - ) -))] +#[cfg(target_os = "linux")] fn test_renameat2_noreplace() { let old_dir = tempfile::tempdir().unwrap(); let old_dirfd =