2016-05-06 18:03:01 +08:00
|
|
|
// +build freebsd darwin
|
|
|
|
|
2018-02-05 16:05:59 -05:00
|
|
|
package operatingsystem // import "github.com/docker/docker/pkg/parsers/operatingsystem"
|
2015-07-29 21:25:56 +03:00
|
|
|
|
|
|
|
import (
|
2019-09-02 15:56:46 +02:00
|
|
|
"bytes"
|
2015-07-29 21:25:56 +03:00
|
|
|
"errors"
|
2019-09-02 15:56:46 +02:00
|
|
|
|
|
|
|
"golang.org/x/sys/unix"
|
2015-07-29 21:25:56 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
// GetOperatingSystem gets the name of the current operating system.
|
|
|
|
func GetOperatingSystem() (string, error) {
|
2019-09-02 15:56:46 +02:00
|
|
|
utsname := &unix.Utsname{}
|
|
|
|
if err := unix.Uname(utsname); err != nil {
|
2016-05-06 18:03:01 +08:00
|
|
|
return "", err
|
|
|
|
}
|
2019-09-02 15:56:46 +02:00
|
|
|
return string(utsname.Machine[:bytes.IndexByte(utsname.Sysname[:], 0)]), nil
|
2015-07-29 21:25:56 +03:00
|
|
|
}
|
|
|
|
|
2019-05-30 09:51:41 -07:00
|
|
|
// GetOperatingSystemVersion gets the version of the current operating system, as a string.
|
|
|
|
func GetOperatingSystemVersion() (string, error) {
|
|
|
|
// there's no standard unix way of getting this, sadly...
|
2019-08-29 18:43:07 +02:00
|
|
|
return "", errors.New("Unsupported on generic unix")
|
2019-05-30 09:51:41 -07:00
|
|
|
}
|
|
|
|
|
2015-07-29 21:25:56 +03:00
|
|
|
// IsContainerized returns true if we are running inside a container.
|
2016-05-06 18:03:01 +08:00
|
|
|
// No-op on FreeBSD and Darwin, always returns false.
|
2015-07-29 21:25:56 +03:00
|
|
|
func IsContainerized() (bool, error) {
|
2016-05-06 18:03:01 +08:00
|
|
|
// TODO: Implement jail detection for freeBSD
|
2015-07-29 21:25:56 +03:00
|
|
|
return false, errors.New("Cannot detect if we are in container")
|
|
|
|
}
|