-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The statx system call and corresponding constants are defined by the Linux kernel and don't depend on the libc or architecture. The only difference is whether a libc exports the statx syscall wrapper or not. We can thus unify the statx definitions for all Linux "like" platforms: GNU (glibc), Android (bionic), and (in a later commit) musl. The statx struct is in a separate file because the style check doesn't allow multiple s! macros in one file, and #[cfg()] doesn't work in s!. Plain u64 (or uint64_t in C) can't be used for the statx fields because bionic defines them as __u64, and provides incompatible definitions of uint64_t and __u64.
- Loading branch information
1 parent
7f2e466
commit c3bc406
Showing
4 changed files
with
83 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
s! { | ||
pub struct statx { | ||
pub stx_mask: ::__u32, | ||
pub stx_blksize: ::__u32, | ||
pub stx_attributes: ::__u64, | ||
pub stx_nlink: ::__u32, | ||
pub stx_uid: ::__u32, | ||
pub stx_gid: ::__u32, | ||
pub stx_mode: ::__u16, | ||
__statx_pad1: [::__u16; 1], | ||
pub stx_ino: ::__u64, | ||
pub stx_size: ::__u64, | ||
pub stx_blocks: ::__u64, | ||
pub stx_attributes_mask: ::__u64, | ||
pub stx_atime: statx_timestamp, | ||
pub stx_btime: statx_timestamp, | ||
pub stx_ctime: statx_timestamp, | ||
pub stx_mtime: statx_timestamp, | ||
pub stx_rdev_major: ::__u32, | ||
pub stx_rdev_minor: ::__u32, | ||
pub stx_dev_major: ::__u32, | ||
pub stx_dev_minor: ::__u32, | ||
pub stx_mnt_id: ::__u64, | ||
pub stx_dio_mem_align: ::__u32, | ||
pub stx_dio_offset_align: ::__u32, | ||
__statx_pad3: [::__u64; 12], | ||
} | ||
|
||
pub struct statx_timestamp { | ||
pub tv_sec: ::__s64, | ||
pub tv_nsec: ::__u32, | ||
__statx_timestamp_pad1: [::__s32; 1], | ||
} | ||
} | ||
|
||
pub const AT_STATX_SYNC_TYPE: ::c_int = 0x6000; | ||
pub const AT_STATX_SYNC_AS_STAT: ::c_int = 0x0000; | ||
pub const AT_STATX_FORCE_SYNC: ::c_int = 0x2000; | ||
pub const AT_STATX_DONT_SYNC: ::c_int = 0x4000; | ||
pub const STATX_TYPE: ::c_uint = 0x0001; | ||
pub const STATX_MODE: ::c_uint = 0x0002; | ||
pub const STATX_NLINK: ::c_uint = 0x0004; | ||
pub const STATX_UID: ::c_uint = 0x0008; | ||
pub const STATX_GID: ::c_uint = 0x0010; | ||
pub const STATX_ATIME: ::c_uint = 0x0020; | ||
pub const STATX_MTIME: ::c_uint = 0x0040; | ||
pub const STATX_CTIME: ::c_uint = 0x0080; | ||
pub const STATX_INO: ::c_uint = 0x0100; | ||
pub const STATX_SIZE: ::c_uint = 0x0200; | ||
pub const STATX_BLOCKS: ::c_uint = 0x0400; | ||
pub const STATX_BASIC_STATS: ::c_uint = 0x07ff; | ||
pub const STATX_BTIME: ::c_uint = 0x0800; | ||
pub const STATX_ALL: ::c_uint = 0x0fff; | ||
pub const STATX_MNT_ID: ::c_uint = 0x1000; | ||
pub const STATX_DIOALIGN: ::c_uint = 0x2000; | ||
pub const STATX__RESERVED: ::c_int = 0x80000000; | ||
pub const STATX_ATTR_COMPRESSED: ::c_int = 0x0004; | ||
pub const STATX_ATTR_IMMUTABLE: ::c_int = 0x0010; | ||
pub const STATX_ATTR_APPEND: ::c_int = 0x0020; | ||
pub const STATX_ATTR_NODUMP: ::c_int = 0x0040; | ||
pub const STATX_ATTR_ENCRYPTED: ::c_int = 0x0800; | ||
pub const STATX_ATTR_AUTOMOUNT: ::c_int = 0x1000; | ||
pub const STATX_ATTR_MOUNT_ROOT: ::c_int = 0x2000; | ||
pub const STATX_ATTR_VERITY: ::c_int = 0x100000; | ||
pub const STATX_ATTR_DAX: ::c_int = 0x200000; | ||
|
||
extern "C" { | ||
pub fn statx( | ||
dirfd: ::c_int, | ||
pathname: *const ::c_char, | ||
flags: ::c_int, | ||
mask: ::c_uint, | ||
statxbuf: *mut statx, | ||
) -> ::c_int; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters