authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-10-16 17:24:42-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-10-16 17:24:42-04:00
log518197080748b3804d76030ad9f02969b01a679a
tree384ddf7bccb680e65ef9756ecef0b412ad7695f2
parent312880f10243b3074c3f176fbea6b9994e733f56
signaturelock-open Commit is signed but in an unrecognized format.

improve docs and field names of Statx struct


2 files changed, 63 insertions(+), 50 deletions(-)

lib/std/os/bits/linux.zig+57-44
......@@ -1322,52 +1322,65 @@ pub const statx_timestamp = extern struct {
13221322 __pad1: u32,
13231323};
13241324
1325/// Renamed to `Statx` to not conflict with the `statx` function.
13251326pub const Statx = extern struct {
1326 // Mask of bits indicating filled fields
1327 stx_mask: u32,
1328 // Block size for filesystem I/O
1329 stx_blksize: u32,
1330 // Extra file attribute indicators
1331 stx_attributes: u64,
1332 // Number of hard links
1333 stx_nlink: u32,
1334 // User ID of owner
1335 stx_uid: u32,
1336 // Group ID of owner
1337 stx_gid: u32,
1338 // File type and mode
1339 stx_mode: u16,
1327 /// Mask of bits indicating filled fields
1328 mask: u32,
1329
1330 /// Block size for filesystem I/O
1331 blksize: u32,
1332
1333 /// Extra file attribute indicators
1334 attributes: u64,
1335
1336 /// Number of hard links
1337 nlink: u32,
1338
1339 /// User ID of owner
1340 uid: u32,
1341
1342 /// Group ID of owner
1343 gid: u32,
1344
1345 /// File type and mode
1346 mode: u16,
13401347 __pad1: u16,
1341 // Inode number
1342 stx_ino: u64,
1343 // Total size in bytes
1344 stx_size: u64,
1345 // Number of 512B blocks allocated
1346 stx_blocks: u64,
1347 // Mask to show what's supported in stx_attributes
1348 stx_attributes_mask: u64,
1349
1350 // The following fields are file timestamps
1351 // Last access
1352 stx_atime: statx_timestamp,
1353 // Creation
1354 stx_btime: statx_timestamp,
1355 // Last status change
1356 stx_ctime: statx_timestamp,
1357 // Last modification
1358 stx_mtime: statx_timestamp,
1359
1360 // If this file represents a device, then the next two fields contain the ID of the device
1361 // Major ID
1362 stx_rdev_major: u32,
1363 // Minor ID
1364 stx_rdev_minor: u32,
1365
1366 // The next two fields contain the ID of the device containing the filesystem where the file resides
1367 // Major ID
1368 stx_dev_major: u32,
1369 // Minor ID
1370 stx_dev_minor: u32,
1348
1349 /// Inode number
1350 ino: u64,
1351
1352 /// Total size in bytes
1353 size: u64,
1354
1355 /// Number of 512B blocks allocated
1356 blocks: u64,
1357
1358 /// Mask to show what's supported in `attributes`.
1359 attributes_mask: u64,
1360
1361 /// Last access file timestamp
1362 atime: statx_timestamp,
1363
1364 /// Creation file timestamp
1365 btime: statx_timestamp,
1366
1367 /// Last status change file timestamp
1368 ctime: statx_timestamp,
1369
1370 /// Last modification file timestamp
1371 mtime: statx_timestamp,
1372
1373 /// Major ID, if this file represents a device.
1374 rdev_major: u32,
1375
1376 /// Minor ID, if this file represents a device.
1377 rdev_minor: u32,
1378
1379 /// Major ID of the device containing the filesystem where this file resides.
1380 dev_major: u32,
1381
1382 /// Minor ID of the device containing the filesystem where this file resides.
1383 dev_minor: u32,
13711384
13721385 __pad2: [14]u64,
13731386};
lib/std/os/linux/test.zig+6-6
......@@ -69,10 +69,10 @@ test "statx" {
6969 else => unreachable,
7070 }
7171
72 expect(stat_buf.mode == statx_buf.stx_mode);
73 expect(@bitCast(u32, stat_buf.uid) == statx_buf.stx_uid);
74 expect(@bitCast(u32, stat_buf.gid) == statx_buf.stx_gid);
75 expect(@bitCast(u64, i64(stat_buf.size)) == statx_buf.stx_size);
76 expect(@bitCast(u64, i64(stat_buf.blksize)) == statx_buf.stx_blksize);
77 expect(@bitCast(u64, i64(stat_buf.blocks)) == statx_buf.stx_blocks);
72 expect(stat_buf.mode == statx_buf.mode);
73 expect(@bitCast(u32, stat_buf.uid) == statx_buf.uid);
74 expect(@bitCast(u32, stat_buf.gid) == statx_buf.gid);
75 expect(@bitCast(u64, i64(stat_buf.size)) == statx_buf.size);
76 expect(@bitCast(u64, i64(stat_buf.blksize)) == statx_buf.blksize);
77 expect(@bitCast(u64, i64(stat_buf.blocks)) == statx_buf.blocks);
7878}