package sborepo

import "syscall"

// KernelVersion returns the kernel version as a string.
// It is only tested on Linux and panics if the syscall fails.
func KernelVersion() string {
	var (
		uname syscall.Utsname
		i     int
		s     [65]byte
	)
	if err := unameFunc(&uname); err != nil {
		panic(err)
	}
	for ; uname.Release[i] != 0; i++ {
		s[i] = byte(uname.Release[i])
	}
	return string(s[:i])
}

// To be overridden in tests.
var unameFunc = syscall.Uname
