| ... | ... | @@ -12,8 +12,6 @@ const socklen_t = linux.socklen_t; |
| 12 | 12 | const iovec = linux.iovec; |
| 13 | 13 | const iovec_const = linux.iovec_const; |
| 14 | 14 | |
| 15 | | pub const mode_t = usize; |
| 16 | | |
| 17 | 15 | pub const SYS = extern enum(usize) { |
| 18 | 16 | restart_syscall = 0, |
| 19 | 17 | exit = 1, |
| ... | ... | @@ -484,14 +482,14 @@ pub const msghdr_const = extern struct { |
| 484 | 482 | |
| 485 | 483 | pub const off_t = i64; |
| 486 | 484 | pub const ino_t = u64; |
| 485 | pub const mode_t = u32; |
| 487 | 486 | |
| 488 | | /// Renamed to Stat to not conflict with the stat function. |
| 489 | 487 | /// atime, mtime, and ctime have functions to return `timespec`, |
| 490 | 488 | /// because although this is a POSIX API, the layout and names of |
| 491 | 489 | /// the structs are inconsistent across operating systems, and |
| 492 | 490 | /// in C, macros are used to hide the differences. Here we use |
| 493 | 491 | /// methods to accomplish this. |
| 494 | | pub const Stat = extern struct { |
| 492 | pub const libc_stat = extern struct { |
| 495 | 493 | dev: u64, |
| 496 | 494 | ino: ino_t, |
| 497 | 495 | mode: u32, |
| ... | ... | @@ -524,6 +522,45 @@ pub const Stat = extern struct { |
| 524 | 522 | } |
| 525 | 523 | }; |
| 526 | 524 | |
| 525 | pub const kernel_stat = extern struct { |
| 526 | dev: u32, |
| 527 | ino: ino_t, |
| 528 | mode: mode_t, |
| 529 | nlink: i16, |
| 530 | |
| 531 | uid: u32, |
| 532 | gid: u32, |
| 533 | rdev: u32, |
| 534 | |
| 535 | size: off_t, |
| 536 | atim: isize, |
| 537 | mtim: isize, |
| 538 | ctim: isize, |
| 539 | |
| 540 | blksize: off_t, |
| 541 | blocks: off_t, |
| 542 | |
| 543 | __unused4: [2]isize, |
| 544 | |
| 545 | // Hack to make the stdlib not complain about atime |
| 546 | // and friends not being a method. |
| 547 | // TODO what should tv_nsec be filled with? |
| 548 | pub fn atime(self: Stat) timespec { |
| 549 | return timespec{.tv_sec=self.atim, .tv_nsec=0}; |
| 550 | } |
| 551 | |
| 552 | pub fn mtime(self: Stat) timespec { |
| 553 | return timespec{.tv_sec=self.mtim, .tv_nsec=0}; |
| 554 | } |
| 555 | |
| 556 | pub fn ctime(self: Stat) timespec { |
| 557 | return timespec{.tv_sec=self.ctim, .tv_nsec=0}; |
| 558 | } |
| 559 | }; |
| 560 | |
| 561 | /// Renamed to Stat to not conflict with the stat function. |
| 562 | pub const Stat = kernel_stat; |
| 563 | |
| 527 | 564 | pub const timespec = extern struct { |
| 528 | 565 | tv_sec: isize, |
| 529 | 566 | tv_nsec: isize, |