Documentation
¶
Overview ¶
Package format defines the pxar binary format types and constants.
All values are stored in little endian ordering. The archive contains a list of items. Each item starts with a Header, followed by item data.
Index ¶
- Constants
- func CheckFilename(name []byte) error
- func HashFilename(name []byte) uint64
- func MarshalACLDefaultBytes(d ACLDefault) []byte
- func MarshalACLGroupBytes(g ACLGroup) []byte
- func MarshalACLGroupObjectBytes(o ACLGroupObject) []byte
- func MarshalACLUserBytes(u ACLUser) []byte
- func MarshalDeviceBytes(d Device) []byte
- func MarshalStatBytes(s Stat) []byte
- func WriteHeader(w io.Writer, h Header) error
- func WriteStat(w io.Writer, s Stat) error
- type ACLDefault
- type ACLGroup
- type ACLGroupObject
- type ACLPermissions
- type ACLUser
- type Device
- type FCaps
- type FormatVersion
- type GoodbyeItem
- type Hardlink
- type Header
- type PayloadRef
- type Prelude
- type QuotaProjectID
- type Stat
- func (s Stat) FileMode() uint64
- func (s Stat) FileType() uint64
- func (s Stat) IsBlockDev() bool
- func (s Stat) IsCharDev() bool
- func (s Stat) IsDevice() bool
- func (s Stat) IsDir() bool
- func (s Stat) IsFIFO() bool
- func (s Stat) IsRegularFile() bool
- func (s Stat) IsSocket() bool
- func (s Stat) IsSymlink() bool
- type StatV1
- type StatxTimestamp
- type Symlink
- type XAttr
Constants ¶
const ( ACLRead uint64 = 4 ACLWrite uint64 = 2 ACLExecute uint64 = 1 ACLNoMask uint64 = ^uint64(0) )
ACL permission bit constants.
const ( HashKey1 uint64 = 0x83ac3f1cfbb450db HashKey2 uint64 = 0xaa4f1b6879369fbd )
Hash keys for SipHash24 filename hashing. Generated from: echo -n 'PROXMOX ARCHIVE FORMAT' | sha1sum
const ( PXARFormatVersion uint64 = 0x730f6c75df16a40d PXAREntry uint64 = 0xd5956474e588acef PXAREntryV1 uint64 = 0x11da850a1c1cceff PXARPrelude uint64 = 0xe309d79d9f7b771b PXARFilename uint64 = 0x16701121063917b3 PXARSymlink uint64 = 0x27f971e7dbf5dc5f PXARDevice uint64 = 0x9fc9e906586d5ce9 PXARXAttr uint64 = 0x0dab0229b57dcd03 PXARACLUser uint64 = 0x2ce8540a457d55b8 PXARACLGroup uint64 = 0x136e3eceb04c03ab PXARACLGroupObj uint64 = 0x10868031e9582876 PXARACLDefault uint64 = 0xbbbb13415a6896f5 PXARACLDefaultUser uint64 = 0xc89357b40532cd1f PXARACLDefaultGroup uint64 = 0xf90a8a5816038ffe PXARFCaps uint64 = 0x2da9dd9db5f7fb67 PXARQuotaProjID uint64 = 0xe07540e82f7d1cbb PXARHardlink uint64 = 0x51269c8422bd7275 PXARPayload uint64 = 0x28147a1b0b7c1a25 PXARPayloadRef uint64 = 0x419d3d6bc4ba977e PXARGoodbye uint64 = 0x2fec4fa642d5731d PXARGoodbyeTailMarker uint64 = 0xef5eed5b753e1555 PXARPayloadStartMarker uint64 = 0x834c68c2194a4ed2 PXARPayloadTailMarker uint64 = 0x6c72b78b984c81b5 )
Pxar format type constants.
const ( ModeIFMT uint64 = 0o0170000 ModeIFSOCK uint64 = 0o0140000 ModeIFLNK uint64 = 0o0120000 ModeIFREG uint64 = 0o0100000 ModeIFBLK uint64 = 0o0060000 ModeIFDIR uint64 = 0o0040000 ModeIFCHR uint64 = 0o0020000 ModeIFIFO uint64 = 0o0010000 ModeISUID uint64 = 0o0004000 ModeISGID uint64 = 0o0002000 ModeISVTX uint64 = 0o0001000 )
File mode type constants matching Linux stat.h values.
const ( MaxFilenameLen uint64 = 4 * 1024 MaxPathLen uint64 = 4 * 1024 MaxXAttrLen uint64 = 255 + 64*1024 )
Size limits.
const HeaderSize = 16
HeaderSize is the byte size of Header.
Variables ¶
This section is empty.
Functions ¶
func CheckFilename ¶
CheckFilename validates that a filename is a legal path component.
func HashFilename ¶
HashFilename computes the SipHash24 of a filename for use in goodbye tables.
func MarshalACLDefaultBytes ¶
func MarshalACLDefaultBytes(d ACLDefault) []byte
MarshalACLDefaultBytes serializes an ACLDefault into a 32-byte slice.
func MarshalACLGroupBytes ¶
MarshalACLGroupBytes serializes an ACLGroup into a 16-byte slice.
func MarshalACLGroupObjectBytes ¶
func MarshalACLGroupObjectBytes(o ACLGroupObject) []byte
MarshalACLGroupObjectBytes serializes an ACLGroupObject into an 8-byte slice.
func MarshalACLUserBytes ¶
MarshalACLUserBytes serializes an ACLUser into a 16-byte slice.
func MarshalDeviceBytes ¶
MarshalDeviceBytes serializes a Device into a 16-byte slice.
func MarshalStatBytes ¶
MarshalStatBytes serializes a Stat into a 40-byte slice.
func WriteHeader ¶
WriteHeader writes a Header to the writer.
Types ¶
type ACLDefault ¶
type ACLDefault struct {
UserObjPermissions ACLPermissions
GroupObjPermissions ACLPermissions
OtherPermissions ACLPermissions
MaskPermissions ACLPermissions
}
ACLDefault represents the default ACL entry for a directory. 32 bytes.
func UnmarshalACLDefaultBytes ¶
func UnmarshalACLDefaultBytes(data []byte) *ACLDefault
UnmarshalACLDefaultBytes parses an ACLDefault from a 32-byte slice.
type ACLGroup ¶
type ACLGroup struct {
GID uint64
Permissions ACLPermissions
}
ACLGroup represents a group ACL entry. 24 bytes.
type ACLGroupObject ¶
type ACLGroupObject struct {
Permissions ACLPermissions
}
ACLGroupObject represents the group object ACL entry. 8 bytes.
type ACLPermissions ¶
type ACLPermissions uint64
ACLPermissions represents ACL permission bits. 8 bytes.
type ACLUser ¶
type ACLUser struct {
UID uint64
Permissions ACLPermissions
}
ACLUser represents a user ACL entry. 24 bytes.
type Device ¶
Device represents a device node with major/minor numbers. 16 bytes.
func DeviceFromDevT ¶
DeviceFromDevT creates a Device from a Linux dev_t value.
func ReadDevice ¶
ReadDevice reads a Device from the reader.
type FormatVersion ¶
type FormatVersion int
FormatVersion represents the pxar format version.
const ( FormatVersion1 FormatVersion = 1 FormatVersion2 FormatVersion = 2 )
func DeserializeFormatVersion ¶
func DeserializeFormatVersion(version uint64) (FormatVersion, error)
DeserializeFormatVersion parses a format version number.
func (FormatVersion) Serialize ¶
func (v FormatVersion) Serialize() []byte
Serialize returns the bytes to write for this format version. V1 returns nil (not encoded), V2 returns the version number as LE uint64.
func (FormatVersion) String ¶
func (v FormatVersion) String() string
String returns a human-readable format version name.
type GoodbyeItem ¶
GoodbyeItem is an entry in the goodbye lookup table. 24 bytes.
func NewGoodbyeItem ¶
func NewGoodbyeItem(name []byte, offset, size uint64) GoodbyeItem
NewGoodbyeItem creates a GoodbyeItem by hashing the filename.
func ReadGoodbyeItem ¶
func ReadGoodbyeItem(r io.Reader) (GoodbyeItem, error)
ReadGoodbyeItem reads a GoodbyeItem from the reader.
type Header ¶
Header is the binary header preceding every pxar item. 16 bytes total.
func HeaderWithContentSize ¶
HeaderWithContentSize creates a Header where Size = contentSize + HeaderSize.
func ReadHeader ¶
ReadHeader reads a Header from the reader.
func (Header) CheckHeaderSize ¶
CheckHeaderSize validates the header's size fields.
func (Header) ContentSize ¶
ContentSize returns the size of the content after the header.
func (Header) MaxContentSize ¶
MaxContentSize returns the maximum allowed content size for this header type.
type PayloadRef ¶
PayloadRef references file content in a separate payload archive. 16 bytes.
func ReadPayloadRef ¶
func ReadPayloadRef(r io.Reader) (PayloadRef, error)
ReadPayloadRef reads a PayloadRef from the reader.
func UnmarshalPayloadRefBytes ¶
func UnmarshalPayloadRefBytes(data []byte) PayloadRef
UnmarshalPayloadRefBytes parses a PayloadRef from a 16-byte slice.
func (PayloadRef) Bytes ¶
func (pr PayloadRef) Bytes() []byte
Bytes returns the little-endian bytes of the PayloadRef.
type Prelude ¶
type Prelude struct {
Data []byte
}
Prelude is an optional blob at the start of a v2 archive.
type QuotaProjectID ¶
type QuotaProjectID struct {
ProjID uint64
}
QuotaProjectID represents an ext4/XFS quota project ID. 8 bytes.
type Stat ¶
type Stat struct {
Mode uint64
Flags uint64
UID uint32
GID uint32
Mtime StatxTimestamp
}
Stat contains file metadata similar to Unix stat. 40 bytes.
func UnmarshalStatBytes ¶
UnmarshalStatBytes parses a Stat from a 40-byte slice.
func (Stat) IsBlockDev ¶
IsBlockDev reports whether the stat represents a block device.
func (Stat) IsRegularFile ¶
IsRegularFile reports whether the stat represents a regular file.
type StatV1 ¶
StatV1 is the legacy format stat structure. 32 bytes.
func UnmarshalStatV1Bytes ¶
UnmarshalStatV1Bytes parses a StatV1 from a 32-byte slice.
type StatxTimestamp ¶
StatxTimestamp represents a high-precision timestamp. 16 bytes.
func StatxTimestampFromDurationSinceEpoch ¶
func StatxTimestampFromDurationSinceEpoch(d time.Duration) StatxTimestamp
StatxTimestampFromDurationSinceEpoch creates a timestamp from a positive duration.
func StatxTimestampNew ¶
func StatxTimestampNew(secs int64, nanos uint32) StatxTimestamp
StatxTimestampNew creates a timestamp from seconds and nanoseconds.
func StatxTimestampZero ¶
func StatxTimestampZero() StatxTimestamp
StatxTimestampZero returns a zero-valued timestamp.
func (StatxTimestamp) Duration ¶
func (ts StatxTimestamp) Duration() time.Duration
Duration converts the timestamp to a duration since epoch.