code wiki / (root) / nx_tar_header.nx

nx_tar_header.nx

buildroot/runtime/nx_tar_header.nx

6642 B188 linesdepth 2pulls 2 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

nx_syscalls.nx nx_tar_header.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

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

main sys_mmap tar_parse_header tar_scan_nul tar_parse_octal tar_is_zero_block

structs

50struct TarHeader

consts

42const TAR_MAGIC_1024: i64 = 1024
44const TAR_BLOCK: i64 = 512
46const TAR_ERR_FORMAT: i64 = -1
47const TAR_ERR_SHORT: i64 = -2
48const TAR_ERR_OCTAL: i64 = -3

functions

69func tar_parse_octal(buf: *u8, off: i64, n: i64) -> i64
called by 1: tar_parse_header
87func tar_scan_nul(buf: *u8, off: i64, max: i64) -> i64
called by 1: tar_parse_header
98func tar_is_zero_block(buf: *u8, off: i64) -> i64
called by 1: main
109func tar_parse_header(buf: *u8, n: i64, off: i64, h: *TarHeader) -> i64
called by 1: main calls 2: tar_scan_nultar_parse_octal
145func main() -> i64