summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-12-21 15:36:35 +0000
committerbors <bors@rust-lang.org>2020-12-21 15:36:35 +0000
commitc7b9771cee8ff72954fc013d896e3b703c16db05 (patch)
tree6d68154777f204e988a5446d17f45bd2b7bd1930
parent7bc84dab6a9d546c738664e0b336be49ad5b5e74 (diff)
parent3d09b9f67c599ad61e4677d9d723b692a822c241 (diff)
downloadrust-libc-c7b9771cee8ff72954fc013d896e3b703c16db05.tar.gz
Auto merge of #1999 - Jakob-Naucke:fix-statfs-magic-s390x, r=JohnTitor
Declare statfs MAGIC constants as c_uint on s390x Hi, I work in container development on Linux on Z at IBM. On s390x (IBM Z) in GNU/Linux, a statfs `f_type` is 4 bytes wide, contrary to 8 bytes on most architectures. This is already implemented in libc: ```sh $ grep -r f_type src/unix/linux_like/linux/gnu/b64 | uniq src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs: pub f_type: ::__fsword_t, src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs: pub f_type: ::__fsword_t, src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs: pub f_type: ::__fsword_t, src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs: pub f_type: ::c_long, src/unix/linux_like/linux/gnu/b64/mips64/mod.rs: pub f_type: ::c_long, src/unix/linux_like/linux/gnu/b64/s390x.rs: pub f_type: ::c_uint, # s390x is uint src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs: pub f_type: ::__fsword_t, ``` However, the `*_MAGIC` constants (such as `EXT4_SUPER_MAGIC`) in `src/unix/linux_like/linux/gnu/mod.rs` are defined as `c_long`, when they should be `c_uint` on s390x. This ends up biting me [here](https://github.com/kata-containers/cgroups-rs/blob/master/src/hierarchies.rs#L231). Thus, I suggest the attached change to only define these constants for architectures other than s390x and instead define them as uint for s390x. This is safe since none of the constants are any wider than 32bit. Please let me know if you think this could be done more elegantly.
-rw-r--r--src/unix/linux_like/linux/gnu/mod.rs155
1 files changed, 105 insertions, 50 deletions
diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs
index d54dd57444..5762a3d780 100644
--- a/src/unix/linux_like/linux/gnu/mod.rs
+++ b/src/unix/linux_like/linux/gnu/mod.rs
@@ -724,56 +724,111 @@ pub const O_ACCMODE: ::c_int = 3;
pub const ST_RELATIME: ::c_ulong = 4096;
pub const NI_MAXHOST: ::socklen_t = 1025;
-pub const ADFS_SUPER_MAGIC: ::c_long = 0x0000adf5;
-pub const AFFS_SUPER_MAGIC: ::c_long = 0x0000adff;
-pub const AFS_SUPER_MAGIC: ::c_long = 0x5346414f;
-pub const AUTOFS_SUPER_MAGIC: ::c_long = 0x0187;
-pub const BINDERFS_SUPER_MAGIC: ::c_long = 0x6c6f6f70;
-pub const BPF_FS_MAGIC: ::c_long = 0xcafe4a11;
-pub const BTRFS_SUPER_MAGIC: ::c_long = 0x9123683e;
-pub const CGROUP2_SUPER_MAGIC: ::c_long = 0x63677270;
-pub const CGROUP_SUPER_MAGIC: ::c_long = 0x27e0eb;
-pub const CODA_SUPER_MAGIC: ::c_long = 0x73757245;
-pub const CRAMFS_MAGIC: ::c_long = 0x28cd3d45;
-pub const DEBUGFS_MAGIC: ::c_long = 0x64626720;
-pub const DEVPTS_SUPER_MAGIC: ::c_long = 0x1cd1;
-pub const ECRYPTFS_SUPER_MAGIC: ::c_long = 0xf15f;
-pub const EFS_SUPER_MAGIC: ::c_long = 0x00414a53;
-pub const EXT2_SUPER_MAGIC: ::c_long = 0x0000ef53;
-pub const EXT3_SUPER_MAGIC: ::c_long = 0x0000ef53;
-pub const EXT4_SUPER_MAGIC: ::c_long = 0x0000ef53;
-pub const F2FS_SUPER_MAGIC: ::c_long = 0xf2f52010;
-pub const FUTEXFS_SUPER_MAGIC: ::c_long = 0xbad1dea;
-pub const HOSTFS_SUPER_MAGIC: ::c_long = 0x00c0ffee;
-pub const HPFS_SUPER_MAGIC: ::c_long = 0xf995e849;
-pub const HUGETLBFS_MAGIC: ::c_long = 0x958458f6;
-pub const ISOFS_SUPER_MAGIC: ::c_long = 0x00009660;
-pub const JFFS2_SUPER_MAGIC: ::c_long = 0x000072b6;
-pub const MINIX2_SUPER_MAGIC2: ::c_long = 0x00002478;
-pub const MINIX2_SUPER_MAGIC: ::c_long = 0x00002468;
-pub const MINIX3_SUPER_MAGIC: ::c_long = 0x4d5a;
-pub const MINIX_SUPER_MAGIC2: ::c_long = 0x0000138f;
-pub const MINIX_SUPER_MAGIC: ::c_long = 0x0000137f;
-pub const MSDOS_SUPER_MAGIC: ::c_long = 0x00004d44;
-pub const NCP_SUPER_MAGIC: ::c_long = 0x0000564c;
-pub const NFS_SUPER_MAGIC: ::c_long = 0x00006969;
-pub const NILFS_SUPER_MAGIC: ::c_long = 0x3434;
-pub const OCFS2_SUPER_MAGIC: ::c_long = 0x7461636f;
-pub const OPENPROM_SUPER_MAGIC: ::c_long = 0x00009fa1;
-pub const OVERLAYFS_SUPER_MAGIC: ::c_long = 0x794c7630;
-pub const PROC_SUPER_MAGIC: ::c_long = 0x00009fa0;
-pub const QNX4_SUPER_MAGIC: ::c_long = 0x0000002f;
-pub const QNX6_SUPER_MAGIC: ::c_long = 0x68191122;
-pub const RDTGROUP_SUPER_MAGIC: ::c_long = 0x7655821;
-pub const REISERFS_SUPER_MAGIC: ::c_long = 0x52654973;
-pub const SMB_SUPER_MAGIC: ::c_long = 0x0000517b;
-pub const SYSFS_MAGIC: ::c_long = 0x62656572;
-pub const TMPFS_MAGIC: ::c_long = 0x01021994;
-pub const TRACEFS_MAGIC: ::c_long = 0x74726163;
-pub const UDF_SUPER_MAGIC: ::c_long = 0x15013346;
-pub const USBDEVICE_SUPER_MAGIC: ::c_long = 0x00009fa2;
-pub const XENFS_SUPER_MAGIC: ::c_long = 0xabba1974;
-pub const XFS_SUPER_MAGIC: ::c_long = 0x58465342;
+cfg_if! {
+ if #[cfg(not(target_arch = "s390x"))] {
+ pub const ADFS_SUPER_MAGIC: ::c_long = 0x0000adf5;
+ pub const AFFS_SUPER_MAGIC: ::c_long = 0x0000adff;
+ pub const AFS_SUPER_MAGIC: ::c_long = 0x5346414f;
+ pub const AUTOFS_SUPER_MAGIC: ::c_long = 0x0187;
+ pub const BINDERFS_SUPER_MAGIC: ::c_long = 0x6c6f6f70;
+ pub const BPF_FS_MAGIC: ::c_long = 0xcafe4a11;
+ pub const BTRFS_SUPER_MAGIC: ::c_long = 0x9123683e;
+ pub const CGROUP2_SUPER_MAGIC: ::c_long = 0x63677270;
+ pub const CGROUP_SUPER_MAGIC: ::c_long = 0x27e0eb;
+ pub const CODA_SUPER_MAGIC: ::c_long = 0x73757245;
+ pub const CRAMFS_MAGIC: ::c_long = 0x28cd3d45;
+ pub const DEBUGFS_MAGIC: ::c_long = 0x64626720;
+ pub const DEVPTS_SUPER_MAGIC: ::c_long = 0x1cd1;
+ pub const ECRYPTFS_SUPER_MAGIC: ::c_long = 0xf15f;
+ pub const EFS_SUPER_MAGIC: ::c_long = 0x00414a53;
+ pub const EXT2_SUPER_MAGIC: ::c_long = 0x0000ef53;
+ pub const EXT3_SUPER_MAGIC: ::c_long = 0x0000ef53;
+ pub const EXT4_SUPER_MAGIC: ::c_long = 0x0000ef53;
+ pub const F2FS_SUPER_MAGIC: ::c_long = 0xf2f52010;
+ pub const FUTEXFS_SUPER_MAGIC: ::c_long = 0xbad1dea;
+ pub const HOSTFS_SUPER_MAGIC: ::c_long = 0x00c0ffee;
+ pub const HPFS_SUPER_MAGIC: ::c_long = 0xf995e849;
+ pub const HUGETLBFS_MAGIC: ::c_long = 0x958458f6;
+ pub const ISOFS_SUPER_MAGIC: ::c_long = 0x00009660;
+ pub const JFFS2_SUPER_MAGIC: ::c_long = 0x000072b6;
+ pub const MINIX2_SUPER_MAGIC2: ::c_long = 0x00002478;
+ pub const MINIX2_SUPER_MAGIC: ::c_long = 0x00002468;
+ pub const MINIX3_SUPER_MAGIC: ::c_long = 0x4d5a;
+ pub const MINIX_SUPER_MAGIC2: ::c_long = 0x0000138f;
+ pub const MINIX_SUPER_MAGIC: ::c_long = 0x0000137f;
+ pub const MSDOS_SUPER_MAGIC: ::c_long = 0x00004d44;
+ pub const NCP_SUPER_MAGIC: ::c_long = 0x0000564c;
+ pub const NFS_SUPER_MAGIC: ::c_long = 0x00006969;
+ pub const NILFS_SUPER_MAGIC: ::c_long = 0x3434;
+ pub const OCFS2_SUPER_MAGIC: ::c_long = 0x7461636f;
+ pub const OPENPROM_SUPER_MAGIC: ::c_long = 0x00009fa1;
+ pub const OVERLAYFS_SUPER_MAGIC: ::c_long = 0x794c7630;
+ pub const PROC_SUPER_MAGIC: ::c_long = 0x00009fa0;
+ pub const QNX4_SUPER_MAGIC: ::c_long = 0x0000002f;
+ pub const QNX6_SUPER_MAGIC: ::c_long = 0x68191122;
+ pub const RDTGROUP_SUPER_MAGIC: ::c_long = 0x7655821;
+ pub const REISERFS_SUPER_MAGIC: ::c_long = 0x52654973;
+ pub const SMB_SUPER_MAGIC: ::c_long = 0x0000517b;
+ pub const SYSFS_MAGIC: ::c_long = 0x62656572;
+ pub const TMPFS_MAGIC: ::c_long = 0x01021994;
+ pub const TRACEFS_MAGIC: ::c_long = 0x74726163;
+ pub const UDF_SUPER_MAGIC: ::c_long = 0x15013346;
+ pub const USBDEVICE_SUPER_MAGIC: ::c_long = 0x00009fa2;
+ pub const XENFS_SUPER_MAGIC: ::c_long = 0xabba1974;
+ pub const XFS_SUPER_MAGIC: ::c_long = 0x58465342;
+ } else if #[cfg(target_arch = "s390x")] {
+ pub const ADFS_SUPER_MAGIC: ::c_uint = 0x0000adf5;
+ pub const AFFS_SUPER_MAGIC: ::c_uint = 0x0000adff;
+ pub const AFS_SUPER_MAGIC: ::c_uint = 0x5346414f;
+ pub const AUTOFS_SUPER_MAGIC: ::c_uint = 0x0187;
+ pub const BINDERFS_SUPER_MAGIC: ::c_uint = 0x6c6f6f70;
+ pub const BPF_FS_MAGIC: ::c_uint = 0xcafe4a11;
+ pub const BTRFS_SUPER_MAGIC: ::c_uint = 0x9123683e;
+ pub const CGROUP2_SUPER_MAGIC: ::c_uint = 0x63677270;
+ pub const CGROUP_SUPER_MAGIC: ::c_uint = 0x27e0eb;
+ pub const CODA_SUPER_MAGIC: ::c_uint = 0x73757245;
+ pub const CRAMFS_MAGIC: ::c_uint = 0x28cd3d45;
+ pub const DEBUGFS_MAGIC: ::c_uint = 0x64626720;
+ pub const DEVPTS_SUPER_MAGIC: ::c_uint = 0x1cd1;
+ pub const ECRYPTFS_SUPER_MAGIC: ::c_uint = 0xf15f;
+ pub const EFS_SUPER_MAGIC: ::c_uint = 0x00414a53;
+ pub const EXT2_SUPER_MAGIC: ::c_uint = 0x0000ef53;
+ pub const EXT3_SUPER_MAGIC: ::c_uint = 0x0000ef53;
+ pub const EXT4_SUPER_MAGIC: ::c_uint = 0x0000ef53;
+ pub const F2FS_SUPER_MAGIC: ::c_uint = 0xf2f52010;
+ pub const FUTEXFS_SUPER_MAGIC: ::c_uint = 0xbad1dea;
+ pub const HOSTFS_SUPER_MAGIC: ::c_uint = 0x00c0ffee;
+ pub const HPFS_SUPER_MAGIC: ::c_uint = 0xf995e849;
+ pub const HUGETLBFS_MAGIC: ::c_uint = 0x958458f6;
+ pub const ISOFS_SUPER_MAGIC: ::c_uint = 0x00009660;
+ pub const JFFS2_SUPER_MAGIC: ::c_uint = 0x000072b6;
+ pub const MINIX2_SUPER_MAGIC2: ::c_uint = 0x00002478;
+ pub const MINIX2_SUPER_MAGIC: ::c_uint = 0x00002468;
+ pub const MINIX3_SUPER_MAGIC: ::c_uint = 0x4d5a;
+ pub const MINIX_SUPER_MAGIC2: ::c_uint = 0x0000138f;
+ pub const MINIX_SUPER_MAGIC: ::c_uint = 0x0000137f;
+ pub const MSDOS_SUPER_MAGIC: ::c_uint = 0x00004d44;
+ pub const NCP_SUPER_MAGIC: ::c_uint = 0x0000564c;
+ pub const NFS_SUPER_MAGIC: ::c_uint = 0x00006969;
+ pub const NILFS_SUPER_MAGIC: ::c_uint = 0x3434;
+ pub const OCFS2_SUPER_MAGIC: ::c_uint = 0x7461636f;
+ pub const OPENPROM_SUPER_MAGIC: ::c_uint = 0x00009fa1;
+ pub const OVERLAYFS_SUPER_MAGIC: ::c_uint = 0x794c7630;
+ pub const PROC_SUPER_MAGIC: ::c_uint = 0x00009fa0;
+ pub const QNX4_SUPER_MAGIC: ::c_uint = 0x0000002f;
+ pub const QNX6_SUPER_MAGIC: ::c_uint = 0x68191122;
+ pub const RDTGROUP_SUPER_MAGIC: ::c_uint = 0x7655821;
+ pub const REISERFS_SUPER_MAGIC: ::c_uint = 0x52654973;
+ pub const SMB_SUPER_MAGIC: ::c_uint = 0x0000517b;
+ pub const SYSFS_MAGIC: ::c_uint = 0x62656572;
+ pub const TMPFS_MAGIC: ::c_uint = 0x01021994;
+ pub const TRACEFS_MAGIC: ::c_uint = 0x74726163;
+ pub const UDF_SUPER_MAGIC: ::c_uint = 0x15013346;
+ pub const USBDEVICE_SUPER_MAGIC: ::c_uint = 0x00009fa2;
+ pub const XENFS_SUPER_MAGIC: ::c_uint = 0xabba1974;
+ pub const XFS_SUPER_MAGIC: ::c_uint = 0x58465342;
+ }
+}
pub const CPU_SETSIZE: ::c_int = 0x400;