Files
ww/selfhost
Hojun-Cho 2f9d6dc43a lib/os+test: add stat / lstat / fstat / exists
Hare-shaped filestat introspection. New types: filestat (80B,
mirrors fs::filestat ref/hare/fs/types.ha:141), mode (31-member
enum mirroring fs::mode ref/hare/fs/types.ha:63), stat_mask (7 bits
mirroring fs::stat_mask ref/hare/fs/types.ha:129), timespec (i64+i64,
layout-compatible with future lib/time::instant).

APIs: stat / lstat / fstat (*filestat, *u8|i32) (void|oserror) over
SYS_newfstatat (nr=262). The out-param shape sidesteps the cgreturn
24B ABI cap; commented inline. exists(*u8) bool goes through the
syscall directly rather than wrapping stat()? — dodges task #22's
80B-scrutinee match-slot disagreement until that lands.

Three latent cgen workarounds in tree, all pointer'd to filed tasks:
  #22: os.exists sidesteps the (void|oserror) match shape
  #24: `at` enum bundles AT_FDCWD/SYMLINK_NOFOLLOW/EMPTY_PATH instead
       of three top-level `def`s (negative-literal def DATA omit)
  #25: kstat.mode typed as `mode` (enum) rather than u32 to skip the
       redundant u32→enum cast emit

Tests: 976_stat_run, 9 rows — stat/lstat/fstat × regfile/dir/symlink
plus exists × {regfile,dir,noent}. Row 1 also pins perm-bit and
atime/mtime/ctime!=0 to catch silent kstat→filestat offset miscompiles
(kstat fields at 72/88/104).

Graduation to lib/fs when it ships is noted inline; signatures stay
rename-compatible.
2026-05-16 02:42:41 +09:00
..