stat_unix.go 716 B

123456789101112131415161718192021222324252627282930313233
  1. // Copyright 2012 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // +build linux darwin dragonfly freebsd openbsd netbsd solaris
  5. package tar
  6. import (
  7. "os"
  8. "syscall"
  9. )
  10. func init() {
  11. sysStat = statUnix
  12. }
  13. func statUnix(fi os.FileInfo, h *Header) error {
  14. sys, ok := fi.Sys().(*syscall.Stat_t)
  15. if !ok {
  16. return nil
  17. }
  18. h.Uid = int(sys.Uid)
  19. h.Gid = int(sys.Gid)
  20. // TODO(bradfitz): populate username & group. os/user
  21. // doesn't cache LookupId lookups, and lacks group
  22. // lookup functions.
  23. h.AccessTime = statAtime(sys)
  24. h.ChangeTime = statCtime(sys)
  25. // TODO(bradfitz): major/minor device numbers?
  26. return nil
  27. }