Documentation ¶
Index ¶
- Variables
- func All(Pool) bool
- func BindMount(src Volume, target string) error
- func FilesUsage(path string) (uint64, error)
- func GetMountTarget(device string) (string, bool)
- func IsMountPoint(path string) bool
- func Partprobe(ctx context.Context) error
- type Btrfs
- type BtrfsDevice
- type BtrfsDiskUsage
- type BtrfsQGroup
- type BtrfsUtil
- func (u *BtrfsUtil) DeviceAdd(ctx context.Context, dev string, root string) error
- func (u *BtrfsUtil) DeviceRemove(ctx context.Context, dev string, root string) error
- func (u *BtrfsUtil) GetDiskUsage(ctx context.Context, path string) (usage BtrfsDiskUsage, err error)
- func (u *BtrfsUtil) List(ctx context.Context, label string, mounted bool) ([]Btrfs, error)
- func (u *BtrfsUtil) QGroupDestroy(ctx context.Context, id, path string) error
- func (u *BtrfsUtil) QGroupEnable(ctx context.Context, root string) error
- func (u *BtrfsUtil) QGroupLimit(ctx context.Context, size uint64, path string) error
- func (u *BtrfsUtil) QGroupList(ctx context.Context, path string) (map[string]BtrfsQGroup, error)
- func (u *BtrfsUtil) SubvolumeAdd(ctx context.Context, root string) error
- func (u *BtrfsUtil) SubvolumeInfo(ctx context.Context, path string) (volume BtrfsVolume, err error)
- func (u *BtrfsUtil) SubvolumeList(ctx context.Context, root string) ([]BtrfsVolume, error)
- func (u *BtrfsUtil) SubvolumeRemove(ctx context.Context, root string) error
- type BtrfsVolume
- type DeviceInfo
- type DeviceManager
- type Devices
- type DiskUsage
- type FSType
- type Filter
- type Pool
- type Usage
- type Volume
Constants ¶
This section is empty.
Variables ¶
var ( // ErrDeviceAlreadyMounted indicates that a mounted device is attempted // to be mounted again (without MS_BIND flag). ErrDeviceAlreadyMounted = fmt.Errorf("device is already mounted") // ErrDeviceNotMounted is returned when an action is performed on a device // which requires the device to be mounted, while it is not. ErrDeviceNotMounted = fmt.Errorf("device is not mounted") )
Functions ¶
func BindMount ¶
BindMount remounts an existing directory in a given target using the mount syscall with the BIND flag set
func FilesUsage ¶
FilesUsage return the total size of files under path (recursively) in bytes
func GetMountTarget ¶
GetMountTarget returns the mount target of a device or false if the device is not mounted. panic, it panics if it can't read /proc/mounts
func IsMountPoint ¶
IsMountPoint checks if a path is a mount point
Types ¶
type Btrfs ¶
type Btrfs struct { Label string `json:"label"` UUID string `json:"uuid"` TotalDevices int `json:"total_devices"` Used int64 `json:"used"` Devices []BtrfsDevice `json:"devices"` Warnings string `json:"warnings"` }
Btrfs holds metadata of underlying btrfs filesystem
type BtrfsDevice ¶
type BtrfsDevice struct { Missing bool `json:"missing,omitempty"` DevID int `json:"dev_id"` Size int64 `json:"size"` Used int64 `json:"used"` Path string `json:"path"` }
BtrfsDevice holds metadata about a single device in a btrfs filesystem
type BtrfsDiskUsage ¶
type BtrfsDiskUsage struct { Data DiskUsage `json:"data"` System DiskUsage `json:"system"` Metadata DiskUsage `json:"metadata"` GlobalReserve DiskUsage `json:"globalreserve"` }
BtrfsDiskUsage is parsed information form btrfs fi df
type BtrfsQGroup ¶
BtrfsQGroup is parsed btrfs qgroup information
type BtrfsUtil ¶
type BtrfsUtil struct {
// contains filtered or unexported fields
}
BtrfsUtil utils for btrfs
func (*BtrfsUtil) DeviceRemove ¶
DeviceRemove removes a device from a btrfs pool
func (*BtrfsUtil) GetDiskUsage ¶
func (u *BtrfsUtil) GetDiskUsage(ctx context.Context, path string) (usage BtrfsDiskUsage, err error)
GetDiskUsage get btrfs usage
func (*BtrfsUtil) List ¶
List lists all availabel btrfs pools if label is provided, only get fs of that label, if mounted = True, only return mounted filesystems, otherwise any.
func (*BtrfsUtil) QGroupDestroy ¶
QGroupDestroy deletes a qgroup on a subvol
func (*BtrfsUtil) QGroupEnable ¶
QGroupEnable enable quota
func (*BtrfsUtil) QGroupLimit ¶
QGroupLimit limit size on subvol
func (*BtrfsUtil) QGroupList ¶
QGroupList list available qgroups
func (*BtrfsUtil) SubvolumeAdd ¶
SubvolumeAdd adds a new subvolume at path
func (*BtrfsUtil) SubvolumeInfo ¶
SubvolumeInfo get info of a subvolume giving its path
func (*BtrfsUtil) SubvolumeList ¶
SubvolumeList list direct subvolumes of this location
type BtrfsVolume ¶
BtrfsVolume holds metadata about a single subvolume
type DeviceInfo ¶ added in v0.5.5
type DeviceInfo struct { Path string `json:"path"` Label string `json:"label"` Size uint64 `json:"size"` Filesystem FSType `json:"fstype"` Rota bool `json:"rota"` Subsystems string `json:"subsystems"` Readtime uint64 `json:"-"` // contains filtered or unexported fields }
DeviceInfo contains information about the device
func (*DeviceInfo) Mountpoint ¶ added in v0.5.5
func (d *DeviceInfo) Mountpoint(ctx context.Context) (string, error)
func (*DeviceInfo) Name ¶ added in v0.5.5
func (i *DeviceInfo) Name() string
func (*DeviceInfo) Type ¶ added in v0.5.5
func (d *DeviceInfo) Type() zos.DeviceType
func (*DeviceInfo) Used ¶ added in v0.5.5
func (i *DeviceInfo) Used() bool
Used assumes that the device is used if it has custom label or fstype or children
type DeviceManager ¶
type DeviceManager interface { // Device returns the device at the specified path Device(ctx context.Context, device string) (DeviceInfo, error) // Devices finds all devices on a system Devices(ctx context.Context) (Devices, error) // ByLabel finds all devices with the specified label ByLabel(ctx context.Context, label string) (Devices, error) // Mountpoint returns mount point of a device Mountpoint(ctx context.Context, device string) (string, error) }
DeviceManager is able to list all/specific devices on a system
func DefaultDeviceManager ¶
func DefaultDeviceManager() DeviceManager
DefaultDeviceManager returns a default device manager implementation
type Devices ¶ added in v0.5.5
type Devices []DeviceInfo
Devices represents a list of cached in memory devices
type FSType ¶
type FSType string
FSType type of filesystem on device
const ( // BtrfsFSType btrfs filesystem type BtrfsFSType FSType = "btrfs" )
type Pool ¶
type Pool interface { Volume // Mounted returns whether the pool is mounted or not. If it is mounted, // the mountpoint is returned Mounted() (string, error) // Mount the pool, the mountpoint is returned Mount() (string, error) // UnMount the pool UnMount() error //AddDevice to the pool // RemoveDevice from the pool // Type of the physical storage in this pool Type() pkg.DeviceType // Reserved is reserved size of the devices in bytes Reserved() (uint64, error) // Volumes are all subvolumes of this volume Volumes() ([]Volume, error) // AddVolume adds a new subvolume with the given name AddVolume(name string) (Volume, error) // RemoveVolume removes a subvolume with the given name RemoveVolume(name string) error // Shutdown spins down the device where the pool is mounted Shutdown() error // Device return device associated with pool Device() DeviceInfo }
Pool represents a created filesystem
func NewBtrfsPool ¶ added in v0.5.5
func NewBtrfsPool(device DeviceInfo) (Pool, error)
NewBtrfsPool creates a btrfs pool associated with device. if device does not have a filesystem one is created
type Volume ¶
type Volume interface { // Volume ID ID() int // Path of the volume Path() string // Usage reports the current usage of the volume Usage() (Usage, error) // Limit the maximum size of the volume Limit(size uint64) error // Name of the volume Name() string // FsType of the volume FsType() string }
Volume represents a logical volume in the pool. Volumes can be nested