From 650ca7d9151df73ce92a6c4ac2e42f91a60d36f9 Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Mon, 19 Jan 2015 15:31:54 -0500 Subject: [PATCH] devicemapper: API for checking cookie support Signed-off-by: Vincent Batts --- devicemapper/devmapper.go | 7 +++++++ devicemapper/devmapper_wrapper.go | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/devicemapper/devmapper.go b/devicemapper/devmapper.go index 486ec15..764971c 100644 --- a/devicemapper/devmapper.go +++ b/devicemapper/devmapper.go @@ -339,6 +339,13 @@ func UdevSetSyncSupport(enable bool) bool { return UdevSyncSupported() } +// 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 CookieSupported() bool { + return DmCookieSupported() != 0 +} + // Useful helper for cleanup func RemoveDevice(name string) error { log.Debugf("[devmapper] RemoveDevice START") diff --git a/devicemapper/devmapper_wrapper.go b/devicemapper/devmapper_wrapper.go index aff8446..6427968 100644 --- a/devicemapper/devmapper_wrapper.go +++ b/devicemapper/devmapper_wrapper.go @@ -109,6 +109,7 @@ var ( DmUdevWait = dmUdevWaitFct DmUdevSetSyncSupport = dmUdevSetSyncSupportFct DmUdevGetSyncSupport = dmUdevGetSyncSupportFct + DmCookieSupported = dmCookieSupportedFct LogWithErrnoInit = logWithErrnoInitFct ) @@ -245,6 +246,10 @@ func dmUdevWaitFct(cookie uint) int { return int(C.dm_udev_wait(C.uint32_t(cookie))) } +func dmCookieSupportedFct() int { + return int(C.dm_cookie_supported()) +} + func dmLogInitVerboseFct(level int) { C.dm_log_init_verbose(C.int(level)) }