Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 1 addition & 15 deletions cache/contenthash/filehash.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"path/filepath"
"time"

"github.com/stevvooe/continuity/sysx"
"github.com/tonistiigi/fsutil"
)

Expand All @@ -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)
}

Expand Down
18 changes: 17 additions & 1 deletion cache/contenthash/filehash_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import (
"os"
"syscall"

"github.com/stevvooe/continuity/sysx"
"github.com/tonistiigi/fsutil"
)

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
Expand All @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion cache/contenthash/filehash_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 2 additions & 0 deletions worker/oci/spec_unix.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !windows

package oci

import (
Expand Down