2017-07-27 21:46:51 +00:00
|
|
|
// +build !windows
|
|
|
|
|
|
|
|
package contenthash
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"syscall"
|
|
|
|
|
2017-09-30 15:41:33 +00:00
|
|
|
"github.com/containerd/continuity/sysx"
|
2018-10-01 11:16:48 +00:00
|
|
|
fstypes "github.com/tonistiigi/fsutil/types"
|
2017-11-27 10:15:06 +00:00
|
|
|
|
|
|
|
"golang.org/x/sys/unix"
|
2017-07-27 21:46:51 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func chmodWindowsTarEntry(perm os.FileMode) os.FileMode {
|
|
|
|
return perm
|
|
|
|
}
|
|
|
|
|
2018-10-01 11:16:48 +00:00
|
|
|
func setUnixOpt(path string, fi os.FileInfo, stat *fstypes.Stat) error {
|
2017-07-27 21:46:51 +00:00
|
|
|
s := fi.Sys().(*syscall.Stat_t)
|
|
|
|
|
|
|
|
stat.Uid = s.Uid
|
|
|
|
stat.Gid = s.Gid
|
|
|
|
|
|
|
|
if !fi.IsDir() {
|
|
|
|
if s.Mode&syscall.S_IFBLK != 0 ||
|
|
|
|
s.Mode&syscall.S_IFCHR != 0 {
|
2017-11-27 10:15:06 +00:00
|
|
|
stat.Devmajor = int64(unix.Major(uint64(s.Rdev)))
|
|
|
|
stat.Devminor = int64(unix.Minor(uint64(s.Rdev)))
|
2017-07-27 21:46:51 +00:00
|
|
|
}
|
|
|
|
}
|
2017-08-04 06:23:44 +00:00
|
|
|
|
|
|
|
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
|
2017-07-27 21:46:51 +00:00
|
|
|
}
|