Fix windows build

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
docker-18.09
Akihiro Suda 2017-08-04 06:23:44 +00:00
parent 0752bd3c78
commit 03f9eee2d0
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 (