Skip to content

Commit 805ccd2

Browse files
committed
pkg/dmesg: deprecate, and use internal utility instead
This package was originally added in 46833ee for use in the devicemapper graphdriver. The devicemapper graphdriver was deprecated and has been removed. The only remaining consumer is an integration test. Deprecate the package and mark it for removal in the next release. Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent c7f4abc commit 805ccd2

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

integration/container/overlayfs_linux_test.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
containertypes "github.com/docker/docker/api/types/container"
99
"github.com/docker/docker/integration/internal/container"
1010
"github.com/docker/docker/pkg/archive"
11-
"github.com/docker/docker/pkg/dmesg"
11+
"golang.org/x/sys/unix"
1212
"gotest.tools/v3/assert"
1313
"gotest.tools/v3/skip"
1414
)
@@ -81,9 +81,15 @@ func TestNoOverlayfsWarningsAboutUndefinedBehaviors(t *testing.T) {
8181
}
8282
}
8383

84-
func dmesgLines(bytes int) []string {
85-
data := dmesg.Dmesg(bytes)
86-
return strings.Split(strings.TrimSpace(string(data)), "\n")
84+
// dmesgLines returns last messages from the kernel log, up to size bytes,
85+
// and splits the output by newlines.
86+
func dmesgLines(size int) []string {
87+
data := make([]byte, size)
88+
amt, err := unix.Klogctl(unix.SYSLOG_ACTION_READ_ALL, data)
89+
if err != nil {
90+
return []string{}
91+
}
92+
return strings.Split(strings.TrimSpace(string(data[:amt])), "\n")
8793
}
8894

8995
func diffDmesg(prev, next []string) []string {

pkg/dmesg/dmesg_linux.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import (
44
"golang.org/x/sys/unix"
55
)
66

7-
// Dmesg returns last messages from the kernel log, up to size bytes
7+
// Dmesg returns last messages from the kernel log, up to size bytes.
8+
//
9+
// Deprecated: the dmesg package is no longer used, and will be removed in the next release.
810
func Dmesg(size int) []byte {
911
b := make([]byte, size)
1012
amt, err := unix.Klogctl(unix.SYSLOG_ACTION_READ_ALL, b)

0 commit comments

Comments
 (0)