commit 405e5dcb9592234cf0e987458de4128bc0a99c16
parent 20d9277ba522f8da0245689e742770cdb860c990
Author: Drew DeVault <sir@cmpwn.com>
Date: Sun, 7 Feb 2021 10:37:56 -0500
rt: drop arch-specific stat buffer
Diffstat:
4 files changed, 38 insertions(+), 53 deletions(-)
diff --git a/rt/+linux/arch+aarch64.ha b/rt/+linux/arch+aarch64.ha
@@ -1,18 +0,0 @@
-export type st = struct {
- dev: dev_t,
- ino: ino_t,
- mode: mode_t,
- nlink: nlink_t,
- uid: uid_t,
- gid: gid_t,
- rdev: dev_t,
- __pad0: u64,
- sz: i64,
- blksz: i64,
- __pad1: int,
- blocks: i64,
- atime: timespec,
- mtime: timespec,
- ctime: timespec,
- __pad2: [2]uint,
-};
diff --git a/rt/+linux/arch+x86_64.ha b/rt/+linux/arch+x86_64.ha
@@ -1,17 +0,0 @@
-export type st = struct {
- dev: dev_t,
- ino: ino_t,
- nlink: nlink_t,
- mode: mode_t,
- uid: uid_t,
- gid: gid_t,
- __pad0: uint,
- rdev: dev_t,
- sz: i64,
- blksz: i64,
- blocks: i64,
- atime: timespec,
- mtime: timespec,
- ctime: timespec,
- __pad1: [3]i64,
-};
diff --git a/rt/+linux/stat.ha b/rt/+linux/stat.ha
@@ -35,16 +35,15 @@ export fn fstatat(
statbuf.uid = statxbuf.uid;
statbuf.gid = statxbuf.gid;
statbuf.rdev = mkdev(statxbuf.dev_major, statxbuf.dev_minor);
- statbuf.sz = statxbuf.sz: i64;
- statbuf.blksz = statxbuf.blksize: i64;
- statbuf.blocks = statxbuf.blocks: i64;
+ statbuf.sz = statxbuf.sz;
+ statbuf.blksz = statxbuf.blksize;
+ statbuf.blocks = statxbuf.blocks;
statbuf.atime.tv_sec = statxbuf.atime.tv_sec;
statbuf.atime.tv_nsec = statxbuf.atime.tv_nsec: i64;
statbuf.mtime.tv_sec = statxbuf.mtime.tv_sec;
statbuf.mtime.tv_nsec = statxbuf.mtime.tv_nsec: i64;
statbuf.ctime.tv_sec = statxbuf.ctime.tv_sec;
statbuf.ctime.tv_nsec = statxbuf.ctime.tv_nsec: i64;
- return void;
};
export fn stat(path: *const char, statbuf: *st) (errno | void) =
diff --git a/rt/+linux/types.ha b/rt/+linux/types.ha
@@ -55,22 +55,43 @@ type stx = struct {
rdev_minor: u32,
dev_major: u32,
dev_minor: u32,
+ __reserved: [14]u64,
};
-def STATX_TYPE: uint = 0x00000001u;
-def STATX_MODE: uint = 0x00000002u;
-def STATX_NLINK: uint = 0x00000004u;
-def STATX_UID: uint = 0x00000008u;
-def STATX_GID: uint = 0x00000010u;
-def STATX_ATIME: uint = 0x00000020u;
-def STATX_MTIME: uint = 0x00000040u;
-def STATX_CTIME: uint = 0x00000080u;
-def STATX_INO: uint = 0x00000100u;
-def STATX_SIZE: uint = 0x00000200u;
-def STATX_BLOCKS: uint = 0x00000400u;
-def STATX_BASIC_STATS: uint = 0x000007FFu;
-def STATX_BTIME: uint = 0x00000800u;
-def STATX_MNT_ID: uint = 0x00001000u;
+// Note: the st type does not match the kernel API. The kernel API has a stat
+// buffer which varies from arch to arch, but because we always use statx(2) and
+// copy the data from the stx type, we don't have to deal with that nonsense.
+
+export type st = struct {
+ dev: dev_t,
+ ino: ino_t,
+ mode: mode_t,
+ nlink: nlink_t,
+ uid: uid_t,
+ gid: gid_t,
+ rdev: dev_t,
+ sz: u64,
+ blksz: u64,
+ blocks: u64,
+ atime: timespec,
+ mtime: timespec,
+ ctime: timespec,
+};
+
+def STATX_TYPE: uint = 0x00000001u;
+def STATX_MODE: uint = 0x00000002u;
+def STATX_NLINK: uint = 0x00000004u;
+def STATX_UID: uint = 0x00000008u;
+def STATX_GID: uint = 0x00000010u;
+def STATX_ATIME: uint = 0x00000020u;
+def STATX_MTIME: uint = 0x00000040u;
+def STATX_CTIME: uint = 0x00000080u;
+def STATX_INO: uint = 0x00000100u;
+def STATX_SIZE: uint = 0x00000200u;
+def STATX_BLOCKS: uint = 0x00000400u;
+def STATX_BASIC_STATS: uint = 0x000007FFu;
+def STATX_BTIME: uint = 0x00000800u;
+def STATX_MNT_ID: uint = 0x00001000u;
export def SIGHUP: int = 1;
export def SIGINT: int = 2;