code wiki / _hdl_build / nx_nas_book_census.nx

nx_nas_book_census.nx

buildroot/runtime/_hdl_build/nx_nas_book_census.nx

20049 B388 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_nas_book_census.nx -- SOVEREIGN, TYPE-DRIVEN NAS book census (Reader-arc RUNG 0). MISSION: the old indexer reported 148 books -- a ~37x undercount. ROOT CAUSE: it (a) mounted only 5 of 26 NAS shares, (b) classified books BY SHARE (nas_scans->"book") instead of by FILE TYPE, (c) included #recycle junk. This organ walks ALL book-bearing mounts with getdents64 (its OWN walk -- no find/grep/python/sqlite), classifies BY FILE EXTENSION across every share, excludes Synology junk (#recycle / @eaDir), and AUTHORS the true book index + a census log. The count is whatever the walk MEASURES -- nothing is hardcoded (no 5760, no 148). COMPOSITION (anti-reinvention): reuses sys_getdents64 + dirent_reclen/dirent_type/dirent_name from nx_syscalls.nx, and the proven raw-offset getdents64 batch loop shape from _si_walk_probe2.nx:37-70 (struct-free; the NxDirent struct path crashes signal-11 under nx_cc_sovereign -- LANDMINE avoided). The ONLY new logic is: (1) an EXPLICIT directory work-stack (the proven walkers are all depth-1; we wrap the depth-1 loop in a bounded push/pop stack to descend the Calibre tree -- NOT self-recursion, JPL bounded-loop discipline), (2) the type/extension classifier, (3) the junk-exclusion substring filter. idx format mirrors nx_media_server.nx ms_handle_list exactly: one absolute path per line, '\n'-terminated, no header/footer (server splits on \n, basename = after last '/'). DEDUP: dedup is STRUCTURAL. The 10 roots are disjoint subtrees and /mnt/nas_home (the duplicate Synology tree of /mnt/nas_homes) is deliberately EXCLUDED, so a single walk of distinct roots cannot revisit any absolute path -- the walk itself is the dedup. Symlink loops are guarded by skipping DT_LNK directories (never pushed) and a hard iteration cap (bounded loop). x86-ONLY lane: sys_getdents64 from nx_syscalls.nx gates on TARGET_X86_64 -> emits 217 (rv64 numbers HANG on this native lane per nx_media_gather.nx). We never reimplement __syscall. license_tier: ORIGINAL

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_itoa_lib.nx nx_nas_book_census.nx

imports: nx_syscalls.nxnx_itoa_lib.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main bc_p bc_w sys_write sys_openat_wr sys_exit sys_openat_append sys_mmap sys_openat_rd sys_getdents64 dirent_reclen dirent_name sys_close bc_pn bc_n nxi_fd sys_mmap ↻ ccz_cat_num sys_write ↻ sys_munmap bc_slen dirent_type bc_has bc_slen ↻ bc_lc bc_ext_id bc_streq bc_ext_name bc_streq ↻ bc_wn sys_write ↻ bc_w ↻ bc_n ↻ sys_now_realtime_sec sys_mmap ↻ sys_clock_gettime_real bc_ext_name ↻

structs

none

consts

29const K_MAGIC_268435456: i64 = 268435456
30const K_MAGIC_4000000: i64 = 4000000
31const K_MAGIC_1048640: i64 = 1048640
32const K_MAGIC_8192: i64 = 8192
33const K_MAGIC_1048576: i64 = 1048576
34const K_MAGIC_8000000: i64 = 8000000
70const NROOT: i64 = 10
88const NEXT: i64 = 19

functions

37func bc_w(fd: i64, s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(fd,s,n); return 0 }
called by 2: bc_pmain calls 1: sys_write
38func bc_wn(fd: i64, buf: *u8, n: i64) -> i64 { sys_write(fd, buf, n); return 0 }
called by 1: main calls 1: sys_write
43func bc_n(fd: i64, v: i64) -> i64 { nxi_fd(fd, v); return 0 }
called by 2: bc_pnmain calls 1: nxi_fd
44func bc_p(s: *u8) -> i64 { bc_w(1, s); return 0 }
called by 1: main calls 1: bc_w
45func bc_pn(v: i64) -> i64 { bc_n(1, v); return 0 }
called by 1: main calls 1: bc_n
47func bc_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
called by 2: bc_hasmain
50func bc_lc(c: i64) -> i64 { if c >= 65 { if c <= 90 { return c + 32 } } return c }
called by 1: main
53func bc_has(hay: *u8, needle: *u8) -> i64
called by 1: main calls 1: bc_slen
71func bc_root(i: i64) -> *u8
89func bc_ext_name(i: i64) -> *u8
called by 2: bc_ext_idmain
113func bc_streq(a: *u8, b: *u8) -> i64
called by 2: bc_ext_idmain
121func bc_ext_id(extlc: *u8) -> i64
called by 1: main calls 2: bc_streqbc_ext_name
127func main() -> i64