mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
e3c130df94
removes the stevvooe/continuity dependency, which has moved to containerd/continuity. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
61 lines
1.2 KiB
Go
61 lines
1.2 KiB
Go
// +build !windows
|
|
|
|
package fsutil
|
|
|
|
import (
|
|
"os"
|
|
"syscall"
|
|
|
|
"github.com/containerd/continuity/sysx"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
func loadXattr(origpath string, stat *Stat) error {
|
|
xattrs, err := sysx.LListxattr(origpath)
|
|
if err != nil {
|
|
return errors.Wrapf(err, "failed to xattr %s", origpath)
|
|
}
|
|
if len(xattrs) > 0 {
|
|
m := make(map[string][]byte)
|
|
for _, key := range xattrs {
|
|
v, err := sysx.LGetxattr(origpath, key)
|
|
if err == nil {
|
|
m[key] = v
|
|
}
|
|
}
|
|
stat.Xattrs = m
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func setUnixOpt(fi os.FileInfo, stat *Stat, path string, seenFiles map[uint64]string) {
|
|
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 {
|
|
stat.Devmajor = int64(major(uint64(s.Rdev)))
|
|
stat.Devminor = int64(minor(uint64(s.Rdev)))
|
|
}
|
|
|
|
ino := s.Ino
|
|
if s.Nlink > 1 {
|
|
if oldpath, ok := seenFiles[ino]; ok {
|
|
stat.Linkname = oldpath
|
|
stat.Size_ = 0
|
|
}
|
|
}
|
|
seenFiles[ino] = path
|
|
}
|
|
}
|
|
|
|
func major(device uint64) uint64 {
|
|
return (device >> 8) & 0xfff
|
|
}
|
|
|
|
func minor(device uint64) uint64 {
|
|
return (device & 0xff) | ((device >> 12) & 0xfff00)
|
|
}
|