operatingsystem_unix.go 1004 B

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