2018-02-05 21:05:59 +00:00
|
|
|
package dmesg // import "github.com/docker/docker/pkg/dmesg"
|
2017-08-21 21:55:20 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"golang.org/x/sys/unix"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Dmesg returns last messages from the kernel log, up to size bytes
|
|
|
|
func Dmesg(size int) []byte {
|
2019-08-09 13:43:18 +00:00
|
|
|
t := 3 // SYSLOG_ACTION_READ_ALL
|
2017-08-21 21:55:20 +00:00
|
|
|
b := make([]byte, size)
|
2019-08-09 13:43:18 +00:00
|
|
|
amt, err := unix.Klogctl(t, b)
|
|
|
|
if err != nil {
|
2017-08-21 21:55:20 +00:00
|
|
|
return []byte{}
|
|
|
|
}
|
|
|
|
return b[:amt]
|
|
|
|
}
|