Skip to content

Commit c05ecd2

Browse files
committed
Add constants and types for nsfs ioctls
1 parent 50a2acf commit c05ecd2

File tree

3 files changed

+54
-6
lines changed

3 files changed

+54
-6
lines changed

libc-test/build.rs

Lines changed: 13 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

@@ -4516,6 +4520,9 @@ fn test_linux(target: &str) {
45164520
true
45174521
}
45184522

4523+
// FIXME(linux): Requires >= 6.12 kernel headers.
4524+
"MNT_NS_INFO_SIZE_VER0" | "NS_MNT_GET_INFO" | "NS_MNT_GET_NEXT" | "NS_MNT_GET_PREV" => true,
4525+
45194526
// FIXME(linux): Requires >= 6.6 kernel headers.
45204527
"SYS_fchmodat2" => true,
45214528

@@ -4868,8 +4875,8 @@ fn test_linux_like_apis(target: &str) {
48684875
"strerror_r" => false,
48694876
_ => true,
48704877
})
4871-
.skip_const(|_| true)
4872-
.skip_struct(|_| true);
4878+
.skip_const(|_| true)
4879+
.skip_struct(|_| true);
48734880
cfg.generate(src_hotfix_dir().join("lib.rs"), "linux_strerror_r.rs");
48744881
}
48754882

@@ -4943,10 +4950,10 @@ fn test_linux_like_apis(target: &str) {
49434950
.skip_const(|_| true)
49444951
.skip_struct(|_| true)
49454952
.skip_const(move |name| match name {
4946-
"IPV6_FLOWINFO"
4947-
| "IPV6_FLOWLABEL_MGR"
4948-
| "IPV6_FLOWINFO_SEND"
4949-
| "IPV6_FLOWINFO_FLOWLABEL"
4953+
"IPV6_FLOWINFO"
4954+
| "IPV6_FLOWLABEL_MGR"
4955+
| "IPV6_FLOWINFO_SEND"
4956+
| "IPV6_FLOWINFO_FLOWLABEL"
49504957
| "IPV6_FLOWINFO_PRIORITY" => false,
49514958
_ => true,
49524959
})

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)