2017-03-29 20:55:42 -04:00
|
|
|
// +build linux,cgo
|
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"
|
|
|
|
|
2015-09-30 04:35:02 -04:00
|
|
|
// DevmapperLogCallback exports the devmapper log callback for cgo.
|
2013-10-10 09:24:39 -04:00
|
|
|
//export DevmapperLogCallback
|
2015-09-04 08:56:45 -04:00
|
|
|
func DevmapperLogCallback(level C.int, file *C.char, line C.int, dmErrnoOrClass 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 {
|
2015-09-04 08:56:45 -04:00
|
|
|
dmLogger.DMLog(int(level), C.GoString(file), int(line), int(dmErrnoOrClass), msg)
|
2013-10-10 09:24:39 -04:00
|
|
|
}
|
|
|
|
}
|