1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/pkg/dmesg/dmesg_linux.go
Tobias Klauser 2841b05b71 Use Klogctl from x/sys/unix to read Linux kernel log
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2019-08-22 08:25:13 +02:00

16 lines
345 B
Go

package dmesg // import "github.com/docker/docker/pkg/dmesg"
import (
"golang.org/x/sys/unix"
)
// Dmesg returns last messages from the kernel log, up to size bytes
func Dmesg(size int) []byte {
t := 3 // SYSLOG_ACTION_READ_ALL
b := make([]byte, size)
amt, err := unix.Klogctl(t, b)
if err != nil {
return []byte{}
}
return b[:amt]
}