devmapper_log.go 668 B

123456789101112131415161718192021222324252627282930
  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. if strings.Contains(msg, "File exists") {
  17. dmSawExist = true
  18. }
  19. }
  20. if dmLogger != nil {
  21. dmLogger.log(int(level), C.GoString(file), int(line), int(dm_errno_or_class), msg)
  22. }
  23. }