code wiki / _hdl_build / nx_corpus_probe.nx

nx_corpus_probe.nx source

↩ module page · 65 lines · 2246 B

1// nx_corpus_probe.nx -- WHY DOES gk_corpus_scan RETURN 0 ON THE NAS? 2// Prints every intermediate the enumerator depends on, so the failing step NAMES ITSELF instead of 3// being guessed at. A verdict is not a diagnosis: corpus_files=0 is the ABSENCE of one. 4// license_tier: ORIGINAL 5import "nx_gatekit_lib.nx" 6const K_MAGIC_65536: i64 = 65536 7const K_MAGIC_2048: i64 = 2048 8 9func main(argc: i64, argv: *i64) -> i64 { 10 let msg: *u8 = sys_mmap(GK_MAGIC_4096) 11 let rt: *u8 = sys_mmap(GK_MAGIC_4096) 12 let hdl: *u8 = sys_mmap(GK_MAGIC_4096) 13 14 let okroot: i64 = gk_corpus_root(rt) 15 var o: i64 = gk_cat(msg, 0, "root_ok=" as *u8) 16 o = gk_catn(msg, o, okroot) 17 o = gk_cat(msg, o, " root=[" as *u8) 18 o = gk_cat(msg, o, rt) 19 o = gk_cat(msg, o, "]\n" as *u8) 20 gk_say(msg, o) 21 22 let okh: i64 = gk_corpus_hdl(hdl) 23 o = gk_cat(msg, 0, "hdl_ok=" as *u8) 24 o = gk_catn(msg, o, okh) 25 o = gk_cat(msg, o, " hdl=[" as *u8) 26 o = gk_cat(msg, o, hdl) 27 o = gk_cat(msg, o, "]\n" as *u8) 28 gk_say(msg, o) 29 30 let fd: i64 = sys_openat_rd(hdl) 31 o = gk_cat(msg, 0, "openat_fd=" as *u8) 32 o = gk_catn(msg, o, fd) 33 o = gk_cat(msg, o, "\n" as *u8) 34 gk_say(msg, o) 35 36 let g: *u8 = sys_mmap(K_MAGIC_65536) 37 let nread: i64 = __syscall(217, fd, g, K_MAGIC_65536, 0, 0, 0) 38 o = gk_cat(msg, 0, "getdents64_nread=" as *u8) 39 o = gk_catn(msg, o, nread) 40 o = gk_cat(msg, o, "\n" as *u8) 41 gk_say(msg, o) 42 43 // first record, if any: reclen and the name it carries 44 if nread > 0 { 45 let reclen: i64 = (g[16] as i64) | ((g[17] as i64) << 8) 46 let nm: *u8 = ((g as i64) + 19) as *u8 47 o = gk_cat(msg, 0, "rec0_reclen=" as *u8) 48 o = gk_catn(msg, o, reclen) 49 o = gk_cat(msg, o, " name=[" as *u8) 50 o = gk_cat(msg, o, nm) 51 o = gk_cat(msg, o, "] isnx=" as *u8) 52 o = gk_catn(msg, o, gk_isnx(nm)) 53 o = gk_cat(msg, o, "\n" as *u8) 54 gk_say(msg, o) 55 } 56 57 let names: *u8 = sys_mmap(K_MAGIC_2048 * 128) 58 let d1: i64 = gk_dirscan(hdl, 0 as *u8, names, 128, K_MAGIC_2048, 0) 59 o = gk_cat(msg, 0, "dirscan_hdl=" as *u8) 60 o = gk_catn(msg, o, d1) 61 o = gk_cat(msg, o, " (negative = refusal code)\n" as *u8) 62 gk_say(msg, o) 63 64 return 0 65}