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"
"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)
}

View File

@ -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 {

View File

@ -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
}

View File

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