Skip to content

Commit 2bb4cea

Browse files
rusty-snaketgross35
authored andcommitted
Add constants and types for nsfs ioctls
(backport <rust-lang#4436>) (cherry picked from commit 0d7f0ce)
1 parent a598506 commit 2bb4cea

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
@@ -3899,6 +3899,7 @@ fn test_linux(target: &str) {
38993899
"linux/netfilter_ipv6.h",
39003900
"linux/netfilter_ipv6/ip6_tables.h",
39013901
"linux/netlink.h",
3902+
"linux/nsfs.h",
39023903
"linux/openat2.h",
39033904
// FIXME(linux): some items require Linux >= 5.6:
39043905
"linux/ptp_clock.h",
@@ -4192,6 +4193,9 @@ fn test_linux(target: &str) {
41924193
// FIXME(linux): Requires >= 6.12 kernel headers.
41934194
"dmabuf_cmsg" | "dmabuf_token" => true,
41944195

4196+
// FIXME(linux): Requires >= 6.12 kernel headers.
4197+
"mnt_ns_info" => true,
4198+
41954199
// FIXME(linux): Requires >= 6.4 kernel headers.
41964200
"ptrace_sud_config" => true,
41974201

@@ -4597,6 +4601,11 @@ fn test_linux(target: &str) {
45974601
true
45984602
}
45994603

4604+
// FIXME(linux): Requires >= 6.11 kernel headers.
4605+
"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,
4606+
// FIXME(linux): Requires >= 6.12 kernel headers.
4607+
"MNT_NS_INFO_SIZE_VER0" | "NS_MNT_GET_INFO" | "NS_MNT_GET_NEXT" | "NS_MNT_GET_PREV" => true,
4608+
46004609
// FIXME(linux): Requires >= 6.6 kernel headers.
46014610
"SYS_fchmodat2" => true,
46024611

@@ -4952,8 +4961,8 @@ fn test_linux_like_apis(target: &str) {
49524961
"strerror_r" => false,
49534962
_ => true,
49544963
})
4955-
.skip_const(|_| true)
4956-
.skip_struct(|_| true);
4964+
.skip_const(|_| true)
4965+
.skip_struct(|_| true);
49574966
cfg.generate(src_hotfix_dir().join("lib.rs"), "linux_strerror_r.rs");
49584967
}
49594968

@@ -5027,10 +5036,10 @@ fn test_linux_like_apis(target: &str) {
50275036
.skip_const(|_| true)
50285037
.skip_struct(|_| true)
50295038
.skip_const(move |name| match name {
5030-
"IPV6_FLOWINFO"
5031-
| "IPV6_FLOWLABEL_MGR"
5032-
| "IPV6_FLOWINFO_SEND"
5033-
| "IPV6_FLOWINFO_FLOWLABEL"
5039+
"IPV6_FLOWINFO"
5040+
| "IPV6_FLOWLABEL_MGR"
5041+
| "IPV6_FLOWINFO_SEND"
5042+
| "IPV6_FLOWINFO_FLOWLABEL"
50345043
| "IPV6_FLOWINFO_PRIORITY" => false,
50355044
_ => true,
50365045
})

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 {
@@ -3211,6 +3218,27 @@ pub const MREMAP_MAYMOVE: c_int = 1;
32113218
pub const MREMAP_FIXED: c_int = 2;
32123219
pub const MREMAP_DONTUNMAP: c_int = 4;
32133220

3221+
// linux/nsfs.h
3222+
const NSIO: c_uint = 0xb7;
3223+
3224+
pub const NS_GET_USERNS: c_uint = _IO(NSIO, 0x1);
3225+
pub const NS_GET_PARENT: c_uint = _IO(NSIO, 0x2);
3226+
pub const NS_GET_NSTYPE: c_uint = _IO(NSIO, 0x3);
3227+
pub const NS_GET_OWNER_UID: c_uint = _IO(NSIO, 0x4);
3228+
3229+
pub const NS_GET_MNTNS_ID: c_uint = _IOR::<__u64>(NSIO, 0x5);
3230+
3231+
pub const NS_GET_PID_FROM_PIDNS: c_uint = _IOR::<c_int>(NSIO, 0x6);
3232+
pub const NS_GET_TGID_FROM_PIDNS: c_uint = _IOR::<c_int>(NSIO, 0x7);
3233+
pub const NS_GET_PID_IN_PIDNS: c_uint = _IOR::<c_int>(NSIO, 0x8);
3234+
pub const NS_GET_TGID_IN_PIDNS: c_uint = _IOR::<c_int>(NSIO, 0x9);
3235+
3236+
pub const MNT_NS_INFO_SIZE_VER0: c_uint = 16;
3237+
3238+
pub const NS_MNT_GET_INFO: c_uint = _IOR::<mnt_ns_info>(NSIO, 10);
3239+
pub const NS_MNT_GET_NEXT: c_uint = _IOR::<mnt_ns_info>(NSIO, 11);
3240+
pub const NS_MNT_GET_PREV: c_uint = _IOR::<mnt_ns_info>(NSIO, 12);
3241+
32143242
// linux/pidfd.h
32153243
pub const PIDFD_NONBLOCK: c_uint = O_NONBLOCK as c_uint;
32163244
pub const PIDFD_THREAD: c_uint = O_EXCL as c_uint;

0 commit comments

Comments
 (0)