code wiki / _hdl_build / nx_nas_book_census.nx
nx_nas_book_census.nx
buildroot/runtime/_hdl_build/nx_nas_book_census.nx
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
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
structs
| none |
consts
| 29 | const K_MAGIC_268435456: i64 = 268435456 |
| 30 | const K_MAGIC_4000000: i64 = 4000000 |
| 31 | const K_MAGIC_1048640: i64 = 1048640 |
| 32 | const K_MAGIC_8192: i64 = 8192 |
| 33 | const K_MAGIC_1048576: i64 = 1048576 |
| 34 | const K_MAGIC_8000000: i64 = 8000000 |
| 70 | const NROOT: i64 = 10 |
| 88 | const NEXT: i64 = 19 |
functions
| 37 | func 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 } |
| 38 | func bc_wn(fd: i64, buf: *u8, n: i64) -> i64 { sys_write(fd, buf, n); return 0 } |
| 43 | func bc_n(fd: i64, v: i64) -> i64 { nxi_fd(fd, v); return 0 } |
| 44 | func bc_p(s: *u8) -> i64 { bc_w(1, s); return 0 } |
| 45 | func bc_pn(v: i64) -> i64 { bc_n(1, v); return 0 } |
| 47 | func bc_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } |
| 50 | func bc_lc(c: i64) -> i64 { if c >= 65 { if c <= 90 { return c + 32 } } return c } called by 1: main |
| 53 | func bc_has(hay: *u8, needle: *u8) -> i64 |
| 71 | func bc_root(i: i64) -> *u8 |
| 89 | func bc_ext_name(i: i64) -> *u8 |
| 113 | func bc_streq(a: *u8, b: *u8) -> i64 |
| 121 | func bc_ext_id(extlc: *u8) -> i64 |
| 127 | func main() -> i64 |