github.com/kaisenlinux/docker.io@v0.0.0-20230510090727-ea55db55fac7/engine/pkg/parsers/operatingsystem/operatingsystem_unix.go (about) 1 //go:build freebsd || darwin 2 // +build freebsd darwin 3 4 package operatingsystem // import "github.com/docker/docker/pkg/parsers/operatingsystem" 5 6 import ( 7 "bytes" 8 "errors" 9 10 "golang.org/x/sys/unix" 11 ) 12 13 // GetOperatingSystem gets the name of the current operating system. 14 func GetOperatingSystem() (string, error) { 15 utsname := &unix.Utsname{} 16 if err := unix.Uname(utsname); err != nil { 17 return "", err 18 } 19 return string(utsname.Machine[:bytes.IndexByte(utsname.Sysname[:], 0)]), nil 20 } 21 22 // GetOperatingSystemVersion gets the version of the current operating system, as a string. 23 func GetOperatingSystemVersion() (string, error) { 24 // there's no standard unix way of getting this, sadly... 25 return "", errors.New("Unsupported on generic unix") 26 } 27 28 // IsContainerized returns true if we are running inside a container. 29 // No-op on FreeBSD and Darwin, always returns false. 30 func IsContainerized() (bool, error) { 31 // TODO: Implement jail detection for freeBSD 32 return false, errors.New("Cannot detect if we are in container") 33 }