Skip to content

Commit e66b2a8

Browse files
committed
Auto merge of #1378 - gnzlbg:statx, r=gnzlbg
Add statx on Linux Closes #1178.
2 parents 3c903c8 + bf1ab2b commit e66b2a8

File tree

9 files changed

+70
-0
lines changed

9 files changed

+70
-0
lines changed

libc-test/build.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1860,6 +1860,7 @@ fn test_linux(target: &str) {
18601860
let x32 = target.contains("x32");
18611861
let mips = target.contains("mips");
18621862
let mips32_musl = mips && !target.contains("64") && musl;
1863+
let sparc64 = target.contains("sparc64");
18631864

18641865
let mut cfg = ctest::TestGenerator::new();
18651866
cfg.define("_GNU_SOURCE", None);
@@ -2193,6 +2194,10 @@ fn test_linux(target: &str) {
21932194
// https://github.com/gnzlbg/ctest/issues/68
21942195
"lio_listio" if musl => true,
21952196

2197+
// FIXME: the glibc version used by the Sparc64 build jobs
2198+
// which use Debian 10.0 is too old.
2199+
"statx" if sparc64 => true,
2200+
21962201
_ => false,
21972202
}
21982203
});

src/unix/notbsd/linux/other/b32/arm.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,3 +607,4 @@ pub const SYS_pwritev2: ::c_long = 393;
607607
pub const SYS_pkey_mprotect: ::c_long = 394;
608608
pub const SYS_pkey_alloc: ::c_long = 395;
609609
pub const SYS_pkey_free: ::c_long = 396;
610+
pub const SYS_statx: ::c_long = 397;

src/unix/notbsd/linux/other/b32/powerpc.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,3 +612,4 @@ pub const SYS_copy_file_range: ::c_long = 379;
612612
pub const SYS_preadv2: ::c_long = 380;
613613
pub const SYS_pwritev2: ::c_long = 381;
614614
pub const SYS_kexec_file_load: ::c_long = 382;
615+
pub const SYS_statx: ::c_long = 383;

src/unix/notbsd/linux/other/b32/x86.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,7 @@ pub const SYS_pwritev2: ::c_long = 379;
840840
pub const SYS_pkey_mprotect: ::c_long = 380;
841841
pub const SYS_pkey_alloc: ::c_long = 381;
842842
pub const SYS_pkey_free: ::c_long = 382;
843+
pub const SYS_statx: ::c_long = 383;
843844

844845
// offsets in user_regs_structs, from sys/reg.h
845846
pub const EBX: ::c_int = 0;

src/unix/notbsd/linux/other/b64/not_x32.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ pub const SYS_pwritev2: ::c_long = 328;
408408
pub const SYS_pkey_mprotect: ::c_long = 329;
409409
pub const SYS_pkey_alloc: ::c_long = 330;
410410
pub const SYS_pkey_free: ::c_long = 331;
411+
pub const SYS_statx: ::c_long = 332;
411412

