operatingsystem_unix.go 932 B

12345678910111213141516171819202122232425262728293031
  1. // +build freebsd darwin
  2. package operatingsystem // import "github.com/docker/docker/pkg/parsers/operatingsystem"
  3. import (
  4. "errors"
  5. "os/exec"
  6. )
  7. // GetOperatingSystem gets the name of the current operating system.
  8. func GetOperatingSystem() (string, error) {
  9. cmd := exec.Command("uname", "-s")
  10. osName, err := cmd.Output()
  11. if err != nil {
  12. return "", err
  13. }
  14. return string(osName), 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. }