btrfs

package module
v0.0.0-...-12ae127 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2024 License: Apache-2.0 Imports: 17 Imported by: 9

README

btrfs

Btrfs library in a pure Go

Documentation

Index

Constants

View Source
const (
	FeatureIncompatMixedBackRef  = IncompatFeatures(1 << 0)
	FeatureIncompatDefaultSubvol = IncompatFeatures(1 << 1)
	FeatureIncompatMixedGroups   = IncompatFeatures(1 << 2)
	FeatureIncompatCompressLZO   = IncompatFeatures(1 << 3)

	// Some patches floated around with a second compression method
	// lets save that incompat here for when they do get in.
	// Note we don't actually support it, we're just reserving the number.
	FeatureIncompatCompressLZOv2 = IncompatFeatures(1 << 4)

	// Older kernels tried to do bigger metadata blocks, but the
	// code was pretty buggy. Lets not let them try anymore.
	FeatureIncompatBigMetadata = IncompatFeatures(1 << 5)

	FeatureIncompatExtendedIRef   = IncompatFeatures(1 << 6)
	FeatureIncompatRAID56         = IncompatFeatures(1 << 7)
	FeatureIncompatSkinnyMetadata = IncompatFeatures(1 << 8)
	FeatureIncompatNoHoles        = IncompatFeatures(1 << 9)
)
View Source
const (
	BalanceData     = BalanceFlags(1 << 0)
	BalanceSystem   = BalanceFlags(1 << 1)
	BalanceMetadata = BalanceFlags(1 << 2)

	BalanceMask = (BalanceData | BalanceSystem | BalanceMetadata)

	BalanceForce  = BalanceFlags(1 << 3)
	BalanceResume = BalanceFlags(1 << 4)
)

Restriper's general type filter.

View Source
const (
	ErrDevRAID1MinNotMet = ErrCode(iota + 1)
	ErrDevRAID10MinNotMet
	ErrDevRAID5MinNotMet
	ErrDevRAID6MinNotMet
	ErrDevTargetReplace
	ErrDevMissingNotFound
	ErrDevOnlyWritable
	ErrDevExclRunInProgress
)
View Source
const (
	FSIDSize = 16
	UUIDSize = 16
)
View Source
const (
	SubvolRootReadOnly = SubvolFlags(1 << 0) // BTRFS_ROOT_SUBVOL_RDONLY, only present in search result copies
	SubvolReadOnly     = SubvolFlags(1 << 1) // BTRFS_SUBVOL_RDONLY

)

flags for subvolumes

Used by: struct btrfs_ioctl_vol_args_v2.flags

BTRFS_SUBVOL_RDONLY is also provided/consumed by the following ioctls: - BTRFS_IOC_SUBVOL_GETFLAGS - BTRFS_IOC_SUBVOL_SETFLAGS

View Source
const (
	CompressionNone = Compression("")
	LZO             = Compression("lzo")
	ZLIB            = Compression("zlib")
)
View Source
const (
	FeatureCompatROFreeSpaceTree = FeatureFlags(1 << 0)
)
View Source
const SuperMagic uint32 = 0x9123683E

Variables

View Source
var (
	ErrNotFound = errors.New("not found")
)

Functions

func CloneFile

func CloneFile(dst, src *os.File) error

func CreateSubVolume

func CreateSubVolume(path string) error

func DeleteSubVolume

func DeleteSubVolume(path string) error

func IsReadOnly

func IsReadOnly(path string) (bool, error)

func IsSubVolume

func IsSubVolume(path string) (bool, error)

func Receive

func Receive(r io.Reader, dstDir string) error

func Send

func Send(w io.Writer, parent string, subvols ...string) error

func SetCompression

func SetCompression(path string, v Compression) error

func SnapshotSubVolume

func SnapshotSubVolume(subvol, dst string, ro bool) error

Types

type BalanceFlags

type BalanceFlags uint64

Flags definition for balance.

type BalanceProgress

type BalanceProgress struct {
	Expected   uint64 // estimated # of chunks that will be relocated to fulfill the request
	Considered uint64 // # of chunks we have considered so far
	Completed  uint64 // # of chunks relocated so far
}

Report balance progress to userspace.

btrfs_balance_progress

type BalanceState

type BalanceState uint64
const (
	BalanceStateRunning   BalanceState = (1 << 0)
	BalanceStatePauseReq  BalanceState = (1 << 1)
	BalanceStateCancelReq BalanceState = (1 << 2)
)

type Compression

type Compression string

func GetCompression

func GetCompression(path string) (Compression, error)

type DevInfo

type DevInfo struct {
	UUID       UUID
	BytesUsed  uint64
	TotalBytes uint64
	Path       string
}

type DevStats

type DevStats struct {
	WriteErrs uint64
	ReadErrs  uint64
	FlushErrs uint64
	// Checksum error, bytenr error or contents is illegal: this is an
	// indication that the block was damaged during read or write, or written to
	// wrong location or read from wrong location.
	CorruptionErrs uint64
	// An indication that blocks have not been written.
	GenerationErrs uint64
	Unknown        []uint64
}

type ErrCode

type ErrCode int

Error codes as returned by the kernel

func (ErrCode) Error

