btrfs

package
v3.0.0-rc67 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package btrfs reads what the btrfs commands say of the subvolumes of a filesystem.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListArgs

func ListArgs(readOnly bool, path string) []string

ListArgs are the arguments of the list command ParseList reads the output of: the subvolumes with their creation generation, uuids and paths, the read-only ones alone when readOnly.

func MountOfSubvol

func MountOfSubvol(b []byte, path string, below bool) (string, bool)

MountOfSubvol returns the mount point of the subvolume at path, or of a subvolume below it, from the content of a /proc/self/mountinfo.

A mount of a btrfs subvolume has the path of the subvolume as its root. The filesystem it is of is not told apart: a subvolume of another btrfs at the same path is taken for this one, which a caller checking a subvolume is not mounted before replacing it errs on the safe side with.

Types

type Location

type Location struct {
	Label  string
	Subvol string
}

Location is a subvolume of the btrfs filesystem of a label, as the sync keywords name it: <label>:<subvol>.

The label names the filesystem on every node: its device may change from a node to another, its label does not. The subvolume is the path from the root of the filesystem, the one an fs.btrfs resource mounts with the subvol=<subvol> mount option.

func ParseLocation

func ParseLocation(s string) (Location, error)

ParseLocation reads a <label>:<subvol> value. The subvolume is not the root of the filesystem.

func (Location) String

func (t Location) String() string

type Subvol

type Subvol struct {
	ID int64

	// CGen is the generation the subvolume was created at. It orders
	// the subvolumes of a filesystem by creation, a received one by the
	// time it was received.
	CGen int64

	// Path is relative to the root of the filesystem when listed on a
	// mount of its root, subvolid=5.
	Path string

	UUID         string
	ParentUUID   string
	ReceivedUUID string
}

Subvol is a subvolume, as "btrfs subvolume list -c -u -q -R" lists it.

func ParseList

func ParseList(b []byte) ([]Subvol, error)

ParseList reads the output of "btrfs subvolume list -c -u -q -R", a line per subvolume:

ID 257 gen 8 cgen 8 top level 5 parent_uuid <u> received_uuid <u> uuid <u> path <path>

The path is the end of the line, spaces included.

func Under

func Under(l []Subvol, path string) []Subvol

Under returns the subvolumes of l whose path is path or below it.

func (Subvol) Identity

func (t Subvol) Identity() string

Identity is the identifier of the snapshot that is the same on both ends of a send: the uuid of the snapshot sent is the received uuid of its copy.

A copy sent on to another node keeps the identity of the original, as a send names its parent by its received uuid when it has one, and a receive looks it up by received uuid then by uuid. So the snapshots two nodes hold in common are the ones with the same identity, whichever node was the source.

func (Subvol) IsReceived

func (t Subvol) IsReceived() bool

IsReceived reports whether the subvolume was made by a receive.

Jump to

Keyboard shortcuts

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