Skip to content

Commit 2699446

Browse files
committed
Linux: add name_to_handle_at and open_by_handle_at
1 parent 939f009 commit 2699446

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

libc-test/build.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4142,6 +4142,9 @@ fn test_linux(target: &str) {
41424142
// FIXME(musl): New fields in newer versions
41434143
"utmpx" if !old_musl => true,
41444144

4145+
// musl: this struct is defined with a flexible array
4146+
"file_handle" if musl => true,
4147+
41454148
_ => false,
41464149
}
41474150
});
@@ -4487,6 +4490,15 @@ fn test_linux(target: &str) {
44874490
// FIXME(linux): Requires >= 6.16 kernel headers.
44884491
"PTRACE_SET_SYSCALL_INFO" => true,
44894492

4493+
// FIXME(linux): Requires >= 6.13 kernel headers.
4494+
"AT_HANDLE_CONNECTABLE" => true,
4495+
4496+
// FIXME(linux): Requires >= 6.12 kernel headers.
4497+
"AT_HANDLE_MNT_ID_UNIQUE" => true,
4498+
4499+
// FIXME(musl): This value is not yet in musl.
4500+
"AT_HANDLE_FID" if musl => true,
4501+
44904502
_ => false,
44914503
}
44924504
});

libc-test/semver/linux.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ AT_EXECVE_CHECK
167167
AT_FDCWD
168168
AT_FLAGS
169169
AT_GID
170+
AT_HANDLE_CONNECTABLE
171+
AT_HANDLE_FID
172+
AT_HANDLE_MNT_ID_UNIQUE
170173
AT_HWCAP
171174
AT_HWCAP2
172175
AT_HWCAP3
@@ -1705,6 +1708,7 @@ MAP_STACK
17051708
MAP_TYPE
17061709
MAXTTL
17071710
MAX_ADDR_LEN
1711+
MAX_HANDLE_SZ
17081712
MAX_IPOPTLEN
17091713
MAX_LINKS
17101714
MCAST_BLOCK_SOURCE
@@ -4026,6 +4030,7 @@ ff_trigger
40264030
fgetpos64
40274031
fgetxattr
40284032
file_clone_range
4033+
file_handle
40294034
flistxattr
40304035
fmemopen
40314036
fopen64
@@ -4189,6 +4194,7 @@ msgrcv
41894194
msgsnd
41904195
msqid_ds
41914196
name_t
4197+
name_to_handle_at
41924198
newlocale
41934199
nice
41944200
nl_item
@@ -4203,6 +4209,7 @@ nlmsghdr
42034209
nrand48
42044210
off64_t
42054211
open64
4212+
open_by_handle_at
42064213
open_how
42074214
open_memstream
42084215
openat

src/unix/linux_like/linux/mod.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,6 +1263,14 @@ s! {
12631263
pub sched_deadline: crate::__u64,
12641264
pub sched_period: crate::__u64,
12651265
}
1266+
1267+
// linux/fcntl.h
1268+
1269+
pub struct file_handle {
1270+
pub handle_bytes: c_uint,
1271+
pub handle_type: c_int,
1272+
pub f_handle: [c_uchar; 0],
1273+
}
12661274
}
12671275

12681276
cfg_if! {
@@ -1398,6 +1406,11 @@ pub const IFF_ECHO: c_int = 0x40000;
13981406
// linux/fcntl.h
13991407
pub const AT_EXECVE_CHECK: c_int = 0x10000;
14001408

1409+
pub const MAX_HANDLE_SZ: c_int = 128;
1410+
pub const AT_HANDLE_FID: c_int = 0x200;
1411+
pub const AT_HANDLE_MNT_ID_UNIQUE: c_int = 0x001;
1412+
pub const AT_HANDLE_CONNECTABLE: c_int = 0x002;
1413+
14011414
// linux/if_addr.h
14021415
pub const IFA_UNSPEC: c_ushort = 0;
14031416
pub const IFA_ADDRESS: c_ushort = 1;
@@ -4366,6 +4379,15 @@ extern "C" {
43664379
pub fn gethostid() -> c_long;
43674380

43684381
pub fn klogctl(syslog_type: c_int, bufp: *mut c_char, len: c_int) -> c_int;
4382+
4383+
pub fn name_to_handle_at(
4384+
dirfd: c_int,
4385+
path: *const c_char,
4386+
handle: *mut file_handle,
4387+
mount_id: *mut c_int,
4388+
flags: c_int,
4389+
) -> c_int;
4390+
pub fn open_by_handle_at(mount_fd: c_int, handle: *mut file_handle, flags: c_int) -> c_int;
43694391
}
43704392

43714393
// LFS64 extensions

0 commit comments

Comments
 (0)