From 1ae3ff23df2c1f59e6f1ee094ca9ed5d82fc9455 Mon Sep 17 00:00:00 2001 From: Pedro Tammela Date: Thu, 12 Sep 2024 15:13:07 -0300 Subject: [PATCH 01/16] ci: update musl headers to Linux 6.6 Update the musl headers in CI to use alpine-linux instead of sabotage-linux. Alpine also uses musl but follows the linux stable releases, providing more up-to-date headers. Signed-off-by: Pedro Tammela (backport ) (cherry picked from commit acc75e75f119483a56fb46e06951004e8cfa5594) Signed-off-by: Trevor Gross --- .../aarch64-unknown-linux-musl/Dockerfile | 2 +- .../arm-unknown-linux-musleabihf/Dockerfile | 2 +- ci/docker/i686-unknown-linux-musl/Dockerfile | 4 +- ci/docker/s390x-unknown-linux-musl/Dockerfile | 3 +- .../x86_64-unknown-linux-musl/Dockerfile | 3 +- ci/install-musl.sh | 66 ++++++++++++++++--- 6 files changed, 66 insertions(+), 14 deletions(-) diff --git a/ci/docker/aarch64-unknown-linux-musl/Dockerfile b/ci/docker/aarch64-unknown-linux-musl/Dockerfile index 65932bd48cfac..053ed837b2e7c 100644 --- a/ci/docker/aarch64-unknown-linux-musl/Dockerfile +++ b/ci/docker/aarch64-unknown-linux-musl/Dockerfile @@ -2,7 +2,7 @@ FROM ubuntu:24.10 RUN apt-get update && apt-get install -y --no-install-recommends \ gcc make libc6-dev git curl ca-certificates \ - gcc-aarch64-linux-gnu qemu-user + gcc-aarch64-linux-gnu qemu-user xz-utils patch rsync COPY install-musl.sh / RUN /install-musl.sh aarch64 diff --git a/ci/docker/arm-unknown-linux-musleabihf/Dockerfile b/ci/docker/arm-unknown-linux-musleabihf/Dockerfile index 7ed23611c351e..c6bd116b6f1cb 100644 --- a/ci/docker/arm-unknown-linux-musleabihf/Dockerfile +++ b/ci/docker/arm-unknown-linux-musleabihf/Dockerfile @@ -5,7 +5,7 @@ RUN sed -i -E 's/(archive|security)\.ubuntu\.com/old-releases.ubuntu.com/g' \ /etc/apt/sources.list && \ apt-get update && apt-get install -y --no-install-recommends \ gcc make libc6-dev git curl ca-certificates \ - gcc-arm-linux-gnueabihf qemu-user + gcc-arm-linux-gnueabihf qemu-user xz-utils patch rsync COPY install-musl.sh / RUN /install-musl.sh arm diff --git a/ci/docker/i686-unknown-linux-musl/Dockerfile b/ci/docker/i686-unknown-linux-musl/Dockerfile index ea5e2e963910b..287f325e9151f 100644 --- a/ci/docker/i686-unknown-linux-musl/Dockerfile +++ b/ci/docker/i686-unknown-linux-musl/Dockerfile @@ -1,12 +1,12 @@ FROM ubuntu:23.10 - # FIXME(time): we are using an EOL release because 24.04 changes to 64-bit time RUN sed -i -E 's/(archive|security)\.ubuntu\.com/old-releases.ubuntu.com/g' \ /etc/apt/sources.list && \ dpkg --add-architecture i386 && \ apt-get update && apt-get install -y --no-install-recommends \ - gcc-multilib make libc6-dev git curl ca-certificates libc6-i386 + gcc-multilib make libc6-dev git curl ca-certificates libc6-i386 \ + xz-utils patch rsync COPY install-musl.sh / RUN /install-musl.sh i686 diff --git a/ci/docker/s390x-unknown-linux-musl/Dockerfile b/ci/docker/s390x-unknown-linux-musl/Dockerfile index 4e202d1905902..2d4ea759c5fbf 100644 --- a/ci/docker/s390x-unknown-linux-musl/Dockerfile +++ b/ci/docker/s390x-unknown-linux-musl/Dockerfile @@ -4,7 +4,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ curl ca-certificates \ gcc \ gcc-s390x-linux-gnu \ - qemu-user + qemu-user \ + xz-utils patch rsync COPY install-musl.sh / RUN /install-musl.sh s390x diff --git a/ci/docker/x86_64-unknown-linux-musl/Dockerfile b/ci/docker/x86_64-unknown-linux-musl/Dockerfile index d03df5b4f54ce..5c1b4b177880c 100644 --- a/ci/docker/x86_64-unknown-linux-musl/Dockerfile +++ b/ci/docker/x86_64-unknown-linux-musl/Dockerfile @@ -2,7 +2,8 @@ FROM ubuntu:24.10 RUN apt-get update RUN apt-get install -y --no-install-recommends \ - gcc make libc6-dev git curl ca-certificates + gcc make libc6-dev git curl ca-certificates \ + xz-utils patch rsync COPY install-musl.sh / RUN /install-musl.sh x86_64 diff --git a/ci/install-musl.sh b/ci/install-musl.sh index 5f8c681fa6678..1cf1ec6500cde 100755 --- a/ci/install-musl.sh +++ b/ci/install-musl.sh @@ -64,13 +64,63 @@ esac cd .. rm -rf "$musl" -# Download, configure, build, and install musl-sanitized kernel headers: -kernel_header_ver="4.19.88" -curl --retry 5 -L \ - "https://github.com/sabotage-linux/kernel-headers/archive/v${kernel_header_ver}.tar.gz" | - tar xzf - +# Download, configure, build, and install musl-sanitized kernel headers. + +# Alpine follows stable kernel releases, 3.20 uses Linux 6.6 headers. +alpine_version=3.20 +alpine_git=https://gitlab.alpinelinux.org/alpine/aports + +# This routine piggybacks on: https://git.alpinelinux.org/aports/tree/main/linux-headers?h=3.20-stable +git clone -n --depth=1 --filter=tree:0 -b "${alpine_version}-stable" "$alpine_git" ( - cd "kernel-headers-${kernel_header_ver}" - make ARCH="${kernel_arch}" prefix="/musl-${musl_arch}" install -j4 + cd aports + git sparse-checkout set --no-cone main/linux-headers + git checkout + + cd main/linux-headers + cp APKBUILD APKBUILD.vars + cat <<- EOF >> APKBUILD.vars + echo "\$source" > alpine-source + echo "\$_kernver" > alpine-kernver + echo "\$pkgver" > alpine-pkgver + echo "\$sha512sums" > alpine-sha512sums +EOF + + # Retrieve all the variables + sh APKBUILD.vars + + cat APKBUILD.vars + + kernel_version=$(tr -d "[:space:]" < alpine-kernver) + pkg_version=$(tr -d "[:space:]" < alpine-pkgver) + + urls=$(grep -o 'https.*' alpine-source) + kernel="" + patch="" + for url in $urls; do + base=$(basename "$url") + curl --retry 5 -L "$url" > "$base" + case $base in + linux-*) kernel=$base;; + patch-*) patch=$base;; + esac + # Check if file is known + grep -o "$base" alpine-sha512sums + done + + # Double check checksums + sha512sum -c alpine-sha512sums + + # Extract, apply patches, compile and install headers + tar -xf "$kernel" + cd "linux-$kernel_version" + if [ "$pkg_version" != "$kernel_version" ]; then + unxz -c < "../$patch" | patch -p1 + fi + for p in ../*.patch; do + patch -p1 < "$p" + done + make headers_install ARCH="${kernel_arch}" INSTALL_HDR_PATH="/musl-${musl_arch}" ) -rm -rf kernel-headers-${kernel_header_ver} + +rm -rf aports From 46316a7871bbb69ef913cd2d7fe3660264e9bf6d Mon Sep 17 00:00:00 2001 From: Pedro Tammela Date: Fri, 13 Sep 2024 12:01:21 -0300 Subject: [PATCH 02/16] ci: clean up musl exceptions Now that we have Linux 6.6 we can clean up some of the test exceptions. Not all of them can be removed, so the comments are updated if needed. Signed-off-by: Pedro Tammela (backport ) (cherry picked from commit 55f945132b70208bdeb1fea2e552cb987929fe5b) Signed-off-by: Trevor Gross --- libc-test/build.rs | 164 ++++----------------------------------------- 1 file changed, 12 insertions(+), 152 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 37696ea670304..50bc16813086a 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -3576,8 +3576,7 @@ fn test_linux(target: &str) { [gnu]: "linux/aio_abi.h", "linux/can.h", "linux/can/raw.h", - // FIXME: requires kernel headers >= 5.4.1. - [!musl]: "linux/can/j1939.h", + "linux/can/j1939.h", "linux/dccp.h", "linux/errqueue.h", "linux/falloc.h", @@ -3602,8 +3601,7 @@ fn test_linux(target: &str) { "linux/mempolicy.h", "linux/mman.h", "linux/module.h", - // FIXME: requires kernel headers >= 5.1. - [!musl]: "linux/mount.h", + "linux/mount.h", "linux/net_tstamp.h", "linux/netfilter/nfnetlink.h", "linux/netfilter/nfnetlink_log.h", @@ -3615,11 +3613,10 @@ fn test_linux(target: &str) { "linux/netfilter_ipv6.h", "linux/netfilter_ipv6/ip6_tables.h", "linux/netlink.h", - // FIXME: requires Linux >= 5.6: - [!musl]: "linux/openat2.h", + "linux/openat2.h", // FIXME: some items require Linux >= 5.6: "linux/ptp_clock.h", - [!musl]: "linux/ptrace.h", + "linux/ptrace.h", "linux/quota.h", "linux/random.h", "linux/reboot.h", @@ -3637,7 +3634,7 @@ fn test_linux(target: &str) { "sys/fanotify.h", // is not present on uclibc [!uclibc]: "sys/auxv.h", - [gnu]: "linux/close_range.h", + [gnu || musl]: "linux/close_range.h", } // note: aio.h must be included before sys/mount.h @@ -3728,11 +3725,6 @@ fn test_linux(target: &str) { // specific type. "Ioctl" => true, - // FIXME: requires >= 5.4.1 kernel headers - "pgn_t" if musl => true, - "priority_t" if musl => true, - "name_t" if musl => true, - // FIXME: "'__uint128' undeclared" in C "__uint128" => true, @@ -3751,22 +3743,6 @@ fn test_linux(target: &str) { if ty.starts_with("__c_anonymous_") { return true; } - // FIXME: musl CI has old headers - if musl && ty.starts_with("uinput_") { - return true; - } - if musl && ty == "seccomp_notif" { - return true; - } - if musl && ty == "seccomp_notif_addfd" { - return true; - } - if musl && ty == "seccomp_notif_resp" { - return true; - } - if musl && ty == "seccomp_notif_sizes" { - return true; - } // FIXME: CI has old headers if ty == "ptp_sys_offset_extended" { @@ -3850,12 +3826,6 @@ fn test_linux(target: &str) { // Might differ between kernel versions "open_how" => true, - // FIXME: requires >= 5.4.1 kernel headers - "j1939_filter" if musl => true, - - // FIXME: requires >= 5.4 kernel headers - "sockaddr_can" if musl => true, - "sctp_initmsg" | "sctp_sndrcvinfo" | "sctp_sndinfo" | "sctp_rcvinfo" | "sctp_nxtinfo" | "sctp_prinfo" | "sctp_authinfo" => true, @@ -4020,7 +3990,7 @@ fn test_linux(target: &str) { return true; } // FIXME: Requires >= 6.3 kernel headers - if name == "MFD_NOEXEC_SEAL" || name == "MFD_EXEC" { + if loongarch64 && (name == "MFD_NOEXEC_SEAL" || name == "MFD_EXEC") { return true; } } @@ -4110,7 +4080,7 @@ fn test_linux(target: &str) { if sparc64 => true, // FIXME: Not currently available in headers on ARM and musl. - "NETLINK_GET_STRICT_CHK" if arm || musl => true, + "NETLINK_GET_STRICT_CHK" if arm => true, // kernel constants not available in uclibc 1.0.34 | "EXTPROC" @@ -4179,62 +4149,14 @@ fn test_linux(target: &str) { | "MINSIGSTKSZ" if gnu => true, - // FIXME: Linux >= 5.10: - // https://github.com/torvalds/linux/commit/d25e2e9388eda61b6e298585024ee3355f50c493 - "NF_INET_INGRESS" if musl => true, - // FIXME: Linux >= 5.16: // https://github.com/torvalds/linux/commit/42df6e1d221dddc0f2acf2be37e68d553ad65f96 - "NF_NETDEV_EGRESS" if musl || sparc64 => true, + "NF_NETDEV_EGRESS" if sparc64 => true, // value changed - "NF_NETDEV_NUMHOOKS" if musl || sparc64 => true, - - // FIXME: requires Linux >= 5.6: - | "RESOLVE_BENEATH" - | "RESOLVE_CACHED" - | "RESOLVE_IN_ROOT" - | "RESOLVE_NO_MAGICLINKS" - | "RESOLVE_NO_SYMLINKS" - | "RESOLVE_NO_XDEV" if musl => true, - - // FIXME: requires Linux >= 5.4: - | "CAN_J1939" - | "CAN_NPROTO" if musl => true, - - // FIXME: requires Linux >= 5.6 - "GRND_INSECURE" if musl => true, - - // FIXME: requires Linux >= 5.7: - "MREMAP_DONTUNMAP" if musl => true, + "NF_NETDEV_NUMHOOKS" if sparc64 => true, // FIXME: requires Linux >= v5.8 - "IF_LINK_MODE_TESTING" if musl || sparc64 => true, - - // FIXME: Requires more recent kernel headers (5.9 / 5.11): - | "CLOSE_RANGE_UNSHARE" - | "CLOSE_RANGE_CLOEXEC" if musl => true, - - // FIXME: requires Linux >= 5.12: - "MPOL_F_NUMA_BALANCING" if musl => true, - - // FIXME: Requires more recent kernel headers - | "NFNL_SUBSYS_COUNT" // bumped in v5.14 - | "NFNL_SUBSYS_HOOK" // v5.14+ - | "NFULA_VLAN" // v5.4+ - | "NFULA_L2HDR" // v5.4+ - | "NFULA_VLAN_PROTO" // v5.4+ - | "NFULA_VLAN_TCI" // v5.4+ - | "NFULA_VLAN_UNSPEC" // v5.4+ - | "RTNLGRP_NEXTHOP" // linux v5.3+ - | "RTNLGRP_BRVLAN" // linux v5.6+ - if musl => true, - - | "MADV_COLD" - | "MADV_PAGEOUT" - | "MADV_POPULATE_READ" - | "MADV_POPULATE_WRITE" - if musl => true, - "CLONE_CLEAR_SIGHAND" | "CLONE_INTO_CGROUP" => true, + "IF_LINK_MODE_TESTING" if sparc64 => true, // kernel 6.1 minimum "MADV_COLLAPSE" => true, @@ -4253,9 +4175,6 @@ fn test_linux(target: &str) { => true, "SCTP_FUTURE_ASSOC" | "SCTP_CURRENT_ASSOC" | "SCTP_ALL_ASSOC" | "SCTP_PEER_ADDR_THLDS_V2" => true, // linux 5.5+ - // FIXME: Requires more recent kernel headers - "HWTSTAMP_TX_ONESTEP_P2P" if musl => true, // linux v5.6+ - // kernel 6.5 minimum "MOVE_MOUNT_BENEATH" => true, // FIXME: Requires linux 6.1 @@ -4277,10 +4196,8 @@ fn test_linux(target: &str) { | "FAN_INFO" // linux v5.16+ => true, - // FIXME: Requires linux 5.15+ - "FAN_REPORT_PIDFD" if musl => true, - - // FIXME: Requires linux 5.9+ + // musl doesn't use in + "FAN_REPORT_PIDFD" | "FAN_REPORT_DIR_FID" | "FAN_REPORT_NAME" | "FAN_REPORT_DFID_NAME" @@ -4294,55 +4211,6 @@ fn test_linux(target: &str) { // FIXME: Requires linux 6.5 "NFT_MSG_MAX" => true, - // FIXME: Requires >= 5.1 kernel headers. - // Everything that uses install-musl.sh has 4.19 kernel headers. - "TLS_1_3_VERSION" - | "TLS_1_3_VERSION_MAJOR" - | "TLS_1_3_VERSION_MINOR" - | "TLS_CIPHER_AES_GCM_256" - | "TLS_CIPHER_AES_GCM_256_IV_SIZE" - | "TLS_CIPHER_AES_GCM_256_KEY_SIZE" - | "TLS_CIPHER_AES_GCM_256_SALT_SIZE" - | "TLS_CIPHER_AES_GCM_256_TAG_SIZE" - | "TLS_CIPHER_AES_GCM_256_REC_SEQ_SIZE" - if (aarch64 || arm || i686 || s390x || x86_64) && musl => - { - true - } - - // FIXME: Requires >= 5.11 kernel headers. - // Everything that uses install-musl.sh has 4.19 kernel headers. - "TLS_CIPHER_CHACHA20_POLY1305" - | "TLS_CIPHER_CHACHA20_POLY1305_IV_SIZE" - | "TLS_CIPHER_CHACHA20_POLY1305_KEY_SIZE" - | "TLS_CIPHER_CHACHA20_POLY1305_SALT_SIZE" - | "TLS_CIPHER_CHACHA20_POLY1305_TAG_SIZE" - | "TLS_CIPHER_CHACHA20_POLY1305_REC_SEQ_SIZE" - if (aarch64 || arm || i686 || s390x || x86_64) && musl => - { - true - } - - // FIXME: Requires >= 5.3 kernel headers. - // Everything that uses install-musl.sh has 4.19 kernel headers. - "XDP_OPTIONS_ZEROCOPY" | "XDP_OPTIONS" - if musl => - { - true - } - - // FIXME: Requires >= 5.4 kernel headers. - // Everything that uses install-musl.sh has 4.19 kernel headers. - "XSK_UNALIGNED_BUF_OFFSET_SHIFT" - | "XSK_UNALIGNED_BUF_ADDR_MASK" - | "XDP_UMEM_UNALIGNED_CHUNK_FLAG" - | "XDP_RING_NEED_WAKEUP" - | "XDP_USE_NEED_WAKEUP" - if musl => - { - true - } - // FIXME: Requires >= 6.6 kernel headers. "XDP_USE_SG" | "XDP_PKT_CONTD" @@ -4401,14 +4269,6 @@ fn test_linux(target: &str) { | "PF_MCE_EARLY" | "PF_MEMALLOC_PIN" => true, - "SCHED_FLAG_KEEP_POLICY" - | "SCHED_FLAG_KEEP_PARAMS" - | "SCHED_FLAG_UTIL_CLAMP_MIN" - | "SCHED_FLAG_UTIL_CLAMP_MAX" - | "SCHED_FLAG_KEEP_ALL" - | "SCHED_FLAG_UTIL_CLAMP" - | "SCHED_FLAG_ALL" if musl => true, // Needs more recent linux headers. - // FIXME: Requires >= 6.9 kernel headers. "EPIOCSPARAMS" | "EPIOCGPARAMS" => true, From 8ffe0fa7ee12880c2404fcc1c31a1c210960a737 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 25 Nov 2024 05:04:49 -0500 Subject: [PATCH 03/16] ci: Add back `CLONE_CLEAR_SIGHAND` and `CLONE_INTO_CGROUP` skips This bug was fixed in e9abac9ac2 ("Set CLONE_CLEAR_SIGHAND and CLONE_INTO_CGROUP to a large enough type") and these checks were removed in acc75e75f1 ("ci: update musl headers to 6.6"). However, we cannot backport the fix, so add back the override here. --- libc-test/build.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index 50bc16813086a..910021c140425 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -4158,6 +4158,9 @@ fn test_linux(target: &str) { // FIXME: requires Linux >= v5.8 "IF_LINK_MODE_TESTING" if sparc64 => true, + // DIFF(main): fixed in 1.0 with e9abac9ac2 + "CLONE_CLEAR_SIGHAND" | "CLONE_INTO_CGROUP" => true, + // kernel 6.1 minimum "MADV_COLLAPSE" => true, From d330ee2fd10c8110b65806bed8a010f093688651 Mon Sep 17 00:00:00 2001 From: Folkert de Vries Date: Wed, 20 Nov 2024 21:23:26 +0100 Subject: [PATCH 04/16] add `ptp_clock_caps` (backport ) (cherry picked from commit 38318cdddf26419d60ce35eee46ec855a187e8ff) --- libc-test/build.rs | 13 +++++++++++-- libc-test/semver/linux.txt | 2 ++ src/unix/linux_like/linux/mod.rs | 19 +++++++++++++++---- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 910021c140425..8a353e5d4a5fb 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -3956,7 +3956,8 @@ fn test_linux(target: &str) { return true; } // FIXME: Requires >= 5.4 kernel headers - if name == "PTP_ENABLE_PPS2" + if name == "PTP_CLOCK_GETCAPS2" + || name == "PTP_ENABLE_PPS2" || name == "PTP_EXTTS_REQUEST2" || name == "PTP_PEROUT_REQUEST2" || name == "PTP_PIN_GETFUNC2" @@ -4410,7 +4411,11 @@ fn test_linux(target: &str) { // `anonymous_1` is an anonymous union (struct_ == "ptp_perout_request" && field == "anonymous_1") || // `anonymous_2` is an anonymous union - (struct_ == "ptp_perout_request" && field == "anonymous_2") + (struct_ == "ptp_perout_request" && field == "anonymous_2") || + // FIXME(linux): `adjust_phase` requires >= 5.7 kernel headers + // FIXME(linux): `max_phase_adj` requires >= 5.19 kernel headers + // the rsv field shrunk when those fields got added, so is omitted too + (struct_ == "ptp_clock_caps" && (loongarch64 || sparc64) && (["adjust_phase", "max_phase_adj", "rsv"].contains(&field))) }); cfg.volatile_item(|i| { @@ -4485,6 +4490,10 @@ fn test_linux(target: &str) { (struct_ == "ptp_perout_request" && field == "anonymous_1") || // `anonymous_2` is an anonymous union (struct_ == "ptp_perout_request" && field == "anonymous_2") || + // FIXME(linux): `adjust_phase` requires >= 5.7 kernel headers + // FIXME(linux): `max_phase_adj` requires >= 5.19 kernel headers + // the rsv field shrunk when those fields got added, so is omitted too + (struct_ == "ptp_clock_caps" && (loongarch64 || sparc64) && (["adjust_phase", "max_phase_adj", "rsv"].contains(&field))) || // invalid application of 'sizeof' to incomplete type 'long unsigned int[]' (musl && struct_ == "mcontext_t" && field == "__extcontext" && loongarch64) || // FIXME(#4121): a new field was added from `f_spare` diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index b9b20c596280f..46022ff35f304 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -2252,6 +2252,7 @@ PTHREAD_PRIO_PROTECT PTHREAD_PROCESS_PRIVATE PTHREAD_PROCESS_SHARED PTHREAD_STACK_MIN +PTP_CLOCK_GETCAPS2 PTP_ENABLE_PPS PTP_ENABLE_PPS2 PTP_EXTTS_REQUEST @@ -3946,6 +3947,7 @@ pthread_spin_lock pthread_spin_trylock pthread_spin_unlock pthread_spinlock_t +ptp_clock_caps ptp_clock_time ptp_extts_event ptp_extts_request diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index fe1f32a907a10..4e8517bc8238c 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -1195,6 +1195,19 @@ s! { pub rsv: [::c_uint; 5], } + pub struct ptp_clock_caps { + pub max_adj: ::c_int, + pub n_alarm: ::c_int, + pub n_ext_ts: ::c_int, + pub n_per_out: ::c_int, + pub pps: ::c_int, + pub n_pins: ::c_int, + pub cross_timestamping: ::c_int, + pub adjust_phase: ::c_int, + pub max_phase_adj: ::c_int, + pub rsv: [::c_int; 11], + } + // linux/if_xdp.h pub struct xsk_tx_metadata_completion { pub tx_timestamp: ::__u64, @@ -4606,8 +4619,7 @@ pub const PTP_MAX_SAMPLES: ::c_uint = 25; // Maximum allowed offset measurement const PTP_CLK_MAGIC: u32 = b'=' as u32; -// FIXME: needs the ptp_clock_caps struct -// pub const PTP_CLOCK_GETCAPS: ::c_uint = _IOR::(PTP_CLK_MAGIC, 1); +pub const PTP_CLOCK_GETCAPS: ::c_uint = _IOR::(PTP_CLK_MAGIC, 1); pub const PTP_EXTTS_REQUEST: ::c_uint = _IOW::(PTP_CLK_MAGIC, 2); pub const PTP_PEROUT_REQUEST: ::c_uint = _IOW::(PTP_CLK_MAGIC, 3); pub const PTP_ENABLE_PPS: ::c_uint = _IOW::<::c_int>(PTP_CLK_MAGIC, 4); @@ -4617,8 +4629,7 @@ pub const PTP_PIN_SETFUNC: ::c_uint = _IOW::(PTP_CLK_MAGIC, 7); pub const PTP_SYS_OFFSET_PRECISE: ::c_uint = _IOWR::(PTP_CLK_MAGIC, 8); pub const PTP_SYS_OFFSET_EXTENDED: ::c_uint = _IOWR::(PTP_CLK_MAGIC, 9); -// FIXME: needs the ptp_clock_caps struct -// pub const PTP_CLOCK_GETCAPS2: ::c_uint = _IOR::(PTP_CLK_MAGIC, 10); +pub const PTP_CLOCK_GETCAPS2: ::c_uint = _IOR::(PTP_CLK_MAGIC, 10); pub const PTP_EXTTS_REQUEST2: ::c_uint = _IOW::(PTP_CLK_MAGIC, 11); pub const PTP_PEROUT_REQUEST2: ::c_uint = _IOW::(PTP_CLK_MAGIC, 12); pub const PTP_ENABLE_PPS2: ::c_uint = _IOW::<::c_int>(PTP_CLK_MAGIC, 13); From 2c490f1eaacfecf26451ad3a0d0307d9152c7b3e Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Fri, 15 Nov 2024 21:42:40 +0000 Subject: [PATCH 05/16] Add struct and constants for mount_setattr syscall (backport ) (cherry picked from commit d691ee7ce1d40007d182c243e08a02fdf6611caf) --- libc-test/semver/linux.txt | 13 +++++++++++++ src/unix/linux_like/linux/mod.rs | 24 ++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index 46022ff35f304..af9e03cfdf912 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -1661,6 +1661,18 @@ MON_6 MON_7 MON_8 MON_9 +MOUNT_ATTR_IDMAP +MOUNT_ATTR_NOATIME +MOUNT_ATTR_NODEV +MOUNT_ATTR_NODIRATIME +MOUNT_ATTR_NOEXEC +MOUNT_ATTR_NOSUID +MOUNT_ATTR_NOSYMFOLLOW +MOUNT_ATTR_RDONLY +MOUNT_ATTR_RELATIME +MOUNT_ATTR_SIZE_VER0 +MOUNT_ATTR_STRICTATIME +MOUNT_ATTR__ATIME MREMAP_FIXED MREMAP_MAYMOVE MSC_CNT @@ -3819,6 +3831,7 @@ mmap64 mmsghdr mntent mount +mount_attr mq_attr mq_close mq_getattr diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 4e8517bc8238c..02a66960f56f6 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -1217,6 +1217,15 @@ s! { pub csum_start: ::__u16, pub csum_offset: ::__u16, } + + // linux/mount.h + + pub struct mount_attr { + pub attr_set: ::__u64, + pub attr_clr: ::__u64, + pub propagation: ::__u64, + pub userns_fd: ::__u64, + } } cfg_if! { @@ -5675,6 +5684,21 @@ pub const XDP_TXMD_FLAGS_CHECKSUM: ::__u32 = 1 << 1; pub const XDP_TX_METADATA: ::__u32 = 1 << 1; +// linux/mount.h +pub const MOUNT_ATTR_RDONLY: ::__u64 = 0x00000001; +pub const MOUNT_ATTR_NOSUID: ::__u64 = 0x00000002; +pub const MOUNT_ATTR_NODEV: ::__u64 = 0x00000004; +pub const MOUNT_ATTR_NOEXEC: ::__u64 = 0x00000008; +pub const MOUNT_ATTR__ATIME: ::__u64 = 0x00000070; +pub const MOUNT_ATTR_RELATIME: ::__u64 = 0x00000000; +pub const MOUNT_ATTR_NOATIME: ::__u64 = 0x00000010; +pub const MOUNT_ATTR_STRICTATIME: ::__u64 = 0x00000020; +pub const MOUNT_ATTR_NODIRATIME: ::__u64 = 0x00000080; +pub const MOUNT_ATTR_IDMAP: ::__u64 = 0x00100000; +pub const MOUNT_ATTR_NOSYMFOLLOW: ::__u64 = 0x00200000; + +pub const MOUNT_ATTR_SIZE_VER0: ::c_int = 32; + // elf.h pub const NT_PRSTATUS: ::c_int = 1; pub const NT_PRFPREG: ::c_int = 2; From 0d0a74562cce4dc263f631d05953cb2f680941f1 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Fri, 22 Nov 2024 21:41:10 -0500 Subject: [PATCH 06/16] style: Allow rustfmt to organize imports Add `group_imports` and `import_granularity` to our rustfmt config. These values are the same as in rust-lang/rust. (backport ) (cherry picked from commit 0456dcb747b0b579119613b9e0ae7568bf499e83) --- rustfmt.toml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rustfmt.toml b/rustfmt.toml index 018747d94867a..de0fc5ecc0166 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,2 +1,4 @@ -error_on_line_overflow = true edition = "2021" +error_on_line_overflow = true +group_imports = "StdExternalCrate" +imports_granularity = "Module" From da089f7864cefdb8a21d870d907bdc1869b325c0 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 25 Nov 2024 04:39:53 -0500 Subject: [PATCH 07/16] style: Run `cargo fmt` with the new configuration `libc-0.2` version of 236e0697ef796b263c751321ce68b15ca137d09f from [1] (not a direct cherry pick). [1]: https://github.com/rust-lang/libc/pull/4136 --- build.rs | 3 +-- libc-test/test/cmsg.rs | 3 ++- src/lib.rs | 3 +-- src/unix/linux_like/emscripten/lfs64.rs | 3 +-- src/unix/linux_like/linux/musl/lfs64.rs | 3 +-- src/unix/nuttx/mod.rs | 6 +----- src/unix/solarish/compat.rs | 1 + src/unix/solarish/illumos.rs | 11 ++++------- src/unix/solarish/solaris.rs | 11 ++++------- src/vxworks/mod.rs | 3 ++- src/wasi/mod.rs | 3 ++- 11 files changed, 20 insertions(+), 30 deletions(-) diff --git a/build.rs b/build.rs index 8b599183f5ec9..fe3b65e44b786 100644 --- a/build.rs +++ b/build.rs @@ -1,6 +1,5 @@ -use std::env; use std::process::{Command, Output}; -use std::str; +use std::{env, str}; // List of cfgs this build script is allowed to set. The list is needed to support check-cfg, as we // need to know all the possible cfgs that this script will set. If you need to set another cfg diff --git a/libc-test/test/cmsg.rs b/libc-test/test/cmsg.rs index 52bf9830212c2..130b143cf9dbd 100644 --- a/libc-test/test/cmsg.rs +++ b/libc-test/test/cmsg.rs @@ -4,9 +4,10 @@ #[cfg(unix)] mod t { - use libc::{self, c_uchar, c_uint, c_void, cmsghdr, msghdr}; use std::mem; + use libc::{self, c_uchar, c_uint, c_void, cmsghdr, msghdr}; + extern "C" { pub fn cmsg_firsthdr(msgh: *const msghdr) -> *mut cmsghdr; // see below diff --git a/src/lib.rs b/src/lib.rs index 8af17cb0cb582..b0b25de44e5d8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -47,6 +47,7 @@ cfg_if! { use core::clone::Clone; #[allow(unused_imports)] use core::ffi; +pub use core::ffi::c_void; #[allow(unused_imports)] use core::fmt; #[allow(unused_imports)] @@ -62,8 +63,6 @@ use core::num; #[allow(unused_imports)] use core::option::Option; -pub use core::ffi::c_void; - cfg_if! { if #[cfg(windows)] { mod fixed_width_ints; diff --git a/src/unix/linux_like/emscripten/lfs64.rs b/src/unix/linux_like/emscripten/lfs64.rs index 1616cc90494be..c4cdfb849a2ff 100644 --- a/src/unix/linux_like/emscripten/lfs64.rs +++ b/src/unix/linux_like/emscripten/lfs64.rs @@ -106,8 +106,7 @@ pub unsafe extern "C" fn mmap64( // // These aliases are mostly fine though, neither function takes a LFS64-namespaced type as an // argument, nor do their names clash with any declared types. -pub use open as open64; -pub use openat as openat64; +pub use {open as open64, openat as openat64}; #[inline] pub unsafe extern "C" fn posix_fadvise64( diff --git a/src/unix/linux_like/linux/musl/lfs64.rs b/src/unix/linux_like/linux/musl/lfs64.rs index 27c1d25836d68..6d1f368695a6b 100644 --- a/src/unix/linux_like/linux/musl/lfs64.rs +++ b/src/unix/linux_like/linux/musl/lfs64.rs @@ -114,8 +114,7 @@ pub unsafe extern "C" fn mmap64( // // These aliases are mostly fine though, neither function takes a LFS64-namespaced type as an // argument, nor do their names clash with any declared types. -pub use open as open64; -pub use openat as openat64; +pub use {open as open64, openat as openat64}; #[inline] pub unsafe extern "C" fn posix_fadvise64( diff --git a/src/unix/nuttx/mod.rs b/src/unix/nuttx/mod.rs index c5eb030c9c2bb..200a795ff87ea 100644 --- a/src/unix/nuttx/mod.rs +++ b/src/unix/nuttx/mod.rs @@ -1,8 +1,4 @@ -use c_void; -use in6_addr; -use in_addr_t; -use timespec; -use DIR; +use {c_void, in6_addr, in_addr_t, timespec, DIR}; pub type nlink_t = u16; pub type ino_t = u16; diff --git a/src/unix/solarish/compat.rs b/src/unix/solarish/compat.rs index cbf955a31edaa..72d1bb436794e 100644 --- a/src/unix/solarish/compat.rs +++ b/src/unix/solarish/compat.rs @@ -2,6 +2,7 @@ // Solaris, but often needed by other crates. use core::cmp::min; + use unix::solarish::*; const PTEM: &[u8] = b"ptem\0"; diff --git a/src/unix/solarish/illumos.rs b/src/unix/solarish/illumos.rs index 16a3ba6661e65..cfdb2d16df034 100644 --- a/src/unix/solarish/illumos.rs +++ b/src/unix/solarish/illumos.rs @@ -1,10 +1,7 @@ -use exit_status; -use NET_MAC_AWARE; -use NET_MAC_AWARE_INHERIT; -use PRIV_AWARE_RESET; -use PRIV_DEBUG; -use PRIV_PFEXEC; -use PRIV_XPOLICY; +use { + exit_status, NET_MAC_AWARE, NET_MAC_AWARE_INHERIT, PRIV_AWARE_RESET, PRIV_DEBUG, PRIV_PFEXEC, + PRIV_XPOLICY, +}; pub type lgrp_rsrc_t = ::c_int; pub type lgrp_affinity_t = ::c_int; diff --git a/src/unix/solarish/solaris.rs b/src/unix/solarish/solaris.rs index 8f271b71d4ead..a2a7b1a60e6f3 100644 --- a/src/unix/solarish/solaris.rs +++ b/src/unix/solarish/solaris.rs @@ -1,10 +1,7 @@ -use exit_status; -use NET_MAC_AWARE; -use NET_MAC_AWARE_INHERIT; -use PRIV_AWARE_RESET; -use PRIV_DEBUG; -use PRIV_PFEXEC; -use PRIV_XPOLICY; +use { + exit_status, NET_MAC_AWARE, NET_MAC_AWARE_INHERIT, PRIV_AWARE_RESET, PRIV_DEBUG, PRIV_PFEXEC, + PRIV_XPOLICY, +}; pub type door_attr_t = ::c_uint; pub type door_id_t = ::c_ulonglong; diff --git a/src/vxworks/mod.rs b/src/vxworks/mod.rs index 4c4f6c1b4de2c..8aaa6171f2cca 100644 --- a/src/vxworks/mod.rs +++ b/src/vxworks/mod.rs @@ -1,9 +1,10 @@ //! Interface to VxWorks C library -use c_void; use core::mem::size_of; use core::ptr::null_mut; +use c_void; + #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum DIR {} impl ::Copy for DIR {} diff --git a/src/wasi/mod.rs b/src/wasi/mod.rs index 0e9f6377cf083..e8580048dfed0 100644 --- a/src/wasi/mod.rs +++ b/src/wasi/mod.rs @@ -5,9 +5,10 @@ use core::iter::Iterator; -use super::{Send, Sync}; use c_void; +use super::{Send, Sync}; + pub type c_char = i8; pub type c_uchar = u8; pub type c_schar = i8; From c1cdf7b0dc519f4392d2a9370657c0c297c46f36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Neusch=C3=A4fer?= Date: Wed, 16 Oct 2024 13:48:23 +0200 Subject: [PATCH 08/16] linux_like: Unify statx definitions The statx system call and corresponding constants are defined by the Linux kernel and don't depend on the libc or architecture. The only difference is whether a libc exports the statx syscall wrapper or not. We can thus unify the statx definitions for all Linux "like" platforms: GNU (glibc), Android (bionic), and (in a later commit) musl. Plain u64 (or uint64_t in C) can't be used for the statx fields because bionic defines them as __u64, and provides incompatible definitions of uint64_t and __u64. (backport ) (cherry picked from commit e46bbe467087e5e6fdfdf480532594296c993d4f) --- src/unix/linux_like/android/mod.rs | 40 ------------- src/unix/linux_like/linux/gnu/mod.rs | 71 ---------------------- src/unix/linux_like/mod.rs | 89 ++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+), 111 deletions(-) diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index 7589914fc5e0a..db83b494a4a48 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -515,39 +515,6 @@ s! { pub ifr6_prefixlen: u32, pub ifr6_ifindex: ::c_int, } - - pub struct statx { - pub stx_mask: ::__u32, - pub stx_blksize: ::__u32, - pub stx_attributes: ::__u64, - pub stx_nlink: ::__u32, - pub stx_uid: ::__u32, - pub stx_gid: ::__u32, - pub stx_mode: ::__u16, - __statx_pad1: [::__u16; 1], - pub stx_ino: ::__u64, - pub stx_size: ::__u64, - pub stx_blocks: ::__u64, - pub stx_attributes_mask: ::__u64, - pub stx_atime: ::statx_timestamp, - pub stx_btime: ::statx_timestamp, - pub stx_ctime: ::statx_timestamp, - pub stx_mtime: ::statx_timestamp, - pub stx_rdev_major: ::__u32, - pub stx_rdev_minor: ::__u32, - pub stx_dev_major: ::__u32, - pub stx_dev_minor: ::__u32, - pub stx_mnt_id: ::__u64, - pub stx_dio_mem_align: ::__u32, - pub stx_dio_offset_align: ::__u32, - __statx_pad3: [::__u64; 12], - } - - pub struct statx_timestamp { - pub tv_sec: ::__s64, - pub tv_nsec: ::__u32, - pub __reserved: ::__s32, - } } s_no_extra_traits! { @@ -4205,13 +4172,6 @@ extern "C" { newpath: *const ::c_char, flags: ::c_uint, ) -> ::c_int; - pub fn statx( - dirfd: ::c_int, - pathname: *const c_char, - flags: ::c_int, - mask: ::c_uint, - statxbuf: *mut statx, - ) -> ::c_int; } cfg_if! { diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index 7b9d84f967fd2..b7e10d2e3f44a 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -16,39 +16,6 @@ cfg_if! { } s! { - pub struct statx { - pub stx_mask: u32, - pub stx_blksize: u32, - pub stx_attributes: u64, - pub stx_nlink: u32, - pub stx_uid: u32, - pub stx_gid: u32, - pub stx_mode: u16, - __statx_pad1: [u16; 1], - pub stx_ino: u64, - pub stx_size: u64, - pub stx_blocks: u64, - pub stx_attributes_mask: u64, - pub stx_atime: ::statx_timestamp, - pub stx_btime: ::statx_timestamp, - pub stx_ctime: ::statx_timestamp, - pub stx_mtime: ::statx_timestamp, - pub stx_rdev_major: u32, - pub stx_rdev_minor: u32, - pub stx_dev_major: u32, - pub stx_dev_minor: u32, - pub stx_mnt_id: u64, - pub stx_dio_mem_align: u32, - pub stx_dio_offset_align: u32, - __statx_pad3: [u64; 12], - } - - pub struct statx_timestamp { - pub tv_sec: i64, - pub tv_nsec: u32, - pub __statx_timestamp_pad1: [i32; 1], - } - pub struct aiocb { pub aio_fildes: ::c_int, pub aio_lio_opcode: ::c_int, @@ -1169,37 +1136,6 @@ pub const M_PERTURB: ::c_int = -6; pub const M_ARENA_TEST: ::c_int = -7; pub const M_ARENA_MAX: ::c_int = -8; -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; -pub const AT_STATX_DONT_SYNC: ::c_int = 0x4000; -pub const STATX_TYPE: ::c_uint = 0x0001; -pub const STATX_MODE: ::c_uint = 0x0002; -pub const STATX_NLINK: ::c_uint = 0x0004; -pub const STATX_UID: ::c_uint = 0x0008; -pub const STATX_GID: ::c_uint = 0x0010; -pub const STATX_ATIME: ::c_uint = 0x0020; -pub const STATX_MTIME: ::c_uint = 0x0040; -pub const STATX_CTIME: ::c_uint = 0x0080; -pub const STATX_INO: ::c_uint = 0x0100; -pub const STATX_SIZE: ::c_uint = 0x0200; -pub const STATX_BLOCKS: ::c_uint = 0x0400; -pub const STATX_BASIC_STATS: ::c_uint = 0x07ff; -pub const STATX_BTIME: ::c_uint = 0x0800; -pub const STATX_MNT_ID: ::c_uint = 0x1000; -pub const STATX_DIOALIGN: ::c_uint = 0x2000; -pub const STATX_ALL: ::c_uint = 0x0fff; -pub const STATX__RESERVED: ::c_int = 0x80000000; -pub const STATX_ATTR_COMPRESSED: ::c_int = 0x0004; -pub const STATX_ATTR_IMMUTABLE: ::c_int = 0x0010; -pub const STATX_ATTR_APPEND: ::c_int = 0x0020; -pub const STATX_ATTR_NODUMP: ::c_int = 0x0040; -pub const STATX_ATTR_ENCRYPTED: ::c_int = 0x0800; -pub const STATX_ATTR_AUTOMOUNT: ::c_int = 0x1000; -pub const STATX_ATTR_MOUNT_ROOT: ::c_int = 0x2000; -pub const STATX_ATTR_VERITY: ::c_int = 0x00100000; -pub const STATX_ATTR_DAX: ::c_int = 0x00200000; - pub const SOMAXCONN: ::c_int = 4096; // linux/mount.h @@ -1405,13 +1341,6 @@ extern "C" { pub fn getpt() -> ::c_int; pub fn mallopt(param: ::c_int, value: ::c_int) -> ::c_int; pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::timezone) -> ::c_int; - pub fn statx( - dirfd: ::c_int, - pathname: *const c_char, - flags: ::c_int, - mask: ::c_uint, - statxbuf: *mut statx, - ) -> ::c_int; pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int; pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t; pub fn getauxval(type_: ::c_ulong) -> ::c_ulong; diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 52400fb2bfd8e..567bf21aeab41 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -205,6 +205,45 @@ s! { } } +cfg_if! { + if #[cfg(any(target_env = "gnu", target_os = "android"))] { + s! { + pub struct statx { + pub stx_mask: ::__u32, + pub stx_blksize: ::__u32, + pub stx_attributes: ::__u64, + pub stx_nlink: ::__u32, + pub stx_uid: ::__u32, + pub stx_gid: ::__u32, + pub stx_mode: ::__u16, + __statx_pad1: [::__u16; 1], + pub stx_ino: ::__u64, + pub stx_size: ::__u64, + pub stx_blocks: ::__u64, + pub stx_attributes_mask: ::__u64, + pub stx_atime: statx_timestamp, + pub stx_btime: statx_timestamp, + pub stx_ctime: statx_timestamp, + pub stx_mtime: statx_timestamp, + pub stx_rdev_major: ::__u32, + pub stx_rdev_minor: ::__u32, + pub stx_dev_major: ::__u32, + pub stx_dev_minor: ::__u32, + pub stx_mnt_id: ::__u64, + pub stx_dio_mem_align: ::__u32, + pub stx_dio_offset_align: ::__u32, + __statx_pad3: [::__u64; 12], + } + + pub struct statx_timestamp { + pub tv_sec: ::__s64, + pub tv_nsec: ::__u32, + __statx_timestamp_pad1: [::__s32; 1], + } + } + } +} + s_no_extra_traits! { #[cfg_attr( any( @@ -1529,6 +1568,41 @@ cfg_if! { } } +cfg_if! { + if #[cfg(any(target_env = "gnu", target_os = "android"))] { + 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; + pub const AT_STATX_DONT_SYNC: ::c_int = 0x4000; + pub const STATX_TYPE: ::c_uint = 0x0001; + pub const STATX_MODE: ::c_uint = 0x0002; + pub const STATX_NLINK: ::c_uint = 0x0004; + pub const STATX_UID: ::c_uint = 0x0008; + pub const STATX_GID: ::c_uint = 0x0010; + pub const STATX_ATIME: ::c_uint = 0x0020; + pub const STATX_MTIME: ::c_uint = 0x0040; + pub const STATX_CTIME: ::c_uint = 0x0080; + pub const STATX_INO: ::c_uint = 0x0100; + pub const STATX_SIZE: ::c_uint = 0x0200; + pub const STATX_BLOCKS: ::c_uint = 0x0400; + pub const STATX_BASIC_STATS: ::c_uint = 0x07ff; + pub const STATX_BTIME: ::c_uint = 0x0800; + pub const STATX_ALL: ::c_uint = 0x0fff; + pub const STATX_MNT_ID: ::c_uint = 0x1000; + pub const STATX_DIOALIGN: ::c_uint = 0x2000; + pub const STATX__RESERVED: ::c_int = 0x80000000; + pub const STATX_ATTR_COMPRESSED: ::c_int = 0x0004; + pub const STATX_ATTR_IMMUTABLE: ::c_int = 0x0010; + pub const STATX_ATTR_APPEND: ::c_int = 0x0020; + pub const STATX_ATTR_NODUMP: ::c_int = 0x0040; + pub const STATX_ATTR_ENCRYPTED: ::c_int = 0x0800; + pub const STATX_ATTR_AUTOMOUNT: ::c_int = 0x1000; + pub const STATX_ATTR_MOUNT_ROOT: ::c_int = 0x2000; + pub const STATX_ATTR_VERITY: ::c_int = 0x100000; + pub const STATX_ATTR_DAX: ::c_int = 0x200000; + } +} + const_fn! { {const} fn CMSG_ALIGN(len: usize) -> usize { len + ::mem::size_of::() - 1 & !(::mem::size_of::() - 1) @@ -1903,6 +1977,21 @@ cfg_if! { } } +// The statx syscall, available on some libcs. +cfg_if! { + if #[cfg(any(target_env = "gnu", target_os = "android"))] { + extern "C" { + pub fn statx( + dirfd: ::c_int, + pathname: *const ::c_char, + flags: ::c_int, + mask: ::c_uint, + statxbuf: *mut statx, + ) -> ::c_int; + } + } +} + cfg_if! { if #[cfg(target_os = "emscripten")] { mod emscripten; From fe4def5d5caefe729b92e1b9458788e1f9a2a1e3 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sun, 24 Nov 2024 01:51:51 -0600 Subject: [PATCH 09/16] apple: remove `if_family_id` This API appears to not be available in more recent MacOS SDKs, and there aren't any functions that use it. Since this hasn't yet made it into a release, remove it. Link: https://github.com/rust-lang/libc/pull/4022 (backport ) (cherry picked from commit e87acbad643d2e5fea1fb5f4df2369bef7df70af) --- src/unix/bsd/apple/mod.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index e2f976c5193a6..057bdfe7432e3 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -1293,12 +1293,6 @@ s! { pub dot3Compliance: u32, } - pub struct if_family_id { - pub iffmid_len: u32, - pub iffmid_id: u32, - pub iffmid_str: [::c_char; 1], - } - // kern_control.h pub struct ctl_info { pub ctl_id: u32, From 036c68ffb2d3d300ad961b6facdb3542656309f3 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 25 Nov 2024 01:59:50 -0500 Subject: [PATCH 10/16] musl: Reorganize some statfs-related types for a cleaner diff This moves similar types together (e.g. statfs and statfs64) so removing them is cleaner. Co-authored-by: Andy Caldwell (backport ) (cherry picked from commit 6c0952e95647b894ea8ae629c2cbbcf159ca07c8) --- src/unix/linux_like/linux/musl/b32/x86/mod.rs | 8 +-- src/unix/linux_like/linux/musl/b64/mod.rs | 60 +++++++++---------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/unix/linux_like/linux/musl/b32/x86/mod.rs b/src/unix/linux_like/linux/musl/b32/x86/mod.rs index 95097d344d29e..aeeb6d118599c 100644 --- a/src/unix/linux_like/linux/musl/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/x86/mod.rs @@ -46,6 +46,10 @@ s! { pub st_ino: ::ino_t, } + pub struct mcontext_t { + __private: [u32; 22], + } + pub struct stack_t { pub ss_sp: *mut ::c_void, pub ss_flags: ::c_int, @@ -112,10 +116,6 @@ s! { pub f_spare: [::c_ulong; 4], } - pub struct mcontext_t { - __private: [u32; 22], - } - pub struct siginfo_t { pub si_signo: ::c_int, pub si_errno: ::c_int, diff --git a/src/unix/linux_like/linux/musl/b64/mod.rs b/src/unix/linux_like/linux/musl/b64/mod.rs index dc25939b5027f..a8a1fb32024fe 100644 --- a/src/unix/linux_like/linux/musl/b64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/mod.rs @@ -3,36 +3,6 @@ pub type c_ulong = u64; pub type regoff_t = ::c_long; s! { - pub struct statfs64 { - pub f_type: ::c_ulong, - pub f_bsize: ::c_ulong, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_fsid: ::fsid_t, - pub f_namelen: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_flags: ::c_ulong, - pub f_spare: [::c_ulong; 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, - pub f_flag: ::c_ulong, - pub f_namemax: ::c_ulong, - __f_spare: [::c_int; 6], - } - pub struct stack_t { pub ss_sp: *mut ::c_void, pub ss_flags: ::c_int, @@ -89,6 +59,36 @@ s! { pub f_spare: [::c_ulong; 4], } + pub struct statfs64 { + pub f_type: ::c_ulong, + pub f_bsize: ::c_ulong, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_fsid: ::fsid_t, + pub f_namelen: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_flags: ::c_ulong, + pub f_spare: [::c_ulong; 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, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } + pub struct msghdr { pub msg_name: *mut ::c_void, pub msg_namelen: ::socklen_t, From 818901620cd6e3134bf19519b3c69a449a989d90 Mon Sep 17 00:00:00 2001 From: Andy Caldwell Date: Mon, 25 Nov 2024 01:40:50 -0500 Subject: [PATCH 11/16] musl: Unify definitions of `siginfo_t` Musl provides a single definition for `siginfo_t` [1] with the order of `si_code` and `si_errno` controlled by `__SI_SWAP_ERRNO_CODE`. This is only set on mips (both 32- and 64-bit). [1]: https://github.com/kraj/musl/blob/ffb23aef7b5339b8c3234f4c6a93c488dc873919/include/signal.h#L99-L147 [ extracted from "Remove all redundant definitions in musl backend", add context to the commit message - Trevor ] (backport ) (cherry picked from commit e1ff5d61e95a4a64b60cbb158986045ebb916149) --- src/unix/linux_like/linux/musl/b32/arm/mod.rs | 8 -------- src/unix/linux_like/linux/musl/b32/hexagon.rs | 8 -------- .../linux_like/linux/musl/b32/mips/mod.rs | 8 -------- src/unix/linux_like/linux/musl/b32/powerpc.rs | 8 -------- .../linux_like/linux/musl/b32/riscv32/mod.rs | 15 -------------- src/unix/linux_like/linux/musl/b32/x86/mod.rs | 8 -------- src/unix/linux_like/linux/musl/b64/mod.rs | 8 -------- .../linux_like/linux/musl/b64/riscv64/mod.rs | 15 -------------- src/unix/linux_like/linux/musl/mod.rs | 20 +++++++++++++++++++ 9 files changed, 20 insertions(+), 78 deletions(-) diff --git a/src/unix/linux_like/linux/musl/b32/arm/mod.rs b/src/unix/linux_like/linux/musl/b32/arm/mod.rs index 4149b7ebb1534..0d291ac0eac09 100644 --- a/src/unix/linux_like/linux/musl/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/arm/mod.rs @@ -112,14 +112,6 @@ s! { pub f_spare: [::c_ulong; 4], } - pub struct siginfo_t { - pub si_signo: ::c_int, - pub si_errno: ::c_int, - pub si_code: ::c_int, - pub _pad: [::c_int; 29], - _align: [usize; 0], - } - pub struct statfs64 { pub f_type: ::c_ulong, pub f_bsize: ::c_ulong, diff --git a/src/unix/linux_like/linux/musl/b32/hexagon.rs b/src/unix/linux_like/linux/musl/b32/hexagon.rs index 4fc29f4f0df05..1802356339d27 100644 --- a/src/unix/linux_like/linux/musl/b32/hexagon.rs +++ b/src/unix/linux_like/linux/musl/b32/hexagon.rs @@ -90,14 +90,6 @@ s! { pub f_spare: [::c_ulong; 4], } - pub struct siginfo_t { - pub si_signo: ::c_int, - pub si_errno: ::c_int, - pub si_code: ::c_int, - pub _pad: [::c_int; 29], - _align: [usize; 0], - } - pub struct statfs64 { pub f_type: ::c_ulong, pub f_bsize: ::c_ulong, diff --git a/src/unix/linux_like/linux/musl/b32/mips/mod.rs b/src/unix/linux_like/linux/musl/b32/mips/mod.rs index 219c96b0d9fd9..04e0126cc66c7 100644 --- a/src/unix/linux_like/linux/musl/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/mips/mod.rs @@ -120,14 +120,6 @@ s! { pub f_spare: [::c_ulong; 5], } - pub struct siginfo_t { - pub si_signo: ::c_int, - pub si_code: ::c_int, - pub si_errno: ::c_int, - pub _pad: [::c_int; 29], - _align: [usize; 0], - } - pub struct statfs64 { pub f_type: ::c_ulong, pub f_bsize: ::c_ulong, diff --git a/src/unix/linux_like/linux/musl/b32/powerpc.rs b/src/unix/linux_like/linux/musl/b32/powerpc.rs index 80eb9f57c2622..cbb7a7b0e277f 100644 --- a/src/unix/linux_like/linux/musl/b32/powerpc.rs +++ b/src/unix/linux_like/linux/musl/b32/powerpc.rs @@ -112,14 +112,6 @@ s! { pub f_spare: [::c_ulong; 4], } - pub struct siginfo_t { - pub si_signo: ::c_int, - pub si_errno: ::c_int, - pub si_code: ::c_int, - pub _pad: [::c_int; 29], - _align: [usize; 0], - } - pub struct statfs64 { pub f_type: ::c_ulong, pub f_bsize: ::c_ulong, diff --git a/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs b/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs index 13a099c18e26c..fe5b02acd2796 100644 --- a/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs @@ -113,21 +113,6 @@ s! { __f_spare: [::c_int; 6], } - pub struct siginfo_t { - pub si_signo: ::c_int, - pub si_errno: ::c_int, - pub si_code: ::c_int, - #[doc(hidden)] - #[deprecated( - since = "0.2.54", - note = "Please leave a comment on \ - https://github.com/rust-lang/libc/pull/1316 if you're using \ - this field" - )] - pub _pad: [::c_int; 29], - _align: [u64; 0], - } - pub struct stack_t { pub ss_sp: *mut ::c_void, pub ss_flags: ::c_int, diff --git a/src/unix/linux_like/linux/musl/b32/x86/mod.rs b/src/unix/linux_like/linux/musl/b32/x86/mod.rs index aeeb6d118599c..f448f536bbbee 100644 --- a/src/unix/linux_like/linux/musl/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/x86/mod.rs @@ -116,14 +116,6 @@ s! { pub f_spare: [::c_ulong; 4], } - pub struct siginfo_t { - pub si_signo: ::c_int, - pub si_errno: ::c_int, - pub si_code: ::c_int, - pub _pad: [::c_int; 29], - _align: [usize; 0], - } - pub struct statfs64 { pub f_type: ::c_ulong, pub f_bsize: ::c_ulong, diff --git a/src/unix/linux_like/linux/musl/b64/mod.rs b/src/unix/linux_like/linux/musl/b64/mod.rs index a8a1fb32024fe..ff58b7003cbd5 100644 --- a/src/unix/linux_like/linux/musl/b64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/mod.rs @@ -120,14 +120,6 @@ s! { pub struct sem_t { __val: [::c_int; 8], } - - pub struct siginfo_t { - pub si_signo: ::c_int, - pub si_errno: ::c_int, - pub si_code: ::c_int, - pub _pad: [::c_int; 29], - _align: [usize; 0], - } } pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; diff --git a/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs b/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs index a2b823c1adf95..1af905701eaf8 100644 --- a/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs @@ -119,21 +119,6 @@ s! { pub __f_spare: [::c_int; 6], } - pub struct siginfo_t { - pub si_signo: ::c_int, - pub si_errno: ::c_int, - pub si_code: ::c_int, - #[doc(hidden)] - #[deprecated( - since = "0.2.54", - note = "Please leave a comment on \ - https://github.com/rust-lang/libc/pull/1316 if you're using \ - this field" - )] - pub _pad: [::c_int; 29], - _align: [u64; 0], - } - pub struct stack_t { pub ss_sp: *mut ::c_void, pub ss_flags: ::c_int, diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index ec295aa57deb3..c21fdaf04efc4 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -144,6 +144,26 @@ s! { pub sa_restorer: ::Option, } + // `mips*` targets swap the `s_errno` and `s_code` fields otherwise this struct is + // target-agnostic (see https://www.openwall.com/lists/musl/2016/01/27/1/2) + pub struct siginfo_t { + pub si_signo: ::c_int, + #[cfg(not(target_arch = "mips"))] + pub si_errno: ::c_int, + pub si_code: ::c_int, + #[cfg(target_arch = "mips")] + pub si_errno: ::c_int, + #[doc(hidden)] + #[deprecated( + since = "0.2.54", + note = "Please leave a comment on \ + https://github.com/rust-lang/libc/pull/1316 if you're using \ + this field" + )] + pub _pad: [::c_int; 29], + _align: [usize; 0], + } + pub struct statvfs { pub f_bsize: ::c_ulong, pub f_frsize: ::c_ulong, From 0300828e6b46da0d34daf30b7b485923a9627b53 Mon Sep 17 00:00:00 2001 From: Andy Caldwell Date: Thu, 1 Jun 2023 17:52:34 +0100 Subject: [PATCH 12/16] musl: Unify definitions of statvfs and statvfs64 `statvfs` already exists in `musl/mod.rs`. Use that were possible and move a common version of `statvfs64` there. [ reduce this patch to only cover statvfs*, leaving statfs as a separate change - Trevor ] (backport ) (cherry picked from commit adcc84d57dea4d63f533a12c5bcc06b16ecb4eb3) --- src/unix/linux_like/linux/musl/b32/arm/mod.rs | 16 ---------- src/unix/linux_like/linux/musl/b32/hexagon.rs | 16 ---------- .../linux_like/linux/musl/b32/mips/mod.rs | 19 ------------ src/unix/linux_like/linux/musl/b32/powerpc.rs | 19 ------------ .../linux_like/linux/musl/b32/riscv32/mod.rs | 31 ------------------- src/unix/linux_like/linux/musl/b32/x86/mod.rs | 16 ---------- src/unix/linux_like/linux/musl/b64/mod.rs | 15 --------- .../linux_like/linux/musl/b64/riscv64/mod.rs | 30 ------------------ src/unix/linux_like/linux/musl/mod.rs | 22 +++++++++++++ 9 files changed, 22 insertions(+), 162 deletions(-) diff --git a/src/unix/linux_like/linux/musl/b32/arm/mod.rs b/src/unix/linux_like/linux/musl/b32/arm/mod.rs index 0d291ac0eac09..14c60f7958aa1 100644 --- a/src/unix/linux_like/linux/musl/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/arm/mod.rs @@ -127,22 +127,6 @@ s! { pub f_spare: [::c_ulong; 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: ::c_int, - pub f_flag: ::c_ulong, - pub f_namemax: ::c_ulong, - __f_spare: [::c_int; 6], - } - pub struct mcontext_t { pub trap_no: ::c_ulong, pub error_code: ::c_ulong, diff --git a/src/unix/linux_like/linux/musl/b32/hexagon.rs b/src/unix/linux_like/linux/musl/b32/hexagon.rs index 1802356339d27..ec55ffb4613c6 100644 --- a/src/unix/linux_like/linux/musl/b32/hexagon.rs +++ b/src/unix/linux_like/linux/musl/b32/hexagon.rs @@ -104,22 +104,6 @@ s! { pub f_flags: ::c_ulong, pub f_spare: [::c_ulong; 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: ::c_int, - pub f_flag: ::c_ulong, - pub f_namemax: ::c_ulong, - __f_spare: [::c_int; 6], - } } pub const AF_FILE: ::c_int = 1; diff --git a/src/unix/linux_like/linux/musl/b32/mips/mod.rs b/src/unix/linux_like/linux/musl/b32/mips/mod.rs index 04e0126cc66c7..39af8372d54e8 100644 --- a/src/unix/linux_like/linux/musl/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/mips/mod.rs @@ -134,25 +134,6 @@ s! { pub f_flags: ::c_ulong, pub f_spare: [::c_ulong; 5], } - - 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, - #[cfg(target_endian = "little")] - pub f_fsid: ::c_ulong, - __f_unused: ::c_int, - #[cfg(target_endian = "big")] - pub f_fsid: ::c_ulong, - pub f_flag: ::c_ulong, - pub f_namemax: ::c_ulong, - __f_spare: [::c_int; 6], - } } s_no_extra_traits! { diff --git a/src/unix/linux_like/linux/musl/b32/powerpc.rs b/src/unix/linux_like/linux/musl/b32/powerpc.rs index cbb7a7b0e277f..8be5a1d0865f2 100644 --- a/src/unix/linux_like/linux/musl/b32/powerpc.rs +++ b/src/unix/linux_like/linux/musl/b32/powerpc.rs @@ -126,25 +126,6 @@ s! { pub f_flags: ::c_ulong, pub f_spare: [::c_ulong; 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, - #[cfg(target_endian = "little")] - pub f_fsid: ::c_ulong, - __f_unused: ::c_int, - #[cfg(target_endian = "big")] - pub f_fsid: ::c_ulong, - pub f_flag: ::c_ulong, - pub f_namemax: ::c_ulong, - __f_spare: [::c_int; 6], - } } pub const MADV_SOFT_OFFLINE: ::c_int = 101; diff --git a/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs b/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs index fe5b02acd2796..be3d9ba275e2e 100644 --- a/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs @@ -67,21 +67,6 @@ s! { pub f_spare: [::c_long; 4], } - pub struct statvfs { - pub f_bsize: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_favail: ::fsfilcnt_t, - pub f_fsid: ::c_ulong, - pub f_flag: ::c_ulong, - pub f_namemax: ::c_ulong, - pub __f_spare: [::c_int; 6], - } - pub struct statfs64 { pub f_type: ::c_ulong, pub f_bsize: ::c_ulong, @@ -97,22 +82,6 @@ s! { pub f_spare: [::c_ulong; 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: ::c_int, - pub f_flag: ::c_ulong, - pub f_namemax: ::c_ulong, - __f_spare: [::c_int; 6], - } - pub struct stack_t { pub ss_sp: *mut ::c_void, pub ss_flags: ::c_int, diff --git a/src/unix/linux_like/linux/musl/b32/x86/mod.rs b/src/unix/linux_like/linux/musl/b32/x86/mod.rs index f448f536bbbee..0d535e950f423 100644 --- a/src/unix/linux_like/linux/musl/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/x86/mod.rs @@ -130,22 +130,6 @@ s! { pub f_flags: ::c_ulong, pub f_spare: [::c_ulong; 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: ::c_int, - pub f_flag: ::c_ulong, - pub f_namemax: ::c_ulong, - __f_spare: [::c_int; 6], - } } s_no_extra_traits! { diff --git a/src/unix/linux_like/linux/musl/b64/mod.rs b/src/unix/linux_like/linux/musl/b64/mod.rs index ff58b7003cbd5..4b0fb4a2b8eb3 100644 --- a/src/unix/linux_like/linux/musl/b64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/mod.rs @@ -74,21 +74,6 @@ s! { pub f_spare: [::c_ulong; 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, - pub f_flag: ::c_ulong, - pub f_namemax: ::c_ulong, - __f_spare: [::c_int; 6], - } - pub struct msghdr { pub msg_name: *mut ::c_void, pub msg_namelen: ::socklen_t, diff --git a/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs b/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs index 1af905701eaf8..bfd34ef1a980e 100644 --- a/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs @@ -89,36 +89,6 @@ s! { pub f_spare: [::c_long; 4], } - pub struct statvfs { - pub f_bsize: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_favail: ::fsfilcnt_t, - pub f_fsid: ::c_ulong, - pub f_flag: ::c_ulong, - pub f_namemax: ::c_ulong, - pub __f_spare: [::c_int; 6], - } - - pub struct statvfs64 { - pub f_bsize: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_blocks: ::fsblkcnt64_t, - pub f_bfree: ::fsblkcnt64_t, - pub f_bavail: ::fsblkcnt64_t, - pub f_files: ::fsfilcnt64_t, - pub f_ffree: ::fsfilcnt64_t, - pub f_favail: ::fsfilcnt64_t, - pub f_fsid: ::c_ulong, - pub f_flag: ::c_ulong, - pub f_namemax: ::c_ulong, - pub __f_spare: [::c_int; 6], - } - pub struct stack_t { pub ss_sp: *mut ::c_void, pub ss_flags: ::c_int, diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index c21fdaf04efc4..467826c92796a 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -19,7 +19,9 @@ pub type shmatt_t = ::c_ulong; pub type msgqnum_t = ::c_ulong; pub type msglen_t = ::c_ulong; pub type fsblkcnt_t = ::c_ulonglong; +pub type fsblkcnt64_t = ::c_ulonglong; pub type fsfilcnt_t = ::c_ulonglong; +pub type fsfilcnt64_t = ::c_ulonglong; pub type rlim_t = ::c_ulonglong; cfg_if! { @@ -184,6 +186,26 @@ s! { __f_spare: [::c_int; 6], } + pub struct statvfs64 { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: ::fsblkcnt64_t, + pub f_bfree: ::fsblkcnt64_t, + pub f_bavail: ::fsblkcnt64_t, + pub f_files: ::fsfilcnt64_t, + pub f_ffree: ::fsfilcnt64_t, + pub f_favail: ::fsfilcnt64_t, + #[cfg(target_endian = "little")] + pub f_fsid: ::c_ulong, + #[cfg(target_pointer_width = "32")] + __f_unused: ::c_int, + #[cfg(target_endian = "big")] + pub f_fsid: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } + pub struct termios { pub c_iflag: ::tcflag_t, pub c_oflag: ::tcflag_t, From ace85eef610e911e905630867e7ca0aee77d9485 Mon Sep 17 00:00:00 2001 From: Andy Caldwell Date: Mon, 25 Nov 2024 02:26:54 -0500 Subject: [PATCH 13/16] musl: Unify definitions of statfs and statfs64 Only mips uses a special statfs(64) [ squash "Use `#[cfg]` blocks to special-case statfs on mips", change this patch to only cover statfs and statfs64, include part of "Remove new redundant definitions" - Trevor ] (backport ) (cherry picked from commit fb7785a71b1a6221c796d909692e339a1bcb9d3f) --- src/unix/linux_like/linux/musl/b32/arm/mod.rs | 30 -------------- src/unix/linux_like/linux/musl/b32/hexagon.rs | 30 -------------- src/unix/linux_like/linux/musl/b32/powerpc.rs | 30 -------------- .../linux_like/linux/musl/b32/riscv32/mod.rs | 30 -------------- src/unix/linux_like/linux/musl/b32/x86/mod.rs | 30 -------------- .../linux/musl/b64/loongarch64/mod.rs | 15 ------- src/unix/linux_like/linux/musl/b64/mips64.rs | 30 -------------- src/unix/linux_like/linux/musl/b64/mod.rs | 30 -------------- .../linux_like/linux/musl/b64/riscv64/mod.rs | 32 --------------- src/unix/linux_like/linux/musl/b64/s390x.rs | 30 -------------- src/unix/linux_like/linux/musl/mod.rs | 39 +++++++++++++++++-- 11 files changed, 36 insertions(+), 290 deletions(-) diff --git a/src/unix/linux_like/linux/musl/b32/arm/mod.rs b/src/unix/linux_like/linux/musl/b32/arm/mod.rs index 14c60f7958aa1..07aabbe1c5824 100644 --- a/src/unix/linux_like/linux/musl/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/arm/mod.rs @@ -97,36 +97,6 @@ s! { __pad2: ::c_ulong, } - pub struct statfs { - pub f_type: ::c_ulong, - pub f_bsize: ::c_ulong, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_fsid: ::fsid_t, - pub f_namelen: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_flags: ::c_ulong, - pub f_spare: [::c_ulong; 4], - } - - pub struct statfs64 { - pub f_type: ::c_ulong, - pub f_bsize: ::c_ulong, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_fsid: ::fsid_t, - pub f_namelen: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_flags: ::c_ulong, - pub f_spare: [::c_ulong; 4], - } - pub struct mcontext_t { pub trap_no: ::c_ulong, pub error_code: ::c_ulong, diff --git a/src/unix/linux_like/linux/musl/b32/hexagon.rs b/src/unix/linux_like/linux/musl/b32/hexagon.rs index ec55ffb4613c6..8678e19dff176 100644 --- a/src/unix/linux_like/linux/musl/b32/hexagon.rs +++ b/src/unix/linux_like/linux/musl/b32/hexagon.rs @@ -74,36 +74,6 @@ s! { __pad1: ::c_ulong, __pad2: ::c_ulong, } - - pub struct statfs { - pub f_type: ::c_ulong, - pub f_bsize: ::c_ulong, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_fsid: ::fsid_t, - pub f_namelen: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_flags: ::c_ulong, - pub f_spare: [::c_ulong; 4], - } - - pub struct statfs64 { - pub f_type: ::c_ulong, - pub f_bsize: ::c_ulong, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_fsid: ::fsid_t, - pub f_namelen: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_flags: ::c_ulong, - pub f_spare: [::c_ulong; 4], - } } pub const AF_FILE: ::c_int = 1; diff --git a/src/unix/linux_like/linux/musl/b32/powerpc.rs b/src/unix/linux_like/linux/musl/b32/powerpc.rs index 8be5a1d0865f2..1f8ee80113e16 100644 --- a/src/unix/linux_like/linux/musl/b32/powerpc.rs +++ b/src/unix/linux_like/linux/musl/b32/powerpc.rs @@ -96,36 +96,6 @@ s! { __pad1: ::c_ulong, __pad2: ::c_ulong, } - - pub struct statfs { - pub f_type: ::c_ulong, - pub f_bsize: ::c_ulong, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_fsid: ::fsid_t, - pub f_namelen: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_flags: ::c_ulong, - pub f_spare: [::c_ulong; 4], - } - - pub struct statfs64 { - pub f_type: ::c_ulong, - pub f_bsize: ::c_ulong, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_fsid: ::fsid_t, - pub f_namelen: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_flags: ::c_ulong, - pub f_spare: [::c_ulong; 4], - } } pub const MADV_SOFT_OFFLINE: ::c_int = 101; diff --git a/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs b/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs index be3d9ba275e2e..6f622e6184acd 100644 --- a/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs @@ -52,36 +52,6 @@ s! { __unused: [::c_int; 2], } - pub struct statfs { - pub f_type: ::c_long, - pub f_bsize: ::c_long, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_fsid: ::fsid_t, - pub f_namelen: ::c_long, - pub f_frsize: ::c_long, - pub f_flags: ::c_long, - pub f_spare: [::c_long; 4], - } - - pub struct statfs64 { - pub f_type: ::c_ulong, - pub f_bsize: ::c_ulong, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_fsid: ::fsid_t, - pub f_namelen: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_flags: ::c_ulong, - pub f_spare: [::c_ulong; 4], - } - pub struct stack_t { pub ss_sp: *mut ::c_void, pub ss_flags: ::c_int, diff --git a/src/unix/linux_like/linux/musl/b32/x86/mod.rs b/src/unix/linux_like/linux/musl/b32/x86/mod.rs index 0d535e950f423..769077c465a62 100644 --- a/src/unix/linux_like/linux/musl/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/x86/mod.rs @@ -100,36 +100,6 @@ s! { __pad1: ::c_ulong, __pad2: ::c_ulong, } - - pub struct statfs { - pub f_type: ::c_ulong, - pub f_bsize: ::c_ulong, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_fsid: ::fsid_t, - pub f_namelen: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_flags: ::c_ulong, - pub f_spare: [::c_ulong; 4], - } - - pub struct statfs64 { - pub f_type: ::c_ulong, - pub f_bsize: ::c_ulong, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_fsid: ::fsid_t, - pub f_namelen: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_flags: ::c_ulong, - pub f_spare: [::c_ulong; 4], - } } s_no_extra_traits! { diff --git a/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs b/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs index 40bdb0aa42e3c..f2fe5fe1a23d2 100644 --- a/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs @@ -55,21 +55,6 @@ s! { __unused: [::c_int; 2], } - pub struct statfs64 { - pub f_type: ::c_long, - pub f_bsize: ::c_long, - pub f_blocks: ::fsblkcnt64_t, - pub f_bfree: ::fsblkcnt64_t, - pub f_bavail: ::fsblkcnt64_t, - pub f_files: ::fsfilcnt64_t, - pub f_ffree: ::fsfilcnt64_t, - pub f_fsid: ::fsid_t, - pub f_namelen: ::c_long, - pub f_frsize: ::c_long, - pub f_flags: ::c_long, - pub f_spare: [::c_long; 4], - } - pub struct ipc_perm { pub __key: ::key_t, pub uid: ::uid_t, diff --git a/src/unix/linux_like/linux/musl/b64/mips64.rs b/src/unix/linux_like/linux/musl/b64/mips64.rs index 962c0759c6ea0..63a47af041487 100644 --- a/src/unix/linux_like/linux/musl/b64/mips64.rs +++ b/src/unix/linux_like/linux/musl/b64/mips64.rs @@ -54,36 +54,6 @@ s! { __pad5: [::c_int; 14], } - pub struct statfs { - pub f_type: ::c_ulong, - pub f_bsize: ::c_ulong, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_fsid: ::fsid_t, - pub f_namelen: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_flags: ::c_ulong, - pub f_spare: [::c_ulong; 5], - } - - pub struct statfs64 { - pub f_type: ::c_ulong, - pub f_bsize: ::c_ulong, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_fsid: ::fsid_t, - pub f_namelen: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_flags: ::c_ulong, - pub f_spare: [::c_ulong; 5], - } - pub struct ipc_perm { pub __ipc_perm_key: ::key_t, pub uid: ::uid_t, diff --git a/src/unix/linux_like/linux/musl/b64/mod.rs b/src/unix/linux_like/linux/musl/b64/mod.rs index 4b0fb4a2b8eb3..9e893a36f8068 100644 --- a/src/unix/linux_like/linux/musl/b64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/mod.rs @@ -44,36 +44,6 @@ s! { __pad2: ::c_ulong, } - pub struct statfs { - pub f_type: ::c_ulong, - pub f_bsize: ::c_ulong, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_fsid: ::fsid_t, - pub f_namelen: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_flags: ::c_ulong, - pub f_spare: [::c_ulong; 4], - } - - pub struct statfs64 { - pub f_type: ::c_ulong, - pub f_bsize: ::c_ulong, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_fsid: ::fsid_t, - pub f_namelen: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_flags: ::c_ulong, - pub f_spare: [::c_ulong; 4], - } - pub struct msghdr { pub msg_name: *mut ::c_void, pub msg_namelen: ::socklen_t, diff --git a/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs b/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs index bfd34ef1a980e..b438294834e03 100644 --- a/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs @@ -5,8 +5,6 @@ pub type wchar_t = ::c_int; pub type nlink_t = ::c_uint; pub type blksize_t = ::c_int; -pub type fsblkcnt64_t = ::c_ulong; -pub type fsfilcnt64_t = ::c_ulong; pub type __u64 = ::c_ulonglong; pub type __s64 = ::c_longlong; @@ -59,36 +57,6 @@ s! { __unused: [::c_int; 2], } - pub struct statfs { - pub f_type: ::c_long, - pub f_bsize: ::c_long, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_fsid: ::fsid_t, - pub f_namelen: ::c_long, - pub f_frsize: ::c_long, - pub f_flags: ::c_long, - pub f_spare: [::c_long; 4], - } - - pub struct statfs64 { - pub f_type: ::c_long, - pub f_bsize: ::c_long, - pub f_blocks: ::fsblkcnt64_t, - pub f_bfree: ::fsblkcnt64_t, - pub f_bavail: ::fsblkcnt64_t, - pub f_files: ::fsfilcnt64_t, - pub f_ffree: ::fsfilcnt64_t, - pub f_fsid: ::fsid_t, - pub f_namelen: ::c_long, - pub f_frsize: ::c_long, - pub f_flags: ::c_long, - pub f_spare: [::c_long; 4], - } - pub struct stack_t { pub ss_sp: *mut ::c_void, pub ss_flags: ::c_int, diff --git a/src/unix/linux_like/linux/musl/b64/s390x.rs b/src/unix/linux_like/linux/musl/b64/s390x.rs index e25a17124002a..67183e8d55177 100644 --- a/src/unix/linux_like/linux/musl/b64/s390x.rs +++ b/src/unix/linux_like/linux/musl/b64/s390x.rs @@ -58,36 +58,6 @@ s! { pub st_blocks: ::blkcnt64_t, __unused: [::c_long; 3], } - - pub struct statfs { - pub f_type: ::c_uint, - pub f_bsize: ::c_uint, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_fsid: ::fsid_t, - pub f_namelen: ::c_uint, - pub f_frsize: ::c_uint, - pub f_flags: ::c_uint, - pub f_spare: [::c_uint; 4], - } - - pub struct statfs64 { - pub f_type: ::c_uint, - pub f_bsize: ::c_uint, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_fsid: ::fsid_t, - pub f_namelen: ::c_uint, - pub f_frsize: ::c_uint, - pub f_flags: ::c_uint, - pub f_spare: [::c_uint; 4], - } } s_no_extra_traits! { diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 467826c92796a..5803874f5ad0b 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -158,9 +158,8 @@ s! { #[doc(hidden)] #[deprecated( since = "0.2.54", - note = "Please leave a comment on \ - https://github.com/rust-lang/libc/pull/1316 if you're using \ - this field" + note = "Please leave a comment on https://github.com/rust-lang/libc/pull/1316 \ + if you're using this field" )] pub _pad: [::c_int; 29], _align: [usize; 0], @@ -458,6 +457,40 @@ s! { #[cfg(target_arch = "loongarch64")] pub tcpi_snd_wnd: u32, } + + // MIPS implementation is special (see mips arch folders) + #[cfg(not(target_arch = "mips"))] + pub struct statfs { + pub f_type: ::c_ulong, + pub f_bsize: ::c_ulong, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_fsid: ::fsid_t, + pub f_namelen: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_flags: ::c_ulong, + pub f_spare: [::c_ulong; 4], + } + + // MIPS implementation is special (see mips arch folders) + #[cfg(not(target_arch = "mips"))] + pub struct statfs64 { + pub f_type: ::c_ulong, + pub f_bsize: ::c_ulong, + pub f_blocks: ::fsblkcnt64_t, + pub f_bfree: ::fsblkcnt64_t, + pub f_bavail: ::fsblkcnt64_t, + pub f_files: ::fsfilcnt64_t, + pub f_ffree: ::fsfilcnt64_t, + pub f_fsid: ::fsid_t, + pub f_namelen: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_flags: ::c_ulong, + pub f_spare: [::c_ulong; 4], + } } s_no_extra_traits! { From ee8ef649b863eaad2880f39c811f807926ffc9ed Mon Sep 17 00:00:00 2001 From: Andy Caldwell Date: Thu, 1 Jun 2023 19:01:34 +0100 Subject: [PATCH 14/16] musl: Remove redundant definitions These types are redundant as they are exported from higher-level modules. [ move some non-statfs fixups here from other commits in the series, add context to the commmit message - Trevor ] (backport ) (cherry picked from commit b196045cc621a71c42ebbdcca95baa7e64f95854) --- .../linux_like/linux/gnu/b32/riscv32/mod.rs | 26 ------ .../linux_like/linux/gnu/b32/sparc/mod.rs | 21 ----- .../linux_like/linux/musl/b32/riscv32/mod.rs | 86 ------------------- .../linux_like/linux/musl/b64/riscv64/mod.rs | 30 ------- 4 files changed, 163 deletions(-) diff --git a/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs b/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs index fcda280411f6c..464b4f560fad3 100644 --- a/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs @@ -4,10 +4,6 @@ pub type c_char = u8; pub type wchar_t = ::c_int; s! { - pub struct pthread_attr_t { - __size: [::c_ulong; 7], - } - pub struct msqid_ds { pub msg_perm: ::ipc_perm, pub msg_stime: ::time_t, @@ -22,28 +18,6 @@ s! { __glibc_reserved5: ::c_ulong, } - pub struct stat { - pub st_dev: ::dev_t, - pub st_ino: ::ino_t, - pub st_mode: ::mode_t, - pub st_nlink: ::nlink_t, - pub st_uid: ::uid_t, - pub st_gid: ::gid_t, - pub st_rdev: ::dev_t, - pub __pad1: ::dev_t, - pub st_size: ::off_t, - pub st_blksize: ::blksize_t, - pub __pad2: ::c_int, - pub st_blocks: ::blkcnt_t, - pub st_atime: ::time_t, - pub st_atime_nsec: ::c_long, - pub st_mtime: ::time_t, - pub st_mtime_nsec: ::c_long, - pub st_ctime: ::time_t, - pub st_ctime_nsec: ::c_long, - __unused: [::c_int; 2usize], - } - pub struct stat64 { pub st_dev: ::dev_t, pub st_ino: ::ino64_t, diff --git a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs index bea8b24355784..189ec8f05a0c3 100644 --- a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs @@ -58,27 +58,6 @@ s! { pub ss_size: ::size_t, } - pub struct stat { - pub st_dev: ::dev_t, - pub st_ino: ::ino64_t, - pub st_mode: ::mode_t, - pub st_nlink: ::nlink_t, - pub st_uid: ::uid_t, - pub st_gid: ::gid_t, - pub st_rdev: ::dev_t, - __pad2: ::c_ushort, - pub st_size: ::off64_t, - pub st_blksize: ::blksize_t, - pub st_blocks: ::blkcnt64_t, - pub st_atime: ::time_t, - pub st_atime_nsec: ::c_long, - pub st_mtime: ::time_t, - pub st_mtime_nsec: ::c_long, - pub st_ctime: ::time_t, - pub st_ctime_nsec: ::c_long, - __unused: [::c_long; 2], - } - pub struct stat64 { pub st_dev: ::dev_t, pub st_ino: ::ino64_t, diff --git a/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs b/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs index 6f622e6184acd..aa8ba42205636 100644 --- a/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs @@ -4,10 +4,6 @@ pub type c_char = u8; pub type wchar_t = ::c_int; s! { - pub struct pthread_attr_t { - __size: [::c_ulong; 7], - } - pub struct stat { pub st_dev: ::dev_t, pub st_ino: ::ino_t, @@ -58,13 +54,6 @@ s! { pub ss_size: ::size_t, } - pub struct sigaction { - pub sa_sigaction: ::sighandler_t, - pub sa_mask: ::sigset_t, - pub sa_flags: ::c_int, - pub sa_restorer: ::Option, - } - pub struct ipc_perm { pub __key: ::key_t, pub uid: ::uid_t, @@ -121,12 +110,6 @@ s_no_extra_traits! { //pub const RLIM_INFINITY: ::rlim_t = !0; pub const VEOF: usize = 4; pub const RTLD_DEEPBIND: ::c_int = 0x8; -pub const RTLD_GLOBAL: ::c_int = 0x100; -pub const RTLD_NOLOAD: ::c_int = 0x4; -pub const TIOCGSOFTCAR: ::c_ulong = 21529; -pub const TIOCSSOFTCAR: ::c_ulong = 21530; -pub const TIOCGRS485: ::c_int = 21550; -pub const TIOCSRS485: ::c_int = 21551; //pub const RLIMIT_RSS: ::__rlimit_resource_t = 5; //pub const RLIMIT_AS: ::__rlimit_resource_t = 9; //pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 8; @@ -253,38 +236,12 @@ pub const SIG_UNBLOCK: ::c_int = 1; pub const POLLWRNORM: ::c_short = 256; pub const POLLWRBAND: ::c_short = 512; pub const O_ASYNC: ::c_int = 8192; -pub const O_NDELAY: ::c_int = 2048; -pub const EFD_NONBLOCK: ::c_int = 2048; pub const F_SETOWN: ::c_int = 8; pub const F_GETOWN: ::c_int = 9; pub const F_GETLK: ::c_int = 12; pub const F_SETLK: ::c_int = 13; pub const F_SETLKW: ::c_int = 14; -pub const SFD_NONBLOCK: ::c_int = 2048; -pub const TCSANOW: ::c_int = 0; -pub const TCSADRAIN: ::c_int = 1; -pub const TCSAFLUSH: ::c_int = 2; -pub const TIOCLINUX: ::c_ulong = 21532; -pub const TIOCGSERIAL: ::c_ulong = 21534; -pub const TIOCEXCL: ::c_ulong = 21516; -pub const TIOCNXCL: ::c_ulong = 21517; -pub const TIOCSCTTY: ::c_ulong = 21518; -pub const TIOCSTI: ::c_ulong = 21522; -pub const TIOCMGET: ::c_ulong = 21525; -pub const TIOCMBIS: ::c_ulong = 21526; -pub const TIOCMBIC: ::c_ulong = 21527; -pub const TIOCMSET: ::c_ulong = 21528; -pub const TIOCCONS: ::c_ulong = 21533; -pub const TIOCM_ST: ::c_int = 8; -pub const TIOCM_SR: ::c_int = 16; -pub const TIOCM_CTS: ::c_int = 32; -pub const TIOCM_CAR: ::c_int = 64; -pub const TIOCM_RNG: ::c_int = 128; -pub const TIOCM_DSR: ::c_int = 256; -pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; -pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; -pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4; pub const O_DIRECT: ::c_int = 16384; pub const O_DIRECTORY: ::c_int = 65536; pub const O_LARGEFILE: ::c_int = 0o0100000; @@ -293,7 +250,6 @@ pub const MAP_HUGETLB: ::c_int = 262144; pub const MAP_LOCKED: ::c_int = 8192; pub const MAP_NORESERVE: ::c_int = 16384; pub const MAP_ANON: ::c_int = 32; -pub const MAP_ANONYMOUS: ::c_int = 32; pub const MAP_DENYWRITE: ::c_int = 2048; pub const MAP_EXECUTABLE: ::c_int = 4096; pub const MAP_POPULATE: ::c_int = 32768; @@ -306,9 +262,6 @@ pub const ENOTNAM: ::c_int = 118; pub const ENAVAIL: ::c_int = 119; pub const EISNAM: ::c_int = 120; pub const EREMOTEIO: ::c_int = 121; -pub const FIOCLEX: ::c_int = 21585; -pub const FIONCLEX: ::c_int = 21584; -pub const FIONBIO: ::c_int = 21537; pub const MCL_CURRENT: ::c_int = 1; pub const MCL_FUTURE: ::c_int = 2; pub const MCL_ONFAULT: ::c_int = 4; @@ -365,24 +318,6 @@ pub const BSDLY: ::tcflag_t = 8192; pub const FFDLY: ::tcflag_t = 32768; pub const VTDLY: ::tcflag_t = 16384; pub const XTABS: ::tcflag_t = 6144; -pub const B0: ::speed_t = 0; -pub const B50: ::speed_t = 1; -pub const B75: ::speed_t = 2; -pub const B110: ::speed_t = 3; -pub const B134: ::speed_t = 4; -pub const B150: ::speed_t = 5; -pub const B200: ::speed_t = 6; -pub const B300: ::speed_t = 7; -pub const B600: ::speed_t = 8; -pub const B1200: ::speed_t = 9; -pub const B1800: ::speed_t = 10; -pub const B2400: ::speed_t = 11; -pub const B4800: ::speed_t = 12; -pub const B9600: ::speed_t = 13; -pub const B19200: ::speed_t = 14; -pub const B38400: ::speed_t = 15; -pub const EXTA: ::speed_t = 14; -pub const EXTB: ::speed_t = 15; pub const B57600: ::speed_t = 4097; pub const B115200: ::speed_t = 4098; pub const B230400: ::speed_t = 4099; @@ -405,27 +340,6 @@ pub const IEXTEN: ::tcflag_t = 32768; pub const TOSTOP: ::tcflag_t = 256; pub const FLUSHO: ::tcflag_t = 4096; pub const EXTPROC: ::tcflag_t = 65536; -pub const TCGETS: ::c_int = 21505; -pub const TCSETS: ::c_int = 21506; -pub const TCSETSW: ::c_int = 21507; -pub const TCSETSF: ::c_int = 21508; -pub const TCGETA: ::c_int = 21509; -pub const TCSETA: ::c_int = 21510; -pub const TCSETAW: ::c_int = 21511; -pub const TCSETAF: ::c_int = 21512; -pub const TCSBRK: ::c_int = 21513; -pub const TCXONC: ::c_int = 21514; -pub const TCFLSH: ::c_int = 21515; -pub const TIOCINQ: ::c_int = 21531; -pub const TIOCGPGRP: ::c_int = 21519; -pub const TIOCSPGRP: ::c_int = 21520; -pub const TIOCOUTQ: ::c_int = 21521; -pub const TIOCGWINSZ: ::c_int = 21523; -pub const TIOCSWINSZ: ::c_int = 21524; -pub const FIONREAD: ::c_int = 21531; -pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; -pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; -pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32; pub const SYS_read: ::c_long = 63; pub const SYS_write: ::c_long = 64; diff --git a/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs b/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs index b438294834e03..e783589d2c0f3 100644 --- a/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs @@ -9,10 +9,6 @@ pub type __u64 = ::c_ulonglong; pub type __s64 = ::c_longlong; s! { - pub struct pthread_attr_t { - __size: [::c_ulong; 7], - } - pub struct stat { pub st_dev: ::dev_t, pub st_ino: ::ino_t, @@ -57,19 +53,6 @@ s! { __unused: [::c_int; 2], } - pub struct stack_t { - pub ss_sp: *mut ::c_void, - pub ss_flags: ::c_int, - pub ss_size: ::size_t, - } - - pub struct sigaction { - pub sa_sigaction: ::sighandler_t, - pub sa_mask: ::sigset_t, - pub sa_flags: ::c_int, - pub sa_restorer: ::Option, - } - pub struct ipc_perm { pub __key: ::key_t, pub uid: ::uid_t, @@ -84,19 +67,6 @@ s! { __unused2: ::c_ulong, } - pub struct shmid_ds { - pub shm_perm: ::ipc_perm, - pub shm_segsz: ::size_t, - pub shm_atime: ::time_t, - pub shm_dtime: ::time_t, - pub shm_ctime: ::time_t, - pub shm_cpid: ::pid_t, - pub shm_lpid: ::pid_t, - pub shm_nattch: ::shmatt_t, - __unused5: ::c_ulong, - __unused6: ::c_ulong, - } - #[repr(align(8))] pub struct clone_args { pub flags: ::c_ulonglong, From cbc560d7be7c565da4a11200c60e9af6c8f872e9 Mon Sep 17 00:00:00 2001 From: Andy Caldwell Date: Thu, 21 Nov 2024 20:50:12 +0000 Subject: [PATCH 15/16] musl: Rename fields to match musl headers [ squash "Re-add explicit padding in 32-bit statvfs", reword commit summary - Trevor ] (backport ) (cherry picked from commit d210d71604be00ea8d2eb2a45009591109a19465) --- src/unix/linux_like/linux/musl/mod.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 5803874f5ad0b..176ab4009e40c 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -148,6 +148,8 @@ s! { // `mips*` targets swap the `s_errno` and `s_code` fields otherwise this struct is // target-agnostic (see https://www.openwall.com/lists/musl/2016/01/27/1/2) + // + // FIXME(union): C implementation uses unions pub struct siginfo_t { pub si_signo: ::c_int, #[cfg(not(target_arch = "mips"))] @@ -177,12 +179,12 @@ s! { #[cfg(target_endian = "little")] pub f_fsid: ::c_ulong, #[cfg(target_pointer_width = "32")] - __f_unused: ::c_int, + __pad: ::c_int, #[cfg(target_endian = "big")] pub f_fsid: ::c_ulong, pub f_flag: ::c_ulong, pub f_namemax: ::c_ulong, - __f_spare: [::c_int; 6], + __f_reserved: [::c_int; 6], } pub struct statvfs64 { @@ -197,12 +199,12 @@ s! { #[cfg(target_endian = "little")] pub f_fsid: ::c_ulong, #[cfg(target_pointer_width = "32")] - __f_unused: ::c_int, + __pad: ::c_int, #[cfg(target_endian = "big")] pub f_fsid: ::c_ulong, pub f_flag: ::c_ulong, pub f_namemax: ::c_ulong, - __f_spare: [::c_int; 6], + __f_reserved: [::c_int; 6], } pub struct termios { From 2018bcab8b937dc1f0788f1fd526b902015318da Mon Sep 17 00:00:00 2001 From: Andy Caldwell Date: Sun, 6 Oct 2024 04:12:33 +0100 Subject: [PATCH 16/16] glibc: Remove redundant definitions These are redundant as they are exported from higher-level modules. [ extract this commit to only cover glibc - Trevor ] (backport ) (cherry picked from commit ca7eedd5f59e9e0a39c5dd42de64a5caf4aea7c3) --- src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs | 15 --------------- src/unix/linux_like/linux/gnu/b32/sparc/mod.rs | 15 --------------- 2 files changed, 30 deletions(-) diff --git a/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs b/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs index 464b4f560fad3..950be29a42ae7 100644 --- a/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs @@ -70,21 +70,6 @@ s! { pub f_spare: [::c_long; 4], } - pub struct statvfs { - pub f_bsize: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_favail: ::fsfilcnt_t, - pub f_fsid: ::c_ulong, - pub f_flag: ::c_ulong, - pub f_namemax: ::c_ulong, - pub __f_spare: [::c_int; 6], - } - pub struct statvfs64 { pub f_bsize: ::c_ulong, pub f_frsize: ::c_ulong, diff --git a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs index 189ec8f05a0c3..fac8cd0a85d83 100644 --- a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs @@ -94,21 +94,6 @@ s! { pub f_spare: [::__fsword_t; 4], } - pub struct statvfs { - pub f_bsize: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_favail: ::fsfilcnt_t, - pub f_fsid: ::c_ulong, - pub f_flag: ::c_ulong, - pub f_namemax: ::c_ulong, - __f_spare: [::c_int; 6], - } - pub struct statvfs64 { pub f_bsize: ::c_ulong, pub f_frsize: ::c_ulong,