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
395b17f8
Commit
395b17f8
authored
Dec 14, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
In Raw API, make separate calls for XAttr size and data.
parent
90cb7766
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
56 additions
and
31 deletions
+56
-31
fuse/api.go
fuse/api.go
+2
-1
fuse/defaultraw.go
fuse/defaultraw.go
+5
-1
fuse/fsops.go
fuse/fsops.go
+7
-1
fuse/lockingfs.go
fuse/lockingfs.go
+7
-2
fuse/loopback.go
fuse/loopback.go
+3
-2
fuse/opcode.go
fuse/opcode.go
+20
-16
fuse/syscall.go
fuse/syscall.go
+1
-2
fuse/xattr_test.go
fuse/xattr_test.go
+11
-6
No files found.
fuse/api.go
View file @
395b17f8
...
...
@@ -260,7 +260,8 @@ type RawFileSystem interface {
Access
(
header
*
InHeader
,
input
*
AccessIn
)
(
code
Status
)
// Extended attributes.
GetXAttr
(
header
*
InHeader
,
attr
string
)
(
data
[]
byte
,
code
Status
)
GetXAttrSize
(
header
*
InHeader
,
attr
string
)
(
sz
int
,
code
Status
)
GetXAttrData
(
header
*
InHeader
,
attr
string
)
(
data
[]
byte
,
code
Status
)
ListXAttr
(
header
*
InHeader
)
(
attributes
[]
byte
,
code
Status
)
SetXAttr
(
header
*
InHeader
,
input
*
SetXAttrIn
,
attr
string
,
data
[]
byte
)
Status
RemoveXAttr
(
header
*
InHeader
,
attr
string
)
(
code
Status
)
...
...
fuse/defaultraw.go
View file @
395b17f8
...
...
@@ -58,7 +58,11 @@ func (me *DefaultRawFileSystem) Link(header *InHeader, input *LinkIn, name strin
return
nil
,
ENOSYS
}
func
(
me
*
DefaultRawFileSystem
)
GetXAttr
(
header
*
InHeader
,
attr
string
)
(
data
[]
byte
,
code
Status
)
{
func
(
me
*
DefaultRawFileSystem
)
GetXAttrSize
(
header
*
InHeader
,
attr
string
)
(
size
int
,
code
Status
)
{
return
0
,
ENOSYS
}
func
(
me
*
DefaultRawFileSystem
)
GetXAttrData
(
header
*
InHeader
,
attr
string
)
(
data
[]
byte
,
code
Status
)
{
return
nil
,
ENOSYS
}
...
...
fuse/fsops.go
View file @
395b17f8
...
...
@@ -289,7 +289,13 @@ func (me *FileSystemConnector) ReleaseDir(header *InHeader, input *ReleaseIn) {
me
.
considerDropInode
(
node
)
}
func
(
me
*
FileSystemConnector
)
GetXAttr
(
header
*
InHeader
,
attribute
string
)
(
data
[]
byte
,
code
Status
)
{
func
(
me
*
FileSystemConnector
)
GetXAttrSize
(
header
*
InHeader
,
attribute
string
)
(
sz
int
,
code
Status
)
{
node
:=
me
.
toInode
(
header
.
NodeId
)
data
,
c
:=
node
.
fsInode
.
GetXAttr
(
attribute
,
&
header
.
Context
)
return
len
(
data
),
c
}
func
(
me
*
FileSystemConnector
)
GetXAttrData
(
header
*
InHeader
,
attribute
string
)
(
data
[]
byte
,
code
Status
)
{
node
:=
me
.
toInode
(
header
.
NodeId
)
return
node
.
fsInode
.
GetXAttr
(
attribute
,
&
header
.
Context
)
}
...
...
fuse/lockingfs.go
View file @
395b17f8
...
...
@@ -228,9 +228,14 @@ func (me *LockingRawFileSystem) SetXAttr(header *InHeader, input *SetXAttrIn, at
return
me
.
RawFileSystem
.
SetXAttr
(
header
,
input
,
attr
,
data
)
}
func
(
me
*
LockingRawFileSystem
)
GetXAttr
(
header
*
InHeader
,
attr
string
)
(
data
[]
byte
,
code
Status
)
{
func
(
me
*
LockingRawFileSystem
)
GetXAttr
Data
(
header
*
InHeader
,
attr
string
)
(
data
[]
byte
,
code
Status
)
{
defer
me
.
locked
()()
return
me
.
RawFileSystem
.
GetXAttr
(
header
,
attr
)
return
me
.
RawFileSystem
.
GetXAttrData
(
header
,
attr
)
}
func
(
me
*
LockingRawFileSystem
)
GetXAttrSize
(
header
*
InHeader
,
attr
string
)
(
sz
int
,
code
Status
)
{
defer
me
.
locked
()()
return
me
.
RawFileSystem
.
GetXAttrSize
(
header
,
attr
)
}
func
(
me
*
LockingRawFileSystem
)
ListXAttr
(
header
*
InHeader
)
(
data
[]
byte
,
code
Status
)
{
...
...
fuse/loopback.go
View file @
395b17f8
...
...
@@ -157,8 +157,9 @@ func (me *LoopbackFileSystem) Create(path string, flags uint32, mode uint32, con
}
func
(
me
*
LoopbackFileSystem
)
GetXAttr
(
name
string
,
attr
string
,
context
*
Context
)
([]
byte
,
Status
)
{
data
,
errNo
:=
GetXAttr
(
me
.
GetPath
(
name
),
attr
)
data
:=
make
([]
byte
,
1024
)
data
,
errNo
:=
GetXAttr
(
me
.
GetPath
(
name
),
attr
,
data
)
return
data
,
Status
(
errNo
)
}
...
...
fuse/opcode.go
View file @
395b17f8
...
...
@@ -161,27 +161,31 @@ func doWrite(state *MountState, req *request) {
func
doGetXAttr
(
state
*
MountState
,
req
*
request
)
{
input
:=
(
*
GetXAttrIn
)(
req
.
inData
)
var
data
[]
byte
if
req
.
inHeader
.
opcode
==
_OP_GETXATTR
{
data
,
req
.
status
=
state
.
fileSystem
.
GetXAttr
(
req
.
inHeader
,
req
.
filenames
[
0
])
}
else
{
data
,
req
.
status
=
state
.
fileSystem
.
ListXAttr
(
req
.
inHeader
)
}
if
req
.
status
!=
OK
{
return
}
size
:=
uint32
(
len
(
data
))
if
input
.
Size
==
0
{
out
:=
&
GetXAttrOut
{
Size
:
size
,
switch
{
case
req
.
inHeader
.
opcode
==
_OP_GETXATTR
&&
input
.
Size
==
0
:
sz
,
code
:=
state
.
fileSystem
.
GetXAttrSize
(
req
.
inHeader
,
req
.
filenames
[
0
])
if
code
.
Ok
()
{
out
:=
&
GetXAttrOut
{
Size
:
uint32
(
sz
),
}
req
.
outData
=
unsafe
.
Pointer
(
out
)
req
.
status
=
ERANGE
return
}
req
.
outData
=
unsafe
.
Pointer
(
out
)
req
.
status
=
code
case
req
.
inHeader
.
opcode
==
_OP_GETXATTR
:
data
,
req
.
status
=
state
.
fileSystem
.
GetXAttrData
(
req
.
inHeader
,
req
.
filenames
[
0
])
default
:
data
,
req
.
status
=
state
.
fileSystem
.
ListXAttr
(
req
.
inHeader
)
}
if
size
>
input
.
Size
{
if
len
(
data
)
>
int
(
input
.
Size
)
{
req
.
status
=
ERANGE
}
if
!
req
.
status
.
Ok
()
{
return
}
req
.
flatData
=
data
}
...
...
fuse/syscall.go
View file @
395b17f8
...
...
@@ -50,8 +50,7 @@ func getxattr(path string, attr string, dest []byte) (sz int, errno int) {
return
int
(
size
),
int
(
errNo
)
}
func
GetXAttr
(
path
string
,
attr
string
)
(
value
[]
byte
,
errno
int
)
{
dest
:=
make
([]
byte
,
1024
)
func
GetXAttr
(
path
string
,
attr
string
,
dest
[]
byte
)
(
value
[]
byte
,
errno
int
)
{
sz
,
errno
:=
getxattr
(
path
,
attr
,
dest
)
for
sz
>
cap
(
dest
)
&&
errno
==
0
{
...
...
fuse/xattr_test.go
View file @
395b17f8
...
...
@@ -6,6 +6,7 @@ import (
"log"
"os"
"path/filepath"
"syscall"
"testing"
)
...
...
@@ -86,6 +87,11 @@ func (me *XAttrTestFs) RemoveXAttr(name string, attr string, context *Context) S
return
OK
}
func
readXAttr
(
p
,
a
string
)
(
val
[]
byte
,
errno
int
)
{
val
=
make
([]
byte
,
1024
)
return
GetXAttr
(
p
,
a
,
val
)
}
func
TestXAttrRead
(
t
*
testing
.
T
)
{
nm
:=
"filename"
...
...
@@ -112,21 +118,20 @@ func TestXAttrRead(t *testing.T) {
t
.
Error
(
"Unexpected stat error"
,
err
)
}
val
,
errno
:=
Get
XAttr
(
mounted
,
"noexist"
)
val
,
errno
:=
read
XAttr
(
mounted
,
"noexist"
)
if
errno
==
0
{
t
.
Error
(
"Expected GetXAttr error"
,
val
)
}
attrs
,
errno
:=
ListXAttr
(
mounted
)
readback
:=
make
(
map
[
string
][]
byte
)
if
errno
!=
0
{
t
.
Error
(
"Unexpected ListXAttr error"
,
errno
)
}
else
{
for
_
,
a
:=
range
attrs
{
val
,
errno
=
Get
XAttr
(
mounted
,
a
)
val
,
errno
=
read
XAttr
(
mounted
,
a
)
if
errno
!=
0
{
t
.
Error
(
"Unexpected GetXAttr error"
,
errno
)
t
.
Error
(
"Unexpected GetXAttr error"
,
syscall
.
Errno
(
errno
)
)
}
readback
[
a
]
=
val
}
...
...
@@ -146,13 +151,13 @@ func TestXAttrRead(t *testing.T) {
if
errno
!=
0
{
t
.
Error
(
"Setxattr error"
,
errno
)
}
val
,
errno
=
Get
XAttr
(
mounted
,
"third"
)
val
,
errno
=
read
XAttr
(
mounted
,
"third"
)
if
errno
!=
0
||
string
(
val
)
!=
"value"
{
t
.
Error
(
"Read back set xattr:"
,
errno
,
string
(
val
))
}
Removexattr
(
mounted
,
"third"
)
val
,
errno
=
Get
XAttr
(
mounted
,
"third"
)
val
,
errno
=
read
XAttr
(
mounted
,
"third"
)
if
errno
!=
int
(
ENODATA
)
{
t
.
Error
(
"Data not removed?"
,
errno
,
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