nx_tar.nx
buildroot/runtime/nx_tar.nx
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
imports: nx_syscalls.nx
imported by: nx_tar_gate.nx
structs
| none |
consts
| 32 | const NX_TAR_BLOCK: i64 = 512 |
| 33 | const NX_TAR_NAME_OFF: i64 = 0 |
| 34 | const NX_TAR_NAME_LEN: i64 = 100 |
| 35 | const NX_TAR_MODE_OFF: i64 = 100 |
| 36 | const NX_TAR_UID_OFF: i64 = 108 |
| 37 | const NX_TAR_GID_OFF: i64 = 116 |
| 38 | const NX_TAR_SIZE_OFF: i64 = 124 |
| 39 | const NX_TAR_MTIME_OFF: i64 = 136 |
| 40 | const NX_TAR_CHK_OFF: i64 = 148 |
| 41 | const NX_TAR_CHK_LEN: i64 = 8 |
| 42 | const NX_TAR_TYPE_OFF: i64 = 156 |
| 43 | const NX_TAR_MAGIC_OFF: i64 = 257 |
| 45 | const NX_TAR_TYPE_FILE: i64 = 0x30 |
| 46 | const NX_TAR_TYPE_DIR: i64 = 0x35 |
| 49 | const NX_TAR_FLD_SIZE: i64 = 0 |
| 50 | const NX_TAR_FLD_MODE: i64 = 1 |
| 51 | const NX_TAR_FLD_MTIME: i64 = 2 |
| 52 | const NX_TAR_FLD_TYPE: i64 = 3 |
| 53 | const NX_TAR_FLD_DATAOFF: i64 = 4 |
| 54 | const NX_TAR_FLD_NEXT: i64 = 5 |
| 55 | const NX_TAR_FLD_NAMELEN: i64 = 6 |
functions
| 64 | func nxtar_octal_w(out: *u8, off: i64, width: i64, v: i64) -> i64 |
| 79 | func nxtar_octal_r(b: *u8, off: i64, width: i64) -> i64 |
| 99 | func nxtar_checksum(h: *u8) -> i64 |
| 117 | func nxtar_strlen(s: *u8) -> i64 called by 1: nxtar_header_build |
| 125 | func nxtar_header_build(name: *u8, size: i64, mode: i64, mtime: i64, |
| 167 | func nxtar_append(out: *u8, cap: i64, off: i64, name: *u8, |
| 183 | func nxtar_finalize(out: *u8, cap: i64, off: i64) -> i64 called by 1: main |
| 195 | func nxtar_read(data: *u8, n: i64, off: i64, fld: *i64) -> i64 |