archive_windows.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package archive // import "github.com/docker/docker/pkg/archive"
  2. import (
  3. "archive/tar"
  4. "os"
  5. "path/filepath"
  6. "github.com/docker/docker/pkg/idtools"
  7. "github.com/docker/docker/pkg/longpath"
  8. )
  9. // fixVolumePathPrefix does platform specific processing to ensure that if
  10. // the path being passed in is not in a volume path format, convert it to one.
  11. func fixVolumePathPrefix(srcPath string) string {
  12. return longpath.AddPrefix(srcPath)
  13. }
  14. // getWalkRoot calculates the root path when performing a TarWithOptions.
  15. // We use a separate function as this is platform specific.
  16. func getWalkRoot(srcPath string, include string) string {
  17. return filepath.Join(srcPath, include)
  18. }
  19. // chmodTarEntry is used to adjust the file permissions used in tar header based
  20. // on the platform the archival is done.
  21. func chmodTarEntry(perm os.FileMode) os.FileMode {
  22. // Remove group- and world-writable bits.
  23. perm &= 0o755
  24. // Add the x bit: make everything +x on Windows
  25. return perm | 0o111
  26. }
  27. func setHeaderForSpecialDevice(hdr *tar.Header, name string, stat interface{}) (err error) {
  28. // do nothing. no notion of Rdev, Nlink in stat on Windows
  29. return
  30. }
  31. func getInodeFromStat(stat interface{}) (inode uint64, err error) {
  32. // do nothing. no notion of Inode in stat on Windows
  33. return
  34. }
  35. // handleTarTypeBlockCharFifo is an OS-specific helper function used by
  36. // createTarFile to handle the following types of header: Block; Char; Fifo
  37. func handleTarTypeBlockCharFifo(hdr *tar.Header, path string) error {
  38. return nil
  39. }
  40. func handleLChmod(hdr *tar.Header, path string, hdrInfo os.FileInfo) error {
  41. return nil
  42. }
  43. func getFileUIDGID(stat interface{}) (idtools.Identity, error) {
  44. // no notion of file ownership mapping yet on Windows
  45. return idtools.Identity{UID: 0, GID: 0}, nil
  46. }