code wiki / _hdl_build / nx_gpt_relocate_gate.nx

nx_gpt_relocate_gate.nx

buildroot/runtime/_hdl_build/nx_gpt_relocate_gate.nx

11496 B179 linesdepth 3pulls 4 transitivereach 0 importersview sourcekind gate/proof
docsdependenciesstructsconstsfunctions

about

nx_gpt_relocate_gate.nx -- the REFEREE for smallos SO0 (nk0_gpt_relocate in nx_efi_fat32_image, 2026-09-02). Authors a real image with the emitter, grows a copy to a larger "device", relocates the backup GPT to the device's true end, and re-reads the DEVICE to prove: backup header at the last LBA, primary AlternateLBA and LastUsableLBA moved, protective MBR widened, both partition entries byte-unchanged, the old mid-disk backup retired, a second run idempotent, and every refusal (smaller device, not GPT, a foreign disk GUID) named and write-free. The gate carries its own CRC32 ONLY to forge a valid-but-foreign header for the neg-control. nx_gpt_relocate_gate [subject-elf] default _build/nx_efi_fat32_image.sov.elf (cwd nxc2) Fixtures are assembled at runtime under /tmp/nx_gpt_relocate_gate/. license_tier: ORIGINAL. No hw writes: every "device" here is a regular file.

dependencies 3 imports · 0 importers

nx_syscalls.nx nx_gate_verdict.nx nx_gatekit_lib.nx nx_gpt_relocate_gate.nx

imports: nx_syscalls.nxnx_gate_verdict.nxnx_gatekit_lib.nx

imported by: nobody (leaf or entry point)

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

main gv_head gv_puts sys_write gv_ctr 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 ↻ gv_need gv_puts ↻ gk_exists sys_openat_rd sys_close gk_mkdir sys_mkdir sys_mmap ↻ rg_write_file sys_openat_wr sys_write ↻ sys_close ↻ sys_mmap ↻ sys_lseek rg_run gk_run_capture gk_run_cap2 gk_run_cap3 sys_mmap ↻ sys_pipe2

structs

none

consts

14const RG_CAP: i64 = 65536
15const RG_SEC: i64 = 512
16const RG_IMG_BYTES: i64 = 69257728 // the emitter's authored size (its IMG_BYTES)
17const RG_OLD_LAST: i64 = 135268 // the emitter's LAST_LBA
18const RG_GROW_BYTES: i64 = 100663296 // 96 MiB "device": larger than the image, sector-aligned
19const RG_SMALL_BYTES: i64 = 1048576 // a "device" smaller than the image
20const RG_HDR_SZ: i64 = 92
21const RG_ARR_SEC: i64 = 32
22const RG_ENTSZ: i64 = 128
23const RG_FAKE_EFI_BYTES: i64 = 1024
24const RG_ROOT: *u8 = "/tmp/nx_gpt_relocate_gate"
25const RG_EFI: *u8 = "/tmp/nx_gpt_relocate_gate/fake.efi"
26const RG_BASE: *u8 = "/tmp/nx_gpt_relocate_gate/base.img"
27const RG_GROW: *u8 = "/tmp/nx_gpt_relocate_gate/grow.img"
28const RG_SMALL: *u8 = "/tmp/nx_gpt_relocate_gate/small.img"
29const RG_NOTGPT: *u8 = "/tmp/nx_gpt_relocate_gate/notgpt.img"
30const RG_FOREIGN: *u8 = "/tmp/nx_gpt_relocate_gate/foreign.img"

functions

32func rg_r32(b: *u8, off: i64) -> i64 { return (b[off] as i64) | ((b[off+1] as i64) << 8) | ((b[off+2] as i64) << 16) | ((b[off+3] as i64) << 24) }
called by 2: rg_r64main
33func rg_r64(b: *u8, off: i64) -> i64 { return rg_r32(b, off) | (rg_r32(b, off + 4) << 32) }
called by 1: main calls 1: rg_r32
34func rg_w32(b: *u8, off: i64, v: i64) -> i64 { b[off]=(v&0xff) as u8; b[off+1]=((v>>8)&0xff) as u8; b[off+2]=((v>>16)&0xff) as u8; b[off+3]=((v>>24)&0xff) as u8; return 0 }
called by 1: main
37func rg_crc32(b: *u8, off: i64, n: i64) -> i64
called by 1: main
54func rg_sig_at(b: *u8, off: i64) -> i64
called by 1: main
61func rg_write_file(path: *u8, buf: *u8, n: i64, total: i64) -> i64
75func rg_same(a: *u8, b: *u8, off: i64, n: i64) -> i64
called by 1: main
80func rg_same2(a: *u8, aoff: i64, b: *u8, boff: i64, n: i64) -> i64
called by 1: main
85func rg_run(elf: *u8, a1: *u8, a2: *u8, out: *u8, ol: *i64) -> i64
called by 1: main calls 1: gk_run_capture
89func main(argc: i64, argv: *i64) -> i64