Some parts of pkg/archive is called on both client/daemon code. To get
it compiling on Windows, these funcs are extracted into files with
build tags.
Signed-off-by: Ahmet Alp Balkan <ahmetb@microsoft.com>
| ... | ... |
@@ -291,7 +291,7 @@ func createTarFile(path, extractDir string, hdr *tar.Header, reader io.Reader, L |
| 291 | 291 |
mode |= syscall.S_IFIFO |
| 292 | 292 |
} |
| 293 | 293 |
|
| 294 |
- if err := syscall.Mknod(path, mode, int(mkdev(hdr.Devmajor, hdr.Devminor))); err != nil {
|
|
| 294 |
+ if err := syscall.Mknod(path, mode, int(system.Mkdev(hdr.Devmajor, hdr.Devminor))); err != nil {
|
|
| 295 | 295 |
return err |
| 296 | 296 |
} |
| 297 | 297 |
|
| ... | ... |
@@ -269,6 +269,14 @@ func newRootFileInfo() *FileInfo {
|
| 269 | 269 |
return root |
| 270 | 270 |
} |
| 271 | 271 |
|
| 272 |
+func lstat(path string) (*stat, error) {
|
|
| 273 |
+ s, err := system.Lstat(path) |
|
| 274 |
+ if err != nil {
|
|
| 275 |
+ return nil, err |
|
| 276 |
+ } |
|
| 277 |
+ return fromStatT(s), nil |
|
| 278 |
+} |
|
| 279 |
+ |
|
| 272 | 280 |
func collectFileInfo(sourceDir string) (*FileInfo, error) {
|
| 273 | 281 |
root := newRootFileInfo() |
| 274 | 282 |
|
| ... | ... |
@@ -299,9 +307,11 @@ func collectFileInfo(sourceDir string) (*FileInfo, error) {
|
| 299 | 299 |
parent: parent, |
| 300 | 300 |
} |
| 301 | 301 |
|
| 302 |
- if err := syscall.Lstat(path, &info.stat); err != nil {
|
|
| 302 |
+ s, err := lstat(path) |
|
| 303 |
+ if err != nil {
|
|
| 303 | 304 |
return err |
| 304 | 305 |
} |
| 306 |
+ info.stat = s |
|
| 305 | 307 |
|
| 306 | 308 |
info.capability, _ = system.Lgetxattr(path, "security.capability") |
| 307 | 309 |
|
| ... | ... |
@@ -14,13 +14,6 @@ import ( |
| 14 | 14 |
"github.com/docker/docker/pkg/pools" |
| 15 | 15 |
) |
| 16 | 16 |
|
| 17 |
-// Linux device nodes are a bit weird due to backwards compat with 16 bit device nodes. |
|
| 18 |
-// They are, from low to high: the lower 8 bits of the minor, then 12 bits of the major, |
|
| 19 |
-// then the top 12 bits of the minor |
|
| 20 |
-func mkdev(major int64, minor int64) uint32 {
|
|
| 21 |
- return uint32(((minor & 0xfff00) << 12) | ((major & 0xfff) << 8) | (minor & 0xff)) |
|
| 22 |
-} |
|
| 23 |
- |
|
| 24 | 17 |
// ApplyLayer parses a diff in the standard layer format from `layer`, and |
| 25 | 18 |
// applies it to the directory `dest`. |
| 26 | 19 |
func ApplyLayer(dest string, layer ArchiveReader) error {
|
| 27 | 20 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,16 @@ |
| 0 |
+// +build !windows |
|
| 1 |
+ |
|
| 2 |
+package system |
|
| 3 |
+ |
|
| 4 |
+import ( |
|
| 5 |
+ "syscall" |
|
| 6 |
+) |
|
| 7 |
+ |
|
| 8 |
+func Lstat(path string) (*syscall.Stat_t, error) {
|
|
| 9 |
+ s := &syscall.Stat_t{}
|
|
| 10 |
+ err := syscall.Lstat(path, s) |
|
| 11 |
+ if err != nil {
|
|
| 12 |
+ return nil, err |
|
| 13 |
+ } |
|
| 14 |
+ return s, nil |
|
| 15 |
+} |
| 0 | 12 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,18 @@ |
| 0 |
+// +build !windows |
|
| 1 |
+ |
|
| 2 |
+package system |
|
| 3 |
+ |
|
| 4 |
+import ( |
|
| 5 |
+ "syscall" |
|
| 6 |
+) |
|
| 7 |
+ |
|
| 8 |
+func Mknod(path string, mode uint32, dev int) error {
|
|
| 9 |
+ return syscall.Mknod(path, mode, dev) |
|
| 10 |
+} |
|
| 11 |
+ |
|
| 12 |
+// Linux device nodes are a bit weird due to backwards compat with 16 bit device nodes. |
|
| 13 |
+// They are, from low to high: the lower 8 bits of the minor, then 12 bits of the major, |
|
| 14 |
+// then the top 12 bits of the minor |
|
| 15 |
+func Mkdev(major int64, minor int64) uint32 {
|
|
| 16 |
+ return uint32(((minor & 0xfff00) << 12) | ((major & 0xfff) << 8) | (minor & 0xff)) |
|
| 17 |
+} |
| 0 | 18 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,12 @@ |
| 0 |
+// +build windows |
|
| 1 |
+ |
|
| 2 |
+package system |
|
| 3 |
+ |
|
| 4 |
+func Mknod(path string, mode uint32, dev int) error {
|
|
| 5 |
+ // should not be called on cli code path |
|
| 6 |
+ return ErrNotSupportedPlatform |
|
| 7 |
+} |
|
| 8 |
+ |
|
| 9 |
+func Mkdev(major int64, minor int64) uint32 {
|
|
| 10 |
+ panic("Mkdev not implemented on windows, should not be called on cli code")
|
|
| 11 |
+} |