mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-10-23 06:20:48 +02:00
fuse integration: add POSIX compliance test suite
Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
e645449872
commit
5fa30f6d4e
27 files changed
+5562
No files matched your search
@@ -0,0 +1,115 @@
|
||||
//go:build linux
|
||||
|
||||
package fuse
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// Extended attributes support for Linux
|
||||
|
||||
func setXattr(path, name string, value []byte, flags int) error {
|
||||
pathBytes, err := syscall.BytePtrFromString(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
nameBytes, err := syscall.BytePtrFromString(name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var valuePtr unsafe.Pointer
|
||||
if len(value) > 0 {
|
||||
valuePtr = unsafe.Pointer(&value[0])
|
||||
}
|
||||
|
||||
_, _, errno := syscall.Syscall6(syscall.SYS_SETXATTR,
|
||||
uintptr(unsafe.Pointer(pathBytes)),
|
||||
uintptr(unsafe.Pointer(nameBytes)),
|
||||
uintptr(valuePtr),
|
||||
uintptr(len(value)),
|
||||
uintptr(flags),
|
||||
0)
|
||||
|
||||
if errno != 0 {
|
||||
return errno
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func getXattr(path, name string, value []byte) (int, error) {
|
||||
pathBytes, err := syscall.BytePtrFromString(path)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
nameBytes, err := syscall.BytePtrFromString(name)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
var valuePtr unsafe.Pointer
|
||||
if len(value) > 0 {
|
||||
valuePtr = unsafe.Pointer(&value[0])
|
||||
}
|
||||
|
||||
size, _, errno := syscall.Syscall6(syscall.SYS_GETXATTR,
|
||||
uintptr(unsafe.Pointer(pathBytes)),
|
||||
uintptr(unsafe.Pointer(nameBytes)),
|
||||
uintptr(valuePtr),
|
||||
uintptr(len(value)),
|
||||
0,
|
||||
0)
|
||||
|
||||
if errno != 0 {
|
||||
return 0, errno
|
||||
}
|
||||
return int(size), nil
|
||||
}
|
||||
|
||||
func listXattr(path string, list []byte) (int, error) {
|
||||
pathBytes, err := syscall.BytePtrFromString(path)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
var listPtr unsafe.Pointer
|
||||
if len(list) > 0 {
|
||||
listPtr = unsafe.Pointer(&list[0])
|
||||
}
|
||||
|
||||
size, _, errno := syscall.Syscall(syscall.SYS_LISTXATTR,
|
||||
uintptr(unsafe.Pointer(pathBytes)),
|
||||
uintptr(listPtr),
|
||||
uintptr(len(list)))
|
||||
|
||||
if errno != 0 {
|
||||
return 0, errno
|
||||
}
|
||||
return int(size), nil
|
||||
}
|
||||
|
||||
func removeXattr(path, name string) error {
|
||||
pathBytes, err := syscall.BytePtrFromString(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
nameBytes, err := syscall.BytePtrFromString(name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, _, errno := syscall.Syscall(syscall.SYS_REMOVEXATTR,
|
||||
uintptr(unsafe.Pointer(pathBytes)),
|
||||
uintptr(unsafe.Pointer(nameBytes)),
|
||||
0)
|
||||
|
||||
if errno != 0 {
|
||||
return errno
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func isXattrSupported() bool {
|
||||
return true
|
||||
}
|
||||
Reference in new issue
Block a user