Skip to content

Commit c7c5070

Browse files
authored
Merge pull request #121 from kolyshkin/xattr
sysx/xattr: unify implementation
2 parents 0377f7d + a408b7b commit c7c5070

153 files changed

Lines changed: 19255 additions & 7186 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

sysx/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This package is for internal use only. It is intended to only have
2+
temporary changes before they are upstreamed to golang.org/x/sys/
3+
(a.k.a. https://github.com/golang/sys).

sysx/asm.s

Lines changed: 0 additions & 10 deletions
This file was deleted.

sysx/sys.go

Lines changed: 0 additions & 37 deletions
This file was deleted.

sysx/xattr.go

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,56 @@
1+
// +build linux darwin
2+
13
package sysx
24

35
import (
46
"bytes"
5-
"fmt"
67
"syscall"
8+
9+
"golang.org/x/sys/unix"
710
)
811

9-
const defaultXattrBufferSize = 5
12+
// Listxattr calls syscall listxattr and reads all content
13+
// and returns a string array
14+
func Listxattr(path string) ([]string, error) {
15+
return listxattrAll(path, unix.Listxattr)
16+
}
17+
18+
// Removexattr calls syscall removexattr
19+
func Removexattr(path string, attr string) (err error) {
20+
return unix.Removexattr(path, attr)
21+
}
22+
23+
// Setxattr calls syscall setxattr
24+
func Setxattr(path string, attr string, data []byte, flags int) (err error) {
25+
return unix.Setxattr(path, attr, data, flags)
26+
}
27+
28+
// Getxattr calls syscall getxattr
29+
func Getxattr(path, attr string) ([]byte, error) {
30+
return getxattrAll(path, attr, unix.Getxattr)
31+
}
1032

11-
var ErrNotSupported = fmt.Errorf("not supported")
33+
// LListxattr lists xattrs, not following symlinks
34+
func LListxattr(path string) ([]string, error) {
35+
return listxattrAll(path, unix.Llistxattr)
36+
}
37+
38+
// LRemovexattr removes an xattr, not following symlinks
39+
func LRemovexattr(path string, attr string) (err error) {
40+
return unix.Lremovexattr(path, attr)
41+
}
42+
43+
// LSetxattr sets an xattr, not following symlinks
44+
func LSetxattr(path string, attr string, data []byte, flags int) (err error) {
45+
return unix.Lsetxattr(path, attr, data, flags)
46+
}
47+
48+
// LGetxattr gets an xattr, not following symlinks
49+
func LGetxattr(path, attr string) ([]byte, error) {
50+
return getxattrAll(path, attr, unix.Lgetxattr)
51+
}
52+
53+
const defaultXattrBufferSize = 5
1254

1355
type listxattrFunc func(path string, dest []byte) (int, error)
1456

sysx/xattr_darwin.go

Lines changed: 0 additions & 70 deletions
This file was deleted.

sysx/xattr_darwin_386.go

Lines changed: 0 additions & 111 deletions
This file was deleted.

0 commit comments

Comments
 (0)