code wiki / (root) / nx_diskfree.nx

nx_diskfree.nx

buildroot/runtime/nx_diskfree.nx

3356 B66 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_diskfree.nx -- THE DISK AXIS, made callable (2026-08-28). WHY THIS EXISTS. On 2026-08-28 a 100%-FULL DISK truncated a sibling seat's MEMORY.md to 0 bytes: open(path,"w") truncates BEFORE it writes, so a full volume does not refuse a write, it DESTROYS the file. Nothing in the estate saw it coming. nx_resmon is "the resource axis nx_health lacks" -- but only for MEMORY and SWAP; a search for the disk primitive returned matches=0 for BOTH sys_statfs and statvfs with corpus_complete=1, and nx_res_census records the same absence in its own header. THE CAPABILITY WAS DARK, NOT MISSING. nx_system_triage.tr_free_gb has read filesystem space since 2026-06-10 -- inside an _hdl_build organ that is NOT REGISTERED, so nx_job_run refuses it as "not an unpinned GREEN tool" and no caller in the estate can reach it. ★A CAPABILITY THAT EXISTS IN ONE UNREACHABLE ORGAN IS INDISTINGUISHABLE FROM ONE NOBODY BUILT -- and its absence is only discovered by the incident it would have prevented. This organ is the reachable form. The arithmetic lives in nx_syscalls (sys_fs_used_permil / sys_fs_avail_bytes) so nx_resmon can compose the SAME ruler rather than growing a second one. THE THIRD STATE IS LOAD-BEARING. statfs can fail (bad path, unmounted, permission) and a volume can report zero blocks. Both return STATFS_ERR and this organ prints UNMEASURABLE with exit 3 -- it never prints 0 permil used, because "I could not look" and "the disk is empty" must never share a representation, and 0-used is the most flattering possible lie. license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_diskfree.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 df_puts sys_write sys_exit sys_fs_used_permil 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 ↻ sys_statfs sys_fs_avail_bytes sys_mmap ↻ sys_statfs ↻ df_num df_puts ↻ sys_mmap ↻ sys_write ↻

structs

none

consts

26const DF_EXIT_UNMEASURABLE: i64 = 3
27const DF_EXIT_USAGE: i64 = 2

functions

29func df_puts(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 2: df_nummain calls 1: sys_write
30func df_num(v: i64) -> i64
called by 1: main calls 3: df_putssys_mmapsys_write
44func main(argc: i64, argv: *i64) -> i64