1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

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:
Vincent Batts 2015-01-19 15:10:37 -05:00
parent 4c38045be1
commit 9c3380039e
2 changed files with 30 additions and 0 deletions

View file

@ -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")

View file

@ -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)))
} }