| ... | @@ -1934,7 +1934,7 @@ fn dirStatFileLinux( | ... | @@ -1934,7 +1934,7 @@ fn dirStatFileLinux( |
| 1934 | try current_thread.beginSyscall(); | 1934 | try current_thread.beginSyscall(); |
| 1935 | while (true) { | 1935 | while (true) { |
| 1936 | var statx = std.mem.zeroes(linux.Statx); | 1936 | var statx = std.mem.zeroes(linux.Statx); |
| 1937 | switch (sys.errno(sys.statx(dir.handle, sub_path_posix, flags, linux_statx_mask, &statx))) { | 1937 | switch (sys.errno(sys.statx(dir.handle, sub_path_posix, flags, linux_statx_request, &statx))) { |
| 1938 | .SUCCESS => { | 1938 | .SUCCESS => { |
| 1939 | current_thread.endSyscall(); | 1939 | current_thread.endSyscall(); |
| 1940 | return statFromLinux(&statx); | 1940 | return statFromLinux(&statx); |
| ... | @@ -2169,7 +2169,7 @@ fn fileStatLinux(userdata: ?*anyopaque, file: File) File.StatError!File.Stat { | ... | @@ -2169,7 +2169,7 @@ fn fileStatLinux(userdata: ?*anyopaque, file: File) File.StatError!File.Stat { |
| 2169 | try current_thread.beginSyscall(); | 2169 | try current_thread.beginSyscall(); |
| 2170 | while (true) { | 2170 | while (true) { |
| 2171 | var statx = std.mem.zeroes(linux.Statx); | 2171 | var statx = std.mem.zeroes(linux.Statx); |
| 2172 | switch (sys.errno(sys.statx(file.handle, "", linux.AT.EMPTY_PATH, linux_statx_mask, &statx))) { | 2172 | switch (sys.errno(sys.statx(file.handle, "", linux.AT.EMPTY_PATH, linux_statx_request, &statx))) { |
| 2173 | .SUCCESS => { | 2173 | .SUCCESS => { |
| 2174 | current_thread.endSyscall(); | 2174 | current_thread.endSyscall(); |
| 2175 | return statFromLinux(&statx); | 2175 | return statFromLinux(&statx); |
| ... | @@ -11101,7 +11101,7 @@ fn clockToWasi(clock: Io.Clock) std.os.wasi.clockid_t { | ... | @@ -11101,7 +11101,7 @@ fn clockToWasi(clock: Io.Clock) std.os.wasi.clockid_t { |
| 11101 | }; | 11101 | }; |
| 11102 | } | 11102 | } |
| 11103 | | 11103 | |
| 11104 | const linux_statx_mask: std.os.linux.STATX = .{ | 11104 | const linux_statx_request: std.os.linux.STATX = .{ |
| 11105 | .TYPE = true, | 11105 | .TYPE = true, |
| 11106 | .MODE = true, | 11106 | .MODE = true, |
| 11107 | .ATIME = true, | 11107 | .ATIME = true, |
| ... | @@ -11112,14 +11112,22 @@ const linux_statx_mask: std.os.linux.STATX = .{ | ... | @@ -11112,14 +11112,22 @@ const linux_statx_mask: std.os.linux.STATX = .{ |
| 11112 | .NLINK = true, | 11112 | .NLINK = true, |
| 11113 | }; | 11113 | }; |
| 11114 | | 11114 | |
| | 11115 | const linux_statx_check: std.os.linux.STATX = .{ |
| | 11116 | .TYPE = true, |
| | 11117 | .MODE = true, |
| | 11118 | .ATIME = false, |
| | 11119 | .MTIME = true, |
| | 11120 | .CTIME = true, |
| | 11121 | .INO = true, |
| | 11122 | .SIZE = true, |
| | 11123 | .NLINK = true, |
| | 11124 | }; |
| | 11125 | |
| 11115 | fn statFromLinux(stx: *const std.os.linux.Statx) Io.UnexpectedError!File.Stat { | 11126 | fn statFromLinux(stx: *const std.os.linux.Statx) Io.UnexpectedError!File.Stat { |
| 11116 | const actual_mask_int: u32 = @bitCast(stx.mask); | 11127 | const actual_mask_int: u32 = @bitCast(stx.mask); |
| 11117 | const wanted_mask_int: u32 = @bitCast(linux_statx_mask); | 11128 | const wanted_mask_int: u32 = @bitCast(linux_statx_check); |
| 11118 | if ((actual_mask_int | wanted_mask_int) != actual_mask_int) return error.Unexpected; | 11129 | if ((actual_mask_int | wanted_mask_int) != actual_mask_int) return error.Unexpected; |
| 11119 | | 11130 | |
| 11120 | const atime = stx.atime; | | |
| 11121 | const mtime = stx.mtime; | | |
| 11122 | const ctime = stx.ctime; | | |
| 11123 | return .{ | 11131 | return .{ |
| 11124 | .inode = stx.ino, | 11132 | .inode = stx.ino, |
| 11125 | .nlink = stx.nlink, | 11133 | .nlink = stx.nlink, |
| ... | @@ -11135,9 +11143,11 @@ fn statFromLinux(stx: *const std.os.linux.Statx) Io.UnexpectedError!File.Stat { | ... | @@ -11135,9 +11143,11 @@ fn statFromLinux(stx: *const std.os.linux.Statx) Io.UnexpectedError!File.Stat { |
| 11135 | std.os.linux.S.IFSOCK => .unix_domain_socket, | 11143 | std.os.linux.S.IFSOCK => .unix_domain_socket, |
| 11136 | else => .unknown, | 11144 | else => .unknown, |
| 11137 | }, | 11145 | }, |
| 11138 | .atime = .{ .nanoseconds = @intCast(@as(i128, atime.sec) * std.time.ns_per_s + atime.nsec) }, | 11146 | .atime = if (!stx.mask.ATIME) null else .{ |
| 11139 | .mtime = .{ .nanoseconds = @intCast(@as(i128, mtime.sec) * std.time.ns_per_s + mtime.nsec) }, | 11147 | .nanoseconds = @intCast(@as(i128, stx.atime.sec) * std.time.ns_per_s + stx.atime.nsec), |
| 11140 | .ctime = .{ .nanoseconds = @intCast(@as(i128, ctime.sec) * std.time.ns_per_s + ctime.nsec) }, | 11148 | }, |
| | 11149 | .mtime = .{ .nanoseconds = @intCast(@as(i128, stx.mtime.sec) * std.time.ns_per_s + stx.mtime.nsec) }, |
| | 11150 | .ctime = .{ .nanoseconds = @intCast(@as(i128, stx.ctime.sec) * std.time.ns_per_s + stx.ctime.nsec) }, |
| 11141 | }; | 11151 | }; |
| 11142 | } | 11152 | } |
| 11143 | | 11153 | |