getKernelVersion gets the current kernel version.
()
| 51 | |
| 52 | // getKernelVersion gets the current kernel version. |
| 53 | func getKernelVersion() (*KernelVersion, error) { |
| 54 | once.Do(func() { |
| 55 | var uts unix.Utsname |
| 56 | if err := unix.Uname(&uts); err != nil { |
| 57 | return |
| 58 | } |
| 59 | // Remove the \x00 from the release for Atoi to parse correctly |
| 60 | currentKernelVersion, kernelVersionError = parseRelease(string(uts.Release[:bytes.IndexByte(uts.Release[:], 0)])) |
| 61 | }) |
| 62 | return currentKernelVersion, kernelVersionError |
| 63 | } |
| 64 | |
| 65 | // parseRelease parses a string and creates a KernelVersion based on it. |
| 66 | func parseRelease(release string) (*KernelVersion, error) { |
searching dependent graphs…