github.com/tompao/docker@v1.9.1/pkg/devicemapper/devmapper_log.go (about)

     1  // +build linux
     2  
     3  package devicemapper
     4  
     5  import "C"
     6  
     7  import (
     8  	"strings"
     9  )
    10  
    11  // Due to the way cgo works this has to be in a separate file, as devmapper.go has
    12  // definitions in the cgo block, which is incompatible with using "//export"
    13  
    14  // DevmapperLogCallback exports the devmapper log callback for cgo.
    15  //export DevmapperLogCallback
    16  func DevmapperLogCallback(level C.int, file *C.char, line C.int, dmErrnoOrClass C.int, message *C.char) {
    17  	msg := C.GoString(message)
    18  	if level < 7 {
    19  		if strings.Contains(msg, "busy") {
    20  			dmSawBusy = true
    21  		}
    22  
    23  		if strings.Contains(msg, "File exists") {
    24  			dmSawExist = true
    25  		}
    26  
    27  		if strings.Contains(msg, "No such device or address") {
    28  			dmSawEnxio = true
    29  		}
    30  	}
    31  
    32  	if dmLogger != nil {
    33  		dmLogger.DMLog(int(level), C.GoString(file), int(line), int(dmErrnoOrClass), msg)
    34  	}
    35  }