github.com/demonoid81/moby@v0.0.0-20200517203328-62dd8e17c460/pkg/dmesg/dmesg_linux.go (about) 1 package dmesg // import "github.com/demonoid81/moby/pkg/dmesg" 2 3 import ( 4 "golang.org/x/sys/unix" 5 ) 6 7 // Dmesg returns last messages from the kernel log, up to size bytes 8 func Dmesg(size int) []byte { 9 t := 3 // SYSLOG_ACTION_READ_ALL 10 b := make([]byte, size) 11 amt, err := unix.Klogctl(t, b) 12 if err != nil { 13 return []byte{} 14 } 15 return b[:amt] 16 }