Skip to content

Support renameat2 and statx under musl libc #4478

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

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/unix/linux_like/linux/musl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,13 @@ extern "C" {
flags: c_int,
) -> ssize_t;
pub fn getauxval(type_: c_ulong) -> c_ulong;
pub fn renameat2(
oldfd: c_int,
old: *const c_char,
newfd: c_int,
new: *const c_char,
flags: c_uint,
) -> c_int;

// Added in `musl` 1.1.20
pub fn explicit_bzero(s: *mut c_void, len: size_t);
Expand Down
18 changes: 15 additions & 3 deletions src/unix/linux_like/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,11 @@ cfg_if! {
}

cfg_if! {
if #[cfg(any(target_env = "gnu", target_os = "android"))] {
if #[cfg(any(
target_env = "gnu",
target_os = "android",
target_env = "musl"
))] {
s! {
pub struct statx {
pub stx_mask: crate::__u32,
Expand Down Expand Up @@ -1656,7 +1660,11 @@ cfg_if! {
}

cfg_if! {
if #[cfg(any(target_env = "gnu", target_os = "android"))] {
if #[cfg(any(
target_env = "gnu",
target_os = "android",
target_env = "musl"
))] {
pub const AT_STATX_SYNC_TYPE: c_int = 0x6000;
pub const AT_STATX_SYNC_AS_STAT: c_int = 0x0000;
pub const AT_STATX_FORCE_SYNC: c_int = 0x2000;
Expand Down Expand Up @@ -2166,7 +2174,11 @@ cfg_if! {

// The statx syscall, available on some libcs.
cfg_if! {
if #[cfg(any(target_env = "gnu", target_os = "android"))] {
if #[cfg(any(
target_env = "gnu",
target_os = "android",
target_env = "musl"
))] {
extern "C" {
pub fn statx(
dirfd: c_int,
Expand Down
Loading