mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
6e5894b551
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
30 lines
617 B
Go
30 lines
617 B
Go
// +build linux freebsd solaris
|
|
|
|
// Package kernel provides helper function to get, parse and compare kernel
|
|
// versions for different platforms.
|
|
package kernel
|
|
|
|
import (
|
|
"bytes"
|
|
)
|
|
|
|
// GetKernelVersion gets the current kernel version.
|
|
func GetKernelVersion() (*VersionInfo, error) {
|
|
uts, err := uname()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
release := make([]byte, len(uts.Release))
|
|
|
|
i := 0
|
|
for _, c := range uts.Release {
|
|
release[i] = byte(c)
|
|
i++
|
|
}
|
|
|
|
// Remove the \x00 from the release for Atoi to parse correctly
|
|
release = release[:bytes.IndexByte(release, 0)]
|
|
|
|
return ParseRelease(string(release))
|
|
}
|