Merge pull request #93 from AkihiroSuda/windows-build

Fix windows build
docker-18.09
Tõnis Tiigi 2017-08-03 23:52:29 -07:00 committed by GitHub
commit fcf2aab63e
4 changed files with 22 additions and 17 deletions

View File

@ -8,7 +8,6 @@ import (
"path/filepath" "path/filepath"
"time" "time"
"github.com/stevvooe/continuity/sysx"
"github.com/tonistiigi/fsutil" "github.com/tonistiigi/fsutil"
) )
@ -30,22 +29,9 @@ func NewFileHash(path string, fi os.FileInfo) (hash.Hash, error) {
Linkname: link, Linkname: link,
} }
setUnixOpt(fi, stat) if err := setUnixOpt(path, fi, stat); err != nil {
attrs, err := sysx.LListxattr(path)
if err != nil {
return nil, err 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) return NewFromStat(stat)
} }

View File

@ -6,6 +6,7 @@ import (
"os" "os"
"syscall" "syscall"
"github.com/stevvooe/continuity/sysx"
"github.com/tonistiigi/fsutil" "github.com/tonistiigi/fsutil"
) )
@ -13,7 +14,7 @@ func chmodWindowsTarEntry(perm os.FileMode) os.FileMode {
return perm 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) s := fi.Sys().(*syscall.Stat_t)
stat.Uid = s.Uid stat.Uid = s.Uid
@ -26,6 +27,21 @@ func setUnixOpt(fi os.FileInfo, stat *fsutil.Stat) {
stat.Devminor = int64(minor(uint64(s.Rdev))) 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 { func major(device uint64) uint64 {

View File

@ -18,5 +18,6 @@ func chmodWindowsTarEntry(perm os.FileMode) os.FileMode {
return perm return perm
} }
func setUnixOpt(fi os.FileInfo, stat *fsutil.Stat) { func setUnixOpt(path string, fi os.FileInfo, stat *fsutil.Stat) error {
return nil
} }

View File

@ -1,3 +1,5 @@
// +build !windows
package oci package oci
import ( import (