Skip to content

Commit bd74cd2

Browse files
authored
Merge pull request #4436 from rusty-snake/ioctl_nsfs
Add constants and types for nsfs ioctls
2 parents 76baec6 + 0d7f0ce commit bd74cd2

File tree

3 files changed

+56
-6
lines changed

3 files changed

+56
-6
lines changed

libc-test/build.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3825,6 +3825,7 @@ fn test_linux(target: &str) {
38253825
"linux/netfilter_ipv6.h",
38263826
"linux/netfilter_ipv6/ip6_tables.h",
38273827
"linux/netlink.h",
3828+
"linux/nsfs.h",
38283829
"linux/openat2.h",
38293830
// FIXME(linux): some items require Linux >= 5.6:
38303831
"linux/ptp_clock.h",
@@ -4118,6 +4119,9 @@ fn test_linux(target: &str) {
41184119
// FIXME(linux): Requires >= 6.12 kernel headers.
41194120
"dmabuf_cmsg" | "dmabuf_token" => true,
41204121

4122+
// FIXME(linux): Requires >= 6.12 kernel headers.
4123+
"mnt_ns_info" => true,
4124+
41214125
// FIXME(linux): Requires >= 6.4 kernel headers.
41224126
"ptrace_sud_config" => true,
41234127

@@ -4523,6 +4527,11 @@ fn test_linux(target: &str) {
45234527
true
45244528
}
45254529

4530+
// FIXME(linux): Requires >= 6.11 kernel headers.
4531+
"NS_GET_MNTNS_ID" | "NS_GET_PID_FROM_PIDNS" | "NS_GET_TGID_FROM_PIDNS" | "NS_GET_PID_IN_PIDNS" | "NS_GET_TGID_IN_PIDNS" => true,
4532+
// FIXME(linux): Requires >= 6.12 kernel headers.
4533+
"MNT_NS_INFO_SIZE_VER0" | "NS_MNT_GET_INFO" | "NS_MNT_GET_NEXT" | "NS_MNT_GET_PREV" => true,
4534+
45264535
// FIXME(linux): Requires >= 6.6 kernel headers.
45274536
"SYS_fchmodat2" => true,
45284537

@@ -4877,8 +4886,8 @@ fn test_linux_like_apis(target: &str) {
48774886
"strerror_r" => false,
48784887
_ => true,
48794888
})
4880-
.skip_const(|_| true)
4881-
.skip_struct(|_| true);
4889+
.skip_const(|_| true)
4890+
.skip_struct(|_| true);
48824891
cfg.generate(src_hotfix_dir().join("lib.rs"), "linux_strerror_r.rs");
48834892
}
48844893

@@ -4952,10 +4961,10 @@ fn test_linux_like_apis(target: &str) {
49524961
.skip_const(|_| true)
49534962
.skip_struct(|_| true)
49544963
.skip_const(move |name| match name {
4955-
"IPV6_FLOWINFO"
4956-
| "IPV6_FLOWLABEL_MGR"
4957-
| "IPV6_FLOWINFO_SEND"
4958-
| "IPV6_FLOWINFO_FLOWLABEL"
4964+
"IPV6_FLOWINFO"
4965+
| "IPV6_FLOWLABEL_MGR"
4966+
| "IPV6_FLOWINFO_SEND"
4967+
| "IPV6_FLOWINFO_FLOWLABEL"
49594968
| "IPV6_FLOWINFO_PRIORITY" => false,
49604969
_ => true,
49614970
})

libc-test/semver/linux.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1667,6 +1667,7 @@ MMAP_PAGE_ZERO
16671667
MNT_DETACH
16681668
MNT_EXPIRE
16691669
MNT_FORCE
1670+
MNT_NS_INFO_SIZE_VER0
16701671
MODULE_INIT_IGNORE_MODVERSIONS
16711672
MODULE_INIT_IGNORE_VERMAGIC
16721673
MON_1
@@ -2022,6 +2023,18 @@ NLM_F_REQUEST
20222023
NLM_F_ROOT
20232024
NOEXPR
20242025
NOSTR
2026+
NS_GET_MNTNS_ID
2027+
NS_GET_NSTYPE
2028+
NS_GET_OWNER_UID
2029+
NS_GET_PARENT
2030+
NS_GET_PID_FROM_PIDNS
2031+
NS_GET_PID_IN_PIDNS
2032+
NS_GET_TGID_FROM_PIDNS
2033+
NS_GET_TGID_IN_PIDNS
2034+
NS_GET_USERNS
2035+
NS_MNT_GET_INFO
2036+
NS_MNT_GET_NEXT
2037+
NS_MNT_GET_PREV
20252038
NTF_PROXY
20262039
NTF_ROUTER
20272040
NTF_SELF

src/unix/linux_like/linux/mod.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,6 +1376,13 @@ s! {
13761376
pub userns_fd: crate::__u64,
13771377
}
13781378

1379+
// linux/nsfs.h
1380+
pub struct mnt_ns_info {
1381+
pub size: crate::__u32,
1382+
pub nr_mounts: crate::__u32,
1383+
pub mnt_ns_id: crate::__u64,
1384+
}
1385+
13791386
// linux/pidfd.h
13801387

13811388
pub struct pidfd_info {
@@ -3172,6 +3179,27 @@ pub const MREMAP_MAYMOVE: c_int = 1;
31723179
pub const MREMAP_FIXED: c_int = 2;
31733180
pub const MREMAP_DONTUNMAP: c_int = 4;
31743181

3182+
// linux/nsfs.h
3183+
const NSIO: c_uint = 0xb7;
3184+
3185+
pub const NS_GET_USERNS: c_uint = _IO(NSIO, 0x1);
3186+
pub const NS_GET_PARENT: c_uint = _IO(NSIO, 0x2);
3187+
pub const NS_GET_NSTYPE: c_uint = _IO(NSIO, 0x3);
3188+
pub const NS_GET_OWNER_UID: c_uint = _IO(NSIO, 0x4);
3189+
3190+
pub const NS_GET_MNTNS_ID: c_uint = _IOR::<__u64>(NSIO, 0x5);
3191+
3192+
pub const NS_GET_PID_FROM_PIDNS: c_uint = _IOR::<c_int>(NSIO, 0x6);
3193+
pub const NS_GET_TGID_FROM_PIDNS: c_uint = _IOR::<c_int>(NSIO, 0x7);
3194+
pub const NS_GET_PID_IN_PIDNS: c_uint = _IOR::<c_int>(NSIO, 0x8);
3195+
pub const NS_GET_TGID_IN_PIDNS: c_uint = _IOR::<c_int>(NSIO, 0x9);
3196+
3197+
pub const MNT_NS_INFO_SIZE_VER0: c_uint = 16;
3198+
3199+
pub const NS_MNT_GET_INFO: c_uint = _IOR::<mnt_ns_info>(NSIO, 10);
3200+
pub const NS_MNT_GET_NEXT: c_uint = _IOR::<mnt_ns_info>(NSIO, 11);
3201+
pub const NS_MNT_GET_PREV: c_uint = _IOR::<mnt_ns_info>(NSIO, 12);
3202+
31753203
// linux/pidfd.h
31763204
pub const PIDFD_NONBLOCK: c_uint = O_NONBLOCK as c_uint;
31773205
pub const PIDFD_THREAD: c_uint = O_EXCL as c_uint;

0 commit comments

Comments
 (0)