55e5d76085
Rename the "DevmapperLogCallback" exported-to-C function to "StorageDevmapperLogCallback", to avoid tripping up anyone who vendors the library but already has a copy of the "pkg/devicemapper" pkg which defines the callback with its previous name. Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
35 lines
834 B
Go
35 lines
834 B
Go
// +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"
|
|
|
|
// StorageDevmapperLogCallback exports the devmapper log callback for cgo.
|
|
//export StorageDevmapperLogCallback
|
|
func StorageDevmapperLogCallback(level C.int, file *C.char, line C.int, dmErrnoOrClass C.int, message *C.char) {
|
|
msg := C.GoString(message)
|
|
if level < 7 {
|
|
if strings.Contains(msg, "busy") {
|
|
dmSawBusy = true
|
|
}
|
|
|
|
if strings.Contains(msg, "File exists") {
|
|
dmSawExist = true
|
|
}
|
|
|
|
if strings.Contains(msg, "No such device or address") {
|
|
dmSawEnxio = true
|
|
}
|
|
}
|
|
|
|
if dmLogger != nil {
|
|
dmLogger.DMLog(int(level), C.GoString(file), int(line), int(dmErrnoOrClass), msg)
|
|
}
|
|
}
|