devicemapper: dm_udev_get_sync_support
expose an api to call dm_udev_get_sync_support/dm_udev_set_sync_support Signed-off-by: Vincent Batts <vbatts@redhat.com>
This commit is contained in:
parent
328a6bbf4e
commit
13fc8f758d
2 changed files with 30 additions and 0 deletions
|
@ -319,6 +319,26 @@ func GetLibraryVersion() (string, error) {
|
||||||
return version, nil
|
return version, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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 UdevSyncSupported() bool {
|
||||||
|
return DmUdevGetSyncSupport() != 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// UdevSetSyncSupport allows setting whether the udev sync should be enabled.
|
||||||
|
// The return bool indicates the state of whether the sync is enabled.
|
||||||
|
func UdevSetSyncSupport(enable bool) bool {
|
||||||
|
if enable {
|
||||||
|
DmUdevSetSyncSupport(1)
|
||||||
|
} else {
|
||||||
|
DmUdevSetSyncSupport(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
return UdevSyncSupported()
|
||||||
|
}
|
||||||
|
|
||||||
// Useful helper for cleanup
|
// Useful helper for cleanup
|
||||||
func RemoveDevice(name string) error {
|
func RemoveDevice(name string) error {
|
||||||
log.Debugf("[devmapper] RemoveDevice START")
|
log.Debugf("[devmapper] RemoveDevice START")
|
||||||
|
|
|
@ -107,6 +107,8 @@ var (
|
||||||
DmTaskSetRo = dmTaskSetRoFct
|
DmTaskSetRo = dmTaskSetRoFct
|
||||||
DmTaskSetSector = dmTaskSetSectorFct
|
DmTaskSetSector = dmTaskSetSectorFct
|
||||||
DmUdevWait = dmUdevWaitFct
|
DmUdevWait = dmUdevWaitFct
|
||||||
|
DmUdevSetSyncSupport = dmUdevSetSyncSupportFct
|
||||||
|
DmUdevGetSyncSupport = dmUdevGetSyncSupportFct
|
||||||
LogWithErrnoInit = logWithErrnoInitFct
|
LogWithErrnoInit = logWithErrnoInitFct
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -231,6 +233,14 @@ func dmGetNextTargetFct(task *CDmTask, next uintptr, start, length *uint64, targ
|
||||||
return uintptr(nextp)
|
return uintptr(nextp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func dmUdevSetSyncSupportFct(syncWithUdev int) {
|
||||||
|
(C.dm_udev_set_sync_support(C.int(syncWithUdev)))
|
||||||
|
}
|
||||||
|
|
||||||
|
func dmUdevGetSyncSupportFct() int {
|
||||||
|
return int(C.dm_udev_get_sync_support())
|
||||||
|
}
|
||||||
|
|
||||||
func dmUdevWaitFct(cookie uint) int {
|
func dmUdevWaitFct(cookie uint) int {
|
||||||
return int(C.dm_udev_wait(C.uint32_t(cookie)))
|
return int(C.dm_udev_wait(C.uint32_t(cookie)))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue