Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go-fuse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Levin Zimmermann
go-fuse
Commits
420b298b
Commit
420b298b
authored
Mar 08, 2019
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fuse/pathfs: remove obsolete copies of syscall code
parent
e028a29e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
88 deletions
+32
-88
fuse/pathfs/loopback_linux.go
fuse/pathfs/loopback_linux.go
+18
-7
fuse/pathfs/syscall_linux.go
fuse/pathfs/syscall_linux.go
+4
-73
fuse/pathfs/xattr_test.go
fuse/pathfs/xattr_test.go
+10
-8
No files found.
fuse/pathfs/loopback_linux.go
View file @
420b298b
...
...
@@ -13,13 +13,12 @@ import (
)
func
(
fs
*
loopbackFileSystem
)
ListXAttr
(
name
string
,
context
*
fuse
.
Context
)
([]
string
,
fuse
.
Status
)
{
data
,
err
:=
listXAttr
(
fs
.
GetPath
(
name
))
return
data
,
fuse
.
ToStatus
(
err
)
attrs
,
err
:=
listXAttr
(
fs
.
GetPath
(
name
))
return
attrs
,
fuse
.
ToStatus
(
err
)
}
func
(
fs
*
loopbackFileSystem
)
RemoveXAttr
(
name
string
,
attr
string
,
context
*
fuse
.
Context
)
fuse
.
Status
{
err
:=
sysRemovexattr
(
fs
.
GetPath
(
name
),
attr
)
err
:=
sys
call
.
Removexattr
(
fs
.
GetPath
(
name
),
attr
)
return
fuse
.
ToStatus
(
err
)
}
...
...
@@ -28,10 +27,22 @@ func (fs *loopbackFileSystem) String() string {
}
func
(
fs
*
loopbackFileSystem
)
GetXAttr
(
name
string
,
attr
string
,
context
*
fuse
.
Context
)
([]
byte
,
fuse
.
Status
)
{
data
:=
make
([]
byte
,
1024
)
data
,
err
:=
getXAttr
(
fs
.
GetPath
(
name
),
attr
,
data
)
return
data
,
fuse
.
ToStatus
(
err
)
bufsz
:=
1024
for
{
data
:=
make
([]
byte
,
bufsz
)
sz
,
err
:=
syscall
.
Getxattr
(
fs
.
GetPath
(
name
),
attr
,
data
)
if
err
==
nil
{
return
data
[
:
sz
],
fuse
.
OK
}
if
err
==
syscall
.
ERANGE
{
bufsz
=
sz
continue
}
return
nil
,
fuse
.
ToStatus
(
err
)
}
}
func
(
fs
*
loopbackFileSystem
)
SetXAttr
(
name
string
,
attr
string
,
data
[]
byte
,
flags
int
,
context
*
fuse
.
Context
)
fuse
.
Status
{
...
...
fuse/pathfs/syscall_linux.go
View file @
420b298b
...
...
@@ -13,10 +13,10 @@ import (
var
_zero
uintptr
func
getXAttr
(
path
string
,
attr
string
,
dest
[]
byte
)
(
value
[]
byte
,
err
error
)
{
sz
,
err
:=
sysGetxattr
(
path
,
attr
,
dest
)
sz
,
err
:=
sys
call
.
Getxattr
(
path
,
attr
,
dest
)
for
sz
>
cap
(
dest
)
&&
err
==
nil
{
dest
=
make
([]
byte
,
sz
)
sz
,
err
=
sysGetxattr
(
path
,
attr
,
dest
)
sz
,
err
=
sys
call
.
Getxattr
(
path
,
attr
,
dest
)
}
if
err
!=
nil
{
...
...
@@ -28,14 +28,14 @@ func getXAttr(path string, attr string, dest []byte) (value []byte, err error) {
func
listXAttr
(
path
string
)
(
attributes
[]
string
,
err
error
)
{
dest
:=
make
([]
byte
,
0
)
sz
,
err
:=
sysListxattr
(
path
,
dest
)
sz
,
err
:=
sys
call
.
Listxattr
(
path
,
dest
)
if
err
!=
nil
{
return
nil
,
err
}
for
sz
>
cap
(
dest
)
&&
err
==
nil
{
dest
=
make
([]
byte
,
sz
)
sz
,
err
=
sysListxattr
(
path
,
dest
)
sz
,
err
=
sys
call
.
Listxattr
(
path
,
dest
)
}
if
sz
==
0
{
...
...
@@ -52,75 +52,6 @@ func listXAttr(path string) (attributes []string, err error) {
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
}
func
sysSetxattr
(
path
string
,
attr
string
,
val
[]
byte
,
flag
int
)
error
{
return
syscall
.
Setxattr
(
path
,
attr
,
val
,
flag
)
}
const
_AT_SYMLINK_NOFOLLOW
=
0x100
// Linux kernel syscall utimensat(2)
...
...
fuse/pathfs/xattr_test.go
View file @
420b298b
...
...
@@ -10,6 +10,7 @@ import (
"bytes"
"os"
"path/filepath"
"syscall"
"testing"
"github.com/hanwen/go-fuse/fuse"
...
...
@@ -99,11 +100,6 @@ func (fs *XAttrTestFs) RemoveXAttr(name string, attr string, context *fuse.Conte
return
fuse
.
OK
}
func
readXAttr
(
p
,
a
string
)
(
val
[]
byte
,
err
error
)
{
val
=
make
([]
byte
,
1024
)
return
getXAttr
(
p
,
a
,
val
)
}
func
xattrTestCase
(
t
*
testing
.
T
,
nm
string
,
m
map
[
string
][]
byte
)
(
mountPoint
string
,
cleanup
func
())
{
xfs
:=
NewXAttrFs
(
nm
,
m
)
mountPoint
=
testutil
.
TempDir
()
...
...
@@ -138,6 +134,11 @@ func TestXAttrNoAttrs(t *testing.T) {
}
}
func
readXAttr
(
p
,
a
string
)
(
val
[]
byte
,
err
error
)
{
val
=
make
([]
byte
,
1024
)
return
getXAttr
(
p
,
a
,
val
)
}
func
TestXAttrNoExist
(
t
*
testing
.
T
)
{
nm
:=
xattrFilename
mountPoint
,
clean
:=
xattrTestCase
(
t
,
nm
,
xattrGolden
)
...
...
@@ -185,8 +186,7 @@ func TestXAttrRead(t *testing.T) {
}
}
err
=
sysSetxattr
(
mounted
,
"third"
,
[]
byte
(
"value"
),
0
)
if
err
!=
nil
{
if
err
=
syscall
.
Setxattr
(
mounted
,
"third"
,
[]
byte
(
"value"
),
0
);
err
!=
nil
{
t
.
Error
(
"Setxattr error"
,
err
)
}
val
,
err
:=
readXAttr
(
mounted
,
"third"
)
...
...
@@ -194,7 +194,9 @@ func TestXAttrRead(t *testing.T) {
t
.
Error
(
"Read back set xattr:"
,
err
,
string
(
val
))
}
sysRemovexattr
(
mounted
,
"third"
)
if
err
:=
syscall
.
Removexattr
(
mounted
,
"third"
);
err
!=
nil
{
t
.
Errorf
(
"Removexattr: %v"
,
err
)
}
val
,
err
=
readXAttr
(
mounted
,
"third"
)
if
fuse
.
ToStatus
(
err
)
!=
fuse
.
ENOATTR
{
t
.
Error
(
"Data not removed?"
,
err
,
val
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment