operatingsystem_unix.go 997 B

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