Documentation
¶
Overview ¶
Package pxar implements the Proxmox Archive format for Go.
pxar is a binary archive format for efficient backup and storage of file system metadata and content with support for random access via goodbye tables.
Entry Model ¶
An archive is a stream of typed entries (Entry). Each entry has a Kind that identifies it as a directory, file, symlink, device node, socket, FIFO, or goodbye table marker. File entries carry content inline; directory entries contain child entries followed by a goodbye table for O(log n) filename lookups.
Metadata ¶
Every filesystem entry carries a Metadata struct with POSIX stat information (format.Stat), extended attributes (XAttr), POSIX ACLs, file capabilities (FCaps), and quota project IDs. Use MetadataBuilder to construct Metadata with a fluent API:
meta := pxar.FileMetadata(0o644).
Owner(1000, 1000).
Build()
File Name Validation ¶
Use CheckPathComponent to validate path components before encoding:
if !pxar.CheckPathComponent(name) {
return fmt.Errorf("invalid filename: %s", name)
}
Index ¶
- func CheckPathComponent(path string) bool
- type ACL
- type Entry
- func (e *Entry) FileName() string
- func (e *Entry) FileSize_() (uint64, bool)
- func (e *Entry) IsDevice() bool
- func (e *Entry) IsDir() bool
- func (e *Entry) IsFifo() bool
- func (e *Entry) IsHardlink() bool
- func (e *Entry) IsRegularFile() bool
- func (e *Entry) IsSocket() bool
- func (e *Entry) IsSymlink() bool
- type EntryKind
- type Metadata
- type MetadataBuilder
- func DeviceMetadata(mode uint64) *MetadataBuilder
- func DirMetadata(mode uint64) *MetadataBuilder
- func FIFOMetadata(mode uint64) *MetadataBuilder
- func FileMetadata(mode uint64) *MetadataBuilder
- func NewMetadataBuilder(mode uint64) *MetadataBuilder
- func SocketMetadata(mode uint64) *MetadataBuilder
- func SymlinkMetadata(mode uint64) *MetadataBuilder
- func (b *MetadataBuilder) Build() Metadata
- func (b *MetadataBuilder) FCaps(data []byte) *MetadataBuilder
- func (b *MetadataBuilder) FileMode(mode uint64) *MetadataBuilder
- func (b *MetadataBuilder) GID(gid uint32) *MetadataBuilder
- func (b *MetadataBuilder) Mtime(ts format.StatxTimestamp) *MetadataBuilder
- func (b *MetadataBuilder) Owner(uid, gid uint32) *MetadataBuilder
- func (b *MetadataBuilder) QuotaProjectID(id uint64) *MetadataBuilder
- func (b *MetadataBuilder) StMode(mode uint64) *MetadataBuilder
- func (b *MetadataBuilder) UID(uid uint32) *MetadataBuilder
- func (b *MetadataBuilder) XAttr(name, value []byte) *MetadataBuilder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckPathComponent ¶
CheckPathComponent validates that a path consists of a single normal component.
Types ¶
type ACL ¶
type ACL struct {
Users []format.ACLUser
Groups []format.ACLGroup
GroupObj *format.ACLGroupObject
Default *format.ACLDefault
DefaultUsers []format.ACLUser
DefaultGroups []format.ACLGroup
}
ACL holds access control list entries.
type Entry ¶
type Entry struct {
Path string
Metadata Metadata
Kind EntryKind
// File-specific fields
FileSize uint64 // valid when Kind == KindFile
FileOffset uint64 // byte offset in archive (start of FILENAME header)
PayloadOffset uint64 // byte offset in payload stream (0 if not split)
ContentOffset uint64 // absolute byte offset where content begins (after PAYLOAD header for files, start of child entries for dirs)
// Symlink/Hardlink target
LinkTarget string
// Device info
DeviceInfo format.Device
}
Entry represents an item in a pxar archive.
func (*Entry) IsHardlink ¶
IsHardlink reports whether the entry is a hard link.
func (*Entry) IsRegularFile ¶
IsRegularFile reports whether the entry is a regular file.
type EntryKind ¶
type EntryKind int
EntryKind identifies the type of a pxar archive entry.
const ( KindVersion EntryKind = iota // Format version KindPrelude // Prelude blob KindSymlink // Symbolic link KindHardlink // Hard link KindDevice // Device node KindSocket // Unix socket KindFifo // Named pipe KindFile // Regular file KindDirectory // Directory KindGoodbyeTable // End-of-directory marker )
type Metadata ¶
type Metadata struct {
Stat format.Stat
XAttrs []format.XAttr
ACL ACL
FCaps []byte // file capability data
QuotaProjectID *uint64
}
Metadata holds file metadata found in pxar archives.
func (Metadata) IsRegularFile ¶
IsRegularFile reports whether this metadata describes a regular file.
type MetadataBuilder ¶
type MetadataBuilder struct {
// contains filtered or unexported fields
}
MetadataBuilder constructs Metadata using a fluent API.
func DeviceMetadata ¶
func DeviceMetadata(mode uint64) *MetadataBuilder
DeviceMetadata creates a builder for a device.
func DirMetadata ¶
func DirMetadata(mode uint64) *MetadataBuilder
DirMetadata creates a builder for a directory.
func FIFOMetadata ¶
func FIFOMetadata(mode uint64) *MetadataBuilder
FIFOMetadata creates a builder for a FIFO.
func FileMetadata ¶
func FileMetadata(mode uint64) *MetadataBuilder
FileMetadata creates a builder for a regular file.
func NewMetadataBuilder ¶
func NewMetadataBuilder(mode uint64) *MetadataBuilder
NewMetadataBuilder creates a builder with the given type+mode.
func SocketMetadata ¶
func SocketMetadata(mode uint64) *MetadataBuilder
SocketMetadata creates a builder for a socket.
func SymlinkMetadata ¶
func SymlinkMetadata(mode uint64) *MetadataBuilder
SymlinkMetadata creates a builder for a symlink.
func (*MetadataBuilder) Build ¶
func (b *MetadataBuilder) Build() Metadata
Build returns the constructed Metadata.
func (*MetadataBuilder) FCaps ¶
func (b *MetadataBuilder) FCaps(data []byte) *MetadataBuilder
FCaps sets the file capabilities.
func (*MetadataBuilder) FileMode ¶
func (b *MetadataBuilder) FileMode(mode uint64) *MetadataBuilder
FileMode sets just the permission bits.
func (*MetadataBuilder) GID ¶
func (b *MetadataBuilder) GID(gid uint32) *MetadataBuilder
GID sets the group ID.
func (*MetadataBuilder) Mtime ¶
func (b *MetadataBuilder) Mtime(ts format.StatxTimestamp) *MetadataBuilder
Mtime sets the modification time.
func (*MetadataBuilder) Owner ¶
func (b *MetadataBuilder) Owner(uid, gid uint32) *MetadataBuilder
Owner sets both UID and GID.
func (*MetadataBuilder) QuotaProjectID ¶
func (b *MetadataBuilder) QuotaProjectID(id uint64) *MetadataBuilder
QuotaProjectID sets the quota project ID.
func (*MetadataBuilder) StMode ¶
func (b *MetadataBuilder) StMode(mode uint64) *MetadataBuilder
StMode sets the complete mode (type + permissions).
func (*MetadataBuilder) UID ¶
func (b *MetadataBuilder) UID(uid uint32) *MetadataBuilder
UID sets the user ID.
func (*MetadataBuilder) XAttr ¶
func (b *MetadataBuilder) XAttr(name, value []byte) *MetadataBuilder
XAttr adds an extended attribute.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package accessor provides random access to pxar archives.
|
Package accessor provides random access to pxar archives. |
|
Package backupproxy provides a pull-mode backup architecture where a server (running on the PBS machine) orchestrates backups by walking a remote client's filesystem, encoding pxar archives, chunking with buzhash, and uploading to a backup store.
|
Package backupproxy provides a pull-mode backup architecture where a server (running on the PBS machine) orchestrates backups by walking a remote client's filesystem, encoding pxar archives, chunking with buzhash, and uploading to a backup store. |
|
Package binarytree implements binary search tree operations on arrays.
|
Package binarytree implements binary search tree operations on arrays. |
|
Package buzhash implements the buzhash rolling hash algorithm for content-defined chunking.
|
Package buzhash implements the buzhash rolling hash algorithm for content-defined chunking. |
|
Package datastore provides chunk storage, indexing, and backup catalog management for pxar archives.
|
Package datastore provides chunk storage, indexing, and backup catalog management for pxar archives. |
|
Package decoder reads pxar archives.
|
Package decoder reads pxar archives. |
|
Package encoder creates pxar archives.
|
Package encoder creates pxar archives. |
|
Package format defines the pxar binary format types and constants.
|
Package format defines the pxar binary format types and constants. |
|
Package fusefs provides a read-only filesystem interface over pxar archives, compatible with hanwen/go-fuse's InodeEmbedder and Inode interfaces.
|
Package fusefs provides a read-only filesystem interface over pxar archives, compatible with hanwen/go-fuse's InodeEmbedder and Inode interfaces. |