code wiki / (root) / nx_tar.nx

nx_tar.nx

buildroot/runtime/nx_tar.nx

8601 B241 linesdepth 2pulls 2 transitivereach 1 importersview sourcekind librarytopic tar
docsdependenciesstructsconstsfunctions

about

nx_tar.nx -- USTAR archive: a COMPLETE format, reader and writer. The tree had nx_tar_header.nx -- a header STRUCT and nothing that could read or write an archive. This finishes it: build a multi-file archive, walk it back, and recover every name, size and byte. Symmetric, so it is provable by exact round-trip rather than against hand-picked constants. tar is unchanged since 1988 and is still the packaging substrate for everything Unix -- and, with the existing gzip, it is the .tar.gz path. THE CHECKSUM'S SELF-REFERENCE. The header checksum is the sum of all 512 header bytes WITH THE CHECKSUM FIELD ITSELF TREATED AS EIGHT SPACES. Both writer and reader must substitute spaces; a reader that sums the stored digits instead rejects every valid archive, and a writer that sums zeros produces archives GNU tar refuses. OCTAL, NOT BINARY. Every numeric field is ASCII octal, right-aligned and zero-padded, terminated by NUL. Writing them as binary integers produces a header that looks fine in a hex dump and is unreadable by every tar on earth. THE TWO-BLOCK TERMINATOR. An archive ends with 1024 zero bytes. One block is not enough -- readers scan for two consecutive zero blocks, and a single-block ending is treated as a truncated archive. genealogy_id: posix_ustar_1988 lineage_id: nx_tar_v1 license_tier: ORIGINAL

dependencies 1 imports · 1 importers

nx_syscalls.nx nx_tar.nx nx_tar_gate.nx

imports: nx_syscalls.nx

imported by: nx_tar_gate.nx

structs

none

consts

32const NX_TAR_BLOCK: i64 = 512
33const NX_TAR_NAME_OFF: i64 = 0
34const NX_TAR_NAME_LEN: i64 = 100
35const NX_TAR_MODE_OFF: i64 = 100
36const NX_TAR_UID_OFF: i64 = 108
37const NX_TAR_GID_OFF: i64 = 116
38const NX_TAR_SIZE_OFF: i64 = 124
39const NX_TAR_MTIME_OFF: i64 = 136
40const NX_TAR_CHK_OFF: i64 = 148
41const NX_TAR_CHK_LEN: i64 = 8
42const NX_TAR_TYPE_OFF: i64 = 156
43const NX_TAR_MAGIC_OFF: i64 = 257
45const NX_TAR_TYPE_FILE: i64 = 0x30
46const NX_TAR_TYPE_DIR: i64 = 0x35
49const NX_TAR_FLD_SIZE: i64 = 0
50const NX_TAR_FLD_MODE: i64 = 1
51const NX_TAR_FLD_MTIME: i64 = 2
52const NX_TAR_FLD_TYPE: i64 = 3
53const NX_TAR_FLD_DATAOFF: i64 = 4
54const NX_TAR_FLD_NEXT: i64 = 5
55const NX_TAR_FLD_NAMELEN: i64 = 6

functions

64func nxtar_octal_w(out: *u8, off: i64, width: i64, v: i64) -> i64
79func nxtar_octal_r(b: *u8, off: i64, width: i64) -> i64
called by 2: nxtar_readmain
99func nxtar_checksum(h: *u8) -> i64
117func nxtar_strlen(s: *u8) -> i64
called by 1: nxtar_header_build
125func nxtar_header_build(name: *u8, size: i64, mode: i64, mtime: i64,
167func nxtar_append(out: *u8, cap: i64, off: i64, name: *u8,
called by 1: main calls 1: nxtar_header_build
183func nxtar_finalize(out: *u8, cap: i64, off: i64) -> i64
called by 1: main
195func nxtar_read(data: *u8, n: i64, off: i64, fld: *i64) -> i64
called by 1: main calls 2: nxtar_octal_rnxtar_checksum