Skip to content

Commit d37715d

Browse files
committed
Make statx available for all Linux targets
1 parent ac40e64 commit d37715d

File tree

2 files changed

+67
-66
lines changed

2 files changed

+67
-66
lines changed

src/unix/linux_like/linux/gnu/mod.rs

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -15,38 +15,6 @@ cfg_if! {
1515
}
1616

1717
s! {
18-
pub struct statx {
19-
pub stx_mask: u32,
20-
pub stx_blksize: u32,
21-
pub stx_attributes: u64,
22-
pub stx_nlink: u32,
23-
pub stx_uid: u32,
24-
pub stx_gid: u32,
25-
pub stx_mode: u16,
26-
__statx_pad1: [u16; 1],
27-
pub stx_ino: u64,
28-
pub stx_size: u64,
29-
pub stx_blocks: u64,
30-
pub stx_attributes_mask: u64,
31-
pub stx_atime: ::statx_timestamp,
32-
pub stx_btime: ::statx_timestamp,
33-
pub stx_ctime: ::statx_timestamp,
34-
pub stx_mtime: ::statx_timestamp,
35-
pub stx_rdev_major: u32,
36-
pub stx_rdev_minor: u32,
37-
pub stx_dev_major: u32,
38-
pub stx_dev_minor: u32,
39-
pub stx_mnt_id: u64,
40-
__statx_pad2: u64,
41-
__statx_pad3: [u64; 12],
42-
}
43-
44-
pub struct statx_timestamp {
45-
pub tv_sec: i64,
46-
pub tv_nsec: u32,
47-
pub __statx_timestamp_pad1: [i32; 1],
48-
}
49-
5018
pub struct aiocb {
5119
pub aio_fildes: ::c_int,
5220
pub aio_lio_opcode: ::c_int,
@@ -994,33 +962,6 @@ pub const M_PERTURB: ::c_int = -6;
994962
pub const M_ARENA_TEST: ::c_int = -7;
995963
pub const M_ARENA_MAX: ::c_int = -8;
996964

997-
pub const AT_STATX_SYNC_TYPE: ::c_int = 0x6000;
998-
pub const AT_STATX_SYNC_AS_STAT: ::c_int = 0x0000;
999-
pub const AT_STATX_FORCE_SYNC: ::c_int = 0x2000;
1000-
pub const AT_STATX_DONT_SYNC: ::c_int = 0x4000;
1001-
pub const STATX_TYPE: ::c_uint = 0x0001;
1002-
pub const STATX_MODE: ::c_uint = 0x0002;
1003-
pub const STATX_NLINK: ::c_uint = 0x0004;
1004-
pub const STATX_UID: ::c_uint = 0x0008;
1005-
pub const STATX_GID: ::c_uint = 0x0010;
1006-
pub const STATX_ATIME: ::c_uint = 0x0020;
1007-
pub const STATX_MTIME: ::c_uint = 0x0040;
1008-
pub const STATX_CTIME: ::c_uint = 0x0080;
1009-
pub const STATX_INO: ::c_uint = 0x0100;
1010-
pub const STATX_SIZE: ::c_uint = 0x0200;
1011-
pub const STATX_BLOCKS: ::c_uint = 0x0400;
1012-
pub const STATX_BASIC_STATS: ::c_uint = 0x07ff;
1013-
pub const STATX_BTIME: ::c_uint = 0x0800;
1014-
pub const STATX_MNT_ID: ::c_uint = 0x1000;
1015-
pub const STATX_ALL: ::c_uint = 0x0fff;
1016-
pub const STATX__RESERVED: ::c_int = 0x80000000;
1017-
pub const STATX_ATTR_COMPRESSED: ::c_int = 0x0004;
1018-
pub const STATX_ATTR_IMMUTABLE: ::c_int = 0x0010;
1019-
pub const STATX_ATTR_APPEND: ::c_int = 0x0020;
1020-
pub const STATX_ATTR_NODUMP: ::c_int = 0x0040;
1021-
pub const STATX_ATTR_ENCRYPTED: ::c_int = 0x0800;
1022-
pub const STATX_ATTR_AUTOMOUNT: ::c_int = 0x1000;
1023-
1024965
//sys/timex.h
1025966
pub const ADJ_OFFSET: ::c_uint = 0x0001;
1026967
pub const ADJ_FREQUENCY: ::c_uint = 0x0002;
@@ -1178,13 +1119,6 @@ extern "C" {
11781119
pub fn getpt() -> ::c_int;
11791120
pub fn mallopt(param: ::c_int, value: ::c_int) -> ::c_int;
11801121
pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::timezone) -> ::c_int;
1181-
pub fn statx(
1182-
dirfd: ::c_int,
1183-
pathname: *const c_char,
1184-
flags: ::c_int,
1185-
mask: ::c_uint,
1186-
statxbuf: *mut statx,
1187-
) -> ::c_int;
11881122
pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int;
11891123
pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t;
11901124
pub fn getauxval(type_: ::c_ulong) -> ::c_ulong;

src/unix/linux_like/linux/mod.rs

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,38 @@ impl ::Clone for fpos64_t {
5353
}
5454

5555
s! {
56+
pub struct statx {
57+
pub stx_mask: u32,
58+
pub stx_blksize: u32,
59+
pub stx_attributes: u64,
60+
pub stx_nlink: u32,
61+
pub stx_uid: u32,
62+
pub stx_gid: u32,
63+
pub stx_mode: u16,
64+
__statx_pad1: [u16; 1],
65+
pub stx_ino: u64,
66+
pub stx_size: u64,
67+
pub stx_blocks: u64,
68+
pub stx_attributes_mask: u64,
69+
pub stx_atime: ::statx_timestamp,
70+
pub stx_btime: ::statx_timestamp,
71+
pub stx_ctime: ::statx_timestamp,
72+
pub stx_mtime: ::statx_timestamp,
73+
pub stx_rdev_major: u32,
74+
pub stx_rdev_minor: u32,
75+
pub stx_dev_major: u32,
76+
pub stx_dev_minor: u32,
77+
pub stx_mnt_id: u64,
78+
__statx_pad2: u64,
79+
__statx_pad3: [u64; 12],
80+
}
81+
82+
pub struct statx_timestamp {
83+
pub tv_sec: i64,
84+
pub tv_nsec: u32,
85+
pub __statx_timestamp_pad1: [i32; 1],
86+
}
87+
5688
pub struct rlimit64 {
5789
pub rlim_cur: rlim64_t,
5890
pub rlim_max: rlim64_t,
@@ -1314,6 +1346,33 @@ pub const AT_HWCAP2: ::c_ulong = 26;
13141346

13151347
pub const AT_EXECFN: ::c_ulong = 31;
13161348

1349+
pub const AT_STATX_SYNC_TYPE: ::c_int = 0x6000;
1350+
pub const AT_STATX_SYNC_AS_STAT: ::c_int = 0x0000;
1351+
pub const AT_STATX_FORCE_SYNC: ::c_int = 0x2000;
1352+
pub const AT_STATX_DONT_SYNC: ::c_int = 0x4000;
1353+
pub const STATX_TYPE: ::c_uint = 0x0001;
1354+
pub const STATX_MODE: ::c_uint = 0x0002;
1355+
pub const STATX_NLINK: ::c_uint = 0x0004;
1356+
pub const STATX_UID: ::c_uint = 0x0008;
1357+
pub const STATX_GID: ::c_uint = 0x0010;
1358+
pub const STATX_ATIME: ::c_uint = 0x0020;
1359+
pub const STATX_MTIME: ::c_uint = 0x0040;
1360+
pub const STATX_CTIME: ::c_uint = 0x0080;
1361+
pub const STATX_INO: ::c_uint = 0x0100;
1362+
pub const STATX_SIZE: ::c_uint = 0x0200;
1363+
pub const STATX_BLOCKS: ::c_uint = 0x0400;
1364+
pub const STATX_BASIC_STATS: ::c_uint = 0x07ff;
1365+
pub const STATX_BTIME: ::c_uint = 0x0800;
1366+
pub const STATX_MNT_ID: ::c_uint = 0x1000;
1367+
pub const STATX_ALL: ::c_uint = 0x0fff;
1368+
pub const STATX__RESERVED: ::c_int = 0x80000000;
1369+
pub const STATX_ATTR_COMPRESSED: ::c_int = 0x0004;
1370+
pub const STATX_ATTR_IMMUTABLE: ::c_int = 0x0010;
1371+
pub const STATX_ATTR_APPEND: ::c_int = 0x0020;
1372+
pub const STATX_ATTR_NODUMP: ::c_int = 0x0040;
1373+
pub const STATX_ATTR_ENCRYPTED: ::c_int = 0x0800;
1374+
pub const STATX_ATTR_AUTOMOUNT: ::c_int = 0x1000;
1375+
13171376
pub const GLOB_ERR: ::c_int = 1 << 0;
13181377
pub const GLOB_MARK: ::c_int = 1 << 1;
13191378
pub const GLOB_NOSORT: ::c_int = 1 << 2;
@@ -3431,6 +3490,14 @@ extern "C" {
34313490

34323491
pub fn shm_open(name: *const c_char, oflag: ::c_int, mode: mode_t) -> ::c_int;
34333492

3493+
pub fn statx(
3494+
dirfd: ::c_int,
3495+
pathname: *const c_char,
3496+
flags: ::c_int,
3497+
mask: ::c_uint,
3498+
statxbuf: *mut statx,
3499+
) -> ::c_int;
3500+
34343501
// System V IPC
34353502
pub fn shmget(key: ::key_t, size: ::size_t, shmflg: ::c_int) -> ::c_int;
34363503
pub fn shmat(shmid: ::c_int, shmaddr: *const ::c_void, shmflg: ::c_int) -> *mut ::c_void;

0 commit comments

Comments
 (0)