412413
#[link(name = "util")]
413414
extern {

src/unix/notbsd/linux/other/b64/powerpc64.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,7 @@ pub const SYS_copy_file_range: ::c_long = 379;
921921
pub const SYS_preadv2: ::c_long = 380;
922922
pub const SYS_pwritev2: ::c_long = 381;
923923
pub const SYS_kexec_file_load: ::c_long = 382;
924+
pub const SYS_statx: ::c_long = 383;
924925

925926
#[link(name = "util")]
926927
extern {

src/unix/notbsd/linux/other/b64/sparc64.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,7 @@ pub const SYS_mlock2: ::c_long = 356;
855855
pub const SYS_copy_file_range: ::c_long = 357;
856856
pub const SYS_preadv2: ::c_long = 358;
857857
pub const SYS_pwritev2: ::c_long = 359;
858+
pub const SYS_statx: ::c_long = 360;
858859

859860
#[link(name = "util")]
860861
extern {

src/unix/notbsd/linux/other/b64/x32.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ pub const SYS_copy_file_range: ::c_long = __X32_SYSCALL_BIT + 326;
336336
pub const SYS_pkey_mprotect: ::c_long = __X32_SYSCALL_BIT + 329;
337337
pub const SYS_pkey_alloc: ::c_long = __X32_SYSCALL_BIT + 330;
338338
pub const SYS_pkey_free: ::c_long = __X32_SYSCALL_BIT + 331;
339+
pub const SYS_statx: ::c_long = __X32_SYSCALL_BIT + 332;
339340
pub const SYS_rt_sigaction: ::c_long = __X32_SYSCALL_BIT + 512;
340341
pub const SYS_rt_sigreturn: ::c_long = __X32_SYSCALL_BIT + 513;
341342
pub const SYS_ioctl: ::c_long = __X32_SYSCALL_BIT + 514;

src/unix/notbsd/linux/other/mod.rs

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,36 @@ pub type __priority_which_t = ::c_uint;
33
pub type __rlimit_resource_t = ::c_uint;
44

55
s! {
6+
pub struct statx {
7+
pub stx_mask: u32,
8+
pub stx_blksize: u32,
9+
pub stx_attributes: u64,
10+
pub stx_nlink: u32,
11+
pub stx_uid: u32,
12+
pub stx_gid: u32,
13+
pub stx_mode: u16,
14+
pub __statx_pad1: [u16; 1],
15+
pub stx_ino: u64,
16+
pub stx_size: u64,
17+
pub stx_blocks: u64,
18+
pub stx_attributes_mask: u64,
19+
pub stx_atime: ::statx_timestamp,
20+
pub stx_btime: ::statx_timestamp,
21+
pub stx_ctime: ::statx_timestamp,
22+
pub stx_mtime: ::statx_timestamp,
23+
pub stx_rdev_major: u32,
24+
pub stx_rdev_minor: u32,
25+
pub stx_dev_major: u32,
26+
pub stx_dev_minor: u32,
27+
pub __statx_pad2: [u64; 14],
28+
}
29+
30+
pub struct statx_timestamp {
31+
pub tv_sec: i64,
32+
pub tv_nsec: u32,
33+
pub __statx_timestamp_pad1: [i32; 1],
34+
}
35+
636
pub struct aiocb {
737
pub aio_fildes: ::c_int,
838
pub aio_lio_opcode: ::c_int,
@@ -942,6 +972,32 @@ pub const AF_MAX: ::c_int = 45;
942972
#[allow(deprecated)]
943973
pub const PF_MAX: ::c_int = AF_MAX;
944974

975+
pub const AT_STATX_SYNC_TYPE: ::c_int = 0x6000;
976+
pub const AT_STATX_SYNC_AS_STAT: ::c_int = 0x0000;
977+
pub const AT_STATX_FORCE_SYNC: ::c_int = 0x2000;
978+
pub const AT_STATX_DONT_SYNC: ::c_int = 0x4000;
979+
pub const STATX_TYPE: ::c_uint = 0x0001;
980+
pub const STATX_MODE: ::c_uint = 0x0002;
981+
pub const STATX_NLINK: ::c_uint = 0x0004;
982+
pub const STATX_UID: ::c_uint = 0x0008;
983+
pub const STATX_GID: ::c_uint = 0x0010;
984+
pub const STATX_ATIME: ::c_uint = 0x0020;
985+
pub const STATX_MTIME: ::c_uint = 0x0040;
986+
pub const STATX_CTIME: ::c_uint = 0x0080;
987+
pub const STATX_INO: ::c_uint = 0x0100;
988+
pub const STATX_SIZE: ::c_uint = 0x0200;
989+
pub const STATX_BLOCKS: ::c_uint = 0x0400;
990+
pub const STATX_BASIC_STATS: ::c_uint = 0x07ff;
991+
pub const STATX_BTIME: ::c_uint = 0x0800;
992+
pub const STATX_ALL: ::c_uint = 0x0fff;
993+
pub const STATX__RESERVED: ::c_int = 0x80000000;
994+
pub const STATX_ATTR_COMPRESSED: ::c_int = 0x0004;
995+
pub const STATX_ATTR_IMMUTABLE: ::c_int = 0x0010;
996+
pub const STATX_ATTR_APPEND: ::c_int = 0x0020;
997+
pub const STATX_ATTR_NODUMP: ::c_int = 0x0040;
998+
pub const STATX_ATTR_ENCRYPTED: ::c_int = 0x0800;
999+
pub const STATX_ATTR_AUTOMOUNT: ::c_int = 0x1000;
1000+
9451001
cfg_if! {
9461002
if #[cfg(any(target_arch = "arm", target_arch = "x86",
9471003
target_arch = "x86_64"))] {
@@ -992,6 +1048,8 @@ extern {
9921048
pub fn mallopt(param: ::c_int, value: ::c_int) -> ::c_int;
9931049
pub fn gettimeofday(tp: *mut ::timeval,
9941050
tz: *mut ::timezone) -> ::c_int;
1051+
pub fn statx(dirfd: ::c_int, pathname: *const c_char, flags: ::c_int,
1052+
mask: ::c_uint, statxbuf: *mut statx) -> ::c_int;
9951053
}
9961054

9971055
#[link(name = "util")]

0 commit comments

Comments
 (0)