dmsetup

package
v0.0.0-...-a00c45c Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DevMapperDir represents devmapper devices location
	DevMapperDir = "/dev/mapper/"
	// SectorSize represents the number of bytes in one sector on devmapper devices
	SectorSize = 512
)

Variables

This section is empty.

Functions

func ActivateDevice

func ActivateDevice(poolName string, deviceName string, deviceID uint32, size uint64, external string) error

ActivateDevice activates the given thin-device using the 'thin' target

func BlockDeviceSize

func BlockDeviceSize(devicePath string) (uint64, error)

BlockDeviceSize returns size of block device in bytes

func CreateDevice

func CreateDevice(poolName string, deviceID uint32) error

CreateDevice sends "create_thin <deviceID>" message to the given thin-pool

func CreatePool

func CreatePool(poolName, dataFile, metaFile string, blockSizeSectors uint32) error

CreatePool creates a device with the given name, data and metadata file and block size (see "dmsetup create")

func CreateSnapshot

func CreateSnapshot(poolName string, deviceID uint32, baseDeviceID uint32) error

CreateSnapshot sends "create_snap" message to the given thin-pool. Caller needs to suspend and resume device if it is active.

func DeleteDevice

func DeleteDevice(poolName string, deviceID uint32) error

DeleteDevice sends "delete <deviceID>" message to the given thin-pool

func GetFullDevicePath

func GetFullDevicePath(deviceName string) string

GetFullDevicePath returns full path for the given device name (like "/dev/mapper/name")

func ReloadPool

func ReloadPool(deviceName, dataFile, metaFile string, blockSizeSectors uint32) error

ReloadPool reloads existing thin-pool (see "dmsetup reload")

func RemoveDevice

func RemoveDevice(deviceName string, opts ...RemoveDeviceOpt) error

RemoveDevice removes a device (see "dmsetup remove")

func ResumeDevice

func ResumeDevice(deviceName string) error

ResumeDevice resumes the given device (see "dmsetup resume")

func SuspendDevice

func SuspendDevice(deviceName string) error

SuspendDevice suspends the given device (see "dmsetup suspend")

func Table

func Table(deviceName string) (string, error)

Table returns the current table for the device

func Version

func Version() (string, error)

Version returns "dmsetup version" output

Types

type DeviceInfo

type DeviceInfo struct {
	Name            string
	BlockDeviceName string
	TableLive       bool
	TableInactive   bool
	Suspended       bool
	ReadOnly        bool
	Major           uint32
	Minor           uint32
	OpenCount       uint32 // Open reference count
	TargetCount     uint32 // Number of targets in the live table
	EventNumber     uint32 // Last event sequence number (used by wait)
}

DeviceInfo represents device info returned by "dmsetup info". dmsetup(8) provides more information on each of these fields.

func Info

func Info(deviceName string) ([]*DeviceInfo, error)

Info outputs device information (see "dmsetup info"). If device name is empty, all device infos will be returned.

type DeviceStatus

type DeviceStatus struct {
	Offset int64
	Length int64
	Target string
	Params []string
}

DeviceStatus represents devmapper device status information

func Status

func Status(deviceName string) (*DeviceStatus, error)

Status provides status information for devmapper device

type RemoveDeviceOpt

type RemoveDeviceOpt string

RemoveDeviceOpt represents command line arguments for "dmsetup remove" command

const (
	// RemoveWithForce flag replaces the table with one that fails all I/O if
	// open device can't be removed
	RemoveWithForce RemoveDeviceOpt = "--force"
	// RemoveWithRetries option will cause the operation to be retried
	// for a few seconds before failing
	RemoveWithRetries RemoveDeviceOpt = "--retry"
	// RemoveDeferred flag will enable deferred removal of open devices,
	// the device will be removed when the last user closes it
	RemoveDeferred RemoveDeviceOpt = "--deferred"
)

Jump to

Keyboard shortcuts

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