btrfsprim

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2023 License: Apache-2.0, GPL-2.0, GPL-3.0-or-later, + 1 more Imports: 9 Imported by: 0

Documentation

Overview

Package btrfsprim contains primitive btrfs datatypes, that all other btrfs sub-packages may make use of.

Index

Constants

View Source
const MaxOffset uint64 = math.MaxUint64

Variables

View Source
var MaxKey = Key{
	ObjectID: math.MaxUint64,
	ItemType: math.MaxUint8,
	Offset:   math.MaxUint64,
}

Functions

This section is empty.

Types

type Generation

type Generation uint64

type ItemType

type ItemType uint8
const (
	BLOCK_GROUP_ITEM_KEY     ItemType = 192
	CHUNK_ITEM_KEY           ItemType = 228
	DEV_EXTENT_KEY           ItemType = 204
	DEV_ITEM_KEY             ItemType = 216
	DIR_INDEX_KEY            ItemType = 96
	DIR_ITEM_KEY             ItemType = 84
	EXTENT_CSUM_KEY          ItemType = 128
	EXTENT_DATA_KEY          ItemType = 108
	EXTENT_DATA_REF_KEY      ItemType = 178
	EXTENT_ITEM_KEY          ItemType = 168
	FREE_SPACE_BITMAP_KEY    ItemType = 200
	FREE_SPACE_EXTENT_KEY    ItemType = 199
	FREE_SPACE_INFO_KEY      ItemType = 198
	INODE_ITEM_KEY           ItemType = 1
	INODE_REF_KEY            ItemType = 12
	METADATA_ITEM_KEY        ItemType = 169
	ORPHAN_ITEM_KEY          ItemType = 48
	PERSISTENT_ITEM_KEY      ItemType = 249
	QGROUP_INFO_KEY          ItemType = 242
	QGROUP_LIMIT_KEY         ItemType = 244
	QGROUP_RELATION_KEY      ItemType = 246
	QGROUP_STATUS_KEY        ItemType = 240
	ROOT_BACKREF_KEY         ItemType = 144
	ROOT_ITEM_KEY            ItemType = 132
	ROOT_REF_KEY             ItemType = 156
	SHARED_BLOCK_REF_KEY     ItemType = 182
	SHARED_DATA_REF_KEY      ItemType = 184
	TREE_BLOCK_REF_KEY       ItemType = 176
	UNTYPED_KEY              ItemType = 0
	UUID_RECEIVED_SUBVOL_KEY ItemType = 252
	UUID_SUBVOL_KEY          ItemType = 251
	XATTR_ITEM_KEY           ItemType = 24

	MAX_KEY ItemType = math.MaxUint8
)

func (ItemType) String

func (t ItemType) String() string

type Key

type Key struct {
	ObjectID      ObjID    `bin:"off=0x0, siz=0x8"` // Each tree has its own set of Object IDs.
	ItemType      ItemType `bin:"off=0x8, siz=0x1"`
	Offset        uint64   `bin:"off=0x9, siz=0x8"` // The meaning depends on the item type.
	binstruct.End `bin:"off=0x11"`
}

func (Key) Compare

func (a Key) Compare(b Key) int

func (Key) Format

func (key Key) Format(tree ObjID) string

Format returns a human-friendly string representation of the Key, according to which tree it appears in.

The formatting of the key mimics print-tree.c:btrfs_print_key().

func (Key) Mm

func (key Key) Mm() Key

func (Key) Pp

func (key Key) Pp() Key

func (Key) String

func (key Key) String() string

type ObjID

type ObjID uint64
const (
	// The IDs of the various trees
	ROOT_TREE_OBJECTID        ObjID = 1 // holds pointers to all of the tree roots
	EXTENT_TREE_OBJECTID      ObjID = 2 // stores information about which extents are in use, and reference counts
	CHUNK_TREE_OBJECTID       ObjID = 3 // chunk tree stores translations from logical -> physical block numbering
	DEV_TREE_OBJECTID         ObjID = 4 // stores info about which areas of a given device are in use; one per device
	FS_TREE_OBJECTID          ObjID = 5 // one per subvolume, storing files and directories
	ROOT_TREE_DIR_OBJECTID    ObjID = 6 // directory objectid inside the root tree
	CSUM_TREE_OBJECTID        ObjID = 7 // holds checksums of all the data extents
	QUOTA_TREE_OBJECTID       ObjID = 8
	UUID_TREE_OBJECTID        ObjID = 9  // for storing items that use the UUID_*_KEY
	FREE_SPACE_TREE_OBJECTID  ObjID = 10 // tracks free space in block groups.
	BLOCK_GROUP_TREE_OBJECTID ObjID = 11 // hold the block group items.

	// Objects in the DEV_TREE
	DEV_STATS_OBJECTID ObjID = 0 // device stats in the device tree

	// ???
	BALANCE_OBJECTID         ObjID = maxUint64pp - 4 // for storing balance parameters in the root tree
	ORPHAN_OBJECTID          ObjID = maxUint64pp - 5 // orphan objectid for tracking unlinked/truncated files
	TREE_LOG_OBJECTID        ObjID = maxUint64pp - 6 // does write ahead logging to speed up fsyncs
	TREE_LOG_FIXUP_OBJECTID  ObjID = maxUint64pp - 7
	TREE_RELOC_OBJECTID      ObjID = maxUint64pp - 8 // space balancing
	DATA_RELOC_TREE_OBJECTID ObjID = maxUint64pp - 9
	EXTENT_CSUM_OBJECTID     ObjID = maxUint64pp - 10 // extent checksums all have this objectid
	FREE_SPACE_OBJECTID      ObjID = maxUint64pp - 11 // For storing free space cache
	FREE_INO_OBJECTID        ObjID = maxUint64pp - 12 // stores the inode number for the free-ino cache

	MULTIPLE_OBJECTIDS ObjID = maxUint64pp - 255 // dummy objectid represents multiple objectids

	// All files have objectids in this range.
	FIRST_FREE_OBJECTID ObjID = 256
	LAST_FREE_OBJECTID  ObjID = maxUint64pp - 256

	// Objects in the CHUNK_TREE
	DEV_ITEMS_OBJECTID        ObjID = 1
	FIRST_CHUNK_TREE_OBJECTID ObjID = 256

	// ???
	EMPTY_SUBVOL_DIR_OBJECTID ObjID = 2

	MAX_OBJECTID ObjID = math.MaxUint64
)

func (ObjID) Format

func (id ObjID) Format(tree ObjID) string

func (ObjID) String

func (id ObjID) String() string

type Time

type Time struct {
	Sec           int64  `bin:"off=0x0, siz=0x8"` // Number of seconds since 1970-01-01T00:00:00Z.
	NSec          uint32 `bin:"off=0x8, siz=0x4"` // Number of nanoseconds since the beginning of the second.
	binstruct.End `bin:"off=0xc"`
}

func (Time) ToStd

func (t Time) ToStd() time.Time

type UUID

type UUID [16]byte

func MustParseUUID

func MustParseUUID(str string) UUID

func ParseUUID

func ParseUUID(str string) (UUID, error)

func (UUID) Compare

func (a UUID) Compare(b UUID) int

func (UUID) Format

func (uuid UUID) Format(f fmt.State, verb rune)

func (UUID) MarshalText

func (uuid UUID) MarshalText() ([]byte, error)

func (UUID) String

func (uuid UUID) String() string

func (*UUID) UnmarshalText

func (uuid *UUID) UnmarshalText(text []byte) error

Jump to

Keyboard shortcuts

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