From d61c2187ad48bccce5af94a7c877907be5cd75c6 Mon Sep 17 00:00:00 2001 From: dybucc <149513579+dybucc@users.noreply.github.com> Date: Wed, 10 Jun 2026 19:04:15 +0200 Subject: [PATCH 1/3] linux(uclibc): add `cfg` for lfs bindings Adds a `cfg` to enable LFS64 bindings under 32-bit targets. This does not apply to 64-bit targets. Their suffixed types are equivalent to their unsuffixed types. They unconditionally get both suffixed and unsuffixed types. This `cfg` replicates a build option upstream. --- build.rs | 9 +++++++ libc-test/build.rs | 7 ++++++ src/unix/linux_like/linux/uclibc/arm/mod.rs | 8 ------- .../linux/uclibc/mips/mips32/mod.rs | 13 +++------- .../linux/uclibc/mips/mips64/mod.rs | 4 ---- src/unix/linux_like/linux/uclibc/mod.rs | 24 ++++++++++++++++++- .../linux_like/linux/uclibc/x86_64/mod.rs | 8 ------- 7 files changed, 42 insertions(+), 31 deletions(-) diff --git a/build.rs b/build.rs index 07df3af2da2ac..69af5d5601b5f 100644 --- a/build.rs +++ b/build.rs @@ -39,6 +39,8 @@ const ALLOWED_CFGS: &[&str] = &[ "musl_redir_time64", "vxworks_lt_25_09", "libc_pauthtest", + // Corresponds with `__USE_FILE_OFFSET64` in uClibc. + "uclibc_file_offset_bits64", ]; // Extra values to allow for check-cfg. @@ -219,6 +221,13 @@ fn main() { } } + match env::var("CARGO_CFG_LIBC_UNSTABLE_UCLIBC_FILE_OFFSET_BITS") { + Ok(val) if val == "64" && target_env == "uclibc" && target_ptr_width == "32" => { + set_cfg("uclibc_file_offset_bits64") + } + _ => (), + } + // On CI: deny all warnings if libc_ci { set_cfg("libc_deny_warnings"); diff --git a/libc-test/build.rs b/libc-test/build.rs index e425c550b476f..432ed23721049 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -4041,6 +4041,13 @@ fn test_linux(target: &str) { // glibc versions older than 2.29. .define("__GLIBC_USE_DEPRECATED_SCANF", None); + if uclibc + && pointer_width == 32 + && env::var("CARGO_CFG_LIBC_UNSTABLE_UCLIBC_FILE_OFFSET_BITS").is_ok() + { + cfg.cfg("uclibc_file_offset_bits64", None); + } + config_gnu_bits(target, &mut cfg); // The L4Re libc headers contain some L4Re helper functions which are not needed for the libc // interface and must not be added to the libc crate diff --git a/src/unix/linux_like/linux/uclibc/arm/mod.rs b/src/unix/linux_like/linux/uclibc/arm/mod.rs index 9d255b7388fcd..c7660297f2aba 100644 --- a/src/unix/linux_like/linux/uclibc/arm/mod.rs +++ b/src/unix/linux_like/linux/uclibc/arm/mod.rs @@ -4,18 +4,10 @@ use crate::prelude::*; pub type wchar_t = c_uint; pub type clock_t = c_long; -pub type fsblkcnt_t = c_ulong; -pub type fsfilcnt_t = c_ulong; -pub type ino_t = c_ulong; -pub type off_t = c_long; pub type pthread_t = c_ulong; pub type nlink_t = c_uint; pub type blksize_t = c_long; -pub type blkcnt_t = c_long; - -pub type fsblkcnt64_t = u64; -pub type fsfilcnt64_t = u64; s! { pub struct cmsghdr { diff --git a/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs b/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs index b6c8559e78b77..f518b71ec33f5 100644 --- a/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs @@ -3,15 +3,8 @@ use crate::prelude::*; pub type clock_t = i32; pub type wchar_t = i32; -pub type off_t = i32; -pub type ino_t = u32; -pub type blkcnt_t = i32; pub type blksize_t = i32; pub type nlink_t = u32; -pub type fsblkcnt_t = c_ulong; -pub type fsfilcnt_t = c_ulong; -pub type fsblkcnt64_t = u64; -pub type fsfilcnt64_t = u64; s! { pub struct stat { @@ -24,7 +17,7 @@ s! { pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, pub st_pad2: [c_long; 1], - pub st_size: off_t, + pub st_size: crate::off_t, st_pad3: Padding, pub st_atime: crate::time_t, pub st_atime_nsec: c_long, @@ -227,8 +220,8 @@ s! { pub struct flock { pub l_type: c_short, pub l_whence: c_short, - pub l_start: off_t, - pub l_len: off_t, + pub l_start: crate::off_t, + pub l_len: crate::off_t, pub l_sysid: c_long, pub l_pid: crate::pid_t, pad: Padding<[c_long; 4]>, diff --git a/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs b/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs index a6a63a33a93b3..08a046a9ab5fd 100644 --- a/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs @@ -1,11 +1,7 @@ use crate::off64_t; use crate::prelude::*; -pub type blkcnt_t = i64; pub type blksize_t = i64; -pub type fsblkcnt_t = c_ulong; -pub type fsfilcnt_t = c_ulong; -pub type ino_t = u64; pub type nlink_t = u64; pub type off_t = i64; pub type wchar_t = i32; diff --git a/src/unix/linux_like/linux/uclibc/mod.rs b/src/unix/linux_like/linux/uclibc/mod.rs index 6c3d8013f9173..23f0581454713 100644 --- a/src/unix/linux_like/linux/uclibc/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mod.rs @@ -8,7 +8,6 @@ pub type shmatt_t = c_ulong; pub type msgqnum_t = c_ulong; pub type msglen_t = c_ulong; pub type regoff_t = c_int; -pub type rlim_t = c_ulong; pub type __rlimit_resource_t = c_ulong; pub type __priority_which_t = c_uint; @@ -23,6 +22,29 @@ cfg_if! { } } +cfg_if! { + if #[cfg(uclibc_file_offset_bits64)] { + pub type ino_t = u64; + pub type off_t = i64; + pub type rlim_t = u64; + pub type blkcnt_t = i64; + pub type fsblkcnt_t = u64; + pub type fsfilcnt_t = u64; + } else { + pub type ino_t = c_ulong; + pub type off_t = c_long; + pub type rlim_t = c_ulong; + pub type blkcnt_t = c_long; + pub type fsblkcnt_t = c_ulong; + pub type fsfilcnt_t = c_ulong; + } +} + +// Other LFS types have definitions provided by top-level modules (i.e. `unix`, +// `linux_like` and `linux`.) +pub type fsblkcnt64_t = u64; +pub type fsfilcnt64_t = u64; + cfg_if! { if #[cfg(doc)] { // Used in `linux::arch` to define ioctl constants. diff --git a/src/unix/linux_like/linux/uclibc/x86_64/mod.rs b/src/unix/linux_like/linux/uclibc/x86_64/mod.rs index 8ffcad9cbaa9d..8eb451184fd87 100644 --- a/src/unix/linux_like/linux/uclibc/x86_64/mod.rs +++ b/src/unix/linux_like/linux/uclibc/x86_64/mod.rs @@ -3,13 +3,8 @@ use crate::off64_t; use crate::prelude::*; -pub type blkcnt_t = i64; pub type blksize_t = i64; pub type clock_t = i64; -pub type fsblkcnt_t = c_ulong; -pub type fsfilcnt_t = c_ulong; -pub type fsword_t = c_long; -pub type ino_t = c_ulong; pub type nlink_t = c_uint; pub type off_t = c_long; // [uClibc docs] Note stat64 has the same shape as stat for x86-64. @@ -17,9 +12,6 @@ pub type stat64 = stat; pub type wchar_t = c_int; pub type pthread_t = c_ulong; -pub type fsblkcnt64_t = u64; -pub type fsfilcnt64_t = u64; - s! { pub struct ipc_perm { pub __key: crate::key_t, From 118f0680b5fa2daf5ebc0f9f7c6d43461514cb71 Mon Sep 17 00:00:00 2001 From: dybucc <149513579+dybucc@users.noreply.github.com> Date: Thu, 25 Jun 2026 11:22:32 +0200 Subject: [PATCH 2/3] linux(uclibc): fix `stat` struct family defs Fixes the definitions of: - `stat`. - `statfs`. - `statvfs`. The analogous 64-bit types wer also tweaked. They are equivalent on some target architectures. They only needed to be aliased. --- src/unix/linux_like/linux/uclibc/arm/mod.rs | 75 +++++++++--------- .../linux/uclibc/mips/mips32/mod.rs | 78 ++++++------------- .../linux/uclibc/mips/mips64/mod.rs | 70 ++++------------- src/unix/linux_like/linux/uclibc/mips/mod.rs | 34 ++++++++ src/unix/linux_like/linux/uclibc/mod.rs | 38 ++++++--- .../linux_like/linux/uclibc/x86_64/mod.rs | 54 +++++-------- 6 files changed, 162 insertions(+), 187 deletions(-) diff --git a/src/unix/linux_like/linux/uclibc/arm/mod.rs b/src/unix/linux_like/linux/uclibc/arm/mod.rs index c7660297f2aba..fa3b2f92f7769 100644 --- a/src/unix/linux_like/linux/uclibc/arm/mod.rs +++ b/src/unix/linux_like/linux/uclibc/arm/mod.rs @@ -1,4 +1,3 @@ -use crate::off64_t; use crate::prelude::*; pub type wchar_t = c_uint; @@ -31,47 +30,68 @@ s! { } pub struct stat { - pub st_dev: c_ulonglong, + pub st_dev: crate::dev_t, + + #[cfg(not(uclibc_file_offset_bits64))] __pad1: Padding, + #[cfg(not(uclibc_file_offset_bits64))] pub st_ino: crate::ino_t, + + #[cfg(uclibc_file_offset_bits64)] + __pad1: Padding, + #[cfg(uclibc_file_offset_bits64)] + pub __st_ino: crate::ino_t, + pub st_mode: crate::mode_t, pub st_nlink: crate::nlink_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, - pub st_rdev: c_ulonglong, + pub st_rdev: crate::dev_t, + + #[cfg(not(uclibc_file_offset_bits64))] __pad2: Padding, - pub st_size: off_t, + + #[cfg(uclibc_file_offset_bits64)] + __pad2: Padding, + + pub st_size: crate::off_t, pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt_t, pub st_atime: crate::time_t, - pub st_atime_nsec: c_long, + pub st_atime_nsec: c_ulong, pub st_mtime: crate::time_t, - pub st_mtime_nsec: c_long, + pub st_mtime_nsec: c_ulong, pub st_ctime: crate::time_t, - pub st_ctime_nsec: c_long, - __unused4: Padding, - __unused5: Padding, + pub st_ctime_nsec: c_ulong, + + #[cfg(not(uclibc_file_offset_bits64))] + __uclibc_unused4: Padding, + #[cfg(not(uclibc_file_offset_bits64))] + __uclibc_unused5: Padding, + + #[cfg(uclibc_file_offset_bits64)] + pub st_ino: crate::ino_t, } pub struct stat64 { - pub st_dev: c_ulonglong, - pub __pad1: c_uint, + pub st_dev: crate::dev_t, + __pad1: Padding, pub __st_ino: crate::ino_t, pub st_mode: crate::mode_t, pub st_nlink: crate::nlink_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, - pub st_rdev: c_ulonglong, - pub __pad2: c_uint, - pub st_size: off64_t, + pub st_rdev: crate::dev_t, + __pad2: Padding, + pub st_size: crate::off64_t, pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt64_t, pub st_atime: crate::time_t, - pub st_atime_nsec: c_long, + pub st_atime_nsec: c_ulong, pub st_mtime: crate::time_t, - pub st_mtime_nsec: c_long, + pub st_mtime_nsec: c_ulong, pub st_ctime: crate::time_t, - pub st_ctime_nsec: c_long, + pub st_ctime_nsec: c_ulong, pub st_ino: crate::ino64_t, } @@ -113,7 +133,7 @@ s! { pub f_namelen: c_int, pub f_frsize: c_int, pub f_flags: c_int, - pub f_spare: [c_int; 4], + f_spare: Padding<[c_int; 4]>, } pub struct statfs64 { @@ -124,27 +144,12 @@ s! { pub f_bavail: crate::fsblkcnt64_t, pub f_files: crate::fsfilcnt64_t, pub f_ffree: crate::fsfilcnt64_t, + pub f_fsid: crate::fsid_t, pub f_namelen: c_int, pub f_frsize: c_int, pub f_flags: c_int, - pub f_spare: [c_int; 4], - } - - pub struct statvfs64 { - pub f_bsize: c_ulong, - pub f_frsize: c_ulong, - pub f_blocks: u64, - pub f_bfree: u64, - pub f_bavail: u64, - pub f_files: u64, - pub f_ffree: u64, - pub f_favail: u64, - pub f_fsid: c_ulong, - __f_unused: Padding, - pub f_flag: c_ulong, - pub f_namemax: c_ulong, - __f_spare: [c_int; 6], + f_spare: Padding<[c_int; 4]>, } pub struct sigset_t { diff --git a/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs b/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs index f518b71ec33f5..6fd23df2d9530 100644 --- a/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs @@ -1,4 +1,3 @@ -use crate::off64_t; use crate::prelude::*; pub type clock_t = i32; @@ -16,16 +15,29 @@ s! { pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, - pub st_pad2: [c_long; 1], + + #[cfg(not(uclibc_file_offset_bits64))] + st_pad2: Padding<[c_long; 1]>, + + #[cfg(uclibc_file_offset_bits64)] + st_pad2: Padding<[c_long; 2]>, + pub st_size: crate::off_t, + + #[cfg(not(uclibc_file_offset_bits64))] st_pad3: Padding, + pub st_atime: crate::time_t, - pub st_atime_nsec: c_long, + pub st_atime_nsec: c_ulong, pub st_mtime: crate::time_t, - pub st_mtime_nsec: c_long, + pub st_mtime_nsec: c_ulong, pub st_ctime: crate::time_t, - pub st_ctime_nsec: c_long, + pub st_ctime_nsec: c_ulong, pub st_blksize: crate::blksize_t, + + #[cfg(uclibc_file_offset_bits64)] + st_pad4: Padding, + pub st_blocks: crate::blkcnt_t, st_pad5: Padding<[c_long; 14]>, } @@ -40,33 +52,17 @@ s! { pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, st_pad2: Padding<[c_long; 2]>, - pub st_size: off64_t, + pub st_size: crate::off64_t, pub st_atime: crate::time_t, - pub st_atime_nsec: c_long, + pub st_atime_nsec: c_ulong, pub st_mtime: crate::time_t, - pub st_mtime_nsec: c_long, + pub st_mtime_nsec: c_ulong, pub st_ctime: crate::time_t, - pub st_ctime_nsec: c_long, + pub st_ctime_nsec: c_ulong, pub st_blksize: crate::blksize_t, st_pad3: Padding, pub st_blocks: crate::blkcnt64_t, - st_pad5: Padding<[c_long; 14]>, - } - - pub struct statvfs64 { - pub f_bsize: c_ulong, - pub f_frsize: c_ulong, - pub f_blocks: crate::fsblkcnt64_t, - pub f_bfree: crate::fsblkcnt64_t, - pub f_bavail: crate::fsblkcnt64_t, - pub f_files: crate::fsfilcnt64_t, - pub f_ffree: crate::fsfilcnt64_t, - pub f_favail: crate::fsfilcnt64_t, - pub f_fsid: c_ulong, - pub __f_unused: c_int, - pub f_flag: c_ulong, - pub f_namemax: c_ulong, - pub __f_spare: [c_int; 6], + st_pad4: Padding<[c_long; 14]>, } pub struct pthread_attr_t { @@ -162,36 +158,6 @@ s! { __glibc_reserved5: Padding, } - pub struct statfs { - pub f_type: c_long, - pub f_bsize: c_long, - pub f_frsize: c_long, - pub f_blocks: crate::fsblkcnt_t, - pub f_bfree: crate::fsblkcnt_t, - pub f_files: crate::fsblkcnt_t, - pub f_ffree: crate::fsblkcnt_t, - pub f_bavail: crate::fsblkcnt_t, - pub f_fsid: crate::fsid_t, - - pub f_namelen: c_long, - f_spare: [c_long; 6], - } - - pub struct statfs64 { - pub f_type: c_long, - pub f_bsize: c_long, - pub f_frsize: c_long, - pub f_blocks: crate::fsblkcnt64_t, - pub f_bfree: crate::fsblkcnt64_t, - pub f_files: crate::fsblkcnt64_t, - pub f_ffree: crate::fsblkcnt64_t, - pub f_bavail: crate::fsblkcnt64_t, - pub f_fsid: crate::fsid_t, - pub f_namelen: c_long, - pub f_flags: c_long, - pub f_spare: [c_long; 5], - } - pub struct msghdr { pub msg_name: *mut c_void, pub msg_namelen: crate::socklen_t, diff --git a/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs b/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs index 08a046a9ab5fd..62faf98c48dec 100644 --- a/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs @@ -1,4 +1,3 @@ -use crate::off64_t; use crate::prelude::*; pub type blksize_t = i64; @@ -6,52 +5,30 @@ pub type nlink_t = u64; pub type off_t = i64; pub type wchar_t = i32; +pub type stat64 = stat; + s! { pub struct stat { - pub st_dev: c_ulong, - st_pad1: Padding<[c_long; 2]>, + pub st_dev: c_uint, + st_pad1: Padding<[c_int; 3]>, pub st_ino: crate::ino_t, pub st_mode: crate::mode_t, pub st_nlink: crate::nlink_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, - pub st_rdev: c_ulong, - st_pad2: Padding<[c_ulong; 1]>, - pub st_size: off_t, - st_pad3: Padding, - pub st_atime: crate::time_t, - pub st_atime_nsec: c_long, - pub st_mtime: crate::time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: crate::time_t, - pub st_ctime_nsec: c_long, - pub st_blksize: crate::blksize_t, - st_pad4: Padding, + pub st_rdev: c_uint, + st_pad2: Padding<[c_uint; 3]>, + pub st_size: crate::off_t, + pub st_atime: c_int, + pub st_atime_nsec: c_int, + pub st_mtime: c_int, + pub st_mtime_nsec: c_int, + pub st_ctime: c_int, + pub st_ctime_nsec: c_int, + pub st_blksize: c_int, + st_pad3: Padding, pub st_blocks: crate::blkcnt_t, - st_pad5: Padding<[c_long; 7]>, - } - - pub struct stat64 { - pub st_dev: c_ulong, - st_pad1: Padding<[c_long; 2]>, - pub st_ino: crate::ino64_t, - pub st_mode: crate::mode_t, - pub st_nlink: crate::nlink_t, - pub st_uid: crate::uid_t, - pub st_gid: crate::gid_t, - pub st_rdev: c_ulong, - st_pad2: Padding<[c_long; 2]>, - pub st_size: off64_t, - pub st_atime: crate::time_t, - pub st_atime_nsec: c_long, - pub st_mtime: crate::time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: crate::time_t, - pub st_ctime_nsec: c_long, - pub st_blksize: crate::blksize_t, - st_pad3: Padding, - pub st_blocks: crate::blkcnt64_t, - st_pad5: Padding<[c_long; 7]>, + st_pad4: Padding<[c_int; 14]>, } pub struct pthread_attr_t { @@ -123,21 +100,6 @@ s! { __glibc_reserved5: Padding, } - pub struct statfs { - pub f_type: c_long, - pub f_bsize: c_long, - pub f_frsize: c_long, - pub f_blocks: crate::fsblkcnt_t, - pub f_bfree: crate::fsblkcnt_t, - pub f_files: crate::fsblkcnt_t, - pub f_ffree: crate::fsblkcnt_t, - pub f_bavail: crate::fsblkcnt_t, - pub f_fsid: crate::fsid_t, - - pub f_namelen: c_long, - f_spare: [c_long; 6], - } - pub struct msghdr { pub msg_name: *mut c_void, pub msg_namelen: crate::socklen_t, diff --git a/src/unix/linux_like/linux/uclibc/mips/mod.rs b/src/unix/linux_like/linux/uclibc/mips/mod.rs index 8d17aa8e98e9a..c7c37b7318ea2 100644 --- a/src/unix/linux_like/linux/uclibc/mips/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mips/mod.rs @@ -2,6 +2,40 @@ use crate::prelude::*; pub type pthread_t = c_ulong; +s! { + pub struct statfs { + pub f_type: c_long, + pub f_bsize: c_long, + pub f_frsize: c_long, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_files: crate::fsblkcnt_t, + pub f_ffree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + + pub f_fsid: crate::fsid_t, + pub f_namelen: c_long, + pub f_flags: c_long, + f_spare: Padding<[c_long; 5]>, + } + + pub struct statfs64 { + pub f_type: c_long, + pub f_bsize: c_long, + pub f_frsize: c_long, + pub f_blocks: crate::fsblkcnt64_t, + pub f_bfree: crate::fsblkcnt64_t, + pub f_files: crate::fsblkcnt64_t, + pub f_ffree: crate::fsblkcnt64_t, + pub f_bavail: crate::fsblkcnt64_t, + + pub f_fsid: crate::fsid_t, + pub f_namelen: c_long, + pub f_flags: c_long, + f_spare: Padding<[c_long; 5]>, + } +} + pub const SFD_CLOEXEC: c_int = 0x080000; pub const NCCS: usize = 32; diff --git a/src/unix/linux_like/linux/uclibc/mod.rs b/src/unix/linux_like/linux/uclibc/mod.rs index 23f0581454713..4798b2a726bda 100644 --- a/src/unix/linux_like/linux/uclibc/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mod.rs @@ -1,7 +1,3 @@ -// FIXME(ulibc): this module has definitions that are redundant with the parent -#![allow(dead_code)] - -use crate::off64_t; use crate::prelude::*; pub type shmatt_t = c_ulong; @@ -66,15 +62,29 @@ s! { pub f_files: crate::fsfilcnt_t, pub f_ffree: crate::fsfilcnt_t, pub f_favail: crate::fsfilcnt_t, - #[cfg(target_endian = "little")] pub f_fsid: c_ulong, #[cfg(target_pointer_width = "32")] __f_unused: Padding, - #[cfg(target_endian = "big")] + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + __f_spare: Padding<[c_int; 6]>, + } + + pub struct statvfs64 { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: crate::fsblkcnt64_t, + pub f_bfree: crate::fsblkcnt64_t, + pub f_bavail: crate::fsblkcnt64_t, + pub f_files: crate::fsfilcnt64_t, + pub f_ffree: crate::fsfilcnt64_t, + pub f_favail: crate::fsfilcnt64_t, pub f_fsid: c_ulong, + #[cfg(target_pointer_width = "32")] + __f_unused: Padding, pub f_flag: c_ulong, pub f_namemax: c_ulong, - __f_spare: [c_int; 6], + __f_spare: Padding<[c_int; 6]>, } pub struct regex_t { @@ -411,8 +421,18 @@ extern "C" { flags: c_int, ) -> c_int; - pub fn pwritev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off64_t) -> ssize_t; - pub fn preadv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off64_t) -> ssize_t; + pub fn pwritev( + fd: c_int, + iov: *const crate::iovec, + iovcnt: c_int, + offset: crate::off64_t, + ) -> ssize_t; + pub fn preadv( + fd: c_int, + iov: *const crate::iovec, + iovcnt: c_int, + offset: crate::off64_t, + ) -> ssize_t; pub fn sethostid(hostid: c_long) -> c_int; pub fn fanotify_mark( diff --git a/src/unix/linux_like/linux/uclibc/x86_64/mod.rs b/src/unix/linux_like/linux/uclibc/x86_64/mod.rs index 8eb451184fd87..4b7d6e1610d8e 100644 --- a/src/unix/linux_like/linux/uclibc/x86_64/mod.rs +++ b/src/unix/linux_like/linux/uclibc/x86_64/mod.rs @@ -1,6 +1,5 @@ //! Definitions for uclibc on 64bit systems -use crate::off64_t; use crate::prelude::*; pub type blksize_t = i64; @@ -12,6 +11,8 @@ pub type stat64 = stat; pub type wchar_t = c_int; pub type pthread_t = c_ulong; +pub type stat64 = stat; + s! { pub struct ipc_perm { pub __key: crate::key_t, @@ -99,7 +100,7 @@ s! { } pub struct stat { - pub st_dev: c_ulong, + pub st_dev: crate::dev_t, pub st_ino: crate::ino_t, // According to uclibc/libc/sysdeps/linux/x86_64/bits/stat.h, order of // nlink and mode are swapped on 64 bit systems. @@ -107,8 +108,9 @@ s! { pub st_mode: crate::mode_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, - pub st_rdev: c_ulong, // dev_t - pub st_size: off_t, // file size + __pad0: Padding, + pub st_rdev: crate::dev_t, // dev_t + pub st_size: crate::off_t, // file size pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt_t, pub st_atime: crate::time_t, @@ -117,7 +119,7 @@ s! { pub st_mtime_nsec: c_ulong, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_ulong, - st_pad4: Padding<[c_long; 3]>, + __uclibc_unused: Padding<[c_long; 3]>, } // FIXME(1.0): This should not implement `PartialEq` @@ -137,49 +139,35 @@ s! { } pub struct statfs { - // FIXME(ulibc) - pub f_type: fsword_t, - pub f_bsize: fsword_t, + pub f_type: c_long, + pub f_bsize: c_long, pub f_blocks: crate::fsblkcnt_t, pub f_bfree: crate::fsblkcnt_t, pub f_bavail: crate::fsblkcnt_t, pub f_files: crate::fsfilcnt_t, pub f_ffree: crate::fsfilcnt_t, + pub f_fsid: crate::fsid_t, - pub f_namelen: fsword_t, - pub f_frsize: fsword_t, - f_spare: [fsword_t; 5], + pub f_namelen: c_long, + pub f_frsize: c_long, + pub f_flags: c_long, + f_spare: Padding<[c_long; 4]>, } pub struct statfs64 { - pub f_type: c_int, - pub f_bsize: c_int, + pub f_type: c_long, + pub f_bsize: c_long, pub f_blocks: crate::fsblkcnt64_t, pub f_bfree: crate::fsblkcnt64_t, pub f_bavail: crate::fsblkcnt64_t, pub f_files: crate::fsfilcnt64_t, pub f_ffree: crate::fsfilcnt64_t, - pub f_fsid: crate::fsid_t, - pub f_namelen: c_int, - pub f_frsize: c_int, - pub f_flags: c_int, - pub f_spare: [c_int; 4], - } - pub struct statvfs64 { - pub f_bsize: c_ulong, - pub f_frsize: c_ulong, - pub f_blocks: u64, - pub f_bfree: u64, - pub f_bavail: u64, - pub f_files: u64, - pub f_ffree: u64, - pub f_favail: u64, - pub f_fsid: c_ulong, - __f_unused: Padding, - pub f_flag: c_ulong, - pub f_namemax: c_ulong, - __f_spare: [c_int; 6], + pub f_fsid: crate::fsid_t, + pub f_namelen: c_long, + pub f_frsize: c_long, + pub f_flags: c_long, + f_spare: Padding<[c_long; 4]>, } pub struct msghdr { From 729cebcaadb9996e850970d5217a6863d1a1d4ef Mon Sep 17 00:00:00 2001 From: dybucc <149513579+dybucc@users.noreply.github.com> Date: Thu, 25 Jun 2026 11:24:50 +0200 Subject: [PATCH 3/3] linux(uclibc): fix cross-architecture `flock` def Replaces existing definitions. They were not correct under MIPS. This target needed some special casing. --- src/unix/linux_like/linux/uclibc/arm/mod.rs | 16 ++++++++-------- .../linux_like/linux/uclibc/mips/mips32/mod.rs | 10 ---------- src/unix/linux_like/linux/uclibc/mips/mod.rs | 12 ++++++++++++ src/unix/linux_like/linux/uclibc/mod.rs | 8 ++++++++ src/unix/linux_like/linux/uclibc/x86_64/mod.rs | 8 ++++++++ 5 files changed, 36 insertions(+), 18 deletions(-) diff --git a/src/unix/linux_like/linux/uclibc/arm/mod.rs b/src/unix/linux_like/linux/uclibc/arm/mod.rs index fa3b2f92f7769..2f1a682ebdb10 100644 --- a/src/unix/linux_like/linux/uclibc/arm/mod.rs +++ b/src/unix/linux_like/linux/uclibc/arm/mod.rs @@ -9,6 +9,14 @@ pub type nlink_t = c_uint; pub type blksize_t = c_long; s! { + pub struct flock { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: crate::off_t, + pub l_len: crate::off_t, + pub l_pid: crate::pid_t, + } + pub struct cmsghdr { pub cmsg_len: size_t, pub cmsg_level: c_int, @@ -95,14 +103,6 @@ s! { pub st_ino: crate::ino64_t, } - pub struct flock { - pub l_type: c_short, - pub l_whence: c_short, - pub l_start: off_t, - pub l_len: off_t, - pub l_pid: crate::pid_t, - } - pub struct sysinfo { pub uptime: c_long, pub loads: [c_ulong; 3], diff --git a/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs b/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs index 6fd23df2d9530..fd7d6402cfab2 100644 --- a/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs @@ -183,16 +183,6 @@ s! { pub c_cc: [crate::cc_t; crate::NCCS], } - pub struct flock { - pub l_type: c_short, - pub l_whence: c_short, - pub l_start: crate::off_t, - pub l_len: crate::off_t, - pub l_sysid: c_long, - pub l_pid: crate::pid_t, - pad: Padding<[c_long; 4]>, - } - pub struct sysinfo { pub uptime: c_long, pub loads: [c_ulong; 3], diff --git a/src/unix/linux_like/linux/uclibc/mips/mod.rs b/src/unix/linux_like/linux/uclibc/mips/mod.rs index c7c37b7318ea2..a5e209ea4ca8b 100644 --- a/src/unix/linux_like/linux/uclibc/mips/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mips/mod.rs @@ -34,6 +34,18 @@ s! { pub f_flags: c_long, f_spare: Padding<[c_long; 5]>, } + + pub struct flock { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: crate::off_t, + pub l_len: crate::off_t, + #[cfg(not(all(uclibc_file_offset_bits64, target_arch = "mips64")))] + pub l_sysid: c_long, + pub l_pid: crate::pid_t, + #[cfg(not(all(uclibc_file_offset_bits64, target_arch = "mips64")))] + pad: [c_long; 4], + } } pub const SFD_CLOEXEC: c_int = 0x080000; diff --git a/src/unix/linux_like/linux/uclibc/mod.rs b/src/unix/linux_like/linux/uclibc/mod.rs index 4798b2a726bda..3c64363ff91ef 100644 --- a/src/unix/linux_like/linux/uclibc/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mod.rs @@ -52,6 +52,14 @@ cfg_if! { } s! { + pub struct flock64 { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: crate::off64_t, + pub l_len: crate::off64_t, + pub l_pid: crate::pid_t, + } + pub struct statvfs { // Different than GNU! pub f_bsize: c_ulong, diff --git a/src/unix/linux_like/linux/uclibc/x86_64/mod.rs b/src/unix/linux_like/linux/uclibc/x86_64/mod.rs index 4b7d6e1610d8e..10492890698da 100644 --- a/src/unix/linux_like/linux/uclibc/x86_64/mod.rs +++ b/src/unix/linux_like/linux/uclibc/x86_64/mod.rs @@ -14,6 +14,14 @@ pub type pthread_t = c_ulong; pub type stat64 = stat; s! { + pub struct flock { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: crate::off_t, + pub l_len: crate::off_t, + pub l_pid: crate::pid_t, + } + pub struct ipc_perm { pub __key: crate::key_t, pub uid: crate::uid_t,