code wiki / _hdl_build / nx_ge_mockcat.nx
nx_ge_mockcat.nx source
↩ module page · 17 lines · 791 B
1// nx_ge_mockcat.nx -- test-only mock "verify" for nx_gated_edit_gate: cat argv[1] to stdout.
2// Deterministic; output reflects the named file's bytes -> lets the gate drive CONSOLIDATED (verify a file
3// the edit does NOT touch) vs REFUSED (verify the edited file itself). license_tier: ORIGINAL No hw writes.
4import "nx_syscalls.nx"
5const K_MAGIC_1048576: i64 = 1048576
6func main(argc: i64, argv: *i64) -> i64 {
7 if argc < 2 { sys_exit(0); return 0 }
8 let p: *u8 = argv[1] as *u8
9 let fd: i64 = sys_openat_rd(p)
10 if fd < 0 { sys_exit(0); return 0 }
11 let buf: *u8 = sys_mmap(K_MAGIC_1048576)
12 var r: i64 = sys_read(fd, buf, K_MAGIC_1048576)
13 while r > 0 { sys_write(1, buf, r); r = sys_read(fd, buf, K_MAGIC_1048576) }
14 sys_close(fd)
15 sys_exit(0)
16 return 0
17}