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
Kirill Smelkov
go-fuse
Commits
962c5624
Commit
962c5624
authored
Mar 08, 2019
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nodefs: XAttr support
parent
0f169dda
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
89 additions
and
10 deletions
+89
-10
nodefs/api.go
nodefs/api.go
+7
-0
nodefs/bridge.go
nodefs/bridge.go
+11
-9
nodefs/default.go
nodefs/default.go
+16
-0
nodefs/loopback.go
nodefs/loopback.go
+20
-0
nodefs/simple_test.go
nodefs/simple_test.go
+35
-1
No files found.
nodefs/api.go
View file @
962c5624
...
...
@@ -107,6 +107,13 @@ type Operations interface {
SetLk
(
ctx
context
.
Context
,
f
FileHandle
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
status
fuse
.
Status
)
SetLkw
(
ctx
context
.
Context
,
f
FileHandle
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
status
fuse
.
Status
)
// Extended attributes
GetXAttr
(
ctx
context
.
Context
,
attr
string
,
dest
[]
byte
)
(
uint32
,
fuse
.
Status
)
SetXAttr
(
ctx
context
.
Context
,
attr
string
,
data
[]
byte
,
flags
uint32
)
fuse
.
Status
RemoveXAttr
(
ctx
context
.
Context
,
attr
string
)
fuse
.
Status
ListXAttr
(
ctx
context
.
Context
,
dest
[]
byte
)
(
uint32
,
fuse
.
Status
)
// The methods below may be called on closed files, due to
// concurrency. In that case, you should return EBADF.
GetAttr
(
ctx
context
.
Context
,
f
FileHandle
,
out
*
fuse
.
AttrOut
)
fuse
.
Status
...
...
nodefs/bridge.go
View file @
962c5624
...
...
@@ -412,24 +412,26 @@ func (b *rawBridge) Access(cancel <-chan struct{}, input *fuse.AccessIn) (status
}
// Extended attributes.
func
(
b
*
rawBridge
)
GetXAttrSize
(
cancel
<-
chan
struct
{},
header
*
fuse
.
InHeader
,
attr
string
)
(
sz
int
,
status
fuse
.
Status
)
{
return
0
,
fuse
.
ENOSYS
}
func
(
b
*
rawBridge
)
GetXAttrData
(
cancel
<-
chan
struct
{},
header
*
fuse
.
InHeader
,
attr
string
)
(
data
[]
byte
,
status
fuse
.
Status
)
{
return
nil
,
fuse
.
ENOSYS
func
(
b
*
rawBridge
)
GetXAttr
(
cancel
<-
chan
struct
{},
header
*
fuse
.
InHeader
,
attr
string
,
data
[]
byte
)
(
uint32
,
fuse
.
Status
)
{
n
,
_
:=
b
.
inode
(
header
.
NodeId
,
0
)
return
n
.
node
.
GetXAttr
(
&
fuse
.
Context
{
Caller
:
header
.
Caller
,
Cancel
:
cancel
},
attr
,
data
)
}
func
(
b
*
rawBridge
)
ListXAttr
(
cancel
<-
chan
struct
{},
header
*
fuse
.
InHeader
)
(
attributes
[]
byte
,
status
fuse
.
Status
)
{
return
nil
,
fuse
.
ENOSYS
func
(
b
*
rawBridge
)
ListXAttr
(
cancel
<-
chan
struct
{},
header
*
fuse
.
InHeader
,
dest
[]
byte
)
(
sz
uint32
,
status
fuse
.
Status
)
{
n
,
_
:=
b
.
inode
(
header
.
NodeId
,
0
)
return
n
.
node
.
ListXAttr
(
&
fuse
.
Context
{
Caller
:
header
.
Caller
,
Cancel
:
cancel
},
dest
)
}
func
(
b
*
rawBridge
)
SetXAttr
(
cancel
<-
chan
struct
{},
input
*
fuse
.
SetXAttrIn
,
attr
string
,
data
[]
byte
)
fuse
.
Status
{
return
fuse
.
ENOSYS
n
,
_
:=
b
.
inode
(
input
.
NodeId
,
0
)
return
n
.
node
.
SetXAttr
(
&
fuse
.
Context
{
Caller
:
input
.
Caller
,
Cancel
:
cancel
},
attr
,
data
,
input
.
Flags
)
}
func
(
b
*
rawBridge
)
RemoveXAttr
(
cancel
<-
chan
struct
{},
header
*
fuse
.
InHeader
,
attr
string
)
(
status
fuse
.
Status
)
{
return
n
,
_
:=
b
.
inode
(
header
.
NodeId
,
0
)
return
n
.
node
.
RemoveXAttr
(
&
fuse
.
Context
{
Caller
:
header
.
Caller
,
Cancel
:
cancel
},
attr
)
}
func
(
b
*
rawBridge
)
Open
(
cancel
<-
chan
struct
{},
input
*
fuse
.
OpenIn
,
out
*
fuse
.
OpenOut
)
(
status
fuse
.
Status
)
{
...
...
nodefs/default.go
View file @
962c5624
...
...
@@ -215,6 +215,22 @@ func (n *DefaultOperations) Link(ctx context.Context, target Operations, name st
return
nil
,
fuse
.
ENOSYS
}
func
(
n
*
DefaultOperations
)
GetXAttr
(
ctx
context
.
Context
,
attr
string
,
dest
[]
byte
)
(
uint32
,
fuse
.
Status
)
{
return
0
,
fuse
.
ENOATTR
}
func
(
n
*
DefaultOperations
)
SetXAttr
(
ctx
context
.
Context
,
attr
string
,
data
[]
byte
,
flags
uint32
)
fuse
.
Status
{
return
fuse
.
ENOATTR
}
func
(
n
*
DefaultOperations
)
RemoveXAttr
(
ctx
context
.
Context
,
attr
string
)
fuse
.
Status
{
return
fuse
.
ENOATTR
}
func
(
n
*
DefaultOperations
)
ListXAttr
(
ctx
context
.
Context
,
dest
[]
byte
)
(
uint32
,
fuse
.
Status
)
{
return
0
,
fuse
.
OK
}
type
DefaultFile
struct
{
}
...
...
nodefs/loopback.go
View file @
962c5624
...
...
@@ -319,3 +319,23 @@ func NewLoopback(root string) Operations {
n
.
openFiles
=
map
[
*
loopbackFile
]
uint32
{}
return
n
}
func
(
n
*
loopbackNode
)
GetXAttr
(
ctx
context
.
Context
,
attr
string
,
dest
[]
byte
)
(
uint32
,
fuse
.
Status
)
{
sz
,
err
:=
syscall
.
Getxattr
(
n
.
path
(),
attr
,
dest
)
return
uint32
(
sz
),
fuse
.
ToStatus
(
err
)
}
func
(
n
*
loopbackNode
)
SetXAttr
(
ctx
context
.
Context
,
attr
string
,
data
[]
byte
,
flags
uint32
)
fuse
.
Status
{
err
:=
syscall
.
Setxattr
(
n
.
path
(),
attr
,
data
,
int
(
flags
))
return
fuse
.
ToStatus
(
err
)
}
func
(
n
*
loopbackNode
)
RemoveXAttr
(
ctx
context
.
Context
,
attr
string
)
fuse
.
Status
{
err
:=
syscall
.
Removexattr
(
n
.
path
(),
attr
)
return
fuse
.
ToStatus
(
err
)
}
func
(
n
*
loopbackNode
)
ListXAttr
(
ctx
context
.
Context
,
dest
[]
byte
)
(
uint32
,
fuse
.
Status
)
{
sz
,
err
:=
syscall
.
Listxattr
(
n
.
path
(),
dest
)
return
uint32
(
sz
),
fuse
.
ToStatus
(
err
)
}
nodefs/simple_test.go
View file @
962c5624
...
...
@@ -58,7 +58,6 @@ func newTestCase(t *testing.T) *testCase {
dir
:
testutil
.
TempDir
(),
T
:
t
,
}
tc
.
origDir
=
tc
.
dir
+
"/orig"
tc
.
mntDir
=
tc
.
dir
+
"/mnt"
if
err
:=
os
.
Mkdir
(
tc
.
origDir
,
0755
);
err
!=
nil
{
...
...
@@ -563,3 +562,38 @@ func TestStatFs(t *testing.T) {
t
.
Errorf
(
"Got %#v, want %#v"
,
mntFuse
,
origFuse
)
}
}
func
TestXAttr
(
t
*
testing
.
T
)
{
tc
:=
newTestCase
(
t
)
defer
tc
.
Clean
()
tc
.
writeOrig
(
"file"
,
""
,
0644
)
buf
:=
make
([]
byte
,
1024
)
attr
:=
"user.xattrtest"
if
_
,
err
:=
syscall
.
Getxattr
(
tc
.
mntDir
+
"/file"
,
attr
,
buf
);
err
==
syscall
.
ENOTSUP
{
t
.
Skip
(
"$TMP does not support xattrs. Rerun this test with a $TMPDIR override"
)
}
if
_
,
err
:=
syscall
.
Getxattr
(
tc
.
mntDir
+
"/file"
,
attr
,
buf
);
err
!=
syscall
.
ENODATA
{
t
.
Fatalf
(
"got %v want ENOATTR"
,
err
)
}
value
:=
[]
byte
(
"value"
)
if
err
:=
syscall
.
Setxattr
(
tc
.
mntDir
+
"/file"
,
attr
,
value
,
0
);
err
!=
nil
{
t
.
Fatalf
(
"Setxattr: %v"
,
err
)
}
sz
,
err
:=
syscall
.
Getxattr
(
tc
.
mntDir
+
"/file"
,
attr
,
buf
)
if
err
!=
nil
{
t
.
Fatalf
(
"Getxattr: %v"
,
err
)
}
if
bytes
.
Compare
(
buf
[
:
sz
],
value
)
!=
0
{
t
.
Fatalf
(
"Getxattr got %q want %q"
,
buf
[
:
sz
],
value
)
}
if
err
:=
syscall
.
Removexattr
(
tc
.
mntDir
+
"/file"
,
attr
);
err
!=
nil
{
t
.
Fatalf
(
"Removexattr: %v"
,
err
)
}
if
_
,
err
:=
syscall
.
Getxattr
(
tc
.
mntDir
+
"/file"
,
attr
,
buf
);
err
!=
syscall
.
ENODATA
{
t
.
Fatalf
(
"got %v want ENOATTR"
,
err
)
}
}
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