diff --git a/lib/std/os/bits/linux.zig b/lib/std/os/bits/linux.zig index 0d70a6bcaa5e4b209762523fabe2106dc95aad38..d2d521a005d30d08c18a95d9b98365ef13673715 100644 --- a/lib/std/os/bits/linux.zig +++ b/lib/std/os/bits/linux.zig @@ -1322,52 +1322,65 @@ pub const statx_timestamp = extern struct { __pad1: u32, }; +/// Renamed to `Statx` to not conflict with the `statx` function. pub const Statx = extern struct { - // Mask of bits indicating filled fields - stx_mask: u32, - // Block size for filesystem I/O - stx_blksize: u32, - // Extra file attribute indicators - stx_attributes: u64, - // Number of hard links - stx_nlink: u32, - // User ID of owner - stx_uid: u32, - // Group ID of owner - stx_gid: u32, - // File type and mode - stx_mode: u16, + /// Mask of bits indicating filled fields + mask: u32, + + /// Block size for filesystem I/O + blksize: u32, + + /// Extra file attribute indicators + attributes: u64, + + /// Number of hard links + nlink: u32, + + /// User ID of owner + uid: u32, + + /// Group ID of owner + gid: u32, + + /// File type and mode + mode: u16, __pad1: u16, - // Inode number - stx_ino: u64, - // Total size in bytes - stx_size: u64, - // Number of 512B blocks allocated - stx_blocks: u64, - // Mask to show what's supported in stx_attributes - stx_attributes_mask: u64, - - // The following fields are file timestamps - // Last access - stx_atime: statx_timestamp, - // Creation - stx_btime: statx_timestamp, - // Last status change - stx_ctime: statx_timestamp, - // Last modification - stx_mtime: statx_timestamp, - - // If this file represents a device, then the next two fields contain the ID of the device - // Major ID - stx_rdev_major: u32, - // Minor ID - stx_rdev_minor: u32, - - // The next two fields contain the ID of the device containing the filesystem where the file resides - // Major ID - stx_dev_major: u32, - // Minor ID - stx_dev_minor: u32, + + /// Inode number + ino: u64, + + /// Total size in bytes + size: u64, + + /// Number of 512B blocks allocated + blocks: u64, + + /// Mask to show what's supported in `attributes`. + attributes_mask: u64, + + /// Last access file timestamp + atime: statx_timestamp, + + /// Creation file timestamp + btime: statx_timestamp, + + /// Last status change file timestamp + ctime: statx_timestamp, + + /// Last modification file timestamp + mtime: statx_timestamp, + + /// Major ID, if this file represents a device. + rdev_major: u32, + + /// Minor ID, if this file represents a device. + rdev_minor: u32, + + /// Major ID of the device containing the filesystem where this file resides. + dev_major: u32, + + /// Minor ID of the device containing the filesystem where this file resides. + dev_minor: u32, __pad2: [14]u64, }; diff --git a/lib/std/os/linux/test.zig b/lib/std/os/linux/test.zig index 3782bc3301eb8ec052798a50ac86309d090e5d6f..e089a024457cd0d45c0f6d926868da8aab084775 100644 --- a/lib/std/os/linux/test.zig +++ b/lib/std/os/linux/test.zig @@ -69,10 +69,10 @@ test "statx" { else => unreachable, } - expect(stat_buf.mode == statx_buf.stx_mode); - expect(@bitCast(u32, stat_buf.uid) == statx_buf.stx_uid); - expect(@bitCast(u32, stat_buf.gid) == statx_buf.stx_gid); - expect(@bitCast(u64, i64(stat_buf.size)) == statx_buf.stx_size); - expect(@bitCast(u64, i64(stat_buf.blksize)) == statx_buf.stx_blksize); - expect(@bitCast(u64, i64(stat_buf.blocks)) == statx_buf.stx_blocks); + expect(stat_buf.mode == statx_buf.mode); + expect(@bitCast(u32, stat_buf.uid) == statx_buf.uid); + expect(@bitCast(u32, stat_buf.gid) == statx_buf.gid); + expect(@bitCast(u64, i64(stat_buf.size)) == statx_buf.size); + expect(@bitCast(u64, i64(stat_buf.blksize)) == statx_buf.blksize); + expect(@bitCast(u64, i64(stat_buf.blocks)) == statx_buf.blocks); }