code wiki / _hdl_build / nx_nishi_install_os.nx

nx_nishi_install_os.nx

buildroot/runtime/_hdl_build/nx_nishi_install_os.nx

13034 B244 linesdepth 5pulls 5 transitivereach 0 importersview sourcekind tooltopic nishi
docsdependenciesstructsconstsfunctions

about

nx_nishi_install_os.nx -- ladder C5 (the INSTALL-OUR-OS capstone): install the OS AS a content-addressed NishiFS. Fuses the whole installer/disk side into ONE flow: FORMAT the OS as a NishiFS disk (C1 partition table + C2/C4 content-addressed FS: superblock + Merkle dir + objects) -> INSTALL it onto a target with the C3 never-brick installer (refuse-system-disk + sha256 read-back verify + golden recovery) -> MOUNT the INSTALLED copy and read a file by CID, and prove the WHOLE-OS root CID survived the install bit-for-bit. KAT 6/6: T1 install OK + sha256 byte-perfect; T2 never-brick (refuse /dev/sda); T3 the installed target MOUNTS as NishiFS (partition->superblock->file-by-CID, bytes match); T4 the whole-OS root CID is PRESERVED (installed root == source root = the entire filesystem verified through the install); T5 golden recovery (corrupt install -> RECOVERED + still mounts); T6 integrity survives install (tamper installed object -> MNT_INTEGRITY). composes nx_sha256 + nx_syscalls; reuses the proven C3 installer + C4 format/mount. NEVER-BRICK (Rule 26): refuses the system disk; writes FILES only (knowledge/status/); no /dev. expect_exit: 0 license_tier: ORIGINAL

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_sha256.nx nx_nishi_install_os.nx

imports: nx_syscalls.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 format_disk wr_u32_le sys_mmap ↻ put_obj 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 sha256_final blk_set_byte ↻ sha256_compress ↻ wr_u32_le ↻ sha_slice sha256_digest ↻ get_root rd_u32_le nx_install fl_safe w_file sys_openat_wr sys_write ↻ sys_close sys_mmap ↻ fl_verify sys_mmap ↻ sys_read_file sys_openat_rd sys_lseek

structs

none

consts

16const DISK_SZ: i64 = 4096
17const PBYTE: i64 = 512
18const OBJSTART_REL: i64 = 512
19const PART_TYPE_NISHI: i64 = 0x9E
20const MNT_OK: i64 = 0
21const MNT_BADMAGIC: i64 = 1
22const MNT_ROOT_MISMATCH: i64 = 2
23const MNT_NOTFOUND: i64 = 3
24const MNT_INTEGRITY: i64 = 4
25const INST_OK: i64 = 0
26const INST_RECOVERED: i64 = 2
27const INST_UNSAFE: i64 = 7
28const INST_FATAL: i64 = 5

functions

30func 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
31func ui_num(v: i64) -> i64 { let b: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m;sys_write(1,"-" as *u8,1)} let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} var i: i64=0; while i<k{b[i]=t[k-1-i];i=i+1} sys_write(1,b,k); return 0 }
called by 1: main calls 2: sys_mmapsys_write
32func ui_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
called by 1: main
33func 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 }
34func wr_u32_le(d: *u8, off: i64, v: i64) -> i64 { d[off]=(v & 0xFF) as u8; d[off+1]=((v>>8)&0xFF) as u8; d[off+2]=((v>>16)&0xFF) as u8; d[off+3]=((v>>24)&0xFF) as u8; return 0 }
called by 2: put_objformat_disk
35func rd_u32_le(d: *u8, off: i64) -> i64 { return (d[off] as i64) | ((d[off+1] as i64)<<8) | ((d[off+2] as i64)<<16) | ((d[off+3] as i64)<<24) }
36func sha_slice(d: *u8, off: i64, len: i64, out: *u8) -> i64 { sha256_digest(((d as i64)+off) as *u8, len, out); return 0 }
called by 2: format_diskmount_read calls 1: sha256_digest
37func 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 }
38func ui_read(path: *u8, out: *u8, cap: i64) -> i64 { let fd: i64=sys_openat_rd(path); if fd<0 { return 0-1 } var n: i64=0; var go: i64=1; while go==1 { let rr: i64=sys_read(fd, ((out as i64)+n) as *u8, cap-n); if rr<=0 { go=0 } else { n=n+rr } if n>=cap { go=0 } } sys_close(fd); return n }
called by 1: main calls 3: sys_openat_rdsys_readsys_close
41func fl_safe(target: *u8) -> i64
called by 1: nx_install
45func fl_verify(img: *u8, n: i64, target: *u8) -> i64
57func nx_install(src: *u8, n: i64, target: *u8, golden: *u8, corrupt: i64) -> i64
78func put_obj(d: *u8, cursor: i64, blob: *u8, n: i64, cidout: *u8) -> i64
called by 1: format_disk calls 2: sha256_digestwr_u32_le
85func find_obj(d: *u8, start: i64, endb: i64, cid: *u8, outlen: *i64) -> i64
called by 1: mount_read calls 1: rd_u32_le
97func dir_find(d: *u8, base: i64, len: i64, name: *u8, cidout: *u8) -> i64
called by 1: mount_read
111func format_disk(d: *u8, nameA: *u8, A: *u8, nA: i64, nameB: *u8, B: *u8, nB: i64) -> i64
142func get_root(d: *u8, out: *u8) -> i64
called by 1: main calls 1: rd_u32_le
153func mount_read(d: *u8, name: *u8, out: *u8, cap: i64, lenout: *i64) -> i64
185func main() -> i64