docker: github.com/docker/docker/pkg/devicemapper Index | Files

package devicemapper

import "github.com/docker/docker/pkg/devicemapper"

Index

Package Files

devmapper.go devmapper_log.go devmapper_wrapper.go devmapper_wrapper_dynamic.go devmapper_wrapper_dynamic_deferred_remove.go ioctl.go log.go

Constants

const (
    BlkGetSize64 = C.BLKGETSIZE64
    BlkDiscard   = C.BLKDISCARD
)

IOCTL 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 tells if the feature is supported by the current Docker invocation.

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")
    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")
    ErrBusy                 = errors.New("Device is Busy")
    ErrDeviceIDExists       = errors.New("Device Id Exists")
    ErrEnxio                = errors.New("No such device or address")
    ErrEnoData              = errors.New("No data available")
)

List of errors returned when using devicemapper.

var (
    DmGetLibraryVersion       = dmGetLibraryVersionFct
    DmGetNextTarget           = dmGetNextTargetFct
    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.

func ActivateDevice Uses

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

ActivateDevice activates the device identified by the specified poolName, name and deviceID with the specified size.

func ActivateDeviceWithExternal Uses

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 BlockDeviceDiscard Uses

func BlockDeviceDiscard(path string) error

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 Uses

func CancelDeferredRemove(deviceName string) error

CancelDeferredRemove cancels a deferred remove for a device.

func CookieSupported Uses

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 Uses

func CreateDevice(poolName string, deviceID int) error

CreateDevice creates a device with the specified poolName with the specified device id.

func CreatePool Uses

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

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 Uses

func CreateSnapDevice(poolName string, deviceID int, baseName string, baseDeviceID int) error

CreateSnapDevice creates a snapshot based on the device identified by the baseName and baseDeviceId,

func CreateSnapDeviceRaw Uses

func CreateSnapDeviceRaw(poolName string, deviceID int, baseDeviceID int) error

CreateSnapDeviceRaw creates a snapshot device. Caller needs to suspend and resume the origin device if it is active.

func DeleteDevice Uses

func DeleteDevice(poolName string, deviceID int) error

DeleteDevice deletes a device with the specified poolName with the specified device id.

func DeviceIDExists Uses

func DeviceIDExists(err error) bool

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 Uses

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

DevmapperLogCallback exports the devmapper log callback for cgo. Note that because we are using callbacks, this function will be called for *every* log in libdm (even debug ones because there's no way of setting the verbosity level for an external logging callback). export DevmapperLogCallback

func GetBlockDeviceSize Uses

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

GetBlockDeviceSize returns the size of a block device identified by the specified file.

func GetDriverVersion Uses

func GetDriverVersion() (string, error)

GetDriverVersion is the programmatic example of "dmsetup version". It outputs version information of the driver.

func GetLibraryVersion Uses

func GetLibraryVersion() (string, error)

GetLibraryVersion returns the device mapper library version.

func GetStatus Uses

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

GetStatus is the programmatic example of "dmsetup status". It outputs status information for the specified device name.

func GetTable Uses

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

GetTable is the programmatic example for "dmsetup table". It outputs the current table for the specified device name.

func LogInit Uses

func LogInit(logger DevmapperLogger)

LogInit changes the logging callback called after processing libdm logs for error message information. The default logger simply forwards all logs to logrus. Calling LogInit(nil) disables the calling of callbacks.

func ReloadPool Uses

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

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 Uses

func RemoveDevice(name string) error

RemoveDevice is a useful helper for cleaning up a device.

func RemoveDeviceDeferred Uses

func RemoveDeviceDeferred(name string) error

RemoveDeviceDeferred is a useful helper for cleaning up a device, but deferred.

func ResumeDevice Uses

func ResumeDevice(name string) error

ResumeDevice is the programmatic example of "dmsetup resume". It un-suspends the specified device.

func SetDevDir Uses

func SetDevDir(dir string) error

SetDevDir sets the dev folder for the device mapper library (usually /dev).

func SetTransactionID Uses

func SetTransactionID(poolName string, oldID uint64, newID uint64) error

SetTransactionID sets a transaction id for the specified device name.

func SuspendDevice Uses

func SuspendDevice(name string) error

SuspendDevice is the programmatic example of "dmsetup suspend". It suspends the specified device.

func UdevSetSyncSupport Uses

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 Uses

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 Uses

func UdevWait(cookie *uint) error

UdevWait waits for any processes that are waiting for udev to complete the specified cookie.

type AddNodeType Uses

type AddNodeType int

AddNodeType represents a type of node to be added

type DefaultLogger Uses

type DefaultLogger struct {
    // Level corresponds to the highest libdm level that will be forwarded to
    // logrus. In order to change this, register a new DefaultLogger.
    Level int
}

DefaultLogger is the default logger used by pkg/devicemapper. It forwards all logs that are of higher or equal priority to the given level to the corresponding logrus level.

func (DefaultLogger) DMLog Uses

func (l DefaultLogger) DMLog(level int, file string, line, dmError int, message string)

DMLog is the logging callback containing all of the information from devicemapper. The interface is identical to the C libdm counterpart.

type Deps Uses

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

Deps represents dependents (layer) of a device.

func GetDeps Uses

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

GetDeps is the programmatic example of "dmsetup deps". It outputs a list of devices referenced by the live table for the specified device.

type DevmapperLogger Uses

type DevmapperLogger interface {
    // DMLog is the logging callback containing all of the information from
    // devicemapper. The interface is identical to the C libdm counterpart.
    DMLog(level int, file string, line int, dmError int, message string)
}

DevmapperLogger defines methods required to register as a callback for logging events received from devicemapper. Note that devicemapper will send *all* logs regardless to callbacks (including debug logs) so it's recommended to not spam the console with the outputs.

type Info Uses

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 Uses

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

GetInfo is the programmatic example of "dmsetup info". It outputs some brief information about the device.

func GetInfoWithDeferred Uses

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

GetInfoWithDeferred is the programmatic example of "dmsetup info", but deferred. It outputs some brief information about the device.

type Task Uses

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 Uses

func TaskCreate(tasktype TaskType) *Task

TaskCreate initializes a devicemapper task of tasktype

func TaskCreateNamed Uses

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

type TaskType Uses

type TaskType int

TaskType represents a type of task

Package devicemapper imports 10 packages (graph) and is imported by 656 packages. Updated 2018-05-29. Refresh now. Tools for package owners.