code wiki / _hdl_build / nx_mc_fix.nx

nx_mc_fix.nx source

↩ module page · 30 lines · 1465 B

1// nx_mc_fix.nx -- MC-applier gate FIXTURE (mock buildonly): argv[1]=target. Reads the shared "lib" 2// file /tmp/mc_shared and writes its content (or "GONE" if absent) to /tmp/<target>.sov.elf, so each 3// importer's artifact DEPENDS on the shared lib -> retiring mc_shared changes every artifact (REFUSE), 4// retiring an unrelated file changes none (CONSOLIDATED). exit 0. 5// license_tier: ORIGINAL No hw writes (Rule 26). 6import "nx_seat_drive_lib.nx" 7import "nx_seg_store.nx" 8import "nx_deploy_lib.nx" 9import "nx_syscalls.nx" 10const K_MAGIC_65536: i64 = 65536 11const K_MAGIC_65535: i64 = 65535 12 13func main(argc: i64, argv: *i64) -> i64 { 14 if argc < 2 { sys_exit(2); return 2 } 15 let t: *u8 = argv[1] as *u8 16 // a "broken" importer never builds (writes no artifact) -- used to gate the unbuilt-importer 17 // coverage path: target basename starting with "mcbroken". 18 if t[0] == (109 as u8) { if t[1] == (99 as u8) { if t[2] == (98 as u8) { if t[3] == (114 as u8) { sys_exit(4); return 4 } } } } 19 let buf: *u8 = sys_mmap(K_MAGIC_65536) 20 let fd: i64 = sys_openat_rd("/tmp/mc_shared" as *u8) 21 var n: i64 = 0 22 if fd >= 0 { n = sys_read(fd, buf, K_MAGIC_65535); sys_close(fd) } 23 let art: *u8 = sys_mmap(512) 24 var o: i64 = sd_cat(art, 0, "/tmp/" as *u8) 25 o = sd_cat(art, o, t) 26 o = sd_cat(art, o, ".sov.elf" as *u8) 27 if n > 0 { ss_writefile(art, buf, n) } else { ss_writefile(art, "GONE" as *u8, 4) } 28 sys_exit(0) 29 return 0 30}