code wiki / _hdl_build / nx_raidwatch.nx

nx_raidwatch.nx

buildroot/runtime/_hdl_build/nx_raidwatch.nx

22670 B457 linesdepth 2pulls 2 transitivereach 1 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_raidwatch.nx -- ARRAY + KERNEL-IO HEALTH BEAT. The estate had NONE. WHY THIS EXISTS (2026-08-07). A grep across every organ for mdstat, smartctl or raid returned only substring false positives (a bip39 wordlist, a chemistry table). Nothing in a 140 TB estate was watching whether its arrays were intact. Two live faults were sitting there unwatched: md3 (raid1, the NVMe mirror) DEGRADED [2/1] [_U] -- one member gone, /dev/nvme0n1p1 has no device node at all, so it cannot even be re-added without physical intervention. It was recorded in a memory file and NOTHING CHECKED IT, which is the difference between a note and a monitor. sata8 throwing repeated UNC (uncorrectable) read errors on ONE sector, 840 kernel records over four hours, while the array it backs still reports [8/8] because raid5 keeps reconstructing the block from parity. A disk can be failing loudly while every array metric reads healthy. ROOT-FREE BY CONSTRUCTION, because the beat runs as the estate user: /sys/block/<md>/md/degraded, raid_disks, level, mismatch_cnt -- structured integers, no text parsing of /proc/mdstat, so this cannot be broken by a format change. /dev/kmsg -- readable here, opened O_NONBLOCK so the final read returns EAGAIN instead of BLOCKING FOREVER at the end of the buffer. A monitor that can hang is not a monitor. smartctl is present but needs root (open of /dev/sata8 = Permission denied, measured), so per-disk SMART is deliberately OUT OF SCOPE here rather than silently half-working. REFUSES if it can read neither surface: ignorance is not health, and a GREEN produced by an unreadable sysfs would be worse than no beat at all.

dependencies 1 imports · 1 importers

nx_syscalls.nx nx_raidwatch.nx nx_raidwatch_gate.nx

imports: nx_syscalls.nx

imported by: nx_raidwatch_gate.nx

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

main sys_mmap nxa_die sys_write sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ rw sys_write ↻ rw_cat rw_catn rw_catn ↻ sys_mmap ↻ sys_munmap rw_sysint sys_openat_rd sys_mmap ↻ sys_read sys_close sys_munmap ↻ rw_sysstr sys_openat_rd ↻ sys_read ↻ sys_close ↻ rwn rw ↻ sys_mmap ↻ sys_write ↻ sys_munmap ↻ rw_member_scan sys_mmap ↻

structs

none

consts

26const RW_MAXMD: i64 = 16
27const RW_MAXSECT: i64 = 256
28const RW_KMSG_RECS: i64 = 8192
29const RW_RECBUF: i64 = 8192
30const RW_SMALL: i64 = 64
31const RW_PATH: i64 = 256
32const RW_O_NONBLOCK: i64 = 2048
33const RW_AT_FDCWD: i64 = 0 - 100
34const RW_SYS_OPENAT: i64 = 257
35const RW_EXIT_RED: i64 = 6
36const RW_EXIT_AMBER: i64 = 4
37const RW_EXIT_NODATA: i64 = 5
38const RW_DIRBUF: i64 = 65536 // getdents64 batch for the per-member walk
39const RW_RECLEN_OFF: i64 = 16 // linux_dirent64.d_reclen
40const RW_NAME_OFF: i64 = 19 // linux_dirent64.d_name
50const RW_STATUS: *u8 = "knowledge/status/raidwatch.status"
51const RW_STATBUF: i64 = 1024

functions

55func rw_verdict_code(degraded: i64, ioerr: i64, memberbad: i64, mismatched: i64) -> i64
called by 2: mainmain
62func rw(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
called by 3: rwnrw_member_scanmain calls 1: sys_write
63func rwe(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(2, s, n); return 0 }
called by 1: main calls 1: sys_write
64func rwn(v: i64) -> i64
81func rw_cat(d: *u8, o: i64, s: *u8) -> i64 { var i: i64 = 0; while s[i] != (0 as u8) { d[o + i] = s[i]; i = i + 1 } return o + i }
called by 2: rw_member_scanmain
83func rw_catn(d: *u8, o: i64, v: i64) -> i64
102func rw_sysint(path: *u8) -> i64
123func rw_sysstr(path: *u8, dst: *u8, cap: i64) -> i64
called by 1: main calls 3: sys_openat_rdsys_readsys_close
135func rw_after(buf: *u8, n: i64, key: *u8) -> i64
called by 1: main
164func rw_has(buf: *u8, n: i64, lit: *u8) -> i64
called by 2: rw_member_scanmain
196func rw_member_scan(mdnum: i64, out: *i64) -> i64
245func main(argc: i64, argv: *i64) -> i64