Commit 27ecdf3b authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

fuse/pathfs: inline xattr calls for gccgo.

parent 82e5e42f
...@@ -32,7 +32,7 @@ func (fs *loopbackFileSystem) ListXAttr(name string, context *fuse.Context) ([]s ...@@ -32,7 +32,7 @@ func (fs *loopbackFileSystem) ListXAttr(name string, context *fuse.Context) ([]s
} }
func (fs *loopbackFileSystem) RemoveXAttr(name string, attr string, context *fuse.Context) fuse.Status { func (fs *loopbackFileSystem) RemoveXAttr(name string, attr string, context *fuse.Context) fuse.Status {
err := syscall.Removexattr(fs.GetPath(name), attr) err := sysRemovexattr(fs.GetPath(name), attr)
return fuse.ToStatus(err) return fuse.ToStatus(err)
} }
......
...@@ -3,13 +3,16 @@ package pathfs ...@@ -3,13 +3,16 @@ package pathfs
import ( import (
"bytes" "bytes"
"syscall" "syscall"
"unsafe"
) )
var _zero uintptr
func getXAttr(path string, attr string, dest []byte) (value []byte, err error) { func getXAttr(path string, attr string, dest []byte) (value []byte, err error) {
sz, err := syscall.Getxattr(path, attr, dest) sz, err := sysGetxattr(path, attr, dest)
for sz > cap(dest) && err == nil { for sz > cap(dest) && err == nil {
dest = make([]byte, sz) dest = make([]byte, sz)
sz, err = syscall.Getxattr(path, attr, dest) sz, err = sysGetxattr(path, attr, dest)
} }
if err != nil { if err != nil {
...@@ -21,14 +24,14 @@ func getXAttr(path string, attr string, dest []byte) (value []byte, err error) { ...@@ -21,14 +24,14 @@ func getXAttr(path string, attr string, dest []byte) (value []byte, err error) {
func listXAttr(path string) (attributes []string, err error) { func listXAttr(path string) (attributes []string, err error) {
dest := make([]byte, 0) dest := make([]byte, 0)
sz, err := syscall.Listxattr(path, dest) sz, err := sysListxattr(path, dest)
if err != nil { if err != nil {
return nil, err return nil, err
} }
for sz > cap(dest) && err == nil { for sz > cap(dest) && err == nil {
dest = make([]byte, sz) dest = make([]byte, sz)
sz, err = syscall.Listxattr(path, dest) sz, err = sysListxattr(path, dest)
} }
// -1 to drop the final empty slice. // -1 to drop the final empty slice.
...@@ -40,3 +43,68 @@ func listXAttr(path string) (attributes []string, err error) { ...@@ -40,3 +43,68 @@ func listXAttr(path string) (attributes []string, err error) {
} }
return attributes, err return attributes, err
} }
// Below is cut & paste from std lib syscall, so gccgo 4.8.1 can
// compile this too.
func sysGetxattr(path string, attr string, dest []byte) (sz int, err error) {
var _p0 *byte
_p0, err = syscall.BytePtrFromString(path)
if err != nil {
return
}
var _p1 *byte
_p1, err = syscall.BytePtrFromString(attr)
if err != nil {
return
}
var _p2 unsafe.Pointer
if len(dest) > 0 {
_p2 = unsafe.Pointer(&dest[0])
} else {
_p2 = unsafe.Pointer(&_zero)
}
r0, _, e1 := syscall.Syscall6(syscall.SYS_GETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(dest)), 0, 0)
sz = int(r0)
if e1 != 0 {
err = e1
}
return
}
func sysRemovexattr(path string, attr string) (err error) {
var _p0 *byte
_p0, err = syscall.BytePtrFromString(path)
if err != nil {
return
}
var _p1 *byte
_p1, err = syscall.BytePtrFromString(attr)
if err != nil {
return
}
_, _, e1 := syscall.Syscall(syscall.SYS_REMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
if e1 != 0 {
err = e1
}
return
}
func sysListxattr(path string, dest []byte) (sz int, err error) {
var _p0 *byte
_p0, err = syscall.BytePtrFromString(path)
if err != nil {
return
}
var _p1 unsafe.Pointer
if len(dest) > 0 {
_p1 = unsafe.Pointer(&dest[0])
} else {
_p1 = unsafe.Pointer(&_zero)
}
r0, _, e1 := syscall.Syscall(syscall.SYS_LISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(dest)))
sz = int(r0)
if e1 != 0 {
err = e1
}
return
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment