code wiki / _hdl_build / nx_nishi_install_os.nx
nx_nishi_install_os.nx
buildroot/runtime/_hdl_build/nx_nishi_install_os.nx
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
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
structs
| none |
consts
| 16 | const DISK_SZ: i64 = 4096 |
| 17 | const PBYTE: i64 = 512 |
| 18 | const OBJSTART_REL: i64 = 512 |
| 19 | const PART_TYPE_NISHI: i64 = 0x9E |
| 20 | const MNT_OK: i64 = 0 |
| 21 | const MNT_BADMAGIC: i64 = 1 |
| 22 | const MNT_ROOT_MISMATCH: i64 = 2 |
| 23 | const MNT_NOTFOUND: i64 = 3 |
| 24 | const MNT_INTEGRITY: i64 = 4 |
| 25 | const INST_OK: i64 = 0 |
| 26 | const INST_RECOVERED: i64 = 2 |
| 27 | const INST_UNSAFE: i64 = 7 |
| 28 | const INST_FATAL: i64 = 5 |
functions
| 30 | func 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 } |
| 31 | func 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 } |
| 32 | func ui_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } called by 1: main |
| 33 | func 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 } |
| 34 | func 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 } |
| 35 | func 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) } |
| 36 | func sha_slice(d: *u8, off: i64, len: i64, out: *u8) -> i64 { sha256_digest(((d as i64)+off) as *u8, len, out); return 0 } |
| 37 | func 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 } |
| 38 | func 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 } |
| 41 | func fl_safe(target: *u8) -> i64 called by 1: nx_install |
| 45 | func fl_verify(img: *u8, n: i64, target: *u8) -> i64 |
| 57 | func nx_install(src: *u8, n: i64, target: *u8, golden: *u8, corrupt: i64) -> i64 |
| 78 | func put_obj(d: *u8, cursor: i64, blob: *u8, n: i64, cidout: *u8) -> i64 |
| 85 | func find_obj(d: *u8, start: i64, endb: i64, cid: *u8, outlen: *i64) -> i64 |
| 97 | func dir_find(d: *u8, base: i64, len: i64, name: *u8, cidout: *u8) -> i64 called by 1: mount_read |
| 111 | func format_disk(d: *u8, nameA: *u8, A: *u8, nA: i64, nameB: *u8, B: *u8, nB: i64) -> i64 |
| 142 | func get_root(d: *u8, out: *u8) -> i64 |
| 153 | func mount_read(d: *u8, name: *u8, out: *u8, cap: i64, lenout: *i64) -> i64 |
| 185 | func main() -> i64 |