2014-11-05 23:10:38 +00:00
|
|
|
// +build linux
|
|
|
|
|
|
|
|
package devicemapper
|
|
|
|
|
|
|
|
import "C"
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
|
|
|
// 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"
|
|
|
|
|
2015-09-04 12:56:45 +00:00
|
|
|
// DevmapperLogCallback exports the devmapper log callback for cgo. (?)
|
2014-11-05 23:10:38 +00:00
|
|
|
//export DevmapperLogCallback
|
2015-09-04 12:56:45 +00:00
|
|
|
func DevmapperLogCallback(level C.int, file *C.char, line C.int, dmErrnoOrClass C.int, message *C.char) {
|
2014-11-05 23:10:38 +00:00
|
|
|
msg := C.GoString(message)
|
|
|
|
if level < 7 {
|
|
|
|
if strings.Contains(msg, "busy") {
|
|
|
|
dmSawBusy = true
|
|
|
|
}
|
|
|
|
|
|
|
|
if strings.Contains(msg, "File exists") {
|
|
|
|
dmSawExist = true
|
|
|
|
}
|
2015-04-21 22:14:59 +00:00
|
|
|
|
|
|
|
if strings.Contains(msg, "No such device or address") {
|
|
|
|
dmSawEnxio = true
|
|
|
|
}
|
2014-11-05 23:10:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if dmLogger != nil {
|
2015-09-04 12:56:45 +00:00
|
|
|
dmLogger.DMLog(int(level), C.GoString(file), int(line), int(dmErrnoOrClass), msg)
|
2014-11-05 23:10:38 +00:00
|
|
|
}
|
|
|
|
}
|