Linux: add name_to_handle_at and open_by_handle_at · rust-lang/libc@e9cca04 (original) (raw)

Original file line number Diff line number Diff line change
@@ -3819,6 +3819,7 @@ fn test_linux(target: &str) {
3819 3819 }
3820 3820
3821 3821 let arm = target.contains("arm");
3822 +let eabihf = target.contains("eabihf");
3822 3823 let aarch64 = target.contains("aarch64");
3823 3824 let i686 = target.contains("i686");
3824 3825 let ppc = target.contains("powerpc");
@@ -4646,6 +4647,16 @@ fn test_linux(target: &str) {
4646 4647 // FIXME(linux): Requires >= 6.16 kernel headers.
4647 4648 "PTRACE_SET_SYSCALL_INFO" => true,
4648 4649
4650 +// FIXME(linux): Requires >= 6.13 kernel headers.
4651 +"AT_HANDLE_CONNECTABLE" => true,
4652 +
4653 +// FIXME(linux): Requires >= 6.12 kernel headers.
4654 +"AT_HANDLE_MNT_ID_UNIQUE" => true,
4655 +
4656 +// FIXME(musl): This value is not yet in musl.
4657 +// eabihf targets are tested using an older version of glibc
4658 +"AT_HANDLE_FID" if musl |
4659 +
4649 4660 _ => false,
4650 4661 }
4651 4662 });
@@ -4902,6 +4913,7 @@ fn test_linux(target: &str) {
4902 4913 ("bcm_msg_head", "frames") => true,
4903 4914 // FAM
4904 4915 ("af_alg_iv", "iv") => true,
4916 +("file_handle", "f_handle") if musl => true,
4905 4917 // FIXME(ctest): ctest does not translate the rust code which computes the padding size
4906 4918 ("pthread_cond_t", "__padding") if l4re => true,
4907 4919 _ => false,
Original file line number Diff line number Diff line change
@@ -167,6 +167,9 @@ AT_EXECVE_CHECK
167 167 AT_FDCWD
168 168 AT_FLAGS
169 169 AT_GID
170 +AT_HANDLE_CONNECTABLE
171 +AT_HANDLE_FID
172 +AT_HANDLE_MNT_ID_UNIQUE
170 173 AT_HWCAP
171 174 AT_HWCAP2
172 175 AT_HWCAP3
@@ -1702,6 +1705,7 @@ MAP_STACK
1702 1705 MAP_TYPE
1703 1706 MAXTTL
1704 1707 MAX_ADDR_LEN
1708 +MAX_HANDLE_SZ
1705 1709 MAX_IPOPTLEN
1706 1710 MAX_LINKS
1707 1711 MCAST_BLOCK_SOURCE
@@ -4024,6 +4028,7 @@ ff_trigger
4024 4028 fgetpos64
4025 4029 fgetxattr
4026 4030 file_clone_range
4031 +file_handle
4027 4032 flistxattr
4028 4033 fmemopen
4029 4034 fopen64
@@ -4187,6 +4192,7 @@ msgrcv
4187 4192 msgsnd
4188 4193 msqid_ds
4189 4194 name_t
4195 +name_to_handle_at
4190 4196 newlocale
4191 4197 nice
4192 4198 nl_item
@@ -4201,6 +4207,7 @@ nlmsghdr
4201 4207 nrand48
4202 4208 off64_t
4203 4209 open64
4210 +open_by_handle_at
4204 4211 open_how
4205 4212 open_memstream
4206 4213 openat
Original file line number Diff line number Diff line change
@@ -1246,6 +1246,14 @@ s! {
1246 1246 pub sched_deadline: crate::__u64,
1247 1247 pub sched_period: crate::__u64,
1248 1248 }
1249 +
1250 +// linux/fcntl.h
1251 +
1252 +pub struct file_handle {
1253 +pub handle_bytes: c_uint,
1254 +pub handle_type: c_int,
1255 +pub f_handle: [c_uchar; 0],
1256 +}
1249 1257 }
1250 1258
1251 1259 cfg_if! {
@@ -1416,6 +1424,11 @@ pub const IFF_ECHO: c_int = 0x40000;
1416 1424 // linux/fcntl.h
1417 1425 pub const AT_EXECVE_CHECK: c_int = 0x10000;
1418 1426
1427 +pub const MAX_HANDLE_SZ: c_int = 128;
1428 +pub const AT_HANDLE_FID: c_int = 0x200;
1429 +pub const AT_HANDLE_MNT_ID_UNIQUE: c_int = 0x001;
1430 +pub const AT_HANDLE_CONNECTABLE: c_int = 0x002;
1431 +
1419 1432 // linux/if_addr.h
1420 1433 pub const IFA_UNSPEC: c_ushort = 0;
1421 1434 pub const IFA_ADDRESS: c_ushort = 1;
@@ -4356,6 +4369,15 @@ extern "C" {
4356 4369 pub fn gethostid() -> c_long;
4357 4370
4358 4371 pub fn klogctl(syslog_type: c_int, bufp: *mut c_char, len: c_int) -> c_int;
4372 +
4373 +pub fn name_to_handle_at(
4374 +dirfd: c_int,
4375 +path: *const c_char,
4376 +handle: *mut file_handle,
4377 +mount_id: *mut c_int,
4378 +flags: c_int,
4379 +) -> c_int;
4380 +pub fn open_by_handle_at(mount_fd: c_int, handle: *mut file_handle, flags: c_int) -> c_int;
4359 4381 }
4360 4382
4361 4383 // LFS64 extensions