forked from davecheney/xattr
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsyscall_linux.go
43 lines (37 loc) · 1.37 KB
/
syscall_linux.go
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
41
42
43
package xattr
import (
"syscall"
"unsafe"
)
func getxattr(path string, name string, value *byte, size int) (int, error) {
r0, _, e1 := syscall.Syscall6(syscall.SYS_GETXATTR, uintptr(unsafe.Pointer(syscall.StringBytePtr(path))), uintptr(unsafe.Pointer(syscall.StringBytePtr(name))), uintptr(unsafe.Pointer(value)), uintptr(size), 0, 0)
var err error = nil
if e1 != 0 {
err = e1
}
return int(r0), err
}
func listxattr(path string, namebuf *byte, size int) (int, error) {
r0, _, e1 := syscall.Syscall(syscall.SYS_LISTXATTR, uintptr(unsafe.Pointer(syscall.StringBytePtr(path))), uintptr(unsafe.Pointer(namebuf)), uintptr(size))
var err error = nil
if e1 != 0 {
err = e1
}
return int(r0), e1
}
func setxattr(path string, name string, value *byte, size int) (err error) {
_, _, e1 := syscall.Syscall6(syscall.SYS_SETXATTR, uintptr(unsafe.Pointer(syscall.StringBytePtr(path))), uintptr(unsafe.Pointer(syscall.StringBytePtr(name))), uintptr(unsafe.Pointer(value)), uintptr(size), 0, 0)
var err error = nil
if e1 != 0 {
err = e1
}
return e1
}
func removexattr(path string, name string) (err error) {
_, _, e1 := syscall.Syscall(syscall.SYS_REMOVEXATTR, uintptr(unsafe.Pointer(syscall.StringBytePtr(path))), uintptr(unsafe.Pointer(syscall.StringBytePtr(name))), 0)
var err error = nil
if e1 != 0 {
err = e1
}
return e1
}