code wiki / _hdl_build / nx_datacurator.nx

nx_datacurator.nx

buildroot/runtime/_hdl_build/nx_datacurator.nx

24799 B434 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_datacurator.nx -- SOVEREIGN storage curator (WizTree / TreeSize / ncdu-class, on the NAS). Recursively walks a target dir, stats every file (one fstatat = mode+size), classifies by MEDIA TYPE, and reports size+count per type + the biggest N files -- so the operator can SEE where the space is by media type and decide what to delete. READ-ONLY: stat only; it NEVER writes or deletes (deletion is the separate soft+confirmed `del` mode). Composes the recursive getdents walk from nx_dr_tree, but is LEAK-SAFE at scale: the per-dir getdents buffer is munmap'd on return (nx_dr_tree leaks it -- fine for one archive, fatal walking 142 TB), and NOTHING is mmap'd per FILE (one reused statbuf threaded down). Bounded memory regardless of file count. Run: nx_datacurator <dir> [topN] (topN default 30, max 64) license_tier: ORIGINAL

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_datacurator.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

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

main dc_streq dc_del_main dc_w sys_write dc_slen dc_pathguard dc_startswith dc_contains dc_slen ↻ dc_streq ↻ sys_mmap dc_rm_contents sys_openat_rd sys_mmap ↻ sys_getdents64 dirent_name dc_isdotdot dc_join sys_fstatat dc_rm_contents ↻ dirent_reclen sys_close sys_munmap dc_bcat dc_bcatn sys_mmap ↻ dc_human dc_bcatn ↻ dc_bcat ↻ dc_flush sys_write ↻ sys_openat_append sys_now_realtime_sec sys_mmap ↻ sys_clock_gettime_real sys_write ↻ sys_close ↻ dc_catalog_main dc_w ↻

structs

none

consts

13const DC_MAGIC_1099511627776: i64 = 1099511627776
14const DC_MAGIC_1073741824: i64 = 1073741824
15const DC_MAGIC_1048576: i64 = 1048576
16const DC_MAGIC_3900: i64 = 3900
17const DC_MAGIC_131072: i64 = 131072
18const DC_MAGIC_61440: i64 = 61440
19const DC_MAGIC_16384: i64 = 16384
20const DC_MAGIC_32768: i64 = 32768
21const DC_MAGIC_4096: i64 = 4096
22const DC_MAGIC_2048: i64 = 2048
23const DC_MAGIC_60000: i64 = 60000
24const DC_MAGIC_65536: i64 = 65536
26const DC_PATHW: i64 = 400 // bytes per stored biggest-file path
27const DC_TOPMAX: i64 = 64
28const DC_NCAT: i64 = 6 // 0=video 1=image 2=audio 3=doc 4=archive 5=other

functions

30func dc_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
31func dc_w(s: *u8) -> i64 { sys_write(1, s, dc_slen(s)); return 0 }
32func dc_bcat(dst: *u8, o: i64, s: *u8) -> i64 { var x: i64 = o; var i: i64 = 0; while s[i] != (0 as u8) { dst[x] = s[i]; x = x + 1; i = i + 1 } return x }
33func dc_bcatn(dst: *u8, o: i64, v: i64) -> i64
43func dc_human(dst: *u8, o: i64, bytes: i64) -> i64
53func dc_flush(buf: *u8, n: i64) -> i64 { sys_write(1, buf, n); return 0 }
56func dc_join(buf: *u8, base_n: i64, name: *u8) -> i64
61func dc_isdotdot(nm: *u8) -> i64
65func dc_lc(c: i64) -> i64 { if c >= 65 { if c <= 90 { return c + 32 } } return c }
called by 1: dc_in_ci
67func dc_in_ci(word: *u8, list: *u8) -> i64
called by 2: dc_classifydc_channel calls 2: dc_slendc_lc
87func dc_classify(nm: *u8) -> i64
called by 1: dc_walk calls 1: dc_in_ci
100func dc_topn(bs: *i64, bp: *u8, nkeep: i64, path: *u8, pn: i64, sz: i64) -> i64
called by 1: dc_walk
114func dc_walk(path: *u8, pn: i64, sb: *u8, cb: *i64, cc: *i64, bs: *i64, bp: *u8, nkeep: i64, tot: *i64) -> i64
158func dc_streq(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 }
called by 2: dc_del_mainmain
159func dc_startswith(s: *u8, p: *u8) -> i64 { var i: i64 = 0; while p[i] != (0 as u8) { if s[i] != p[i] { return 0 } i = i + 1 } return 1 }
called by 1: dc_pathguard
160func dc_contains(hay: *u8, needle: *u8) -> i64
called by 2: dc_pathguarddc_channel calls 1: dc_slen
167func dc_pathguard(path: *u8) -> i64
182func dc_rm_contents(path: *u8, pn: i64, exec: i64, st: *i64, sb: *u8) -> i64
222func dc_del_main(argc: i64, argv: *i64) -> i64
261func dc_ext(nm: *u8) -> *u8
called by 1: dc_channel
271func dc_channel(nm: *u8, path: *u8) -> i64
285func dc_chname(ch: i64) -> *u8
called by 1: dc_catalog_walk
294func dc_catalog_walk(path: *u8, pn: i64, sb: *u8, fd: i64, wbuf: *u8, wo: *i64, chb: *i64, chc: *i64, tot: *i64) -> i64
343func dc_catalog_main(argc: i64, argv: *i64) -> i64
374func main(argc: i64, argv: *i64) -> i64