code wiki / _hdl_build / nx_journal.nx
nx_journal.nx
buildroot/runtime/_hdl_build/nx_journal.nx
about
nx_journal.nx -- GATE: WRITE-AHEAD JOURNALING + CRASH RECOVERY on the block-backed VFS (NSFS v2, nx_vfsblock_lib).
Closes the FILESYSTEM census gap half "journaling". Grounded on the banked field research (osb_journalfs/osb_ext4:
jbd2-class physical redo WAL -- stage whole new blocks, COMMIT with a checksum, apply, checkpoint; an uncommitted
or unprovable txn is NEVER applied). The crash points are SIMULATED FOR REAL: the gate stages a txn, saves the
image at the exact crash instant, wipes RAM, reloads, and MOUNTS -- recovery is what mount actually does.
T1 journaled ops end-to-end (mkdir+create through the WAL; checkpointed after).
T2 CRASH AFTER COMMIT, BEFORE APPLY -> mount REPLAYS -> the file EXISTS byte-exact (durability of committed).
T3 CRASH BEFORE COMMIT -> mount discards -> the file is ABSENT, allocator + prior files untouched (atomicity).
T4 teeth: a COMMITTED txn with a corrupted journal byte -> checksum REFUSES the replay, txn discarded, FS intact.
T5 replay is IDEMPOTENT (second replay = no-op) + the FS stays fully consistent for new journaled writes.
expect_exit: 0 Sovereign: nx_cc->nxasm via nx_syscalls. NEVER-BRICK: RAM + an image file, 0 firmware writes.
dependencies 3 imports · 0 importers
imports: nx_vfsblock_lib.nxnx_itoa_lib.nxnx_g_puts_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
| none |
functions
| 20 | func g_pn(v: i64) -> i64 { nxi_out(v); return 0 } |
| 21 | func ck(name: *u8, c: i64) -> i64 { if c==1 { g_puts(" PASS " as *u8) } else { g_puts(" FAIL " as *u8) } g_puts(name); g_puts("\n" as *u8); return c } |
| 22 | func streq_n(a: *u8, b: *u8, n: i64) -> i64 { var i: i64=0; while i<n { if a[i]!=b[i] { return 0 } i=i+1 } return 1 } called by 1: main |
| 23 | func wlog(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 1: main |
| 24 | func jcommitted(a: *u8) -> i64 { return vb_rd(a,vbj_hdr()+24) } |
| 27 | func stage_small(a: *u8, scr: *u8, parent: i64, name: *u8, data: *u8, len: i64) -> i64 |
| 43 | func main() -> i64 |