@@ -514,6 +514,24 @@ pub const Stat = struct {
514
514
.ctime = st .ctime (),
515
515
};
516
516
}
517
+
518
+ fn fromStatx (stx : Statx ) @This () {
519
+ return .{
520
+ .dev = makedev (stx .dev_major , stx .dev_minor ),
521
+ .ino = stx .ino ,
522
+ .mode = stx .mode ,
523
+ .nlink = stx .nlink ,
524
+ .uid = stx .uid ,
525
+ .gid = stx .gid ,
526
+ .rdev = makedev (stx .rdev_major , stx .rdev_minor ),
527
+ .size = stx .size ,
528
+ .blksize = stx .blksize ,
529
+ .blocks = @intCast (stx .blocks ),
530
+ .atime = stx .atime .toTimespec (),
531
+ .mtime = stx .mtime .toTimespec (),
532
+ .ctime = stx .ctime .toTimespec (),
533
+ };
534
+ }
517
535
};
518
536
519
537
// The 64-bit `stat` definition used by the Linux kernel,
@@ -6496,68 +6514,56 @@ pub const statx_timestamp = extern struct {
6496
6514
sec : i64 ,
6497
6515
nsec : u32 ,
6498
6516
__pad1 : u32 ,
6517
+
6518
+ fn toTimespec (self : @This ()) timespec {
6519
+ return .{
6520
+ .sec = self .sec ,
6521
+ .nsec = @as (i32 , @bitCast (self .nsec )),
6522
+ };
6523
+ }
6499
6524
};
6500
6525
6501
6526
/// Renamed to `Statx` to not conflict with the `statx` function.
6502
6527
pub const Statx = extern struct {
6503
6528
/// Mask of bits indicating filled fields
6504
6529
mask : u32 ,
6505
-
6506
6530
/// Block size for filesystem I/O
6507
6531
blksize : u32 ,
6508
-
6509
6532
/// Extra file attribute indicators
6510
6533
attributes : u64 ,
6511
-
6512
6534
/// Number of hard links
6513
6535
nlink : u32 ,
6514
-
6515
6536
/// User ID of owner
6516
6537
uid : uid_t ,
6517
-
6518
6538
/// Group ID of owner
6519
6539
gid : gid_t ,
6520
-
6521
6540
/// File type and mode
6522
6541
mode : u16 ,
6523
6542
__pad1 : u16 ,
6524
-
6525
6543
/// Inode number
6526
6544
ino : u64 ,
6527
-
6528
6545
/// Total size in bytes
6529
6546
size : u64 ,
6530
-
6531
6547
/// Number of 512B blocks allocated
6532
6548
blocks : u64 ,
6533
-
6534
6549
/// Mask to show what's supported in `attributes`.
6535
6550
attributes_mask : u64 ,
6536
-
6537
6551
/// Last access file timestamp
6538
6552
atime : statx_timestamp ,
6539
-
6540
6553
/// Creation file timestamp
6541
6554
btime : statx_timestamp ,
6542
-
6543
6555
/// Last status change file timestamp
6544
6556
ctime : statx_timestamp ,
6545
-
6546
6557
/// Last modification file timestamp
6547
6558
mtime : statx_timestamp ,
6548
-
6549
6559
/// Major ID, if this file represents a device.
6550
6560
rdev_major : u32 ,
6551
-
6552
6561
/// Minor ID, if this file represents a device.
6553
6562
rdev_minor : u32 ,
6554
-
6555
6563
/// Major ID of the device containing the filesystem where this file resides.
6556
6564
dev_major : u32 ,
6557
-
6558
6565
/// Minor ID of the device containing the filesystem where this file resides.
6559
6566
dev_minor : u32 ,
6560
-
6561
6567
__pad2 : [14 ]u64 ,
6562
6568
};
6563
6569
0 commit comments