From c120d9a33396dde09d887d7b4108893403d43347 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] linux(uclibc): change file offset bindings The currently exposed bindings to file offset types and routines are often found to be either lacking or incorrect in the current worktree. This has been fixed by means of changing multiple type definitions across child modules of the `linux/uclibc` module, such that a more cohesive interface is exposed. Types with LFS64 variants in 32-bit platforms will now have equivalent definitions to their "unsuffixed" variants if the `uclibc_file_offset_bits` `cfg` is set. In 64-bit machine word targets, both the unsuffixed and suffixed types are unconditionally exposed with the same bit width. --- build.rs | 14 ++- src/unix/linux_like/linux/uclibc/arm/mod.rs | 98 +++++++++---------- .../linux/uclibc/mips/mips32/mod.rs | 98 +++++-------------- .../linux/uclibc/mips/mips64/mod.rs | 75 +++----------- src/unix/linux_like/linux/uclibc/mips/mod.rs | 46 +++++++++ src/unix/linux_like/linux/uclibc/mod.rs | 70 +++++++++++-- .../linux_like/linux/uclibc/x86_64/mod.rs | 95 ++++++------------ 7 files changed, 231 insertions(+), 265 deletions(-) diff --git a/build.rs b/build.rs index ee07f965228cf..aa3eff3ebe31c 100644 --- a/build.rs +++ b/build.rs @@ -35,6 +35,8 @@ const ALLOWED_CFGS: &[&str] = &[ // Corresponds to `_REDIR_TIME64` in musl: symbol redirects to __*_time64 "musl_redir_time64", "vxworks_lt_25_09", + // Corresponds with `__USE_FILE_OFFSET64` in uClibc. + "uclibc_file_offset_bits64", ]; // Extra values to allow for check-cfg. @@ -131,11 +133,6 @@ fn main() { } } - let uclibc_use_time64 = env_flag("CARGO_CFG_LIBC_UNSTABLE_UCLIBC_TIME64"); - if target_env == "uclibc" && uclibc_use_time64 { - set_cfg("linux_time_bits64"); - } - let linux_time_bits64 = env::var("RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64").is_ok(); println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64"); if linux_time_bits64 { @@ -180,6 +177,13 @@ fn main() { } } + if target_env == "uclibc" + && target_ptr_width == "32" + && env::var("CARGO_CFG_LIBC_UNSTABLE_UCLIBC_FILE_OFFSET_BITS").is_ok() + { + set_cfg("uclibc_file_offset_bits64"); + } + // On CI: deny all warnings if libc_ci { set_cfg("libc_deny_warnings"); diff --git a/src/unix/linux_like/linux/uclibc/arm/mod.rs b/src/unix/linux_like/linux/uclibc/arm/mod.rs index 1c09954cc834d..097a2c2cc16ef 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; @@ -15,22 +14,23 @@ cfg_if! { } 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; pub type __u64 = c_ulonglong; pub type __s64 = c_longlong; 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, @@ -52,58 +52,71 @@ 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, } - 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], @@ -134,7 +147,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 { @@ -145,27 +158,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 93ed7ab213335..868706d5cb841 100644 --- a/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs @@ -1,21 +1,13 @@ -use crate::off64_t; use crate::prelude::*; pub type clock_t = i32; pub type time_t = i32; pub type suseconds_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 __u64 = c_ulonglong; pub type __s64 = c_longlong; -pub type fsblkcnt64_t = u64; -pub type fsfilcnt64_t = u64; s! { pub struct stat { @@ -27,16 +19,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], - pub st_size: off_t, + + #[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]>, } @@ -51,33 +56,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 { @@ -173,36 +162,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, @@ -228,16 +187,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: off_t, - pub l_len: 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], @@ -665,7 +614,6 @@ pub const SYS_process_mrelease: c_long = 4000 + 448; pub const SYS_futex_waitv: c_long = 4000 + 449; pub const SYS_set_mempolicy_home_node: c_long = 4000 + 450; -#[link(name = "util")] extern "C" { pub fn sysctl( name: *mut c_int, 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 4495181400d48..d15cb1bb68782 100644 --- a/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs @@ -1,63 +1,35 @@ -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 suseconds_t = i64; pub type time_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 { @@ -129,21 +101,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..a5e209ea4ca8b 100644 --- a/src/unix/linux_like/linux/uclibc/mips/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mips/mod.rs @@ -2,6 +2,52 @@ 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 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; 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 ead968a1c65c5..8cc40bb5f5b70 100644 --- a/src/unix/linux_like/linux/uclibc/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mod.rs @@ -1,17 +1,35 @@ -// 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; 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; +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. @@ -23,6 +41,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, @@ -33,15 +59,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 { @@ -378,8 +418,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 510b90b599108..07783311fdb46 100644 --- a/src/unix/linux_like/linux/uclibc/x86_64/mod.rs +++ b/src/unix/linux_like/linux/uclibc/x86_64/mod.rs @@ -1,30 +1,29 @@ //! Definitions for uclibc on 64bit systems -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. -pub type stat64 = stat; pub type suseconds_t = c_long; pub type time_t = c_int; pub type wchar_t = c_int; pub type pthread_t = c_ulong; -pub type fsblkcnt64_t = u64; -pub type fsfilcnt64_t = u64; pub type __u64 = c_ulong; pub type __s64 = c_long; +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, @@ -111,7 +110,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. @@ -119,8 +118,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, @@ -129,7 +129,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` @@ -149,49 +149,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 { @@ -238,19 +224,6 @@ s! { pub _f: [c_char; 0], } - pub struct glob_t { - // FIXME(ulibc) - pub gl_pathc: size_t, - pub gl_pathv: *mut *mut c_char, - pub gl_offs: size_t, - pub gl_flags: c_int, - __unused1: Padding<*mut c_void>, - __unused2: Padding<*mut c_void>, - __unused3: Padding<*mut c_void>, - __unused4: Padding<*mut c_void>, - __unused5: Padding<*mut c_void>, - } - pub struct cpu_set_t { // FIXME(ulibc) #[cfg(target_pointer_width = "32")] @@ -280,16 +253,6 @@ s! { } } -s_no_extra_traits! { - pub struct dirent { - pub d_ino: crate::ino64_t, - pub d_off: off64_t, - pub d_reclen: u16, - pub d_type: u8, - pub d_name: [c_char; 256], - } -} - // constants pub const ENAMETOOLONG: c_int = 36; // File name too long pub const ENOTEMPTY: c_int = 39; // Directory not empty