devmapper_log.go 598 B

1234567891011121314151617181920212223242526
  1. // +build linux,amd64
  2. package devmapper
  3. import "C"
  4. import (
  5. "strings"
  6. )
  7. // Due to the way cgo works this has to be in a separate file, as devmapper.go has
  8. // definitions in the cgo block, which is incompatible with using "//export"
  9. //export DevmapperLogCallback
  10. func DevmapperLogCallback(level C.int, file *C.char, line C.int, dm_errno_or_class C.int, message *C.char) {
  11. msg := C.GoString(message)
  12. if level < 7 {
  13. if strings.Contains(msg, "busy") {
  14. dmSawBusy = true
  15. }
  16. }
  17. if dmLogger != nil {
  18. dmLogger.log(int(level), C.GoString(file), int(line), int(dm_errno_or_class), msg)
  19. }
  20. }