lib/os+selfhost: *u8→str path migration (#23)
Path-shaped entrypoints now take str: open, tryopen, access, remove, mkdir, rmdir, mkdirs, stat, lstat, exists, execve (path arg only). Each cites its Hare source (ref/hare/os/*.ha, ref/hare/sys/+linux/ *.ha). New internal kpath(str) *u8 copies into module-level pathbuf: [4096]u8 and NUL-terminates; mirrors ref/hare/sys/+linux/syscalls.ha:25,53. Non-reentrant — graduates with thread story. mkdirs flattens to one kpath at entry then walks pathbuf invoking raw SYS_mkdir to avoid nested kpath clobber. One Hare divergence at kpath: ships *u8 with nil ENAMETOOLONG sentinel instead of (*const u8 | errno). Reason: wwstage over-allocates 1-word-payload tagged returns to 24B (cstage emits 16B); filed as follow-up. Repro at .ai/probe_tagged_return_pointer_payload.ww; graduates when fix lands. Each selfhost cmd grew a private pathstr(*u8) str (cstrlen + bs) for remaining *u8 path sites; w6l shares via obj.ww. Probe 7 in smoke updated. Tests 975/976/981 cover migrated entrypoints; 976 extended with two ENAMETOOLONG rows (-36 for stat, false for exists).
This commit is contained in:
@@ -186,7 +186,9 @@ export fn named(outfd: *i32, outpath: *str,
|
||||
};
|
||||
for (true) {
|
||||
pathlen = makenamed(dir);
|
||||
let fd: i32 = os.open(&pathbuf[0], flags, perm);
|
||||
let bs: str;
|
||||
bs.ptr = &pathbuf[0]; bs.len = pathlen;
|
||||
let fd: i32 = os.open(bs, flags, perm);
|
||||
if (fd >= 0) {
|
||||
*outfd = fd;
|
||||
let p: str;
|
||||
@@ -227,7 +229,9 @@ export fn file(iomode: mode, perm: i32) (i32 | os.oserror) = {
|
||||
export fn dir() str = {
|
||||
for (true) {
|
||||
pathlen = makedir();
|
||||
let r: i32 = os.mkdir(&pathbuf[0], 448i32); // 0o700
|
||||
let bs: str;
|
||||
bs.ptr = &pathbuf[0]; bs.len = pathlen;
|
||||
let r: i32 = os.mkdir(bs, 448i32); // 0o700
|
||||
if (r >= 0) {
|
||||
let p: str;
|
||||
p.ptr = &pathbuf[0];
|
||||
|
||||
Reference in New Issue
Block a user