2014-08-02 11:46:15 +04:00
|
|
|
// +build linux
|
2013-11-28 07:12:51 +04:00
|
|
|
|
2014-11-06 02:10:38 +03:00
|
|
|
package devicemapper
|
2013-10-10 17:24:39 +04:00
|
|
|
|
|
|
|
import "C"
|
|
|
|
|
2014-04-25 00:17:04 +04:00
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
2013-10-10 17: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-25 00:17:04 +04:00
|
|
|
msg := C.GoString(message)
|
|
|
|
if level < 7 {
|
|
|
|
if strings.Contains(msg, "busy") {
|
|
|
|
dmSawBusy = true
|
|
|
|
}
|
2014-04-25 00:36:45 +04:00
|
|
|
|
|
|
|
if strings.Contains(msg, "File exists") {
|
|
|
|
dmSawExist = true
|
|
|
|
}
|
2015-04-22 01:14:59 +03:00
|
|
|
|
|
|
|
if strings.Contains(msg, "No such device or address") {
|
|
|
|
dmSawEnxio = true
|
|
|
|
}
|
2014-04-25 00:17:04 +04:00
|
|
|
}
|
|
|
|
|
2013-10-10 17:24:39 +04:00
|
|
|
if dmLogger != nil {
|
2014-11-06 02:10:38 +03:00
|
|
|
dmLogger.DMLog(int(level), C.GoString(file), int(line), int(dm_errno_or_class), msg)
|
2013-10-10 17:24:39 +04:00
|
|
|
}
|
|
|
|
}
|