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 {...@@ -1322,52 +1322,65 @@ pub const statx_timestamp = extern struct {
1322 __pad1: u32,1322 __pad1: u32,
1323};1323};
13241324
1325/// Renamed to `Statx` to not conflict with the `statx` function.
1325pub const Statx = extern struct {1326pub const Statx = extern struct {
1326 // Mask of bits indicating filled fields1327 /// Mask of bits indicating filled fields
1327 stx_mask: u32,1328 mask: u32,
1328 // Block size for filesystem I/O1329
1329 stx_blksize: u32,1330 /// Block size for filesystem I/O
1330 // Extra file attribute indicators1331 blksize: u32,
1331 stx_attributes: u64,1332
1332 // Number of hard links1333 /// Extra file attribute indicators
1333 stx_nlink: u32,1334 attributes: u64,
1334 // User ID of owner1335
1335 stx_uid: u32,1336 /// Number of hard links
1336 // Group ID of owner1337 nlink: u32,
1337 stx_gid: u32,1338
1338 // File type and mode1339 /// User ID of owner
1339 stx_mode: u16,1340 uid: u32,
1341
1342 /// Group ID of owner
1343 gid: u32,
1344
1345 /// File type and mode
1346 mode: u16,
1340 __pad1: u16,1347 __pad1: u16,
1341 // Inode number1348
1342 stx_ino: u64,1349 /// Inode number
1343 // Total size in bytes1350 ino: u64,
1344 stx_size: u64,1351
1345 // Number of 512B blocks allocated1352 /// Total size in bytes
1346 stx_blocks: u64,1353 size: u64,
1347 // Mask to show what's supported in stx_attributes1354
1348 stx_attributes_mask: u64,1355 /// Number of 512B blocks allocated
13491356 blocks: u64,
1350 // The following fields are file timestamps1357
1351 // Last access1358 /// Mask to show what's supported in `attributes`.
1352 stx_atime: statx_timestamp,1359 attributes_mask: u64,
1353 // Creation1360
1354 stx_btime: statx_timestamp,1361 /// Last access file timestamp
1355 // Last status change1362 atime: statx_timestamp,
1356 stx_ctime: statx_timestamp,1363
1357 // Last modification1364 /// Creation file timestamp
1358 stx_mtime: statx_timestamp,1365 btime: statx_timestamp,
13591366
1360 // If this file represents a device, then the next two fields contain the ID of the device1367 /// Last status change file timestamp
1361 // Major ID1368 ctime: statx_timestamp,
1362 stx_rdev_major: u32,1369
1363 // Minor ID1370 /// Last modification file timestamp
1364 stx_rdev_minor: u32,1371 mtime: statx_timestamp,
13651372
1366 // The next two fields contain the ID of the device containing the filesystem where the file resides1373 /// Major ID, if this file represents a device.
1367 // Major ID1374 rdev_major: u32,
1368 stx_dev_major: u32,1375
1369 // Minor ID1376 /// Minor ID, if this file represents a device.
1370 stx_dev_minor: u32,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
1372 __pad2: [14]u64,1385 __pad2: [14]u64,
1373};1386};
lib/std/os/linux/test.zig+6-6
...@@ -69,10 +69,10 @@ test "statx" {...@@ -69,10 +69,10 @@ test "statx" {
69 else => unreachable,69 else => unreachable,
70 }70 }
7171
72 expect(stat_buf.mode == statx_buf.stx_mode);72 expect(stat_buf.mode == statx_buf.mode);
73 expect(@bitCast(u32, stat_buf.uid) == statx_buf.stx_uid);73 expect(@bitCast(u32, stat_buf.uid) == statx_buf.uid);
74 expect(@bitCast(u32, stat_buf.gid) == statx_buf.stx_gid);74 expect(@bitCast(u32, stat_buf.gid) == statx_buf.gid);
75 expect(@bitCast(u64, i64(stat_buf.size)) == statx_buf.stx_size);75 expect(@bitCast(u64, i64(stat_buf.size)) == statx_buf.size);
76 expect(@bitCast(u64, i64(stat_buf.blksize)) == statx_buf.stx_blksize);76 expect(@bitCast(u64, i64(stat_buf.blksize)) == statx_buf.blksize);
77 expect(@bitCast(u64, i64(stat_buf.blocks)) == statx_buf.stx_blocks);77 expect(@bitCast(u64, i64(stat_buf.blocks)) == statx_buf.blocks);
78}78}