Documentation ¶
Index ¶
- Constants
- Variables
- func ActivateDevice(poolName string, name string, deviceID int, size uint64) error
- func ActivateDeviceWithExternal(poolName string, name string, deviceID int, size uint64, external string) error
- func AttachLoopDevice(sparseName string) (loop *os.File, err error)
- func BlockDeviceDiscard(path string) error
- func CancelDeferredRemove(deviceName string) error
- func CookieSupported() bool
- func CreateDevice(poolName string, deviceID int) error
- func CreatePool(poolName string, dataFile, metadataFile *os.File, poolBlockSize uint32) error
- func CreateSnapDevice(poolName string, deviceID int, baseName string, baseDeviceID int) error
- func DeleteDevice(poolName string, deviceID int) error
- func DeviceIDExists(err error) bool
- func DevmapperLogCallback(level C.int, file *C.char, line C.int, dmErrnoOrClass C.int, message *C.char)
- func FindLoopDeviceFor(file *os.File) *os.File
- func GetBlockDeviceSize(file *os.File) (uint64, error)
- func GetDriverVersion() (string, error)
- func GetLibraryVersion() (string, error)
- func GetStatus(name string) (uint64, uint64, string, string, error)
- func GetTable(name string) (uint64, uint64, string, string, error)
- func LogInit(logger DevmapperLogger)
- func LogInitVerbose(level int)
- func LoopbackSetCapacity(file *os.File) error
- func ReloadPool(poolName string, dataFile, metadataFile *os.File, poolBlockSize uint32) error
- func RemoveDevice(name string) error
- func RemoveDeviceDeferred(name string) error
- func ResumeDevice(name string) error
- func SetDevDir(dir string) error
- func SetTransactionID(poolName string, oldID uint64, newID uint64) error
- func SuspendDevice(name string) error
- func UdevSetSyncSupport(enable bool) bool
- func UdevSyncSupported() bool
- func UdevWait(cookie *uint) error
- type AddNodeType
- type Deps
- type DevmapperLogger
- type Info
- type Task
- type TaskType
Constants ¶
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
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 )
LOOP consts.
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 )
Devicemapper cookie flags.
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
const LibraryDeferredRemovalSupport = true
LibraryDeferredRemovalsupport is supported when statically linked.
Variables ¶
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") ErrTaskDeferredRemove = errors.New("dm_task_deferred_remove 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") ErrEnxio = errors.New("No such device or address") )
List of errors returned when using devicemapper.
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 DmTaskDeferredRemove = dmTaskDeferredRemoveFct DmTaskGetInfoWithDeferred = dmTaskGetInfoWithDeferredFct )
DeviceMapper mapped functions.
Functions ¶
func ActivateDevice ¶
ActivateDevice activates the device identified by the specified poolName, name and deviceID with the specified size.
func ActivateDeviceWithExternal ¶ added in v1.8.0
func ActivateDeviceWithExternal(poolName string, name string, deviceID int, size uint64, external string) error
ActivateDeviceWithExternal activates the device identified by the specified poolName, name and deviceID with the specified size.
func AttachLoopDevice ¶
AttachLoopDevice attaches the given sparse file to the next available loopback device. It returns an opened *os.File.
func BlockDeviceDiscard ¶
BlockDeviceDiscard runs discard for the given path. This is used as a workaround for the kernel not discarding block so on the thin pool when we remove a thinp device, so we do it manually
func CancelDeferredRemove ¶ added in v1.7.0
CancelDeferredRemove cancels a deferred remove for a device.
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 ¶
CreateDevice creates a device with the specified poolName with the specified device id.
func CreatePool ¶
CreatePool is the programmatic example of "dmsetup create". It creates a device with the specified poolName, data and metadata file and block size.
func CreateSnapDevice ¶
CreateSnapDevice creates a snapshot based on the device identified by the baseName and baseDeviceId,
func DeleteDevice ¶
DeleteDevice deletes a device with the specified poolName with the specified device id.
func DeviceIDExists ¶ added in v1.9.0
DeviceIDExists 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, dmErrnoOrClass C.int, message *C.char)
DevmapperLogCallback exports the devmapper log callback for cgo.
func FindLoopDeviceFor ¶
FindLoopDeviceFor returns a loopback device file for the specified file which is backing file of a loop back device.
func GetBlockDeviceSize ¶
GetBlockDeviceSize returns the size of a block device identified by the specified file.
func GetDriverVersion ¶
GetDriverVersion is the programmatic example of "dmsetup version". It outputs version information of the driver.
func GetLibraryVersion ¶
GetLibraryVersion returns the device mapper library version.
func GetStatus ¶
GetStatus is the programmatic example of "dmsetup status". It outputs status information for the specified device name.
func GetTable ¶ added in v1.8.0
GetTable is the programmatic example for "dmsetup table". It outputs the current table for the specified device name.
func LogInit ¶
func LogInit(logger DevmapperLogger)
LogInit initializes the logger for the device mapper library.
func LogInitVerbose ¶
func LogInitVerbose(level int)
LogInitVerbose is an interface to initialize the verbose logger for the device mapper library.
func LoopbackSetCapacity ¶
LoopbackSetCapacity reloads the size for the loopback device.
func ReloadPool ¶
ReloadPool is the programmatic example of "dmsetup reload". It reloads the table with the specified poolName, data and metadata file and block size.
func RemoveDevice ¶
RemoveDevice is a useful helper for cleaning up a device.
func RemoveDeviceDeferred ¶ added in v1.7.0
RemoveDeviceDeferred is a useful helper for cleaning up a device, but deferred.
func ResumeDevice ¶
ResumeDevice is the programmatic example of "dmsetup resume". It un-suspends the specified device.
func SetTransactionID ¶ added in v1.9.0
SetTransactionID sets a transaction id for the specified device name.
func SuspendDevice ¶
SuspendDevice is the programmatic example of "dmsetup suspend". It suspends the specified device.
func UdevSetSyncSupport ¶ added in v1.5.0
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.
Types ¶
type DevmapperLogger ¶
type DevmapperLogger interface {
DMLog(level int, file string, line int, dmError int, message string)
}
DevmapperLogger defines methods for logging with devicemapper.
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 DeferredRemove int }
Info represents information about a device.
func GetInfo ¶
GetInfo is the programmatic example of "dmsetup info". It outputs some brief information about the device.
func GetInfoWithDeferred ¶ added in v1.7.0
GetInfoWithDeferred is the programmatic example of "dmsetup info", but deferred. It outputs some brief information about the device.
type Task ¶
type Task struct {
// contains filtered or unexported fields
}
Task represents a devicemapper task (like lvcreate, etc.) ; a task is needed for each ioctl command to execute.
func TaskCreate ¶
TaskCreate initializes a devicemapper task of tasktype