-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsys_posix.go
More file actions
40 lines (35 loc) · 755 Bytes
/
sys_posix.go
File metadata and controls
40 lines (35 loc) · 755 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// +build linux darwin freebsd netbsd solaris
package xsum
import (
"github.com/pkg/xattr"
"github.com/sclevine/xsum/encoding"
)
func getXattr(path string, hash Hash, follow bool) ([]encoding.NamedHash, error) {
xlist, xget := xattr.List, xattr.Get
if !follow {
xlist, xget = xattr.LList, xattr.LGet
}
attrs, err := xlist(path)
if err != nil {
return nil, err
}
var hashes []encoding.NamedHash
for _, attr := range attrs {
val, err := xget(path, attr)
if err != nil {
return nil, err
}
valSum, err := hash.Metadata(val)
if err != nil {
return nil, err
}
hashes = append(hashes, encoding.NamedHash{
Hash: valSum,
Name: []byte(attr),
})
}
return hashes, nil
}
func validateMask(_ Mask) error {
return nil
}