Skip to content

Commit

Permalink
sysx: use xattr functions from x/sys/unix
Browse files Browse the repository at this point in the history
Use the xattr functions from package golang.org/x/sys/unix instead of
syscall. Also use its L*xattr functions instead of locally duplicating
them.

Signed-off-by: Tobias Klauser <[email protected]>
  • Loading branch information
tklauser committed Feb 23, 2018
1 parent d8fb858 commit 6268e28
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 803 deletions.
35 changes: 9 additions & 26 deletions sysx/xattr_linux.go
Original file line number Diff line number Diff line change
@@ -1,61 +1,44 @@
package sysx

import "syscall"

// These functions will be generated by generate.sh
// $ GOOS=linux GOARCH=386 ./generate.sh xattr
// $ GOOS=linux GOARCH=amd64 ./generate.sh xattr
// $ GOOS=linux GOARCH=arm ./generate.sh xattr
// $ GOOS=linux GOARCH=arm64 ./generate.sh xattr
// $ GOOS=linux GOARCH=ppc64 ./generate.sh xattr
// $ GOOS=linux GOARCH=ppc64le ./generate.sh xattr
// $ GOOS=linux GOARCH=s390x ./generate.sh xattr
import "golang.org/x/sys/unix"

// Listxattr calls syscall listxattr and reads all content
// and returns a string array
func Listxattr(path string) ([]string, error) {
return listxattrAll(path, syscall.Listxattr)
return listxattrAll(path, unix.Listxattr)
}

// Removexattr calls syscall removexattr
func Removexattr(path string, attr string) (err error) {
return syscall.Removexattr(path, attr)
return unix.Removexattr(path, attr)
}

// Setxattr calls syscall setxattr
func Setxattr(path string, attr string, data []byte, flags int) (err error) {
return syscall.Setxattr(path, attr, data, flags)
return unix.Setxattr(path, attr, data, flags)
}

// Getxattr calls syscall getxattr
func Getxattr(path, attr string) ([]byte, error) {
return getxattrAll(path, attr, syscall.Getxattr)
return getxattrAll(path, attr, unix.Getxattr)
}

//sys llistxattr(path string, dest []byte) (sz int, err error)

// LListxattr lists xattrs, not following symlinks
func LListxattr(path string) ([]string, error) {
return listxattrAll(path, llistxattr)
return listxattrAll(path, unix.Llistxattr)
}

//sys lremovexattr(path string, attr string) (err error)

// LRemovexattr removes an xattr, not following symlinks
func LRemovexattr(path string, attr string) (err error) {
return lremovexattr(path, attr)
return unix.Lremovexattr(path, attr)
}

//sys lsetxattr(path string, attr string, data []byte, flags int) (err error)

// LSetxattr sets an xattr, not following symlinks
func LSetxattr(path string, attr string, data []byte, flags int) (err error) {
return lsetxattr(path, attr, data, flags)
return unix.Lsetxattr(path, attr, data, flags)
}

//sys lgetxattr(path string, attr string, dest []byte) (sz int, err error)

// LGetxattr gets an xattr, not following symlinks
func LGetxattr(path, attr string) ([]byte, error) {
return getxattrAll(path, attr, lgetxattr)
return getxattrAll(path, attr, unix.Lgetxattr)
}
111 changes: 0 additions & 111 deletions sysx/xattr_linux_386.go

This file was deleted.

111 changes: 0 additions & 111 deletions sysx/xattr_linux_amd64.go

This file was deleted.

Loading

0 comments on commit 6268e28

Please sign in to comment.