devicemapper

package
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: May 11, 2015 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BlkGetSize64 = C.BLKGETSIZE64
	BlkDiscard   = C.BLKDISCARD

	LoopSetFd       = C.LOOP_SET_FD
	LoopCtlGetFree  = C.LOOP_CTL_GET_FREE
	LoopGetStatus64 = C.LOOP_GET_STATUS64
	LoopSetStatus64 = C.LOOP_SET_STATUS64
	LoopClrFd       = C.LOOP_CLR_FD
	LoopSetCapacity = C.LOOP_SET_CAPACITY
)

IOCTL consts

View Source
const (
	LoFlagsAutoClear = C.LO_FLAGS_AUTOCLEAR
	LoFlagsReadOnly  = C.LO_FLAGS_READ_ONLY
	LoFlagsPartScan  = C.LO_FLAGS_PARTSCAN
	LoKeySize        = C.LO_KEY_SIZE
	LoNameSize       = C.LO_NAME_SIZE
)
View Source
const (
	DmUdevDisableSubsystemRulesFlag = C.DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG
	DmUdevDisableDiskRulesFlag      = C.DM_UDEV_DISABLE_DISK_RULES_FLAG
	DmUdevDisableOtherRulesFlag     = C.DM_UDEV_DISABLE_OTHER_RULES_FLAG
	DmUdevDisableLibraryFallback    = C.DM_UDEV_DISABLE_LIBRARY_FALLBACK
)
View Source
const (
	LogLevelFatal  = 2 + iota // _LOG_FATAL
	LogLevelErr               // _LOG_ERR
	LogLevelWarn              // _LOG_WARN
	LogLevelNotice            // _LOG_NOTICE
	LogLevelInfo              // _LOG_INFO
	LogLevelDebug             // _LOG_DEBUG
)

definitions from lvm2 lib/log/log.h

Variables

View Source
var (
	ErrTaskRun                = errors.New("dm_task_run failed")
	ErrTaskSetName            = errors.New("dm_task_set_name failed")
	ErrTaskSetMessage         = errors.New("dm_task_set_message failed")
	ErrTaskSetAddNode         = errors.New("dm_task_set_add_node failed")
	ErrTaskSetRo              = errors.New("dm_task_set_ro failed")
	ErrTaskAddTarget          = errors.New("dm_task_add_target failed")
	ErrTaskSetSector          = errors.New("dm_task_set_sector failed")
	ErrTaskGetDeps            = errors.New("dm_task_get_deps failed")
	ErrTaskGetInfo            = errors.New("dm_task_get_info failed")
	ErrTaskGetDriverVersion   = errors.New("dm_task_get_driver_version failed")
	ErrTaskSetCookie          = errors.New("dm_task_set_cookie failed")
	ErrNilCookie              = errors.New("cookie ptr can't be nil")
	ErrAttachLoopbackDevice   = errors.New("loopback mounting failed")
	ErrGetBlockSize           = errors.New("Can't get block size")
	ErrUdevWait               = errors.New("wait on udev cookie failed")
	ErrSetDevDir              = errors.New("dm_set_dev_dir failed")
	ErrGetLibraryVersion      = errors.New("dm_get_library_version failed")
	ErrCreateRemoveTask       = errors.New("Can't create task of type DeviceRemove")
	ErrRunRemoveDevice        = errors.New("running RemoveDevice failed")
	ErrInvalidAddNode         = errors.New("Invalid AddNode type")
	ErrGetLoopbackBackingFile = errors.New("Unable to get loopback backing file")
	ErrLoopbackSetCapacity    = errors.New("Unable set loopback capacity")
	ErrBusy                   = errors.New("Device is Busy")
	ErrDeviceIdExists         = errors.New("Device Id Exists")
)
View Source
var (
	DmGetLibraryVersion    = dmGetLibraryVersionFct
	DmGetNextTarget        = dmGetNextTargetFct
	DmLogInitVerbose       = dmLogInitVerboseFct
	DmSetDevDir            = dmSetDevDirFct
	DmTaskAddTarget        = dmTaskAddTargetFct
	DmTaskCreate           = dmTaskCreateFct
	DmTaskDestroy          = dmTaskDestroyFct
	DmTaskGetDeps          = dmTaskGetDepsFct
	DmTaskGetInfo          = dmTaskGetInfoFct
	DmTaskGetDriverVersion = dmTaskGetDriverVersionFct
	DmTaskRun              = dmTaskRunFct
	DmTaskSetAddNode       = dmTaskSetAddNodeFct
	DmTaskSetCookie        = dmTaskSetCookieFct
	DmTaskSetMessage       = dmTaskSetMessageFct
	DmTaskSetName          = dmTaskSetNameFct
	DmTaskSetRo            = dmTaskSetRoFct
	DmTaskSetSector        = dmTaskSetSectorFct
	DmUdevWait             = dmUdevWaitFct
	DmUdevSetSyncSupport   = dmUdevSetSyncSupportFct
	DmUdevGetSyncSupport   = dmUdevGetSyncSupportFct
	DmCookieSupported      = dmCookieSupportedFct
	LogWithErrnoInit       = logWithErrnoInitFct
)

Functions

func ActivateDevice

func ActivateDevice(poolName string, name string, deviceId int, size uint64) error

func AttachLoopDevice

func AttachLoopDevice(sparseName string) (loop *os.File, err error)

attachLoopDevice attaches the given sparse file to the next available loopback device. It returns an opened *os.File.

func BlockDeviceDiscard

func BlockDeviceDiscard(path string) error

func CookieSupported added in v1.6.0

