catalog

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 16, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package catalog encodes the Proxmox .pcat1 catalog format used alongside PXAR v1 archives. Catalogs are written bottom-up (children's tables before their parents) so directory entries can reference child tables by backward delta, and terminated by a root pointer trailer (fixed little-endian u64).

PXAR v2 split archives do not use a catalog; the metadata stream serves that role.

Index

Constants

View Source
const (
	TypeDirectory   = 'd'
	TypeFile        = 'f'
	TypeSymlink     = 'l'
	TypeHardlink    = 'h'
	TypeBlockDevice = 'b'
	TypeCharDevice  = 'c'
	TypeFifo        = 'p'
	TypeSocket      = 's'
)

Entry type bytes as stored on disk.

Variables

View Source
var Magic = []byte{145, 253, 96, 249, 196, 103, 88, 213}

Magic identifies a .pcat1 catalog (PROXMOX_CATALOG_FILE_MAGIC_1_0).

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Name      string
	Type      byte
	Size      uint64
	MtimeSecs int64
	Children  []*Entry
}

Entry is one decoded catalog entry. Directories carry Children; files carry Size and MtimeSecs. Decode returns a synthetic root directory whose children are the archive entries.

func Decode

func Decode(data []byte) (*Entry, error)

Decode parses a complete .pcat1 catalog.

func (*Entry) Child

func (e *Entry) Child(name string) *Entry

Child returns the named child of a directory entry, or nil.

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

Writer streams a .pcat1 catalog. Directory tables are written bottom-up as directories close, so parents reference children by backward delta; entries within a table appear in the order they were added (canonical: sorted walk order, directories recorded when they close).

Usage: NewWriter, StartDirectory(archiveName), Add*/nested directories, EndDirectory, Finish. The top-level directory conventionally carries the archive's index name (e.g. "root.pxar.didx"); a catalog may hold several.

func NewWriter

func NewWriter(w io.Writer) (*Writer, error)

NewWriter writes the magic and returns a Writer positioned at the root.

func (*Writer) AddBlockDevice

func (c *Writer) AddBlockDevice(name string) error

func (*Writer) AddCharDevice

func (c *Writer) AddCharDevice(name string) error

func (*Writer) AddFifo

func (c *Writer) AddFifo(name string) error

func (*Writer) AddFile

func (c *Writer) AddFile(name string, size uint64, mtimeSecs int64) error

AddFile records a regular file in the current directory.

func (c *Writer) AddHardlink(name string) error

func (*Writer) AddSocket

func (c *Writer) AddSocket(name string) error
func (c *Writer) AddSymlink(name string) error

AddSymlink, AddHardlink, AddBlockDevice, AddCharDevice, AddFifo and AddSocket record name-only entries of the respective type.

func (*Writer) EndDirectory

func (c *Writer) EndDirectory() error

EndDirectory encodes and writes the current directory's table and records it in the parent.

func (*Writer) Finish

func (c *Writer) Finish() error

Finish writes the root table and the trailing little-endian u64 pointing at it. The Writer is unusable afterwards.

func (*Writer) StartDirectory

func (c *Writer) StartDirectory(name string) error

StartDirectory opens a directory (or, at the top level, an archive entry).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL