authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-08-16 11:23:02+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-08-18 07:27:23+02:00
logea38009f3d0476867d945c3f14f5053206ec87f9
tree48d7dd0b195ed78e20b020a40c3819c698fa011e
parented9a502dffa8db45ef2f73edcbd20c52e26c548f

std.os.linux: Fix Stat struct for mips/mips64.


2 files changed, 47 insertions(+), 25 deletions(-)

lib/std/os/linux/mips.zig+24-13
...@@ -322,7 +322,7 @@ pub const msghdr_const = extern struct {...@@ -322,7 +322,7 @@ pub const msghdr_const = extern struct {
322 flags: i32,322 flags: i32,
323};323};
324324
325pub const blksize_t = i32;325pub const blksize_t = u32;
326pub const nlink_t = u32;326pub const nlink_t = u32;
327pub const time_t = i32;327pub const time_t = i32;
328pub const mode_t = u32;328pub const mode_t = u32;
...@@ -331,36 +331,47 @@ pub const ino_t = u64;...@@ -331,36 +331,47 @@ pub const ino_t = u64;
331pub const dev_t = u64;331pub const dev_t = u64;
332pub const blkcnt_t = i64;332pub const blkcnt_t = i64;
333333
334// The `stat` definition used by the Linux kernel.334// The `stat64` definition used by the Linux kernel.
335pub const Stat = extern struct {335pub const Stat = extern struct {
336 dev: u32,336 dev: dev_t,
337 __pad0: [3]u32, // Reserved for st_dev expansion337 __pad0: [2]u32, // -1 because our dev_t is u64 (kernel dev_t is really u32).
338 ino: ino_t,338 ino: ino_t,
339 mode: mode_t,339 mode: mode_t,
340 nlink: nlink_t,340 nlink: nlink_t,
341 uid: uid_t,341 uid: uid_t,
342 gid: gid_t,342 gid: gid_t,
343 rdev: u32,343 rdev: dev_t,
344 __pad1: [3]u32,344 __pad1: [2]u32, // -1 because our dev_t is u64 (kernel dev_t is really u32).
345 size: off_t,345 size: off_t,
346 atim: timespec,346 atim: i32,
347 mtim: timespec,347 atim_nsec: u32,
348 ctim: timespec,348 mtim: i32,
349 mtim_nsec: u32,
350 ctim: i32,
351 ctim_nsec: u32,
349 blksize: blksize_t,352 blksize: blksize_t,
350 __pad3: u32,353 __pad3: u32,
351 blocks: blkcnt_t,354 blocks: blkcnt_t,
352 __pad4: [14]usize,
353355
354 pub fn atime(self: @This()) timespec {356 pub fn atime(self: @This()) timespec {
355 return self.atim;357 return .{
358 .sec = self.atim,
359 .nsec = self.atim_nsec,
360 };
356 }361 }
357362
358 pub fn mtime(self: @This()) timespec {363 pub fn mtime(self: @This()) timespec {
359 return self.mtim;364 return .{
365 .sec = self.mtim,
366 .nsec = self.mtim_nsec,
367 };
360 }368 }
361369
362 pub fn ctime(self: @This()) timespec {370 pub fn ctime(self: @This()) timespec {
363 return self.ctim;371 return .{
372 .sec = self.ctim,
373 .nsec = self.ctim_nsec,
374 };
364 }375 }
365};376};
366377
lib/std/os/linux/mips64.zig+23-12
...@@ -301,7 +301,7 @@ pub const msghdr_const = extern struct {...@@ -301,7 +301,7 @@ pub const msghdr_const = extern struct {
301 flags: i32,301 flags: i32,
302};302};
303303
304pub const blksize_t = i32;304pub const blksize_t = u32;
305pub const nlink_t = u32;305pub const nlink_t = u32;
306pub const time_t = i32;306pub const time_t = i32;
307pub const mode_t = u32;307pub const mode_t = u32;
...@@ -312,34 +312,45 @@ pub const blkcnt_t = i64;...@@ -312,34 +312,45 @@ pub const blkcnt_t = i64;
312312
313// The `stat` definition used by the Linux kernel.313// The `stat` definition used by the Linux kernel.
314pub const Stat = extern struct {314pub const Stat = extern struct {
315 dev: u32,315 dev: dev_t,
316 __pad0: [3]u32, // Reserved for st_dev expansion316 __pad0: [2]u32, // -1 because our dev_t is u64 (kernel dev_t is really u32).
317 ino: ino_t,317 ino: ino_t,
318 mode: mode_t,318 mode: mode_t,
319 nlink: nlink_t,319 nlink: nlink_t,
320 uid: uid_t,320 uid: uid_t,
321 gid: gid_t,321 gid: gid_t,
322 rdev: u32,322 rdev: dev_t,
323 __pad1: [3]u32,323 __pad1: [2]u32, // -1 because our dev_t is u64 (kernel dev_t is really u32).
324 size: off_t,324 size: off_t,
325 atim: timespec,325 atim: u32,
326 mtim: timespec,326 atim_nsec: u32,
327 ctim: timespec,327 mtim: u32,
328 mtim_nsec: u32,
329 ctim: u32,
330 ctim_nsec: u32,
328 blksize: blksize_t,331 blksize: blksize_t,
329 __pad3: u32,332 __pad3: u32,
330 blocks: blkcnt_t,333 blocks: blkcnt_t,
331 __pad4: [14]usize,
332334
333 pub fn atime(self: @This()) timespec {335 pub fn atime(self: @This()) timespec {
334 return self.atim;336 return .{
337 .sec = self.atim,
338 .nsec = self.atim_nsec,
339 };
335 }340 }
336341
337 pub fn mtime(self: @This()) timespec {342 pub fn mtime(self: @This()) timespec {
338 return self.mtim;343 return .{
344 .sec = self.mtim,
345 .nsec = self.mtim_nsec,
346 };
339 }347 }
340348
341 pub fn ctime(self: @This()) timespec {349 pub fn ctime(self: @This()) timespec {
342 return self.ctim;350 return .{
351 .sec = self.ctim,
352 .nsec = self.ctim_nsec,
353 };
343 }354 }
344};355};
345356