func CookieSupported() bool

CookieSupported returns whether the version of device-mapper supports the use of cookie's in the tasks. This is largely a lower level call that other functions use.

func CreateDevice

func CreateDevice(poolName string, deviceId int) error

func CreatePool

func CreatePool(poolName string, dataFile, metadataFile *os.File, poolBlockSize uint32) error

This is the programmatic example of "dmsetup create"

func CreateSnapDevice

func CreateSnapDevice(poolName string, deviceId int, baseName string, baseDeviceId int) error

func DeleteDevice

func DeleteDevice(poolName string, deviceId int) error

func DeviceIdExists

func DeviceIdExists(err error) bool

Returns whether error conveys the information about device Id already exist or not. This will be true if device creation or snap creation operation fails if device or snap device already exists in pool. Current implementation is little crude as it scans the error string for exact pattern match. Replacing it with more robust implementation is desirable.

func DevmapperLogCallback

func DevmapperLogCallback(level C.int, file *C.char, line C.int, dm_errno_or_class C.int, message *C.char)

func FindLoopDeviceFor

func FindLoopDeviceFor(file *os.File) *os.File

func GetBlockDeviceSize

func GetBlockDeviceSize(file *os.File) (uint64, error)

func GetDriverVersion

func GetDriverVersion() (string, error)

func GetLibraryVersion

func GetLibraryVersion() (string, error)

func GetStatus

func GetStatus(name string) (uint64, uint64, string, string, error)

func LogInit

func LogInit(logger DevmapperLogger)

initialize the logger for the device mapper library

func LogInitVerbose

func LogInitVerbose(level int)

func LoopbackSetCapacity

func LoopbackSetCapacity(file *os.File) error

func ReloadPool

func ReloadPool(poolName string, dataFile, metadataFile *os.File, poolBlockSize uint32) error

func RemoveDevice

func RemoveDevice(name string) error

Useful helper for cleanup

func ResumeDevice

func ResumeDevice(name string) error

func SetDevDir

func SetDevDir(dir string) error

func SetTransactionId

func SetTransactionId(poolName string, oldId uint64, newId uint64) error

func SuspendDevice

func SuspendDevice(name string) error

func UdevSetSyncSupport added in v1.5.0

func UdevSetSyncSupport(enable bool) bool

UdevSetSyncSupport allows setting whether the udev sync should be enabled. The return bool indicates the state of whether the sync is enabled.

func UdevSyncSupported added in v1.5.0

func UdevSyncSupported() bool

UdevSyncSupported returns whether device-mapper is able to sync with udev

This is essential otherwise race conditions can arise where both udev and device-mapper attempt to create and destroy devices.

func UdevWait

func UdevWait(cookie uint) error

Types

type AddNodeType

type AddNodeType int
const (
	AddNodeOnResume AddNodeType = iota
	AddNodeOnCreate
)

type CDmTask

type CDmTask C.struct_dm_task

type CLoopInfo64

type CLoopInfo64 C.struct_loop_info64

type Deps

type Deps struct {
	Count  uint32
	Filler uint32
	Device []uint64
}

func GetDeps

func GetDeps(name string) (*Deps, error)

type DevmapperLogger

type DevmapperLogger interface {
	DMLog(level int, file string, line int, dmError int, message string)
}

type Info

type Info struct {
	Exists        int
	Suspended     int
	LiveTable     int
	InactiveTable int
	OpenCount     int32
	EventNr       uint32
	Major         uint32
	Minor         uint32
	ReadOnly      int
	TargetCount   int32
}

func GetInfo

func GetInfo(name string) (*Info, error)

type LoopInfo64

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

type Task

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

func TaskCreate

func TaskCreate(tasktype TaskType) *Task

TaskCreate initializes a devicemapper task of tasktype

func TaskCreateNamed

func TaskCreateNamed(t TaskType, name string) (*Task, error)

TaskCreateNamed is a convenience function for TaskCreate when a name will be set on the task as well

func (*Task) AddTarget

func (t *Task) AddTarget(start, size uint64, ttype, params string) error

func (*Task) GetDeps

func (t *Task) GetDeps() (*Deps, error)

func (*Task) GetDriverVersion

func (t *Task) GetDriverVersion() (string, error)

func (*Task) GetInfo

func (t *Task) GetInfo() (*Info, error)

func (*Task) GetNextTarget

func (t *Task) GetNextTarget(next uintptr) (nextPtr uintptr, start uint64,
	length uint64, targetType string, params string)

func (*Task) Run

func (t *Task) Run() error

func (*Task) SetAddNode

func (t *Task) SetAddNode(addNode AddNodeType) error

func (*Task) SetCookie

func (t *Task) SetCookie(cookie *uint, flags uint16) error

func (*Task) SetMessage

func (t *Task) SetMessage(message string) error

func (*Task) SetName

func (t *Task) SetName(name string) error

func (*Task) SetRo

func (t *Task) SetRo() error

func (*Task) SetSector

func (t *Task) SetSector(sector uint64) error

type TaskType

type TaskType int
const (
	DeviceCreate TaskType = iota
	DeviceReload
	DeviceRemove
	DeviceRemoveAll
	DeviceSuspend
	DeviceResume
	DeviceInfo
	DeviceDeps
	DeviceRename
	DeviceVersion
	DeviceStatus
	DeviceTable
	DeviceWaitevent
	DeviceList
	DeviceClear
	DeviceMknodes
	DeviceListVersions
	DeviceTargetMsg
	DeviceSetGeometry
)

Jump to

Keyboard shortcuts

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