code wiki / (root) / tar_header.nx

tar_header.nx

buildroot/runtime/tar_header.nx

6506 B181 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tooltopic tar
docsdependenciesstructsconstsfunctions

about

tar_header.nx -- parse POSIX ustar tar headers (IEEE 1003.1). Each tar entry is a 512-byte header followed by its file data padded to a 512-byte boundary. The archive ends with at least two zero-filled 512-byte blocks. Header layout: offset size field 0 100 name (NUL-terminated if shorter) 100 8 mode (octal ASCII) 108 8 uid (octal ASCII) 116 8 gid (octal ASCII) 124 12 size (octal ASCII, bytes of file data) 136 12 mtime (octal ASCII seconds since epoch) 148 8 header checksum (octal ASCII) 156 1 typeflag ('0'=regular, '5'=dir, '2'=symlink, '1'=hardlink, 'x'=pax extended, 'g'=pax global) 157 100 linkname 257 6 magic "ustar\0" (POSIX) or "ustar " (GNU) 263 2 version "00" (POSIX) or " \0" (GNU) 265 32 uname (owner name) 297 32 gname (group name) 329 8 devmajor (octal) 337 8 devminor (octal) 345 155 prefix (prepended to name for long paths) Invariants: T1 Magic must be "ustar" -- the first 5 bytes at offset 257. T2 Size fields are parsed as big-endian octal ASCII. GNU tar optionally encodes large sizes as binary with MSB=0x80; we reject those (caller can detect and extend). T3 Checksum verification not performed here (future work); we parse the field value but don't validate.

dependencies 1 imports · 0 importers

syscalls.nx tar_header.nx

imports: syscalls.nx

imported by: nobody (leaf or entry point)

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

main tar_parse_header tar_scan_nul tar_parse_octal tar_is_zero_block

structs

43struct TarHeader {

consts

37const TAR_BLOCK: i64 = 512
39const TAR_ERR_FORMAT: i64 = -1
40const TAR_ERR_SHORT: i64 = -2
41const TAR_ERR_OCTAL: i64 = -3

functions

62func tar_parse_octal(buf: *u8, off: i64, n: i64) -> i64 {
called by 1: tar_parse_header
80func tar_scan_nul(buf: *u8, off: i64, max: i64) -> i64 {
called by 1: tar_parse_header
91func tar_is_zero_block(buf: *u8, off: i64) -> i64 {
called by 1: main
102func tar_parse_header(buf: *u8, n: i64, off: i64, h: *TarHeader) -> i64 {
called by 1: main calls 2: tar_scan_nultar_parse_octal
138func main() -> i64 {