lib/os: drop kstat.mode typed-alias workaround (post-#33)

Pre-#33 workaround widened kstat.mode to a typed alias to dodge
an MOVL emit issue. With #33 (session 3) landed, plain u32 works
and matches both the kernel SYS_newfstatat struct layout (st_mode
is unsigned int) and Hare's sys/+linux/types.ha:120 st.mode width.
The cast-to-mode at fillfilestat is retained (kstat.mode is a u32
holding mode-typed bits, and the cast carries that intent).

Keeps the kstat surface internally consistent with its other raw-
primitive fields (uid: u32, gid: u32, ino: u64, …). A future
Hare-fidelity pass can graduate kstat to the t-suffixed aliases
({uid,gid,mode,…}_t) but that's a separate consolidation.
This commit is contained in:
2026-05-18 00:30:49 +09:00
parent dd274315a0
commit 225ee97f5c
7 changed files with 14 additions and 56 deletions

View File

@@ -625,17 +625,11 @@ export type filestat = struct {
// fields). 144 bytes. Module-internal; SYS_newfstatat writes into
// this buffer and the public stat fns then copy the bits into the
// Hare-shaped [[filestat]].
//
// Mode is typed as the public [[mode]] enum (rather than raw u32)
// so [[fillfilestat]]'s `out.mode = k.mode` needs no cast. Cstage
// emits a redundant `MOVL AX, AX` on u32 → enum-u32 casts that
// wwstage skips (task #25); the in-tree shape sidesteps it.
// Identical byte layout (both 4B at offset 24).
type kstat = struct {
dev: u64, // 0
ino: u64, // 8
nlink: u64, // 16
mode: mode, // 24
mode: u32, // 24
uid: u32, // 28
gid: u32, // 32
pad0: u32, // 36
@@ -670,7 +664,7 @@ fn fillfilestat(out: *filestat, k: *kstat) void = {
out.mask = stat_mask.UID | stat_mask.GID | stat_mask.SIZE
| stat_mask.INODE | stat_mask.ATIME | stat_mask.MTIME
| stat_mask.CTIME;
out.mode = k.mode;
out.mode = k.mode: mode;
out.uid = k.uid;
out.gid = k.gid;
out.sz = k.sz: u64;

View File

@@ -625,17 +625,11 @@ export type filestat = struct {
// fields). 144 bytes. Module-internal; SYS_newfstatat writes into
// this buffer and the public stat fns then copy the bits into the
// Hare-shaped [[filestat]].
//
// Mode is typed as the public [[mode]] enum (rather than raw u32)
// so [[fillfilestat]]'s `out.mode = k.mode` needs no cast. Cstage
// emits a redundant `MOVL AX, AX` on u32 → enum-u32 casts that
// wwstage skips (task #25); the in-tree shape sidesteps it.
// Identical byte layout (both 4B at offset 24).
type kstat = struct {
dev: u64, // 0
ino: u64, // 8
nlink: u64, // 16
mode: mode, // 24
mode: u32, // 24
uid: u32, // 28
gid: u32, // 32
pad0: u32, // 36
@@ -670,7 +664,7 @@ fn fillfilestat(out: *filestat, k: *kstat) void = {
out.mask = stat_mask.UID | stat_mask.GID | stat_mask.SIZE
| stat_mask.INODE | stat_mask.ATIME | stat_mask.MTIME
| stat_mask.CTIME;
out.mode = k.mode;
out.mode = k.mode: mode;
out.uid = k.uid;
out.gid = k.gid;
out.sz = k.sz: u64;

View File

@@ -625,17 +625,11 @@ export type filestat = struct {
// fields). 144 bytes. Module-internal; SYS_newfstatat writes into
// this buffer and the public stat fns then copy the bits into the
// Hare-shaped [[filestat]].
//
// Mode is typed as the public [[mode]] enum (rather than raw u32)
// so [[fillfilestat]]'s `out.mode = k.mode` needs no cast. Cstage
// emits a redundant `MOVL AX, AX` on u32 → enum-u32 casts that
// wwstage skips (task #25); the in-tree shape sidesteps it.
// Identical byte layout (both 4B at offset 24).
type kstat = struct {
dev: u64, // 0
ino: u64, // 8
nlink: u64, // 16
mode: mode, // 24
mode: u32, // 24
uid: u32, // 28
gid: u32, // 32
pad0: u32, // 36
@@ -670,7 +664,7 @@ fn fillfilestat(out: *filestat, k: *kstat) void = {
out.mask = stat_mask.UID | stat_mask.GID | stat_mask.SIZE
| stat_mask.INODE | stat_mask.ATIME | stat_mask.MTIME
| stat_mask.CTIME;
out.mode = k.mode;
out.mode = k.mode: mode;
out.uid = k.uid;
out.gid = k.gid;
out.sz = k.sz: u64;

View File

@@ -625,17 +625,11 @@ export type filestat = struct {
// fields). 144 bytes. Module-internal; SYS_newfstatat writes into
// this buffer and the public stat fns then copy the bits into the
// Hare-shaped [[filestat]].
//
// Mode is typed as the public [[mode]] enum (rather than raw u32)
// so [[fillfilestat]]'s `out.mode = k.mode` needs no cast. Cstage
// emits a redundant `MOVL AX, AX` on u32 → enum-u32 casts that
// wwstage skips (task #25); the in-tree shape sidesteps it.
// Identical byte layout (both 4B at offset 24).
type kstat = struct {
dev: u64, // 0
ino: u64, // 8
nlink: u64, // 16
mode: mode, // 24
mode: u32, // 24
uid: u32, // 28
gid: u32, // 32
pad0: u32, // 36
@@ -670,7 +664,7 @@ fn fillfilestat(out: *filestat, k: *kstat) void = {
out.mask = stat_mask.UID | stat_mask.GID | stat_mask.SIZE
| stat_mask.INODE | stat_mask.ATIME | stat_mask.MTIME
| stat_mask.CTIME;
out.mode = k.mode;
out.mode = k.mode: mode;
out.uid = k.uid;
out.gid = k.gid;
out.sz = k.sz: u64;

View File

@@ -625,17 +625,11 @@ export type filestat = struct {
// fields). 144 bytes. Module-internal; SYS_newfstatat writes into
// this buffer and the public stat fns then copy the bits into the
// Hare-shaped [[filestat]].
//
// Mode is typed as the public [[mode]] enum (rather than raw u32)
// so [[fillfilestat]]'s `out.mode = k.mode` needs no cast. Cstage
// emits a redundant `MOVL AX, AX` on u32 → enum-u32 casts that
// wwstage skips (task #25); the in-tree shape sidesteps it.
// Identical byte layout (both 4B at offset 24).
type kstat = struct {
dev: u64, // 0
ino: u64, // 8
nlink: u64, // 16
mode: mode, // 24
mode: u32, // 24
uid: u32, // 28
gid: u32, // 32
pad0: u32, // 36
@@ -670,7 +664,7 @@ fn fillfilestat(out: *filestat, k: *kstat) void = {
out.mask = stat_mask.UID | stat_mask.GID | stat_mask.SIZE
| stat_mask.INODE | stat_mask.ATIME | stat_mask.MTIME
| stat_mask.CTIME;
out.mode = k.mode;
out.mode = k.mode: mode;
out.uid = k.uid;
out.gid = k.gid;
out.sz = k.sz: u64;