From 03f9eee2d00b8d67c6986a20ff76c79fedb77fbc Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Fri, 4 Aug 2017 06:23:44 +0000 Subject: [PATCH] Fix windows build Signed-off-by: Akihiro Suda --- cache/contenthash/filehash.go | 16 +--------------- cache/contenthash/filehash_unix.go | 18 +++++++++++++++++- cache/contenthash/filehash_windows.go | 3 ++- worker/oci/spec_unix.go | 2 ++ 4 files changed, 22 insertions(+), 17 deletions(-) diff --git a/cache/contenthash/filehash.go b/cache/contenthash/filehash.go index 7dbebde0..f62ef31c 100644 --- a/cache/contenthash/filehash.go +++ b/cache/contenthash/filehash.go @@ -8,7 +8,6 @@ import ( "path/filepath" "time" - "github.com/stevvooe/continuity/sysx" "github.com/tonistiigi/fsutil" ) @@ -30,22 +29,9 @@ func NewFileHash(path string, fi os.FileInfo) (hash.Hash, error) { Linkname: link, } - setUnixOpt(fi, stat) - - attrs, err := sysx.LListxattr(path) - if err != nil { + if err := setUnixOpt(path, fi, stat); err != nil { return nil, err } - if len(attrs) > 0 { - stat.Xattrs = map[string][]byte{} - for _, attr := range attrs { - v, err := sysx.LGetxattr(path, attr) - if err == nil { - stat.Xattrs[attr] = v - } - } - } - return NewFromStat(stat) } diff --git a/cache/contenthash/filehash_unix.go b/cache/contenthash/filehash_unix.go index 7eb38f90..1bad164c 100644 --- a/cache/contenthash/filehash_unix.go +++ b/cache/contenthash/filehash_unix.go @@ -6,6 +6,7 @@ import ( "os" "syscall" + "github.com/stevvooe/continuity/sysx" "github.com/tonistiigi/fsutil" ) @@ -13,7 +14,7 @@ func chmodWindowsTarEntry(perm os.FileMode) os.FileMode { return perm } -func setUnixOpt(fi os.FileInfo, stat *fsutil.Stat) { +func setUnixOpt(path string, fi os.FileInfo, stat *fsutil.Stat) error { s := fi.Sys().(*syscall.Stat_t) stat.Uid = s.Uid @@ -26,6 +27,21 @@ func setUnixOpt(fi os.FileInfo, stat *fsutil.Stat) { stat.Devminor = int64(minor(uint64(s.Rdev))) } } + + attrs, err := sysx.LListxattr(path) + if err != nil { + return err + } + if len(attrs) > 0 { + stat.Xattrs = map[string][]byte{} + for _, attr := range attrs { + v, err := sysx.LGetxattr(path, attr) + if err == nil { + stat.Xattrs[attr] = v + } + } + } + return nil } func major(device uint64) uint64 { diff --git a/cache/contenthash/filehash_windows.go b/cache/contenthash/filehash_windows.go index fb3dc56e..340954aa 100644 --- a/cache/contenthash/filehash_windows.go +++ b/cache/contenthash/filehash_windows.go @@ -18,5 +18,6 @@ func chmodWindowsTarEntry(perm os.FileMode) os.FileMode { return perm } -func setUnixOpt(fi os.FileInfo, stat *fsutil.Stat) { +func setUnixOpt(path string, fi os.FileInfo, stat *fsutil.Stat) error { + return nil } diff --git a/worker/oci/spec_unix.go b/worker/oci/spec_unix.go index 2d12d4df..735a7451 100644 --- a/worker/oci/spec_unix.go +++ b/worker/oci/spec_unix.go @@ -1,3 +1,5 @@ +// +build !windows + package oci import (