Documentation ¶
Index ¶
- Constants
- Variables
- func KF(args ...uint64) (k btrfs.Key)
- func KL(args ...uint64) btrfs.Key
- func NameHash(name string) uint32
- func NewIndexKeyFromV1(ik keyV1) keyV2
- type FullRange
- type Index
- func (ix *Index) Chunks() (Range, btrfs.Chunk)
- func (ix *Index) Close()
- func (ix *Index) Commit() error
- func (ix *Index) DevItems() (Range, btrfs.DevItem)
- func (ix *Index) DirItems(owner, id uint64) (Range, btrfs.DirItem)
- func (ix *Index) FileExtentItems(owner, id uint64) (Range, btrfs.FileExtentItem)
- func (ix *Index) FindDirItemForPath(owner uint64, path string) btrfs.DirItem
- func (ix *Index) FindExtentItem(diskByteNr, diskNumBytes uint64) btrfs.ExtentItem
- func (ix *Index) FindFileExtentItem(owner uint64, id uint64) btrfs.FileExtentItem
- func (ix *Index) FindInodeItem(owner uint64, inode uint64) btrfs.InodeItem
- func (ix *Index) FindItem(owner uint64, k btrfs.Key) btrfs.Item
- func (ix *Index) FullRange() (FullRange, []byte)
- func (ix *Index) InsertItem(k btrfs.Key, h btrfs.Header, item, data []byte) error
- func (ix *Index) Metadata() indexMetadata
- func (ix *Index) Physical(logical uint64) (devID uint64, offset uint64)
- func (ix *Index) Range(owner uint64, first, last btrfs.Key) (Range, []byte)
- func (ix *Index) RangeAll(owner uint64, t uint8, id uint64) (Range, []byte)
- func (ix *Index) RawTx(fn func(db *bbolt.DB, tx *bbolt.Tx, bucket *bbolt.Bucket) error) error
- func (ix *Index) Subvolumes() (Range, btrfs.RootItem)
- func (ix *Index) XAttrItems(owner, id uint64) (Range, btrfs.DirItem)
- type KeyV1
- type KeyV2
- type Options
- type Range
Constants ¶
const ( // Index metadata version. Set to ISO date (decimal) whenever there are // incompatible changes. MetadataVersion = 20190809 // V2: Put generation first (descending) in key MetadataVersionUpgradable = 20161109 // V1: Orignal format using Boltdb )
Variables ¶
var MetadataKey = metadataKey
Functions ¶
func KF ¶
KF returns a new key useful for searching an index. To enable more natural queries, the order of the arguments is different from the one in the Key struct: Type, ObjectID, Offset.
func NameHash ¶
NameHash computes the CRC32C value of an FS object name. The initial CRC in BTRFS is ^uint32(1) and the end result is _not_ inverted.
func NewIndexKeyFromV1 ¶
func NewIndexKeyFromV1(ik keyV1) keyV2
Types ¶
type Index ¶
type Index struct { Generation uint64 // contains filtered or unexported fields }
Index encapsulates metadata of a BTRFS to be recovered/analyzed. It uses a memory-mapped key-value store to quickly access FS objects. When opened read/write, concurrent access to this object must be guarded.
func OpenReadOnly ¶
OpenReadOnly opens a metadata index for reading/querying.
func (*Index) Close ¶
func (ix *Index) Close()
Close closes the index and its underlying bbolt database.
func (*Index) FileExtentItems ¶
func (ix *Index) FileExtentItems(owner, id uint64) (Range, btrfs.FileExtentItem)
func (*Index) FindDirItemForPath ¶
FindDirItemForPath finds the DirItem for a given FS path. It assumes that the path is clean, as returned by path.Clean().
func (*Index) FindExtentItem ¶
func (ix *Index) FindExtentItem(diskByteNr, diskNumBytes uint64) btrfs.ExtentItem
func (*Index) FindFileExtentItem ¶
func (ix *Index) FindFileExtentItem(owner uint64, id uint64) btrfs.FileExtentItem
func (*Index) FindInodeItem ¶
func (*Index) FindItem ¶
FindItem searches for an FS key at the latest generation smaller or equal to the current index generation. If the index generation is smaller than any existing generation, the data at the earliest generatation is returned.
func (*Index) FullRange ¶
FullRange returns an index range for all items in the index regardless of generation. This is mainly useful for debugging.
func (*Index) InsertItem ¶
InsertItem inserts a filesystem item into the index, referenceable by its BTRFS key. Also stores the item's owner and generation number, as well as its inline data.
func (*Index) Physical ¶
Physical maps a filesystem logical address to a physical, on-disk address. Note: No attempt is made to deal with "holes", missing chunk entries, or logical addresses not mapping to any chunk.
func (*Index) RawTx ¶
RawTx executes a transaction function on underlying BoltDB database. This is an advanced feature that should not be called in regular operation. It is used by the upgrade-index sub-command, for example, to upgrade legacy metadata indices. This function requires that the index was opened read-write. It behaves similar to bbolt.Update() otherwise.
func (*Index) Subvolumes ¶
Subvolumes returns an index range containing all of the subvolumes. Note that this excludes the FS tree root itself, which is not considered to be a subvolume. To access the FS tree root, use
Find(KF(RootItemKey, FSTreeObjectID))
type Options ¶
type Options struct { ReadOnly bool BlockSize uint FSID uuid.UUID Generation uint64 AllowOldVersion bool }
Options sets options for opening a metadata index.
type Range ¶
type Range struct {
// contains filtered or unexported fields
}
Range encapsulates a generic index range. Internally, it holds a cursor of the underlying key-value store as well as the current position and the end of range marker.