From 2841b05b71095d662ecb47831d88371e9cb033ff Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Fri, 9 Aug 2019 15:43:18 +0200 Subject: [PATCH] Use Klogctl from x/sys/unix to read Linux kernel log Signed-off-by: Tobias Klauser --- pkg/dmesg/dmesg_linux.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pkg/dmesg/dmesg_linux.go b/pkg/dmesg/dmesg_linux.go index bc71b5b31f..524c35a883 100644 --- a/pkg/dmesg/dmesg_linux.go +++ b/pkg/dmesg/dmesg_linux.go @@ -1,17 +1,15 @@ package dmesg // import "github.com/docker/docker/pkg/dmesg" import ( - "unsafe" - "golang.org/x/sys/unix" ) // Dmesg returns last messages from the kernel log, up to size bytes func Dmesg(size int) []byte { - t := uintptr(3) // SYSLOG_ACTION_READ_ALL + t := 3 // SYSLOG_ACTION_READ_ALL b := make([]byte, size) - amt, _, err := unix.Syscall(unix.SYS_SYSLOG, t, uintptr(unsafe.Pointer(&b[0])), uintptr(len(b))) - if err != 0 { + amt, err := unix.Klogctl(t, b) + if err != nil { return []byte{} } return b[:amt]