Documentation
¶
Overview ¶
Package btrfsitem contains the definitions of all "items" that may be stored in a btrfs tree.
Index ¶
- Constants
- func KeyToUUID(key btrfsprim.Key) btrfsprim.UUID
- func NameHash(dat []byte) uint64
- func UUIDToKey(uuid btrfsprim.UUID) btrfsprim.Key
- type BlockGroup
- type Chunk
- type ChunkHeader
- type ChunkStripe
- type CompressionType
- type Dev
- type DevExtent
- type DevStats
- type DirEntry
- type Empty
- type Error
- type Extent
- type ExtentCSum
- type ExtentDataRef
- type ExtentFlags
- type ExtentHeader
- type ExtentInlineRef
- type FileExtent
- type FileExtentExtent
- type FileExtentType
- type FileType
- type FreeSpaceBitmap
- type FreeSpaceFlags
- type FreeSpaceHeader
- type FreeSpaceInfo
- type Inode
- type InodeFlags
- type InodeRef
- type InodeRefs
- type Item
- type Metadata
- type QGroupInfo
- type QGroupLimit
- type QGroupLimitFlags
- type QGroupStatus
- type QGroupStatusFlags
- type Root
- type RootFlags
- type RootRef
- type SharedDataRef
- type StatMode
- type TreeBlockInfo
- type Type
- type UUIDMap
Constants ¶
const ( DEV_STAT_WRITE_ERRS = iota DEV_STAT_READ_ERRS DEV_STAT_FLUSH_ERRS DEV_STAT_CORRUPTION_ERRS DEV_STAT_GENERATION_ERRS DEV_STAT_VALUES_MAX )
const ( QGroupLimitFlagMaxRfer = 1 << iota QGroupLimitFlagMaxExcl QGroupLimitFlagRsvRfer QGroupLimitFlagRsvExcl QGroupLimitFlagRferCmpr QGroupLimitFlagExclCmpr )
const ( BLOCK_GROUP_ITEM_KEY = btrfsprim.BLOCK_GROUP_ITEM_KEY CHUNK_ITEM_KEY = btrfsprim.CHUNK_ITEM_KEY DEV_EXTENT_KEY = btrfsprim.DEV_EXTENT_KEY DEV_ITEM_KEY = btrfsprim.DEV_ITEM_KEY DIR_INDEX_KEY = btrfsprim.DIR_INDEX_KEY DIR_ITEM_KEY = btrfsprim.DIR_ITEM_KEY EXTENT_CSUM_KEY = btrfsprim.EXTENT_CSUM_KEY EXTENT_DATA_KEY = btrfsprim.EXTENT_DATA_KEY EXTENT_DATA_REF_KEY = btrfsprim.EXTENT_DATA_REF_KEY EXTENT_ITEM_KEY = btrfsprim.EXTENT_ITEM_KEY FREE_SPACE_BITMAP_KEY = btrfsprim.FREE_SPACE_BITMAP_KEY FREE_SPACE_EXTENT_KEY = btrfsprim.FREE_SPACE_EXTENT_KEY FREE_SPACE_INFO_KEY = btrfsprim.FREE_SPACE_INFO_KEY INODE_ITEM_KEY = btrfsprim.INODE_ITEM_KEY INODE_REF_KEY = btrfsprim.INODE_REF_KEY METADATA_ITEM_KEY = btrfsprim.METADATA_ITEM_KEY ORPHAN_ITEM_KEY = btrfsprim.ORPHAN_ITEM_KEY PERSISTENT_ITEM_KEY = btrfsprim.PERSISTENT_ITEM_KEY QGROUP_INFO_KEY = btrfsprim.QGROUP_INFO_KEY QGROUP_LIMIT_KEY = btrfsprim.QGROUP_LIMIT_KEY QGROUP_RELATION_KEY = btrfsprim.QGROUP_RELATION_KEY QGROUP_STATUS_KEY = btrfsprim.QGROUP_STATUS_KEY ROOT_BACKREF_KEY = btrfsprim.ROOT_BACKREF_KEY ROOT_ITEM_KEY = btrfsprim.ROOT_ITEM_KEY ROOT_REF_KEY = btrfsprim.ROOT_REF_KEY SHARED_BLOCK_REF_KEY = btrfsprim.SHARED_BLOCK_REF_KEY SHARED_DATA_REF_KEY = btrfsprim.SHARED_DATA_REF_KEY TREE_BLOCK_REF_KEY = btrfsprim.TREE_BLOCK_REF_KEY UNTYPED_KEY = btrfsprim.UNTYPED_KEY UUID_RECEIVED_SUBVOL_KEY = btrfsprim.UUID_RECEIVED_SUBVOL_KEY UUID_SUBVOL_KEY = btrfsprim.UUID_SUBVOL_KEY XATTR_ITEM_KEY = btrfsprim.XATTR_ITEM_KEY )
const MaxNameLen = 255
const QGroupStatusVersion uint64 = 1
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BlockGroup ¶
type BlockGroup struct { Used int64 `bin:"off=0, siz=8"` ChunkObjectID btrfsprim.ObjID `bin:"off=8, siz=8"` // always FIRST_CHUNK_TREE_OBJECTID Flags btrfsvol.BlockGroupFlags `bin:"off=16, siz=8"` binstruct.End `bin:"off=24"` }
A BlockGroup tracks allocation of the logical address space.
Compare with:
- DevExtents, which track allocation of the physical address space.
- Chunks, which map logical addresses to physical addresses.
The relationship between the three is
DevExtent---[many:one]---Chunk---[one:one]---BlockGroup
Key:
key.objectid = logical_addr key.offset = size of chunk
type Chunk ¶
type Chunk struct { Head ChunkHeader Stripes []ChunkStripe }
A Chunk maps logical addresses to physical addresses.
Compare with:
- DevExtents, which track allocation of the physical address space.
- BlockGroups, which track allocation of the logical address space.
The relationship between the three is
DevExtent---[many:one]---Chunk---[one:one]---BlockGroup
Key:
key.objectid = BTRFS_FIRST_CHUNK_TREE_OBJECTID key.offset = logical_addr
type ChunkHeader ¶
type ChunkHeader struct { Size btrfsvol.AddrDelta `bin:"off=0x0, siz=0x8"` Owner btrfsprim.ObjID `bin:"off=0x8, siz=0x8"` // root referencing this chunk (always EXTENT_TREE_OBJECTID=2) StripeLen uint64 `bin:"off=0x10, siz=0x8"` // ??? Type btrfsvol.BlockGroupFlags `bin:"off=0x18, siz=0x8"` IOOptimalAlign uint32 `bin:"off=0x20, siz=0x4"` IOOptimalWidth uint32 `bin:"off=0x24, siz=0x4"` IOMinSize uint32 `bin:"off=0x28, siz=0x4"` // sector size NumStripes uint16 `bin:"off=0x2c, siz=0x2"` // [ignored-when-writing] SubStripes uint16 `bin:"off=0x2e, siz=0x2"` // ??? binstruct.End `bin:"off=0x30"` }
type ChunkStripe ¶
type CompressionType ¶
type CompressionType uint8
const ( COMPRESS_NONE CompressionType = iota COMPRESS_ZLIB COMPRESS_LZO COMPRESS_ZSTD )
func (CompressionType) String ¶
func (ct CompressionType) String() string
type Dev ¶
type Dev struct { DevID btrfsvol.DeviceID `bin:"off=0x0, siz=0x8"` NumBytes uint64 `bin:"off=0x8, siz=0x8"` NumBytesUsed uint64 `bin:"off=0x10, siz=0x8"` IOOptimalAlign uint32 `bin:"off=0x18, siz=0x4"` IOOptimalWidth uint32 `bin:"off=0x1c, siz=0x4"` IOMinSize uint32 `bin:"off=0x20, siz=0x4"` // sector size Type uint64 `bin:"off=0x24, siz=0x8"` Generation btrfsprim.Generation `bin:"off=0x2c, siz=0x8"` StartOffset uint64 `bin:"off=0x34, siz=0x8"` DevGroup uint32 `bin:"off=0x3c, siz=0x4"` SeekSpeed uint8 `bin:"off=0x40, siz=0x1"` Bandwidth uint8 `bin:"off=0x41, siz=0x1"` DevUUID btrfsprim.UUID `bin:"off=0x42, siz=0x10"` FSUUID btrfsprim.UUID `bin:"off=0x52, siz=0x10"` binstruct.End `bin:"off=0x62"` }
A Dev describes a physical volume that is part of the filesystem.
Key:
key.objectid = BTRFS_DEV_ITEMS_OBJECTID key.offset = device_id (starting at 1)
type DevExtent ¶
type DevExtent struct { ChunkTree btrfsprim.ObjID `bin:"off=0, siz=8"` // always CHUNK_TREE_OBJECTID ChunkObjectID btrfsprim.ObjID `bin:"off=8, siz=8"` // which chunk within .ChunkTree owns this extent, always FIRST_CHUNK_TREE_OBJECTID ChunkOffset btrfsvol.LogicalAddr `bin:"off=16, siz=8"` // offset of the CHUNK_ITEM that owns this extent, within the .ChunkObjectID Length btrfsvol.AddrDelta `bin:"off=24, siz=8"` ChunkTreeUUID btrfsprim.UUID `bin:"off=32, siz=16"` binstruct.End `bin:"off=48"` }
A DevExtent tracks allocation of the physical address space.
Compare with:
- BlockGroups, which track allocation of the logical address space.
- Chunks, which map logical addresses to physical addresses.
The relationship between the three is
DevExtent---[many:one]---Chunk---[one:one]---BlockGroup
The device ID identifies which Dev item describes the physical volume that the DevExtent is on.
Key:
key.objectid = device_id key.offset = physical_addr
type DevStats ¶
type DevStats struct { Values [DEV_STAT_VALUES_MAX]int64 `bin:"off=0, siz=40"` binstruct.End `bin:"off=40"` }
type DirEntry ¶
type DirEntry struct { Location btrfsprim.Key `bin:"off=0x0, siz=0x11"` TransID int64 `bin:"off=0x11, siz=8"` DataLen uint16 `bin:"off=0x19, siz=2"` // [ignored-when-writing] NameLen uint16 `bin:"off=0x1b, siz=2"` // [ignored-when-writing] Type FileType `bin:"off=0x1d, siz=1"` binstruct.End `bin:"off=0x1e"` Data []byte `bin:"-"` // xattr value (only for XATTR_ITEM) Name []byte `bin:"-"` }
A DirEntry is an member of a directory.
Key:
key.objectid = inode of directory containing this entry key.offset = one of: - for DIR_ITEM and XATTR_ITEM = NameHash(name) - for DIR_INDEX = index id in the directory (starting at 2, because of "." and "..")
type Empty ¶
type Error ¶
type Extent ¶
type Extent struct { Head ExtentHeader Info TreeBlockInfo // only if .Head.Flags.Has(EXTENT_FLAG_TREE_BLOCK) Refs []ExtentInlineRef }
Extent items map from regions in the logical address space to regions in a file.
Compare with:
- Metadata, which are like Extents but without .Info.
- FileExtents, which map from regions in a file to regions in the logical address space.
An Extent may contain (inline or not) several ExtentDataRef items and/or ShareDataRef items.
Key:
key.objectid = laddr of the extent key.offset = length of the extent
type ExtentCSum ¶
type ExtentCSum struct { // Checksum of each sector starting at key.offset btrfssum.SumRun[btrfsvol.LogicalAddr] }
An ExtentCSum checksums regions of the logical address space.
Key:
key.objectid = BTRFS_EXTENT_CSUM_OBJECTID key.offset = laddr of checksummed region
func (ExtentCSum) Clone ¶
func (o ExtentCSum) Clone() ExtentCSum
func (*ExtentCSum) CloneItem ¶
func (o *ExtentCSum) CloneItem() Item
func (*ExtentCSum) Free ¶
func (o *ExtentCSum) Free()
func (ExtentCSum) MarshalBinary ¶
func (o ExtentCSum) MarshalBinary() ([]byte, error)
func (*ExtentCSum) UnmarshalBinary ¶
func (o *ExtentCSum) UnmarshalBinary(dat []byte) (int, error)
type ExtentDataRef ¶
type ExtentDataRef struct { Root btrfsprim.ObjID `bin:"off=0, siz=8"` // subvolume tree ID that references this extent ObjectID btrfsprim.ObjID `bin:"off=8, siz=8"` // inode number that references this extent within the .Root subvolume Offset int64 `bin:"off=16, siz=8"` // byte offset for the extent within the file Count int32 `bin:"off=24, siz=4"` // reference count binstruct.End `bin:"off=28"` }
ExtentDataRef is part of an Extent.
Key:
key.objectid = laddr of the extent being referenced key.offset = crc32c([root,objectid,offset])
func (ExtentDataRef) Clone ¶
func (o ExtentDataRef) Clone() ExtentDataRef
func (*ExtentDataRef) CloneItem ¶
func (o *ExtentDataRef) CloneItem() Item
func (*ExtentDataRef) Free ¶
func (o *ExtentDataRef) Free()
type ExtentFlags ¶
type ExtentFlags uint64
const ( EXTENT_FLAG_DATA ExtentFlags = 1 << iota EXTENT_FLAG_TREE_BLOCK )
func (ExtentFlags) Has ¶
func (f ExtentFlags) Has(req ExtentFlags) bool
func (ExtentFlags) String ¶
func (f ExtentFlags) String() string
type ExtentHeader ¶
type ExtentHeader struct { Refs int64 `bin:"off=0, siz=8"` Generation btrfsprim.Generation `bin:"off=8, siz=8"` Flags ExtentFlags `bin:"off=16, siz=8"` binstruct.End `bin:"off=24"` }
type ExtentInlineRef ¶
type ExtentInlineRef struct { Type Type // only 4 valid values: {TREE,SHARED}_BLOCK_REF_KEY, {EXTENT,SHARED}_DATA_REF_KEY Offset uint64 // only when Type != EXTENT_DATA_REF_KEY Body Item // only when Type == *_DATA_REF_KEY }
func (ExtentInlineRef) MarshalBinary ¶
func (o ExtentInlineRef) MarshalBinary() ([]byte, error)
func (*ExtentInlineRef) UnmarshalBinary ¶
func (o *ExtentInlineRef) UnmarshalBinary(dat []byte) (int, error)
type FileExtent ¶
type FileExtent struct { Generation btrfsprim.Generation `bin:"off=0x0, siz=0x8"` // transaction ID that created this extent RAMBytes int64 `bin:"off=0x8, siz=0x8"` // upper bound of what compressed data will decompress to // 32 bits describing the data encoding Compression CompressionType `bin:"off=0x10, siz=0x1"` Encryption uint8 `bin:"off=0x11, siz=0x1"` OtherEncoding uint16 `bin:"off=0x12, siz=0x2"` // reserved for later use Type FileExtentType `bin:"off=0x14, siz=0x1"` // inline data or real extent binstruct.End `bin:"off=0x15"` // only one of these, depending on .Type BodyInline []byte `bin:"-"` // .Type == FILE_EXTENT_INLINE BodyExtent FileExtentExtent `bin:"-"` // .Type == FILE_EXTENT_REG or FILE_EXTENT_PREALLOC }
FileExtent items map from regions in a file to regions in the logical address space.
Compare with:
- Extents, which map from regions in the logical address space to regions in a file.
- Metadata, which are like Extents but without .Info.
Key:
key.objectid = inode key.offset = offset within file
func (FileExtent) Clone ¶
func (o FileExtent) Clone() FileExtent
func (*FileExtent) CloneItem ¶
func (o *FileExtent) CloneItem() Item
func (*FileExtent) Free ¶
func (o *FileExtent) Free()
func (FileExtent) MarshalBinary ¶
func (o FileExtent) MarshalBinary() ([]byte, error)
func (FileExtent) Size ¶
func (o FileExtent) Size() (int64, error)
func (*FileExtent) UnmarshalBinary ¶
func (o *FileExtent) UnmarshalBinary(dat []byte) (int, error)
type FileExtentExtent ¶
type FileExtentExtent struct { // Position and size of extent within the device DiskByteNr btrfsvol.LogicalAddr `bin:"off=0x0, siz=0x8"` DiskNumBytes btrfsvol.AddrDelta `bin:"off=0x8, siz=0x8"` // Position of data within the extent Offset btrfsvol.AddrDelta `bin:"off=0x10, siz=0x8"` // Decompressed/unencrypted size NumBytes int64 `bin:"off=0x18, siz=0x8"` binstruct.End `bin:"off=0x20"` }
type FileExtentType ¶
type FileExtentType uint8
const ( FILE_EXTENT_INLINE FileExtentType = iota FILE_EXTENT_REG FILE_EXTENT_PREALLOC )
func (FileExtentType) String ¶
func (fet FileExtentType) String() string
type FreeSpaceBitmap ¶
type FreeSpaceBitmap struct {
Bitmap []byte
}
FreeSpaceBitmap is used in conjunction with FreeSpaceInfo for highly-fragmented blockgroups.
Key:
key.objectid = object ID of the FreeSpaceInfo (logical_addr) key.offset = offset of the FreeSpaceInfo (size)
func (FreeSpaceBitmap) Clone ¶
func (o FreeSpaceBitmap) Clone() FreeSpaceBitmap
func (*FreeSpaceBitmap) CloneItem ¶
func (o *FreeSpaceBitmap) CloneItem() Item
func (*FreeSpaceBitmap) Free ¶
func (o *FreeSpaceBitmap) Free()
func (FreeSpaceBitmap) MarshalBinary ¶
func (o FreeSpaceBitmap) MarshalBinary() ([]byte, error)
func (*FreeSpaceBitmap) UnmarshalBinary ¶
func (o *FreeSpaceBitmap) UnmarshalBinary(dat []byte) (int, error)
type FreeSpaceFlags ¶
type FreeSpaceFlags uint32
const (
FREE_SPACE_USING_BITMAPS FreeSpaceFlags = 1 << iota
)
func (FreeSpaceFlags) Has ¶
func (f FreeSpaceFlags) Has(req FreeSpaceFlags) bool
func (FreeSpaceFlags) String ¶
func (f FreeSpaceFlags) String() string
type FreeSpaceHeader ¶
type FreeSpaceHeader struct { Location btrfsprim.Key `bin:"off=0x00, siz=0x11"` Generation btrfsprim.Generation `bin:"off=0x11, siz=0x8"` NumEntries int64 `bin:"off=0x19, siz=0x8"` NumBitmaps int64 `bin:"off=0x21, siz=0x8"` binstruct.End `bin:"off=0x29"` }
func (FreeSpaceHeader) Clone ¶
func (o FreeSpaceHeader) Clone() FreeSpaceHeader
func (*FreeSpaceHeader) CloneItem ¶
func (o *FreeSpaceHeader) CloneItem() Item
func (*FreeSpaceHeader) Free ¶
func (o *FreeSpaceHeader) Free()
type FreeSpaceInfo ¶
type FreeSpaceInfo struct { ExtentCount int32 `bin:"off=0, siz=4"` Flags FreeSpaceFlags `bin:"off=4, siz=4"` binstruct.End `bin:"off=8"` }
FreeSpaceInfo is the main way (v2) that free space is tracked in a BlockGroup. For highly-fragmented blockgorups, it may be augmented by a FreeSpaceBitmap.
Key:
key.objectid = object ID of the BlockGroup (logical_addr) key.offset = offset of the BlockGroup (size)
func (FreeSpaceInfo) Clone ¶
func (o FreeSpaceInfo) Clone() FreeSpaceInfo
func (*FreeSpaceInfo) CloneItem ¶
func (o *FreeSpaceInfo) CloneItem() Item
func (*FreeSpaceInfo) Free ¶
func (o *FreeSpaceInfo) Free()
type Inode ¶
type Inode struct { Generation btrfsprim.Generation `bin:"off=0x00, siz=0x08"` TransID int64 `bin:"off=0x08, siz=0x08"` Size int64 `bin:"off=0x10, siz=0x08"` // stat NumBytes int64 `bin:"off=0x18, siz=0x08"` // allocated bytes, may be larger than size (or smaller if there are holes?) BlockGroup btrfsprim.ObjID `bin:"off=0x20, siz=0x08"` // only used for freespace inodes NLink int32 `bin:"off=0x28, siz=0x04"` // stat UID int32 `bin:"off=0x2C, siz=0x04"` // stat GID int32 `bin:"off=0x30, siz=0x04"` // stat Mode StatMode `bin:"off=0x34, siz=0x04"` // stat RDev int64 `bin:"off=0x38, siz=0x08"` // stat Flags InodeFlags `bin:"off=0x40, siz=0x08"` // statx.stx_attributes, sorta Sequence int64 `bin:"off=0x48, siz=0x08"` // NFS Reserved [4]int64 `bin:"off=0x50, siz=0x20"` ATime btrfsprim.Time `bin:"off=0x70, siz=0x0c"` // stat CTime btrfsprim.Time `bin:"off=0x7c, siz=0x0c"` // stat MTime btrfsprim.Time `bin:"off=0x88, siz=0x0c"` // stat OTime btrfsprim.Time `bin:"off=0x94, siz=0x0c"` // statx.stx_btime (why is this called "otime" instead of "btime"?) binstruct.End `bin:"off=0xa0"` }
Inode is a file/dir/whatever in the filesystem.
key.objectid = inode number key.offset = 0
type InodeFlags ¶
type InodeFlags uint64
const ( INODE_NODATASUM InodeFlags = 1 << iota INODE_NODATACOW INODE_READONLY INODE_NOCOMPRESS INODE_PREALLOC INODE_SYNC INODE_IMMUTABLE INODE_APPEND INODE_NODUMP INODE_NOATIME INODE_DIRSYNC INODE_COMPRESS )
func (InodeFlags) Has ¶
func (f InodeFlags) Has(req InodeFlags) bool
func (InodeFlags) String ¶
func (f InodeFlags) String() string
type InodeRef ¶
type InodeRefs ¶
type InodeRefs struct {
Refs []InodeRef
}
An InodeRefs item is a set of back-references that point to a given Inode.
Key:
key.objectid = inode number of the file key.offset = inode number of the parent directory
There might be multiple back-references in a single InodeRef item if the same file has multiple hardlinks in the same directory.
type Item ¶
type Item interface { Free() CloneItem() Item // contains filtered or unexported methods }
type Metadata ¶
type Metadata struct { Head ExtentHeader Refs []ExtentInlineRef }
Metadata items map from regions in the logical address space to regions in a file.
Metadata is like Extent, but doesn't have .Info.
Compare with:
- Extents, which are the same as Metadata, but have an extra .Info member.
- FileExtents, which map from regions in a file to regions in the logical address space.
Key:
key.objectid = laddr of the extent key.offset = length of the extent
type QGroupInfo ¶
type QGroupInfo struct { Generation btrfsprim.Generation `bin:"off=0, siz=8"` ReferencedBytes uint64 `bin:"off=8, siz=8"` ReferencedBytesCompressed uint64 `bin:"off=16, siz=8"` ExclusiveBytes uint64 `bin:"off=24, siz=8"` ExclusiveBytesCompressed uint64 `bin:"off=32, siz=8"` binstruct.End `bin:"off=40"` }
QGroupInfo tracks the amount of space used by a given qgroup in the containing subvolume.
Key:
key.objectid = 0 key.offset = ID of the qgroup
func (QGroupInfo) Clone ¶
func (o QGroupInfo) Clone() QGroupInfo
func (*QGroupInfo) CloneItem ¶
func (o *QGroupInfo) CloneItem() Item
func (*QGroupInfo) Free ¶
func (o *QGroupInfo) Free()
type QGroupLimit ¶
type QGroupLimit struct { Flags QGroupLimitFlags `bin:"off=0, siz=8"` MaxReferenced uint64 `bin:"off=8, siz=8"` MaxExclusive uint64 `bin:"off=16, siz=8"` RsvReferenced uint64 `bin:"off=24, siz=8"` RsvExclusive uint64 `bin:"off=32, siz=8"` binstruct.End `bin:"off=40"` }
QGroupLimit configures the maximum permissible amount of space that a given qgroup can consume (tracked in a QGroupInfo item) on the containing subvolume.
Key:
key.objectid = 0 key.offset = ID of the qgroup
func (QGroupLimit) Clone ¶
func (o QGroupLimit) Clone() QGroupLimit
func (*QGroupLimit) CloneItem ¶
func (o *QGroupLimit) CloneItem() Item
func (*QGroupLimit) Free ¶
func (o *QGroupLimit) Free()
type QGroupLimitFlags ¶
type QGroupLimitFlags uint64
func (QGroupLimitFlags) Has ¶
func (f QGroupLimitFlags) Has(req QGroupLimitFlags) bool
func (QGroupLimitFlags) String ¶
func (f QGroupLimitFlags) String() string
type QGroupStatus ¶
type QGroupStatus struct { Version uint64 `bin:"off=0, siz=8"` Generation btrfsprim.Generation `bin:"off=8, siz=8"` Flags QGroupStatusFlags `bin:"off=16, siz=8"` RescanProgress btrfsvol.LogicalAddr `bin:"off=24, siz=8"` binstruct.End `bin:"off=32"` }
A QGroupStatus holds the qgroup state of a subvolume (I think that implies that the QGroupStatus goes in the subvolume tree that it is describing?).
Key:
key.objectid = 0 key.offset = 0
func (QGroupStatus) Clone ¶
func (o QGroupStatus) Clone() QGroupStatus
func (*QGroupStatus) CloneItem ¶
func (o *QGroupStatus) CloneItem() Item
func (*QGroupStatus) Free ¶
func (o *QGroupStatus) Free()
type QGroupStatusFlags ¶
type QGroupStatusFlags uint64
const ( QGroupStatusFlagOn QGroupStatusFlags = 1 << iota QGroupStatusFlagRescan QGroupStatusFlagInconsistent )
func (QGroupStatusFlags) Has ¶
func (f QGroupStatusFlags) Has(req QGroupStatusFlags) bool
func (QGroupStatusFlags) String ¶
func (f QGroupStatusFlags) String() string
type Root ¶
type Root struct { Inode Inode `bin:"off=0x000, siz=0xa0"` // ??? Generation btrfsprim.Generation `bin:"off=0x0a0, siz=0x08"` RootDirID btrfsprim.ObjID `bin:"off=0x0a8, siz=0x08"` // inode number of the root inode ByteNr btrfsvol.LogicalAddr `bin:"off=0x0b0, siz=0x08"` // root node ByteLimit int64 `bin:"off=0x0b8, siz=0x08"` // always 0 (unused) BytesUsed int64 `bin:"off=0x0c0, siz=0x08"` LastSnapshot int64 `bin:"off=0x0c8, siz=0x08"` Flags RootFlags `bin:"off=0x0d0, siz=0x08"` Refs int32 `bin:"off=0x0d8, siz=0x04"` DropProgress btrfsprim.Key `bin:"off=0x0dc, siz=0x11"` DropLevel uint8 `bin:"off=0x0ed, siz=0x01"` Level uint8 `bin:"off=0x0ee, siz=0x01"` GenerationV2 btrfsprim.Generation `bin:"off=0x0ef, siz=0x08"` UUID btrfsprim.UUID `bin:"off=0x0f7, siz=0x10"` ParentUUID btrfsprim.UUID `bin:"off=0x107, siz=0x10"` ReceivedUUID btrfsprim.UUID `bin:"off=0x117, siz=0x10"` CTransID int64 `bin:"off=0x127, siz=0x08"` OTransID int64 `bin:"off=0x12f, siz=0x08"` STransID int64 `bin:"off=0x137, siz=0x08"` RTransID int64 `bin:"off=0x13f, siz=0x08"` CTime btrfsprim.Time `bin:"off=0x147, siz=0x0c"` OTime btrfsprim.Time `bin:"off=0x153, siz=0x0c"` STime btrfsprim.Time `bin:"off=0x15f, siz=0x0c"` RTime btrfsprim.Time `bin:"off=0x16b, siz=0x0c"` GlobalTreeID btrfsprim.ObjID `bin:"off=0x177, siz=0x08"` // ??? Reserved [7]int64 `bin:"off=0x17f, siz=0x38"` binstruct.End `bin:"off=0x1b7"` }
A Root goes in the ROOT_TREE and defines one of the other trees in the filesystem. All trees have a Root item describing them, except for the ROOT_TREE, CHUNK_TREE, TREE_LOG, and BLOCK_GROUP_TREE, which are defined directly in the superblock.
Key:
key.objectid = tree ID key.offset = one of: - 0 if objectid is one of the BTRFS_*_TREE_OBJECTID defines or a non-snapshot volume; or - transaction_id of when this snapshot was created
This tree might contain nodes with node.Head.Owner set to the root.ParentUUID tree, *if* the node.Head.Generation is less-than-or-equal-to the root's key.offset. The "or-equal-to" part of that might be surprising, which is why I called it out.
type RootRef ¶
type RootRef struct { DirID btrfsprim.ObjID `bin:"off=0x00, siz=0x8"` // inode of the parent directory of the dir entry Sequence int64 `bin:"off=0x08, siz=0x8"` // index of that dir entry within the parent NameLen uint16 `bin:"off=0x10, siz=0x2"` // [ignored-when-writing] binstruct.End `bin:"off=0x12"` Name []byte `bin:"-"` }
A RootRef links subvolumes parent→child for normal subvolumes and base→snapshot for snapshot subvolumes. BACKREF items go the other direction; child→parent and snapshot→base.
Key:
ROOT_REF | ROOT_BACKREF key.objectid = ID of the parent subvolume | ID of the child subvolume key.offset = ID of the child subvolume | ID of the parent subvolume
type SharedDataRef ¶
type SharedDataRef struct {}
SharedDataRef is part of an Extent.
Key:
key.objectid = laddr of the extent being referenced key.offset = laddr of the leaf node containing the FileExtent (EXTENT_DATA_KEY) for this reference.
func (SharedDataRef) Clone ¶
func (o SharedDataRef) Clone() SharedDataRef
func (*SharedDataRef) CloneItem ¶
func (o *SharedDataRef) CloneItem() Item
func (*SharedDataRef) Free ¶
func (o *SharedDataRef) Free()
type StatMode ¶
type StatMode uint32
const ( ModeFmt StatMode = 0o17_0000 // mask for the type bits ModeFmtNamedPipe StatMode = 0o01_0000 // type: named pipe (FIFO) ModeFmtCharDevice StatMode = 0o02_0000 // type: character device ModeFmtDir StatMode = 0o04_0000 // type: directory ModeFmtBlockDevice StatMode = 0o06_0000 // type: block device ModeFmtRegular StatMode = 0o10_0000 // type: regular file ModeFmtSymlink StatMode = 0o12_0000 // type: symbolic link ModeFmtSocket StatMode = 0o14_0000 // type: socket file ModePerm StatMode = 0o00_7777 // mask for permission bits ModePermSetUID StatMode = 0o00_4000 // permission: set user id ModePermSetGID StatMode = 0o00_2000 // permission: set group ID ModePermSticky StatMode = 0o00_1000 // permission: sticky bit ModePermUsrR StatMode = 0o00_0400 // permission: user: read ModePermUsrW StatMode = 0o00_0200 // permission: user: write ModePermUsrX StatMode = 0o00_0100 // permission: user: execute ModePermGrpR StatMode = 0o00_0040 // permission: group: read ModePermGrpW StatMode = 0o00_0020 // permission: group: write ModePermGrpX StatMode = 0o00_0010 // permission: group: execute ModePermOthR StatMode = 0o00_0004 // permission: other: read ModePermOthW StatMode = 0o00_0002 // permission: other: write ModePermOthX StatMode = 0o00_0001 // permission: other: execute )
func (StatMode) IsDir ¶
IsDir reports whether mode describes a directory.
That is, it tests that the ModeFmt bits are set to ModeFmtDir.
func (StatMode) IsRegular ¶
IsRegular reports whether m describes a regular file.
That is, it tests that the ModeFmt bits are set to ModeFmtRegular.
func (StatMode) String ¶
String returns a textual representation of the mode.
This is the format that POSIX specifies for showing the mode in the output of the `ls -l` command. POSIX does not specify the character to use to indicate a ModeFmtSocket file; this method uses 's' (GNU `ls` behavior; though POSIX notes that many implementations use '=' for sockets).
type TreeBlockInfo ¶
type UUIDMap ¶
A UUIDMap item goes in the UUID_TREE and maps from a UUID to a btrfsprim.ObjID.
The Key for this item is a UUID, and the item is a subvolume ID that UUID maps to.
Key:
key.objectid = first half of UUID key.offset = second half of UUID
Source Files
¶
- item_blockgroup.go
- item_chunk.go
- item_dev.go
- item_devextent.go
- item_dir.go
- item_empty.go
- item_extent.go
- item_extentcsum.go
- item_extentdataref.go
- item_fileextent.go
- item_freespacebitmap.go
- item_freespaceinfo.go
- item_inode.go
- item_inoderef.go
- item_metadata.go
- item_persistent.go
- item_qgroupinfo.go
- item_qgrouplimit.go
- item_qgroupstatus.go
- item_root.go
- item_rootref.go
- item_shareddataref.go
- item_untyped.go
- item_uuid.go
- items.go
- items_gen.go
- statmode.go