From 6898024026e503b8d13f42efa5d854d85591ba20 Mon Sep 17 00:00:00 2001 From: Jakob Naucke Date: Fri, 8 Jan 2021 15:47:41 +0100 Subject: [PATCH 1/2] Define *_MAGIC filesystem constants on Linux s390x Since rust-lang/libc is now using the correct data type on s390x (c_uint) for statfs constants, the s390x exemptions in the statfs MAGIC definitions like EXT4_SUPER_MAGIC can be removed. Signed-off-by: Jakob Naucke --- CHANGELOG.md | 3 +++ Cargo.toml | 2 +- src/sys/statfs.rs | 58 +++++++++++++++++++++++------------------------ 3 files changed, 33 insertions(+), 30 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 54295f5d81..999724781f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,9 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Added limited Fuchsia support (#[1285](https://github.com/nix-rust/nix/pull/1285)) - Added `getpeereid` (#[1342](https://github.com/nix-rust/nix/pull/1342)) ### Fixed +- Define `*_MAGIC` filesystem constants on Linux s390x + (#[1372](https://github.com/nix-rust/nix/pull/1372)) + ### Changed - Minimum supported Rust version is now 1.40.0. diff --git a/Cargo.toml b/Cargo.toml index 8c12b6dc5b..c74889b0cc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,7 +31,7 @@ targets = [ ] [dependencies] -libc = { version = "0.2.78", features = [ "extra_traits" ] } +libc = { version = "0.2.82", features = [ "extra_traits" ] } bitflags = "1.1" cfg-if = "1.0" diff --git a/src/sys/statfs.rs b/src/sys/statfs.rs index 8e90a58d8f..924d293fe9 100644 --- a/src/sys/statfs.rs +++ b/src/sys/statfs.rs @@ -31,63 +31,63 @@ pub struct FsType(pub libc::c_ulong); #[derive(Eq, Copy, Clone, PartialEq, Debug)] pub struct FsType(pub libc::c_long); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const ADFS_SUPER_MAGIC: FsType = FsType(libc::ADFS_SUPER_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const AFFS_SUPER_MAGIC: FsType = FsType(libc::AFFS_SUPER_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const CODA_SUPER_MAGIC: FsType = FsType(libc::CODA_SUPER_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const CRAMFS_MAGIC: FsType = FsType(libc::CRAMFS_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const EFS_SUPER_MAGIC: FsType = FsType(libc::EFS_SUPER_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const EXT2_SUPER_MAGIC: FsType = FsType(libc::EXT2_SUPER_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const EXT3_SUPER_MAGIC: FsType = FsType(libc::EXT3_SUPER_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const EXT4_SUPER_MAGIC: FsType = FsType(libc::EXT4_SUPER_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const HPFS_SUPER_MAGIC: FsType = FsType(libc::HPFS_SUPER_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const HUGETLBFS_MAGIC: FsType = FsType(libc::HUGETLBFS_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const ISOFS_SUPER_MAGIC: FsType = FsType(libc::ISOFS_SUPER_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const JFFS2_SUPER_MAGIC: FsType = FsType(libc::JFFS2_SUPER_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const MINIX_SUPER_MAGIC: FsType = FsType(libc::MINIX_SUPER_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const MINIX_SUPER_MAGIC2: FsType = FsType(libc::MINIX_SUPER_MAGIC2); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const MINIX2_SUPER_MAGIC: FsType = FsType(libc::MINIX2_SUPER_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const MINIX2_SUPER_MAGIC2: FsType = FsType(libc::MINIX2_SUPER_MAGIC2); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const MSDOS_SUPER_MAGIC: FsType = FsType(libc::MSDOS_SUPER_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const NCP_SUPER_MAGIC: FsType = FsType(libc::NCP_SUPER_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const NFS_SUPER_MAGIC: FsType = FsType(libc::NFS_SUPER_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const OPENPROM_SUPER_MAGIC: FsType = FsType(libc::OPENPROM_SUPER_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const OVERLAYFS_SUPER_MAGIC: FsType = FsType(libc::OVERLAYFS_SUPER_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const PROC_SUPER_MAGIC: FsType = FsType(libc::PROC_SUPER_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const QNX4_SUPER_MAGIC: FsType = FsType(libc::QNX4_SUPER_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const REISERFS_SUPER_MAGIC: FsType = FsType(libc::REISERFS_SUPER_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const SMB_SUPER_MAGIC: FsType = FsType(libc::SMB_SUPER_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const TMPFS_MAGIC: FsType = FsType(libc::TMPFS_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const USBDEVICE_SUPER_MAGIC: FsType = FsType(libc::USBDEVICE_SUPER_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const CGROUP_SUPER_MAGIC: FsType = FsType(libc::CGROUP_SUPER_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const CGROUP2_SUPER_MAGIC: FsType = FsType(libc::CGROUP2_SUPER_MAGIC); impl Statfs { From 8dc757bb545a7a3f1339ae69abcb649e38700cca Mon Sep 17 00:00:00 2001 From: Ben Linsay Date: Sat, 26 Sep 2020 19:50:27 -0400 Subject: [PATCH 2/2] add passwords to Groups --- CHANGELOG.md | 2 ++ src/unistd.rs | 3 +++ 2 files changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 999724781f..a109b7f169 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] - ReleaseDate ### Added + +- Added a `passwd` field to `Group` (#[1338](https://github.com/nix-rust/nix/pull/1338)) - Added `mremap` (#[1306](https://github.com/nix-rust/nix/pull/1306)) - Added `personality` (#[1331](https://github.com/nix-rust/nix/pull/1331)) - Added limited Fuchsia support (#[1285](https://github.com/nix-rust/nix/pull/1285)) diff --git a/src/unistd.rs b/src/unistd.rs index dd33559624..7a4517e65f 100644 --- a/src/unistd.rs +++ b/src/unistd.rs @@ -2671,6 +2671,8 @@ impl User { pub struct Group { /// Group name pub name: String, + /// Group password + pub passwd: CString, /// Group ID pub gid: Gid, /// List of Group members @@ -2683,6 +2685,7 @@ impl From<&libc::group> for Group { unsafe { Group { name: CStr::from_ptr((*gr).gr_name).to_string_lossy().into_owned(), + passwd: CString::new(CStr::from_ptr((*gr).gr_passwd).to_bytes()).unwrap(), gid: Gid::from_raw((*gr).gr_gid), mem: Group::members((*gr).gr_mem) }