From ac861b668cc3d3a8a1d1942240240b42e474c740 Mon Sep 17 00:00:00 2001 From: Stephen Gregoratto Date: Sun, 29 Sep 2024 15:45:22 +1000 Subject: [PATCH] Linux: Use the 64-bit `Stat` and move it up a level Stat has been moved into the `linux` module since the fields are so similar between the architectures. Each architecture now uses the proper 64-bit stat structure, and each field has been audited to match the kernel headers. This effectively reverts #ea38009 in doing so. --- lib/std/os/linux.zig | 342 ++++++++++++++++++++++++++++++++- lib/std/os/linux/arm-eabi.zig | 32 --- lib/std/os/linux/arm64.zig | 32 --- lib/std/os/linux/mips.zig | 44 ----- lib/std/os/linux/mips64.zig | 44 ----- lib/std/os/linux/powerpc.zig | 31 --- lib/std/os/linux/powerpc64.zig | 30 --- lib/std/os/linux/riscv32.zig | 32 --- lib/std/os/linux/riscv64.zig | 32 --- lib/std/os/linux/s390x.zig | 30 --- lib/std/os/linux/sparc64.zig | 37 +--- lib/std/os/linux/x86.zig | 32 --- lib/std/os/linux/x86_64.zig | 33 ---- 13 files changed, 343 insertions(+), 408 deletions(-) diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig index 56c62f811dea..0276fb727797 100644 --- a/lib/std/os/linux.zig +++ b/lib/std/os/linux.zig @@ -96,7 +96,6 @@ pub const HWCAP = arch_bits.HWCAP; pub const MMAP2_UNIT = arch_bits.MMAP2_UNIT; pub const REG = arch_bits.REG; pub const SC = arch_bits.SC; -pub const Stat = arch_bits.Stat; pub const VDSO = arch_bits.VDSO; pub const blkcnt_t = arch_bits.blkcnt_t; pub const blksize_t = arch_bits.blksize_t; @@ -470,6 +469,347 @@ pub const O = switch (native_arch) { else => @compileError("missing std.os.linux.O constants for this architecture"), }; +// The 64-bit `stat` definition used by the Linux kernel, +// which is one of the following choices: +// - struct stat on 64-bit target. +// - struct stat64 on a 32-bit target. +// - struct stat64 on a 64-bit target. +pub const Stat = switch (native_arch) { + .x86 => extern struct { // stat64 + dev: dev_t, + __pad0: [4]u8 = .{ 0, 0, 0, 0 }, + __ino: u32 = 0, + mode: mode_t, + nlink: nlink_t, + uid: uid_t, + gid: gid_t, + rdev: dev_t, + __pad3: [4]u8 = .{ 0, 0, 0, 0 }, + size: off_t, + blksize: blksize_t, + blocks: blkcnt_t, + atim: u32, + atim_nsec: u32, + mtim: u32, + mtim_nsec: u32, + ctim: u32, + ctim_nsec: u32, + ino: ino_t, + + pub fn atime(self: @This()) timespec { + return timespec.makeTimespec(self.atim, self.atim_nsec); + } + + pub fn mtime(self: @This()) timespec { + return timespec.makeTimespec(self.mtim, self.mtim_nsec); + } + + pub fn ctime(self: @This()) timespec { + return timespec.makeTimespec(self.ctim, self.ctim_nsec); + } + }, + .x86_64 => extern struct { // stat + dev: dev_t, + ino: ino_t, + nlink: nlink_t, + mode: mode_t, + uid: uid_t, + gid: gid_t, + __pad0: u32 = 0, + rdev: dev_t, + size: off_t, + blksize: blksize_t, + blocks: blkcnt_t, + atim: u64, + atim_nsec: u64, + mtim: u64, + mtim_nsec: u64, + ctim: u64, + ctim_nsec: u64, + __unused: [3]isize = .{ 0, 0, 0 }, + + pub fn atime(self: @This()) timespec { + return timespec.makeTimespec(self.atim, self.atim_nsec); + } + + pub fn mtime(self: @This()) timespec { + return timespec.makeTimespec(self.mtim, self.mtim_nsec); + } + + pub fn ctime(self: @This()) timespec { + return timespec.makeTimespec(self.ctim, self.ctim_nsec); + } + }, + .arm, .armeb, .thumb, .thumbeb => extern struct { // stat64 + dev: dev_t, + __dev_padding: [4]u8 = .{ 0, 0, 0, 0 }, + __ino: u32 = 0, + mode: mode_t, + nlink: nlink_t, + uid: uid_t, + gid: gid_t, + rdev: dev_t, + __rdev_padding: [4]u8 = .{ 0, 0, 0, 0 }, + size: off_t, + blksize: blksize_t, + blocks: blkcnt_t, + atim: usize, + atim_nsec: usize, + mtim: usize, + mtim_nsec: usize, + ctim: usize, + ctim_nsec: usize, + ino: ino_t, + + pub fn atime(self: @This()) timespec { + return timespec.makeTimespec(self.atim, self.atim_nsec); + } + + pub fn mtime(self: @This()) timespec { + return timespec.makeTimespec(self.mtim, self.mtim_nsec); + } + + pub fn ctime(self: @This()) timespec { + return timespec.makeTimespec(self.ctim, self.ctim_nsec); + } + }, + .sparc64 => extern struct { // stat64 + dev: dev_t, + ino: ino_t, + nlink: u64, + mode: mode_t, + uid: uid_t, + gid: gid_t, + __pad0: u32 = 0, + rdev: dev_t, + size: off_t, + blksize: blksize_t, + blocks: blkcnt_t, + atim: usize, + atim_nsec: usize, + mtim: usize, + mtim_nsec: usize, + ctim: usize, + ctim_nsec: usize, + __unused: [3]isize = .{ 0, 0, 0 }, + + pub fn atime(self: @This()) timespec { + return timespec.makeTimespec(self.atim, self.atim_nsec); + } + + pub fn mtime(self: @This()) timespec { + return timespec.makeTimespec(self.mtim, self.mtim_nsec); + } + + pub fn ctime(self: @This()) timespec { + return timespec.makeTimespec(self.ctim, self.ctim_nsec); + } + }, + .mips, .mipsel => extern struct { // stat64 + dev: usize, + __pad0: [3]u32 = .{ 0, 0, 0 }, + ino: ino_t, + mode: mode_t, + nlink: nlink_t, + uid: uid_t, + gid: gid_t, + rdev: usize, + __pad1: [3]u32 = .{ 0, 0, 0 }, + size: off_t, + atim: isize, + atim_nsec: usize, + mtim: isize, + mtim_nsec: usize, + ctim: isize, + ctim_nsec: usize, + blksize: blksize_t, + __pad2: u32 = 0, + blocks: blkcnt_t, + + pub fn atime(self: @This()) timespec { + return timespec.makeTimespec(self.atim, self.atim_nsec); + } + + pub fn mtime(self: @This()) timespec { + return timespec.makeTimespec(self.mtim, self.mtim_nsec); + } + + pub fn ctime(self: @This()) timespec { + return timespec.makeTimespec(self.ctim, self.ctim_nsec); + } + }, + .mips64, .mips64el => extern struct { // stat + dev: u32, + __pad0: [3]u32 = .{ 0, 0, 0 }, + ino: ino_t, + mode: mode_t, + nlink: nlink_t, + uid: uid_t, + gid: gid_t, + rdev: u32, + __pad1: [3]u32 = .{ 0, 0, 0 }, + size: off_t, + atim: u32, + atim_nsec: u32, + mtim: u32, + mtim_nsec: u32, + ctim: u32, + ctim_nsec: u32, + blksize: blksize_t, + __pad2: u32 = 0, + blocks: blkcnt_t, + + pub fn atime(self: @This()) timespec { + return timespec.makeTimespec(self.atim, self.atim_nsec); + } + + pub fn mtime(self: @This()) timespec { + return timespec.makeTimespec(self.mtim, self.mtim_nsec); + } + + pub fn ctime(self: @This()) timespec { + return timespec.makeTimespec(self.ctim, self.ctim_nsec); + } + }, + .powerpc, .powerpcle => extern struct { // stat64 + dev: dev_t, + ino: ino_t, + mode: mode_t, + nlink: nlink_t, + uid: uid_t, + gid: gid_t, + rdev: dev_t, + __pad2: u16 = 0, + size: off_t, + blksize: blksize_t, + blocks: blkcnt_t, + atim: i32, + atim_nsec: u32, + mtim: i32, + mtim_nsec: u32, + ctim: i32, + ctim_nsec: u32, + __unused: [2]u32 = .{ 0, 0 }, + + pub fn atime(self: @This()) timespec { + return timespec.makeTimespec(self.atim, self.atim_nsec); + } + + pub fn mtime(self: @This()) timespec { + return timespec.makeTimespec(self.mtim, self.mtim_nsec); + } + + pub fn ctime(self: @This()) timespec { + return timespec.makeTimespec(self.ctim, self.ctim_nsec); + } + }, + .powerpc64, .powerpc64le => extern struct { // stat64 + dev: dev_t, + ino: ino_t, + mode: mode_t, + nlink: nlink_t, + uid: uid_t, + gid: gid_t, + rdev: dev_t, + __pad2: u16 = 0, + size: off_t, + blksize: i32, + blocks: blkcnt_t, + atim: i32, + atim_nsec: u32, + mtim: i32, + mtim_nsec: u32, + ctim: i32, + ctim_nsec: u32, + __unused: [2]u32 = .{ 0, 0 }, + + pub fn atime(self: @This()) timespec { + return timespec.makeTimespec(self.atim, self.atim_nsec); + } + + pub fn mtime(self: @This()) timespec { + return timespec.makeTimespec(self.mtim, self.mtim_nsec); + } + + pub fn ctime(self: @This()) timespec { + return timespec.makeTimespec(self.ctim, self.ctim_nsec); + } + }, + .s390x => extern struct { + dev: dev_t, + ino: ino_t, + nlink: nlink_t, + mode: mode_t, + uid: uid_t, + gid: gid_t, + __pad1: u32 = 0, + rdev: dev_t, + size: off_t, + atim: usize, + atim_nsec: usize, + mtim: usize, + mtim_nsec: usize, + ctim: usize, + ctim_nsec: usize, + blksize: blksize_t, + blocks: blkcnt_t, + __unused: [3]usize = .{ 0, 0, 0 }, + + pub fn atime(self: @This()) timespec { + return timespec.makeTimespec(self.atim, self.atim_nsec); + } + + pub fn mtime(self: @This()) timespec { + return timespec.makeTimespec(self.mtim, self.mtim_nsec); + } + + pub fn ctime(self: @This()) timespec { + return timespec.makeTimespec(self.ctim, self.ctim_nsec); + } + }, + .aarch64, + .aarch64_be, + .riscv32, + .riscv64, + .loongarch64, + => extern struct { // generic stat/stat64 + dev: u64, + ino: u64, + mode: u32, + nlink: u32, + uid: uid_t, + gid: gid_t, + rdev: u64, + __pad1: u64 = 0, + size: i64, + blksize: i32, + __pad2: i32 = 0, + blocks: i64, + // Yes, the second fields will be 32-bit on 32-bit targets. + // Presumably this is due to statx being preferred - hence newer arch's not implementing the *stat family + atim: isize, + atim_nsec: usize, + mtim: isize, + mtim_nsec: usize, + ctim: isize, + ctim_nsec: usize, + __unused: [2]u32 = .{ 0, 0 }, + + pub fn atime(self: @This()) timespec { + return timespec.makeTimespec(self.atim, self.atim_nsec); + } + + pub fn mtime(self: @This()) timespec { + return timespec.makeTimespec(self.mtim, self.mtim_nsec); + } + + pub fn ctime(self: @This()) timespec { + return timespec.makeTimespec(self.ctim, self.ctim_nsec); + } + }, + else => @compileError("missing std.linux.Stat definition for this architecture"), +}; + /// Set by startup code, used by `getauxval`. pub var elf_aux_maybe: ?[*]std.elf.Auxv = null; diff --git a/lib/std/os/linux/arm-eabi.zig b/lib/std/os/linux/arm-eabi.zig index 1d22b8c3dba7..6a43a6b72de1 100644 --- a/lib/std/os/linux/arm-eabi.zig +++ b/lib/std/os/linux/arm-eabi.zig @@ -263,38 +263,6 @@ pub const ino_t = u64; pub const dev_t = u64; pub const blkcnt_t = i64; -// The `stat` definition used by the Linux kernel. -pub const Stat = extern struct { - dev: dev_t, - __dev_padding: u32, - __ino_truncated: u32, - mode: mode_t, - nlink: nlink_t, - uid: uid_t, - gid: gid_t, - rdev: dev_t, - __rdev_padding: u32, - size: off_t, - blksize: blksize_t, - blocks: blkcnt_t, - atim: timespec, - mtim: timespec, - ctim: timespec, - ino: ino_t, - - pub fn atime(self: @This()) timespec { - return self.atim; - } - - pub fn mtime(self: @This()) timespec { - return self.mtim; - } - - pub fn ctime(self: @This()) timespec { - return self.ctim; - } -}; - pub const timeval = extern struct { sec: i32, usec: i32, diff --git a/lib/std/os/linux/arm64.zig b/lib/std/os/linux/arm64.zig index 9248360ae97d..2bf702562109 100644 --- a/lib/std/os/linux/arm64.zig +++ b/lib/std/os/linux/arm64.zig @@ -221,38 +221,6 @@ pub const ino_t = usize; pub const dev_t = usize; pub const blkcnt_t = isize; -// The `stat` definition used by the Linux kernel. -pub const Stat = extern struct { - dev: dev_t, - ino: ino_t, - mode: mode_t, - nlink: nlink_t, - uid: uid_t, - gid: gid_t, - rdev: dev_t, - __pad: usize, - size: off_t, - blksize: blksize_t, - __pad2: i32, - blocks: blkcnt_t, - atim: timespec, - mtim: timespec, - ctim: timespec, - __unused: [2]u32, - - pub fn atime(self: @This()) timespec { - return self.atim; - } - - pub fn mtime(self: @This()) timespec { - return self.mtim; - } - - pub fn ctime(self: @This()) timespec { - return self.ctim; - } -}; - pub const timeval = extern struct { sec: isize, usec: isize, diff --git a/lib/std/os/linux/mips.zig b/lib/std/os/linux/mips.zig index e6cb5f790025..05e984dd7aac 100644 --- a/lib/std/os/linux/mips.zig +++ b/lib/std/os/linux/mips.zig @@ -331,50 +331,6 @@ pub const ino_t = u64; pub const dev_t = u64; pub const blkcnt_t = i64; -// The `stat64` definition used by the Linux kernel. -pub const Stat = extern struct { - dev: dev_t, - __pad0: [2]u32, // -1 because our dev_t is u64 (kernel dev_t is really u32). - ino: ino_t, - mode: mode_t, - nlink: nlink_t, - uid: uid_t, - gid: gid_t, - rdev: dev_t, - __pad1: [2]u32, // -1 because our dev_t is u64 (kernel dev_t is really u32). - size: off_t, - atim: i32, - atim_nsec: u32, - mtim: i32, - mtim_nsec: u32, - ctim: i32, - ctim_nsec: u32, - blksize: blksize_t, - __pad3: u32, - blocks: blkcnt_t, - - pub fn atime(self: @This()) timespec { - return .{ - .sec = self.atim, - .nsec = self.atim_nsec, - }; - } - - pub fn mtime(self: @This()) timespec { - return .{ - .sec = self.mtim, - .nsec = self.mtim_nsec, - }; - } - - pub fn ctime(self: @This()) timespec { - return .{ - .sec = self.ctim, - .nsec = self.ctim_nsec, - }; - } -}; - pub const timeval = extern struct { sec: isize, usec: isize, diff --git a/lib/std/os/linux/mips64.zig b/lib/std/os/linux/mips64.zig index 5e6661eae5cf..54506e352881 100644 --- a/lib/std/os/linux/mips64.zig +++ b/lib/std/os/linux/mips64.zig @@ -310,50 +310,6 @@ pub const ino_t = u64; pub const dev_t = u64; pub const blkcnt_t = i64; -// The `stat` definition used by the Linux kernel. -pub const Stat = extern struct { - dev: dev_t, - __pad0: [2]u32, // -1 because our dev_t is u64 (kernel dev_t is really u32). - ino: ino_t, - mode: mode_t, - nlink: nlink_t, - uid: uid_t, - gid: gid_t, - rdev: dev_t, - __pad1: [2]u32, // -1 because our dev_t is u64 (kernel dev_t is really u32). - size: off_t, - atim: u32, - atim_nsec: u32, - mtim: u32, - mtim_nsec: u32, - ctim: u32, - ctim_nsec: u32, - blksize: blksize_t, - __pad3: u32, - blocks: blkcnt_t, - - pub fn atime(self: @This()) timespec { - return .{ - .sec = self.atim, - .nsec = self.atim_nsec, - }; - } - - pub fn mtime(self: @This()) timespec { - return .{ - .sec = self.mtim, - .nsec = self.mtim_nsec, - }; - } - - pub fn ctime(self: @This()) timespec { - return .{ - .sec = self.ctim, - .nsec = self.ctim_nsec, - }; - } -}; - pub const timeval = extern struct { sec: isize, usec: isize, diff --git a/lib/std/os/linux/powerpc.zig b/lib/std/os/linux/powerpc.zig index 7b56b94823cd..022d25a0119b 100644 --- a/lib/std/os/linux/powerpc.zig +++ b/lib/std/os/linux/powerpc.zig @@ -271,37 +271,6 @@ pub const ino_t = u64; pub const dev_t = u64; pub const blkcnt_t = i64; -// The `stat` definition used by the Linux kernel. -pub const Stat = extern struct { - dev: dev_t, - ino: ino_t, - mode: mode_t, - nlink: nlink_t, - uid: uid_t, - gid: gid_t, - rdev: dev_t, - __rdev_padding: i16, - size: off_t, - blksize: blksize_t, - blocks: blkcnt_t, - atim: timespec, - mtim: timespec, - ctim: timespec, - __unused: [2]u32, - - pub fn atime(self: @This()) timespec { - return self.atim; - } - - pub fn mtime(self: @This()) timespec { - return self.mtim; - } - - pub fn ctime(self: @This()) timespec { - return self.ctim; - } -}; - pub const timeval = extern struct { sec: time_t, usec: isize, diff --git a/lib/std/os/linux/powerpc64.zig b/lib/std/os/linux/powerpc64.zig index 04936a113d4a..9582ba3b1517 100644 --- a/lib/std/os/linux/powerpc64.zig +++ b/lib/std/os/linux/powerpc64.zig @@ -252,36 +252,6 @@ pub const ino_t = u64; pub const dev_t = u64; pub const blkcnt_t = i64; -// The `stat` definition used by the Linux kernel. -pub const Stat = extern struct { - dev: dev_t, - ino: ino_t, - nlink: nlink_t, - mode: mode_t, - uid: uid_t, - gid: gid_t, - rdev: dev_t, - size: off_t, - blksize: blksize_t, - blocks: blkcnt_t, - atim: timespec, - mtim: timespec, - ctim: timespec, - __unused: [3]u64, - - pub fn atime(self: @This()) timespec { - return self.atim; - } - - pub fn mtime(self: @This()) timespec { - return self.mtim; - } - - pub fn ctime(self: @This()) timespec { - return self.ctim; - } -}; - pub const timeval = extern struct { sec: isize, usec: isize, diff --git a/lib/std/os/linux/riscv32.zig b/lib/std/os/linux/riscv32.zig index 457d7e50b4b4..cb088fba4163 100644 --- a/lib/std/os/linux/riscv32.zig +++ b/lib/std/os/linux/riscv32.zig @@ -212,38 +212,6 @@ pub const msghdr_const = extern struct { flags: i32, }; -// The `stat` definition used by the Linux kernel. -pub const Stat = extern struct { - dev: dev_t, - ino: ino_t, - mode: mode_t, - nlink: nlink_t, - uid: uid_t, - gid: gid_t, - rdev: dev_t, - __pad: usize, - size: off_t, - blksize: blksize_t, - __pad2: i32, - blocks: blkcnt_t, - atim: timespec, - mtim: timespec, - ctim: timespec, - __unused: [2]u32, - - pub fn atime(self: @This()) timespec { - return self.atim; - } - - pub fn mtime(self: @This()) timespec { - return self.mtim; - } - - pub fn ctime(self: @This()) timespec { - return self.ctim; - } -}; - pub const Elf_Symndx = u32; pub const MMAP2_UNIT = 4096; diff --git a/lib/std/os/linux/riscv64.zig b/lib/std/os/linux/riscv64.zig index e33169c5b115..a713137f45a9 100644 --- a/lib/std/os/linux/riscv64.zig +++ b/lib/std/os/linux/riscv64.zig @@ -212,38 +212,6 @@ pub const msghdr_const = extern struct { flags: i32, }; -// The `stat` definition used by the Linux kernel. -pub const Stat = extern struct { - dev: dev_t, - ino: ino_t, - mode: mode_t, - nlink: nlink_t, - uid: uid_t, - gid: gid_t, - rdev: dev_t, - __pad: usize, - size: off_t, - blksize: blksize_t, - __pad2: i32, - blocks: blkcnt_t, - atim: timespec, - mtim: timespec, - ctim: timespec, - __unused: [2]u32, - - pub fn atime(self: @This()) timespec { - return self.atim; - } - - pub fn mtime(self: @This()) timespec { - return self.mtim; - } - - pub fn ctime(self: @This()) timespec { - return self.ctim; - } -}; - pub const Elf_Symndx = u32; pub const VDSO = struct { diff --git a/lib/std/os/linux/s390x.zig b/lib/std/os/linux/s390x.zig index efc48af4ff39..367ef21318c2 100644 --- a/lib/std/os/linux/s390x.zig +++ b/lib/std/os/linux/s390x.zig @@ -221,36 +221,6 @@ pub const msghdr_const = extern struct { flags: i32, }; -// The `stat` definition used by the Linux kernel. -pub const Stat = extern struct { - dev: dev_t, - ino: ino_t, - nlink: nlink_t, - mode: mode_t, - uid: uid_t, - gid: gid_t, - rdev: dev_t, - size: off_t, - atim: timespec, - mtim: timespec, - ctim: timespec, - blksize: blksize_t, - blocks: blkcnt_t, - __unused: [3]c_ulong, - - pub fn atime(self: @This()) timespec { - return self.atim; - } - - pub fn mtime(self: @This()) timespec { - return self.mtim; - } - - pub fn ctime(self: @This()) timespec { - return self.ctim; - } -}; - pub const Elf_Symndx = u64; pub const VDSO = struct { diff --git a/lib/std/os/linux/sparc64.zig b/lib/std/os/linux/sparc64.zig index c146ed17cf2a..cc0f907ab254 100644 --- a/lib/std/os/linux/sparc64.zig +++ b/lib/std/os/linux/sparc64.zig @@ -2,6 +2,7 @@ const std = @import("../../std.zig"); const maxInt = std.math.maxInt; const pid_t = linux.pid_t; const uid_t = linux.uid_t; +const gid_t = linux.gid_t; const clock_t = linux.clock_t; const stack_t = linux.stack_t; const sigset_t = linux.sigset_t; @@ -295,45 +296,11 @@ pub const msghdr_const = extern struct { pub const off_t = i64; pub const ino_t = u64; pub const mode_t = u32; -pub const dev_t = usize; +pub const dev_t = u64; pub const nlink_t = u32; pub const blksize_t = isize; pub const blkcnt_t = isize; -// The `stat64` definition used by the kernel. -pub const Stat = extern struct { - dev: u64, - ino: u64, - nlink: u64, - - mode: u32, - uid: u32, - gid: u32, - __pad0: u32, - - rdev: u64, - size: i64, - blksize: i64, - blocks: i64, - - atim: timespec, - mtim: timespec, - ctim: timespec, - __unused: [3]u64, - - pub fn atime(self: @This()) timespec { - return self.atim; - } - - pub fn mtime(self: @This()) timespec { - return self.mtim; - } - - pub fn ctime(self: @This()) timespec { - return self.ctim; - } -}; - pub const timeval = extern struct { sec: isize, usec: i32, diff --git a/lib/std/os/linux/x86.zig b/lib/std/os/linux/x86.zig index abcfb99b3777..c550b5e8a2b3 100644 --- a/lib/std/os/linux/x86.zig +++ b/lib/std/os/linux/x86.zig @@ -268,38 +268,6 @@ pub const ino_t = u64; pub const dev_t = u64; pub const blkcnt_t = i64; -// The `stat` definition used by the Linux kernel. -pub const Stat = extern struct { - dev: dev_t, - __dev_padding: u32, - __ino_truncated: u32, - mode: mode_t, - nlink: nlink_t, - uid: uid_t, - gid: gid_t, - rdev: dev_t, - __rdev_padding: u32, - size: off_t, - blksize: blksize_t, - blocks: blkcnt_t, - atim: timespec, - mtim: timespec, - ctim: timespec, - ino: ino_t, - - pub fn atime(self: @This()) timespec { - return self.atim; - } - - pub fn mtime(self: @This()) timespec { - return self.mtim; - } - - pub fn ctime(self: @This()) timespec { - return self.ctim; - } -}; - pub const timeval = extern struct { sec: i32, usec: i32, diff --git a/lib/std/os/linux/x86_64.zig b/lib/std/os/linux/x86_64.zig index cef15105eee7..560d8ac0c05b 100644 --- a/lib/std/os/linux/x86_64.zig +++ b/lib/std/os/linux/x86_64.zig @@ -253,39 +253,6 @@ pub const off_t = i64; pub const ino_t = u64; pub const dev_t = u64; -// The `stat` definition used by the Linux kernel. -pub const Stat = extern struct { - dev: dev_t, - ino: ino_t, - nlink: usize, - - mode: u32, - uid: uid_t, - gid: gid_t, - __pad0: u32, - rdev: dev_t, - size: off_t, - blksize: isize, - blocks: i64, - - atim: timespec, - mtim: timespec, - ctim: timespec, - __unused: [3]isize, - - pub fn atime(self: @This()) timespec { - return self.atim; - } - - pub fn mtime(self: @This()) timespec { - return self.mtim; - } - - pub fn ctime(self: @This()) timespec { - return self.ctim; - } -}; - pub const timeval = extern struct { sec: isize, usec: isize,