func (e ErrCode) Error() string

type ErrNotBtrfs

type ErrNotBtrfs struct {
	Path string
}

func (ErrNotBtrfs) Error

func (e ErrNotBtrfs) Error() string

type FS

type FS struct {
	// contains filtered or unexported fields
}

func Open

func Open(path string, ro bool) (*FS, error)

func (*FS) Balance

func (f *FS) Balance(flags BalanceFlags) (BalanceProgress, error)

func (*FS) Close

func (f *FS) Close() error

func (*FS) CreateSubVolume

func (f *FS) CreateSubVolume(name string) error

func (*FS) DeleteSubVolume

func (f *FS) DeleteSubVolume(name string) error

func (*FS) GetDevInfo

func (f *FS) GetDevInfo(id uint64) (out DevInfo, err error)

func (*FS) GetDevStats

func (f *FS) GetDevStats(id uint64) (out DevStats, err error)

func (*FS) GetFeatures

func (f *FS) GetFeatures() (out FSFeatureFlags, err error)

func (*FS) GetFlags

func (f *FS) GetFlags() (SubvolFlags, error)

func (*FS) GetSupportedFeatures

func (f *FS) GetSupportedFeatures() (out FSFeatureFlags, err error)

func (*FS) Info

func (f *FS) Info() (out Info, err error)

func (*FS) ListSubvolumes

func (f *FS) ListSubvolumes(filter func(SubvolInfo) bool) ([]SubvolInfo, error)

func (*FS) Receive

func (f *FS) Receive(r io.Reader) error

func (*FS) ReceiveTo

func (f *FS) ReceiveTo(r io.Reader, mount string) error

func (*FS) Resize

func (f *FS) Resize(size int64) error

func (*FS) ResizeToMax

func (f *FS) ResizeToMax() error

func (*FS) Send

func (f *FS) Send(w io.Writer, parent string, subvols ...string) error

func (*FS) SetFlags

func (f *FS) SetFlags(flags SubvolFlags) error

func (*FS) Snapshot

func (f *FS) Snapshot(dst string, ro bool) error

func (*FS) SnapshotSubVolume

func (f *FS) SnapshotSubVolume(name string, dst string, ro bool) error

func (*FS) SubVolumeID

func (f *FS) SubVolumeID() (uint64, error)

func (*FS) SubvolumeByPath

func (f *FS) SubvolumeByPath(path string) (*SubvolInfo, error)

func (*FS) SubvolumeByReceivedUUID

func (f *FS) SubvolumeByReceivedUUID(uuid UUID) (*SubvolInfo, error)

func (*FS) SubvolumeByUUID

func (f *FS) SubvolumeByUUID(uuid UUID) (*SubvolInfo, error)

func (*FS) Sync

func (f *FS) Sync() (err error)

func (*FS) Usage

func (f *FS) Usage() (UsageInfo, error)

type FSFeatureFlags

type FSFeatureFlags struct {
	Compatible   FeatureFlags
	CompatibleRO FeatureFlags
	Incompatible IncompatFeatures
}

type FSID

type FSID [FSIDSize]byte

func (FSID) String

func (id FSID) String() string

type FeatureFlags

type FeatureFlags uint64

type IncompatFeatures

type IncompatFeatures uint64

func (IncompatFeatures) String

func (f IncompatFeatures) String() string

type Info

type Info struct {
	MaxID          uint64
	NumDevices     uint64
	FSID           FSID
	NodeSize       uint32
	SectorSize     uint32
	CloneAlignment uint32
}

type SubvolFlags

type SubvolFlags uint64

func GetFlags

func GetFlags(path string) (SubvolFlags, error)

func (SubvolFlags) ReadOnly

func (f SubvolFlags) ReadOnly() bool

func (SubvolFlags) String

func (f SubvolFlags) String() string

type SubvolInfo

type SubvolInfo struct {
	RootID uint64

	Flags SubvolFlags

	UUID         UUID
	ParentUUID   UUID
	ReceivedUUID UUID

	CTime time.Time
	OTime time.Time
	STime time.Time
	RTime time.Time

	CTransID uint64
	OTransID uint64
	STransID uint64
	RTransID uint64

	Path string
}

type UUID

type UUID [UUIDSize]byte

func (UUID) IsZero

func (id UUID) IsZero() bool

func (UUID) String

func (id UUID) String() string

type UsageInfo

type UsageInfo struct {
	Total       uint64
	TotalUnused uint64
	TotalUsed   uint64
	TotalChunks uint64

	FreeEstimated uint64
	FreeMin       uint64

	LogicalDataChunks uint64
	RawDataChunks     uint64
	RawDataUsed       uint64

	LogicalMetaChunks uint64
	RawMetaChunks     uint64
	RawMetaUsed       uint64

	SystemUsed   uint64
	SystemChunks uint64

	DataRatio     float64
	MetadataRatio float64

	GlobalReserve     uint64
	GlobalReserveUsed uint64
}

Directories

Path Synopsis
cmd
gbtrfs Module
internal
cmd
Package mtab contains tools to work with /etc/mtab file.
Package mtab contains tools to work with /etc/mtab file.

Jump to

Keyboard shortcuts

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