resource_unix.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // +build linux darwin freebsd solaris
  2. package continuity
  3. import (
  4. "fmt"
  5. "os"
  6. "syscall"
  7. )
  8. // newBaseResource returns a *resource, populated with data from p and fi,
  9. // where p will be populated directly.
  10. func newBaseResource(p string, fi os.FileInfo) (*resource, error) {
  11. // TODO(stevvooe): This need to be resolved for the container's root,
  12. // where here we are really getting the host OS's value. We need to allow
  13. // this be passed in and fixed up to make these uid/gid mappings portable.
  14. // Either this can be part of the driver or we can achieve it through some
  15. // other mechanism.
  16. sys, ok := fi.Sys().(*syscall.Stat_t)
  17. if !ok {
  18. // TODO(stevvooe): This may not be a hard error for all platforms. We
  19. // may want to move this to the driver.
  20. return nil, fmt.Errorf("unable to resolve syscall.Stat_t from (os.FileInfo).Sys(): %#v", fi)
  21. }
  22. return &resource{
  23. paths: []string{p},
  24. mode: fi.Mode(),
  25. uid: int64(sys.Uid),
  26. gid: int64(sys.Gid),
  27. // NOTE(stevvooe): Population of shared xattrs field is deferred to
  28. // the resource types that populate it. Since they are a property of
  29. // the context, they must set there.
  30. }, nil
  31. }