{"modulePath":"github.com/hyperhq/hypercli","version":"v1.10.16","isLatest":true,"isStandardLibrary":false,"goos":"linux","goarch":"amd64","docs":"# package devicemapper\n\n## Constants\n\n```go\nconst (\n\tBlkGetSize64 = C.BLKGETSIZE64\n\tBlkDiscard   = C.BLKDISCARD\n)\n```\nIOCTL consts\n\n```go\nconst (\n\tDmUdevDisableSubsystemRulesFlag = C.DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG\n\tDmUdevDisableDiskRulesFlag      = C.DM_UDEV_DISABLE_DISK_RULES_FLAG\n\tDmUdevDisableOtherRulesFlag     = C.DM_UDEV_DISABLE_OTHER_RULES_FLAG\n\tDmUdevDisableLibraryFallback    = C.DM_UDEV_DISABLE_LIBRARY_FALLBACK\n)\n```\nDevicemapper cookie flags.\n\n```go\nconst (\n\tLogLevelFatal  = 2 + iota // _LOG_FATAL\n\tLogLevelErr               // _LOG_ERR\n\tLogLevelWarn              // _LOG_WARN\n\tLogLevelNotice            // _LOG_NOTICE\n\tLogLevelInfo              // _LOG_INFO\n\tLogLevelDebug             // _LOG_DEBUG\n)\n```\ndefinitions from lvm2 lib/log/log.h\n\n```go\nconst LibraryDeferredRemovalSupport = true\n```\nLibraryDeferredRemovalSupport is supported when statically linked.\n\n## Variables\n\n```go\nvar (\n\tErrTaskRun              = errors.New(\"dm_task_run failed\")\n\tErrTaskSetName          = errors.New(\"dm_task_set_name failed\")\n\tErrTaskSetMessage       = errors.New(\"dm_task_set_message failed\")\n\tErrTaskSetAddNode       = errors.New(\"dm_task_set_add_node failed\")\n\tErrTaskSetRo            = errors.New(\"dm_task_set_ro failed\")\n\tErrTaskAddTarget        = errors.New(\"dm_task_add_target failed\")\n\tErrTaskSetSector        = errors.New(\"dm_task_set_sector failed\")\n\tErrTaskGetDeps          = errors.New(\"dm_task_get_deps failed\")\n\tErrTaskGetInfo          = errors.New(\"dm_task_get_info failed\")\n\tErrTaskGetDriverVersion = errors.New(\"dm_task_get_driver_version failed\")\n\tErrTaskDeferredRemove   = errors.New(\"dm_task_deferred_remove failed\")\n\tErrTaskSetCookie        = errors.New(\"dm_task_set_cookie failed\")\n\tErrNilCookie            = errors.New(\"cookie ptr can't be nil\")\n\tErrGetBlockSize         = errors.New(\"Can't get block size\")\n\tErrUdevWait             = errors.New(\"wait on udev cookie failed\")\n\tErrSetDevDir            = errors.New(\"dm_set_dev_dir failed\")\n\tErrGetLibraryVersion    = errors.New(\"dm_get_library_version failed\")\n\tErrCreateRemoveTask     = errors.New(\"Can't create task of type deviceRemove\")\n\tErrRunRemoveDevice      = errors.New(\"running RemoveDevice failed\")\n\tErrInvalidAddNode       = errors.New(\"Invalid AddNode type\")\n\tErrBusy                 = errors.New(\"Device is Busy\")\n\tErrDeviceIDExists       = errors.New(\"Device Id Exists\")\n\tErrEnxio                = errors.New(\"No such device or address\")\n)\n```\nList of errors returned when using devicemapper.\n\n```go\nvar (\n\tDmGetLibraryVersion       = dmGetLibraryVersionFct\n\tDmGetNextTarget           = dmGetNextTargetFct\n\tDmLogInitVerbose          = dmLogInitVerboseFct\n\tDmSetDevDir               = dmSetDevDirFct\n\tDmTaskAddTarget           = dmTaskAddTargetFct\n\tDmTaskCreate              = dmTaskCreateFct\n\tDmTaskDestroy             = dmTaskDestroyFct\n\tDmTaskGetDeps             = dmTaskGetDepsFct\n\tDmTaskGetInfo             = dmTaskGetInfoFct\n\tDmTaskGetDriverVersion    = dmTaskGetDriverVersionFct\n\tDmTaskRun                 = dmTaskRunFct\n\tDmTaskSetAddNode          = dmTaskSetAddNodeFct\n\tDmTaskSetCookie           = dmTaskSetCookieFct\n\tDmTaskSetMessage          = dmTaskSetMessageFct\n\tDmTaskSetName             = dmTaskSetNameFct\n\tDmTaskSetRo               = dmTaskSetRoFct\n\tDmTaskSetSector           = dmTaskSetSectorFct\n\tDmUdevWait                = dmUdevWaitFct\n\tDmUdevSetSyncSupport      = dmUdevSetSyncSupportFct\n\tDmUdevGetSyncSupport      = dmUdevGetSyncSupportFct\n\tDmCookieSupported         = dmCookieSupportedFct\n\tLogWithErrnoInit          = logWithErrnoInitFct\n\tDmTaskDeferredRemove      = dmTaskDeferredRemoveFct\n\tDmTaskGetInfoWithDeferred = dmTaskGetInfoWithDeferredFct\n)\n```\nDeviceMapper mapped functions.\n\n## Functions\n\n```go\nfunc ActivateDevice(poolName string, name string, deviceID int, size uint64) error\n```\nActivateDevice activates the device identified by the specified poolName, name and deviceID with the specified size.\n\n```go\nfunc ActivateDeviceWithExternal(poolName string, name string, deviceID int, size uint64, external string) error\n```\nActivateDeviceWithExternal activates the device identified by the specified poolName, name and deviceID with the specified size.\n\n```go\nfunc BlockDeviceDiscard(path string) error\n```\nBlockDeviceDiscard 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\n\n```go\nfunc CancelDeferredRemove(deviceName string) error\n```\nCancelDeferredRemove cancels a deferred remove for a device.\n\n```go\nfunc CookieSupported() bool\n```\nCookieSupported 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.\n\n```go\nfunc CreateDevice(poolName string, deviceID int) error\n```\nCreateDevice creates a device with the specified poolName with the specified device id.\n\n```go\nfunc CreatePool(poolName string, dataFile, metadataFile *os.File, poolBlockSize uint32) error\n```\nCreatePool is the programmatic example of \"dmsetup create\". It creates a device with the specified poolName, data and metadata file and block size.\n\n```go\nfunc CreateSnapDevice(poolName string, deviceID int, baseName string, baseDeviceID int) error\n```\nCreateSnapDevice creates a snapshot based on the device identified by the baseName and baseDeviceId,\n\n```go\nfunc DeleteDevice(poolName string, deviceID int) error\n```\nDeleteDevice deletes a device with the specified poolName with the specified device id.\n\n```go\nfunc DeviceIDExists(err error) bool\n```\nDeviceIDExists 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.\n\n```go\nfunc DevmapperLogCallback(level C.int, file *C.char, line C.int, dmErrnoOrClass C.int, message *C.char)\n```\nDevmapperLogCallback exports the devmapper log callback for cgo.\n\n```go\nfunc GetBlockDeviceSize(file *os.File) (uint64, error)\n```\nGetBlockDeviceSize returns the size of a block device identified by the specified file.\n\n```go\nfunc GetDriverVersion() (string, error)\n```\nGetDriverVersion is the programmatic example of \"dmsetup version\". It outputs version information of the driver.\n\n```go\nfunc GetLibraryVersion() (string, error)\n```\nGetLibraryVersion returns the device mapper library version.\n\n```go\nfunc GetStatus(name string) (uint64, uint64, string, string, error)\n```\nGetStatus is the programmatic example of \"dmsetup status\". It outputs status information for the specified device name.\n\n```go\nfunc GetTable(name string) (uint64, uint64, string, string, error)\n```\nGetTable is the programmatic example for \"dmsetup table\". It outputs the current table for the specified device name.\n\n```go\nfunc LogInit(logger DevmapperLogger)\n```\nLogInit initializes the logger for the device mapper library.\n\n```go\nfunc LogInitVerbose(level int)\n```\nLogInitVerbose is an interface to initialize the verbose logger for the device mapper library.\n\n```go\nfunc ReloadPool(poolName string, dataFile, metadataFile *os.File, poolBlockSize uint32) error\n```\nReloadPool is the programmatic example of \"dmsetup reload\". It reloads the table with the specified poolName, data and metadata file and block size.\n\n```go\nfunc RemoveDevice(name string) error\n```\nRemoveDevice is a useful helper for cleaning up a device.\n\n```go\nfunc RemoveDeviceDeferred(name string) error\n```\nRemoveDeviceDeferred is a useful helper for cleaning up a device, but deferred.\n\n```go\nfunc ResumeDevice(name string) error\n```\nResumeDevice is the programmatic example of \"dmsetup resume\". It un-suspends the specified device.\n\n```go\nfunc SetDevDir(dir string) error\n```\nSetDevDir sets the dev folder for the device mapper library (usually /dev).\n\n```go\nfunc SetTransactionID(poolName string, oldID uint64, newID uint64) error\n```\nSetTransactionID sets a transaction id for the specified device name.\n\n```go\nfunc SuspendDevice(name string) error\n```\nSuspendDevice is the programmatic example of \"dmsetup suspend\". It suspends the specified device.\n\n```go\nfunc UdevSetSyncSupport(enable bool) bool\n```\nUdevSetSyncSupport allows setting whether the udev sync should be enabled. The return bool indicates the state of whether the sync is enabled.\n\n```go\nfunc UdevSyncSupported() bool\n```\nUdevSyncSupported returns whether device-mapper is able to sync with udev\n\nThis is essential otherwise race conditions can arise where both udev and device-mapper attempt to create and destroy devices.\n\n```go\nfunc UdevWait(cookie *uint) error\n```\nUdevWait waits for any processes that are waiting for udev to complete the specified cookie.\n\n## Types\n\n```go\ntype AddNodeType int\n```\nAddNodeType represents a type of node to be added\n\n```go\ntype Deps struct {\n\tCount  uint32\n\tFiller uint32\n\tDevice []uint64\n}\n```\nDeps represents dependents (layer) of a device.\n\n```go\nfunc GetDeps(name string) (*Deps, error)\n```\nGetDeps is the programmatic example of \"dmsetup deps\". It outputs a list of devices referenced by the live table for the specified device.\n\n```go\ntype DevmapperLogger interface {\n\tDMLog(level int, file string, line int, dmError int, message string)\n}\n```\nDevmapperLogger defines methods for logging with devicemapper.\n\n```go\ntype Info struct {\n\tExists         int\n\tSuspended      int\n\tLiveTable      int\n\tInactiveTable  int\n\tOpenCount      int32\n\tEventNr        uint32\n\tMajor          uint32\n\tMinor          uint32\n\tReadOnly       int\n\tTargetCount    int32\n\tDeferredRemove int\n}\n```\nInfo represents information about a device.\n\n```go\nfunc GetInfo(name string) (*Info, error)\n```\nGetInfo is the programmatic example of \"dmsetup info\". It outputs some brief information about the device.\n\n```go\nfunc GetInfoWithDeferred(name string) (*Info, error)\n```\nGetInfoWithDeferred is the programmatic example of \"dmsetup info\", but deferred. It outputs some brief information about the device.\n\n```go\ntype Task struct {\n\t// contains filtered or unexported fields\n}\n```\nTask represents a devicemapper task (like lvcreate, etc.) ; a task is needed for each ioctl command to execute.\n\n```go\nfunc TaskCreate(tasktype TaskType) *Task\n```\nTaskCreate initializes a devicemapper task of tasktype\n\n```go\nfunc TaskCreateNamed(t TaskType, name string) (*Task, error)\n```\nTaskCreateNamed is a convenience function for TaskCreate when a name will be set on the task as well\n\n```go\ntype TaskType int\n```\nTaskType represents a type of task\n\n","path":"github.com/hyperhq/hypercli/pkg/devicemapper","name":"devicemapper","synopsis":"","isRedistributable":true}
