code wiki / _hdl_build / nx_nishifs_cid.nx

nx_nishifs_cid.nx

buildroot/runtime/_hdl_build/nx_nishifs_cid.nx

8703 B167 linesdepth 5pulls 6 transitivereach 0 importersview sourcekind tooltopic nishifs
docsdependenciesstructsconstsfunctions

about

nx_nishifs_cid.nx -- ladder C2 (the FILE SYSTEM): NishiFS CORE = a content-addressed (CID/Merkle) object store. This is the rung that turns the OS+FS design's headline exceed axis from DESIGN-TARGET into MEASURED reality. June-2026 research (deep-research wf_b31a496b-971): dm-verity is fixed-ADDRESS Merkle (not hash-keyed retrieval), composefs verifies in USERSPACE, and APFS/ext4 have NO data checksums. NishiFS goes content-ADDRESSED: every object is stored BY its sha256 (the CID), git/IPFS-style, at /tmp/nishifs/<cidhex>. Properties, all proven here: * content-addressed put/get: store a blob -> get its CID; retrieve BY CID -> the bytes back. * INTEGRITY-ON-READ: cid_get returns bytes ONLY if they re-hash to the requested CID (tamper -> caught). * DEDUP by construction: identical content -> identical CID -> one object. * MERKLE directory: a dir = (name,childCID) entries; the dir's CID = sha256(serialized) -> the whole-tree state is ONE root CID, so changing ANY leaf changes the root (tamper-evident whole-FS state). composes nx_sha256 (CID = sha256, proven in the C3 installer) + nx_syscalls. CoW snapshots, mount/format onto a C1 partition, and native encryption are the NEXT rungs. NEVER-BRICK (Rule 26): writes FILES only (under /tmp/nishifs); no /dev, no firmware. expect_exit: 0 license_tier: ORIGINAL

dependencies 3 imports · 0 importers

nx_syscalls.nx nx_itoa_lib.nx nx_sha256.nx nx_nishifs_cid.nx

imports: nx_syscalls.nxnx_itoa_lib.nxnx_sha256.nx

imported by: nobody (leaf or entry point)

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

main ui_puts sys_write ui_slen sys_mmap cid_put sha256_digest sys_mmap ↻ sha256_init sys_mmap ↻ sha256_k sha256_update sha256_compress_ni_blocks blk_set_byte sha256_compress sha256_compress_ni blk_word blk_byte sha256_final blk_set_byte ↻ sha256_compress ↻ sys_mmap ↻ cid_hex obj_path w_file sys_openat_wr sys_write ↻ sys_close cid_get sys_mmap ↻ cid_hex ↻ obj_path ↻ sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close ↻ sha256_digest ↻ cid_eq

structs

none

consts

19const GET_OK: i64 = 0
20const GET_NOTFOUND: i64 = 3
21const GET_INTEGRITY_FAIL: i64 = 7

functions

23func ui_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 1: main calls 1: sys_write
28func ui_num(v: i64) -> i64 { nxi_out(v); return 0 }
called by 1: main calls 1: nxi_out
29func ui_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
called by 1: main
30func cid_eq(a: *u8, b: *u8) -> i64 { var i: i64=0; while i<32 { if a[i]!=b[i] { return 0 } i=i+1 } return 1 }
called by 2: cid_getmain
33func cid_hex(cid: *u8, out: *u8) -> i64
called by 3: cid_putcid_getmain
49func obj_path(hex: *u8, out: *u8) -> i64
called by 3: cid_putcid_getmain
58func w_file(path: *u8, buf: *u8, n: i64) -> i64 { let fd: i64=sys_openat_wr(path, 0x1a4); if fd<=0 { return 0-1 } sys_write(fd, buf, n); sys_close(fd); return 0 }
61func cid_put(blob: *u8, n: i64, cidout: *u8) -> i64
70func cid_get(cid: *u8, out: *u8, cap: i64, lenout: *i64) -> i64
89func dir_serialize(nA: *u8, cA: *u8, nB: *u8, cB: *u8, out: *u8) -> i64
called by 1: main
101func main() -> i64