2014-08-02 03:46:15 -04:00
|
|
|
// +build linux
|
2013-11-27 22:12:51 -05:00
|
|
|
|
2014-11-05 18:10:38 -05:00
|
|
|
package devicemapper
|
2013-10-10 09:24:39 -04:00
|
|
|
|
|
|
|
import "C"
|
|
|
|
|
2014-04-24 16:17:04 -04:00
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
2013-10-10 09:24:39 -04:00
|
|
|
// Due to the way cgo works this has to be in a separate file, as devmapper.go has
|
|
|
|
// definitions in the cgo block, which is incompatible with using "//export"
|
|
|
|
|
|
|
|
//export DevmapperLogCallback
|
|
|
|
func DevmapperLogCallback(level C.int, file *C.char, line C.int, dm_errno_or_class C.int, message *C.char) {
|
2014-04-24 16:17:04 -04:00
|
|
|
msg := C.GoString(message)
|
|
|
|
if level < 7 {
|
|
|
|
if strings.Contains(msg, "busy") {
|
|
|
|
dmSawBusy = true
|
|
|
|
}
|
2014-04-24 16:36:45 -04:00
|
|
|
|
|
|
|
if strings.Contains(msg, "File exists") {
|
|
|
|
dmSawExist = true
|
|
|
|
}
|
2015-04-21 18:14:59 -04:00
|
|
|
|
|
|
|
if strings.Contains(msg, "No such device or address") {
|
|
|
|
dmSawEnxio = true
|
|
|
|
}
|
2014-04-24 16:17:04 -04:00
|
|
|
}
|
|
|
|
|
2013-10-10 09:24:39 -04:00
|
|
|
if dmLogger != nil {
|
2014-11-05 18:10:38 -05:00
|
|
|
dmLogger.DMLog(int(level), C.GoString(file), int(line), int(dm_errno_or_class), msg)
|
2013-10-10 09:24:39 -04:00
|
|
|
}
|
|
|
|
}
|