Documentation
¶
Overview ¶
Package tarutil archives and restores a directory tree as a tar file, preserving the metadata a workload's data directory depends on: modes, ownership, modification times, symlinks, hardlinks, FIFOs, device nodes, and user.* / trusted.overlay.* extended attributes (as PAX SCHILY.xattr records).
It exists for snapshotting durable-dir volumes and rootfs overlay uppers (see cmd/ateom-microvm): the contents are written by the sandboxed workload under arbitrary uids, shipped to object storage, and restored — possibly onto another node — where the workload must see them unchanged. The upper is why device nodes and overlay xattrs matter: the host kernel's overlayfs records a deleted file as a 0:0 character device (whiteout) and a replaced directory as a trusted.overlay.opaque xattr, and losing either silently resurrects deleted content after a resume.
Extraction is confined to the destination with os.Root, so a crafted archive cannot write outside it via "..", an absolute path, or a symlink.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Create ¶
Create writes a tar archive of srcDir's contents to tarPath. Entry names are relative to srcDir, so extracting into another directory reproduces the tree. srcDir itself is not an entry.
Regular files, directories, symlinks, FIFOs, and device nodes are archived with their mode, ownership, modification time, and user.* / trusted.overlay.* xattrs. A file with multiple links inside srcDir is archived once and referenced as a hardlink thereafter. Sockets are skipped (see writeTree).
func CreateFiltered ¶
CreateFiltered is Create with entries omitted where skip returns true. A nil skip archives everything.
func Extract ¶
Extract unpacks tarPath into dstDir, which must already exist. Modes, ownership, modification times, symlinks, and hardlinks are restored.
All writes go through an os.Root rooted at dstDir, so entries naming a path outside it — via "..", an absolute path, or a symlink planted earlier in the same archive — are refused rather than followed. An entry that collides with an existing path replaces it ("later entry wins", standard tar semantics), except that an existing directory is kept when the entry is also a directory.