code wiki / _hdl_build / nx_organ_callers.nx
nx_organ_callers.nx
buildroot/runtime/_hdl_build/nx_organ_callers.nx
about
nx_organ_callers.nx -- SOVEREIGN caller-finder: given an organ basename, walk the .nx tree and list every
file that REFERENCES it (by name, import, or path). This is the missing tool that makes a rename SAFE -- you
can SEE all callers before touching a name, instead of a blind rename (#19 contract stability) or a grep that
times out on this tree. It is the prerequisite for resolving the 22 shadow collisions nx_janitor_dupname found.
Bounded BFS getdents walk; reads each .nx into a REUSED buffer + sys_munmap (no 4GB-per-call reserve, no leak,
no timeout) -- the proven nx_janitor_sprawl walk shape. Match = substring of the needle with a LEFT word
boundary so "nx_grep" is not matched inside "nx_grep_test" (over-reporting a caller is safe; this avoids it).
READ-ONLY (never-brick). Sovereign. license_tier: ORIGINAL
dependencies 1 imports · 6 importers
imports: nx_syscalls.nx
imported by: nx_buildsearch_gate.nxnx_capability_shape.nxnx_capability_shape_audit.nxnx_collision_harm.nxnx_dupname_worklist.nxnx_organ_callers_gate.nx
structs
| none |
consts
| 11 | const OC_PATH_SLOT: i64 = 768 |
| 12 | const OC_QUEUE_CAP: i64 = 16384 |
| 13 | const OC_DENT_BUF: i64 = 65536 |
| 14 | const OC_FILE_CAP: i64 = 4194304 |
| 15 | const OC_MAX_HITS: i64 = 4096 |
| 16 | const OC_HIT_ARENA: i64 = 3145728 // bytes for the caller-path list |
functions
| 18 | func oc_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } |
| 19 | func oc_eq(a: *u8, b: *u8) -> i64 { var i: i64=0; while a[i]!=(0 as u8){ if a[i]!=b[i]{return 0} i=i+1 } if b[i]!=(0 as u8){return 0} return 1 } |
| 20 | func oc_ends(path: *u8, pl: i64, ext: *u8) -> i64 { let el: i64=oc_slen(ext); if el>pl { return 0 } var i: i64=0; while i<el { if path[pl-el+i]!=ext[i] { return 0 } i=i+1 } return 1 } |
| 21 | func oc_is_ident(c: i64) -> i64 { if c>=48 { if c<=57 { return 1 } } if c>=65 { if c<=90 { return 1 } } if c>=97 { if c<=122 { return 1 } } if c==95 { return 1 } return 0 } called by 1: oc_referenced |
| 23 | func oc_referenced(buf: *u8, n: i64, pat: *u8) -> i64 |
| 34 | func oc_join(dst: *u8, dir: *u8, name: *u8) -> i64 { var o: i64=0; var i: i64=0; while dir[i]!=(0 as u8){ dst[o]=dir[i]; o=o+1; i=i+1 } dst[o]=47 as u8; o=o+1; i=0; while name[i]!=(0 as u8){ dst[o]=name[i]; o=o+1; i=i+1 } dst[o]=0 as u8; return o } |
| 35 | func oc_getdents(fd: i64, buf: *u8, count: i64) -> i64 { return __syscall(SYS_GETDENTS64, fd, buf, count, 0, 0, 0) } |
| 36 | func oc_isdir(path: *u8, st: *u8) -> i64 { let r: i64=__syscall(262, 0-100, path, st, 0, 0, 0); if r<0 { return 0-1 } let mode: i64=(st[24] as i64)|((st[25] as i64)<<8)|((st[26] as i64)<<16)|((st[27] as i64)<<24); if (mode & 0xF000)==0x4000 { return 1 } return 0 } |
| 37 | func oc_read(path: *u8, buf: *u8, cap: i64) -> i64 { let fd: i64=sys_openat_rd(path); if fd<0 { return 0-1 } var total: i64=0; var nrd: i64=sys_read(fd, buf, cap); while nrd>0 { total=total+nrd; if total>=cap { nrd=0 } else { nrd=sys_read(fd, ((buf as i64)+total) as *u8, cap-total) } } sys_close(fd); return total } |
| 42 | func oc_grep(root: *u8, needle: *u8, maxsize: i64, hits: *u8, hitoff: *i64, maxh: i64) -> i64 |
| 95 | func oc_find(root: *u8, needle: *u8, self_skip: *u8, hits: *u8, hitoff: *i64, maxh: i64) -> i64 |