operatingsystem_unix.go 970 B

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