btrfs

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: 19 Imported by: 0

Documentation

Overview

Package btrfs (and its sub-packages) are the core implementation of the btrfs filesystem.

Index

Constants

This section is empty.

Variables

View Source
var SuperblockAddrs = []btrfsvol.PhysicalAddr{
	0x00_0001_0000,
	0x00_0400_0000,
	0x40_0000_0000,
}

Functions

func ChecksumLogical

func ChecksumPhysical

func ChecksumPhysical(dev *Device, alg btrfssum.CSumType, paddr btrfsvol.PhysicalAddr) (btrfssum.CSum, error)

func ChecksumQualifiedPhysical

func ChecksumQualifiedPhysical(fs *FS, alg btrfssum.CSumType, paddr btrfsvol.QualifiedPhysicalAddr) (btrfssum.CSum, error)

func LookupCSum

Types

type BareInode

type BareInode struct {
	Inode     btrfsprim.ObjID
	InodeItem *btrfsitem.Inode
	Errs      derror.MultiError
}

type Device

type Device struct {
	diskio.File[btrfsvol.PhysicalAddr]
	// contains filtered or unexported fields
}

func (*Device) Superblock

func (dev *Device) Superblock() (*btrfstree.Superblock, error)

func (*Device) Superblocks

func (dev *Device) Superblocks() ([]*diskio.Ref[btrfsvol.PhysicalAddr, btrfstree.Superblock], error)

type Dir

type Dir struct {
	FullInode
	DotDot          *InodeRef
	ChildrenByName  map[string]btrfsitem.DirEntry
	ChildrenByIndex map[uint64]btrfsitem.DirEntry
	SV              *Subvolume
}

func (*Dir) AbsPath

func (dir *Dir) AbsPath() (string, error)

type FS

type FS struct {
	// You should probably not access .LV directly, except when
	// implementing special things like fsck.
	LV btrfsvol.LogicalVolume[*Device]
	// contains filtered or unexported fields
}

func (*FS) AcquireNode

func (fs *FS) AcquireNode(ctx context.Context, addr btrfsvol.LogicalAddr, exp btrfstree.NodeExpectations) (*btrfstree.Node, error)

AcquireNode implements btrfstree.NodeSource.

func (*FS) AddDevice

func (fs *FS) AddDevice(ctx context.Context, dev *Device) error

func (*FS) Close

func (fs *FS) Close() error

func (*FS) ForrestLookup

func (fs *FS) ForrestLookup(ctx context.Context, treeID btrfsprim.ObjID) (btrfstree.Tree, error)

ForrestLookup implements btree.Forrest.

func (*FS) Name

func (fs *FS) Name() string

func (*FS) RawTree

func (fs *FS) RawTree(ctx context.Context, treeID btrfsprim.ObjID) (*btrfstree.RawTree, error)

RawTree is a variant of ForrestLookup that returns a concrete type instead of an interface.

func (*FS) ReInit

func (fs *FS) ReInit(ctx context.Context) error

func (*FS) ReadAt

func (fs *FS) ReadAt(p []byte, off btrfsvol.LogicalAddr) (int, error)

func (*FS) ReleaseNode

func (fs *FS) ReleaseNode(node *btrfstree.Node)

ReleaseNode implements btrfstree.NodeSource.

func (*FS) Size

func (fs *FS) Size() btrfsvol.LogicalAddr

func (*FS) Superblock

func (fs *FS) Superblock() (*btrfstree.Superblock, error)

func (*FS) Superblocks

func (fs *FS) Superblocks() ([]*diskio.Ref[btrfsvol.PhysicalAddr, btrfstree.Superblock], error)

func (*FS) WriteAt

func (fs *FS) WriteAt(p []byte, off btrfsvol.LogicalAddr) (int, error)

type File

type File struct {
	FullInode
	Extents []FileExtent
	SV      *Subvolume
}

func (*File) ReadAt

func (file *File) ReadAt(dat []byte, off int64) (int, error)

type FileExtent

type FileExtent struct {
	OffsetWithinFile int64
	btrfsitem.FileExtent
}

type FullInode

type FullInode struct {
	BareInode
	XAttrs     map[string]string
	OtherItems []btrfstree.Item
}

type InodeRef

type InodeRef struct {
	Inode btrfsprim.ObjID
	btrfsitem.InodeRef
}

type ReadableFS

type ReadableFS interface {
	Name() string

	// For reading btrees.
	btrfstree.Forrest

	// For reading the superblock and raw nodes.
	btrfstree.NodeSource

	// For reading file contents.
	diskio.ReaderAt[btrfsvol.LogicalAddr]
}

type Subvolume

type Subvolume struct {
	TreeID btrfsprim.ObjID
	// contains filtered or unexported fields
}

func NewSubvolume

func NewSubvolume(
	ctx context.Context,
	fs ReadableFS,
	treeID btrfsprim.ObjID,
	noChecksums bool,
) *Subvolume

func (*Subvolume) AcquireBareInode

func (sv *Subvolume) AcquireBareInode(inode btrfsprim.ObjID) (*BareInode, error)

func (*Subvolume) AcquireDir

func (sv *Subvolume) AcquireDir(inode btrfsprim.ObjID) (*Dir, error)

func (*Subvolume) AcquireFile

func (sv *Subvolume) AcquireFile(inode btrfsprim.ObjID) (*File, error)

func (*Subvolume) AcquireFullInode

func (sv *Subvolume) AcquireFullInode(inode btrfsprim.ObjID) (*FullInode, error)

func (*Subvolume) GetRootInode

func (sv *Subvolume) GetRootInode() (btrfsprim.ObjID, error)

func (*Subvolume) NewChildSubvolume

func (sv *Subvolume) NewChildSubvolume(childID btrfsprim.ObjID) *Subvolume

func (*Subvolume) ReleaseBareInode

func (sv *Subvolume) ReleaseBareInode(inode btrfsprim.ObjID)

func (*Subvolume) ReleaseDir

func (sv *Subvolume) ReleaseDir(inode btrfsprim.ObjID)

func (*Subvolume) ReleaseFile

func (sv *Subvolume) ReleaseFile(inode btrfsprim.ObjID)

func (*Subvolume) ReleaseFullInode

func (sv *Subvolume) ReleaseFullInode(inode btrfsprim.ObjID)

Directories

Path Synopsis
Package btrfsitem contains the definitions of all "items" that may be stored in a btrfs tree.
Package btrfsitem contains the definitions of all "items" that may be stored in a btrfs tree.
Package btrfsprim contains primitive btrfs datatypes, that all other btrfs sub-packages may make use of.
Package btrfsprim contains primitive btrfs datatypes, that all other btrfs sub-packages may make use of.
Package btrfssum contains the checksum types and algorithms that btrfs uses.
Package btrfssum contains the checksum types and algorithms that btrfs uses.
Package btrfstree contains core b+-tree implementation and interfaces.
Package btrfstree contains core b+-tree implementation and interfaces.
Package btrfsvol contains core logical-volume-management layer of btrfs.
Package btrfsvol contains core logical-volume-management layer of btrfs.

Jump to

Keyboard shortcuts

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