github.com/cdoern/storage@v1.12.13/pkg/dmesg/dmesg_linux.go (about) 1 // +build linux 2 3 package dmesg 4 5 import ( 6 "unsafe" 7 8 "golang.org/x/sys/unix" 9 ) 10 11 // Dmesg returns last messages from the kernel log, up to size bytes 12 func Dmesg(size int) []byte { 13 t := uintptr(3) // SYSLOG_ACTION_READ_ALL 14 b := make([]byte, size) 15 amt, _, err := unix.Syscall(unix.SYS_SYSLOG, t, uintptr(unsafe.Pointer(&b[0])), uintptr(len(b))) 16 if err != 0 { 17 return []byte{} 18 } 19 return b[:amt] 20 }