code wiki / (root) / nx_fio.nx

nx_fio.nx source

↩ module page · 15 lines · 818 B

1// nx_fio.nx -- canonical sovereign file operations: unlink (delete) + existence check. Importable (no main). 2// Retires Remove-Item / rm. rename is already canonical (sys_renameat in nx_syscalls). unlinkat x86_64=263 is passed 3// DIRECTLY (the fsync-74 / fstatat-262 / unlinkat-263 precedent: a raw x86_64 number not in the rv64->x86 swap table 4// passes through untranslated). AT_FDCWD=-100, flags=0. Returns 0 on success, -errno on failure. license_tier: ORIGINAL 5import "nx_syscalls.nx" 6 7// delete a file (unlinkat). Returns 0 on success. 8func fio_unlink(path: *u8) -> i64 { return __syscall(263, 0 - 100, path as i64, 0, 0, 0, 0) } 9 10// 1 if `path` exists (fstatat succeeds), else 0. 11func fio_exists(path: *u8) -> i64 { 12 let st: *u8 = sys_mmap(160) 13 if sys_fstatat(path, st) == 0 { return 1 } 14 return 0 15}