From 3be48b4f26451e65df415eb1428683ac287eb747 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sat, 6 Jun 2026 21:55:13 +0100 Subject: [PATCH] adding OPEN_TREE_NAMESPACE and fsopen/fsconfig/fsmount/fspick constants for Linux (7.0) rust-lang/libc#5072 [ref](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/mount.h?h=v7.0) --- libc-test/build.rs | 13 +++++++++++++ libc-test/semver/linux.txt | 17 +++++++++++++++++ src/unix/linux_like/linux/mod.rs | 24 ++++++++++++++++++++++++ 3 files changed, 54 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index c5b49558ce9f..2954209a674f 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -4198,6 +4198,14 @@ fn test_linux(target: &str) { cfg.skip_const(move |constant| { let name = constant.ident(); + // FIXME(linux): Requires newer kernel headers than CI has. These uapi/linux/mount.h + // constants (OPEN_TREE_NAMESPACE landed in v7.0, FSCONFIG_CMD_CREATE_EXCL in v6.6) + // aren't defined by the headers CI builds against on several targets (notably the + // tier2 cross sysroots), so skip on every libc until CI catches up. + if name == "OPEN_TREE_NAMESPACE" || name == "FSCONFIG_CMD_CREATE_EXCL" { + return true; + } + // L4Re requires a min stack size of 64k; that isn't defined in uClibc, but // somewhere in the core libraries. uClibc wants 16k, but that's not enough. if l4re && name == "PTHREAD_STACK_MIN" { @@ -4220,6 +4228,10 @@ fn test_linux(target: &str) { || name.starts_with("EPOLL") || name.starts_with("F_") || name.starts_with("FALLOC_FL_") + || name.starts_with("FSCONFIG_") + || name.starts_with("FSMOUNT_") + || name.starts_with("FSOPEN_") + || name.starts_with("FSPICK_") || name.starts_with("FUTEX2_") || name.starts_with("IFLA_") || name.starts_with("KEXEC_") @@ -4561,6 +4573,7 @@ fn test_linux(target: &str) { let c_enums = [ "can_state", + "fsconfig_command", "membarrier_cmd", "pid_type", "proc_cn_event", diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index 3d1c73dca9ef..940297916080 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -901,6 +901,21 @@ FIONCLEX FIONREAD FLUSHO FOPEN_MAX +FSCONFIG_CMD_CREATE +FSCONFIG_CMD_CREATE_EXCL +FSCONFIG_CMD_RECONFIGURE +FSCONFIG_SET_BINARY +FSCONFIG_SET_FD +FSCONFIG_SET_FLAG +FSCONFIG_SET_PATH +FSCONFIG_SET_PATH_EMPTY +FSCONFIG_SET_STRING +FSMOUNT_CLOEXEC +FSOPEN_CLOEXEC +FSPICK_CLOEXEC +FSPICK_EMPTY_PATH +FSPICK_NO_AUTOMOUNT +FSPICK_SYMLINK_NOFOLLOW FS_IOC32_GETFLAGS FS_IOC32_GETVERSION FS_IOC32_SETFLAGS @@ -2205,6 +2220,7 @@ OFILL OLCUC OPEN_TREE_CLOEXEC OPEN_TREE_CLONE +OPEN_TREE_NAMESPACE O_ASYNC O_DIRECT O_DSYNC @@ -4109,6 +4125,7 @@ freeifaddrs freelocale fremovexattr freopen64 +fsconfig_command fseeko64 fsetpos64 fsetxattr diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 081b16d78ce3..ccdc5baf9e31 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -3106,8 +3106,32 @@ pub const IN_NONBLOCK: c_int = O_NONBLOCK; // uapi/linux/mount.h pub const OPEN_TREE_CLONE: c_uint = 0x01; +pub const OPEN_TREE_NAMESPACE: c_uint = 0x02; pub const OPEN_TREE_CLOEXEC: c_uint = O_CLOEXEC as c_uint; +pub const FSOPEN_CLOEXEC: c_uint = 0x00000001; + +pub const FSPICK_CLOEXEC: c_uint = 0x00000001; +pub const FSPICK_SYMLINK_NOFOLLOW: c_uint = 0x00000002; +pub const FSPICK_NO_AUTOMOUNT: c_uint = 0x00000004; +pub const FSPICK_EMPTY_PATH: c_uint = 0x00000008; + +pub const FSMOUNT_CLOEXEC: c_uint = 0x00000001; + +c_enum! { + pub enum fsconfig_command { + pub FSCONFIG_SET_FLAG, + pub FSCONFIG_SET_STRING, + pub FSCONFIG_SET_BINARY, + pub FSCONFIG_SET_PATH, + pub FSCONFIG_SET_PATH_EMPTY, + pub FSCONFIG_SET_FD, + pub FSCONFIG_CMD_CREATE, + pub FSCONFIG_CMD_RECONFIGURE, + pub FSCONFIG_CMD_CREATE_EXCL, + } +} + // uapi/linux/netfilter/nf_tables.h pub const NFT_TABLE_MAXNAMELEN: c_int = 256; pub const NFT_CHAIN_MAXNAMELEN: c_int = 256;