code wiki / _hdl_build / nx_gpt_relocate_gate.nx
nx_gpt_relocate_gate.nx
buildroot/runtime/_hdl_build/nx_gpt_relocate_gate.nx
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
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
structs
| none |
consts
| 14 | const RG_CAP: i64 = 65536 |
| 15 | const RG_SEC: i64 = 512 |
| 16 | const RG_IMG_BYTES: i64 = 69257728 // the emitter's authored size (its IMG_BYTES) |
| 17 | const RG_OLD_LAST: i64 = 135268 // the emitter's LAST_LBA |
| 18 | const RG_GROW_BYTES: i64 = 100663296 // 96 MiB "device": larger than the image, sector-aligned |
| 19 | const RG_SMALL_BYTES: i64 = 1048576 // a "device" smaller than the image |
| 20 | const RG_HDR_SZ: i64 = 92 |
| 21 | const RG_ARR_SEC: i64 = 32 |
| 22 | const RG_ENTSZ: i64 = 128 |
| 23 | const RG_FAKE_EFI_BYTES: i64 = 1024 |
| 24 | const RG_ROOT: *u8 = "/tmp/nx_gpt_relocate_gate" |
| 25 | const RG_EFI: *u8 = "/tmp/nx_gpt_relocate_gate/fake.efi" |
| 26 | const RG_BASE: *u8 = "/tmp/nx_gpt_relocate_gate/base.img" |
| 27 | const RG_GROW: *u8 = "/tmp/nx_gpt_relocate_gate/grow.img" |
| 28 | const RG_SMALL: *u8 = "/tmp/nx_gpt_relocate_gate/small.img" |
| 29 | const RG_NOTGPT: *u8 = "/tmp/nx_gpt_relocate_gate/notgpt.img" |
| 30 | const RG_FOREIGN: *u8 = "/tmp/nx_gpt_relocate_gate/foreign.img" |
functions
| 32 | func 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) } |
| 33 | func rg_r64(b: *u8, off: i64) -> i64 { return rg_r32(b, off) | (rg_r32(b, off + 4) << 32) } |
| 34 | func 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 |
| 37 | func rg_crc32(b: *u8, off: i64, n: i64) -> i64 called by 1: main |
| 54 | func rg_sig_at(b: *u8, off: i64) -> i64 called by 1: main |
| 61 | func rg_write_file(path: *u8, buf: *u8, n: i64, total: i64) -> i64 |
| 75 | func rg_same(a: *u8, b: *u8, off: i64, n: i64) -> i64 called by 1: main |
| 80 | func rg_same2(a: *u8, aoff: i64, b: *u8, boff: i64, n: i64) -> i64 called by 1: main |
| 85 | func rg_run(elf: *u8, a1: *u8, a2: *u8, out: *u8, ol: *i64) -> i64 |
| 89 | func main(argc: i64, argv: *i64) -> i64 |