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
b87b9b17
Commit
b87b9b17
authored
Mar 24, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a simple XAttr filesystem, for coverage of both Xattr syscalls and
XAttr FUSE support.
parent
6eda76d6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
84 additions
and
0 deletions
+84
-0
fuse/xattr_test.go
fuse/xattr_test.go
+84
-0
No files found.
fuse/xattr_test.go
0 → 100644
View file @
b87b9b17
package
fuse
import
(
"testing"
"path/filepath"
"os"
"syscall"
)
type
XAttrTestFs
struct
{
filename
string
attrs
map
[
string
][]
byte
DefaultPathFilesystem
}
func
NewXAttrFs
(
nm
string
,
m
map
[
string
][]
byte
)
*
XAttrTestFs
{
x
:=
new
(
XAttrTestFs
)
x
.
filename
=
nm
x
.
attrs
=
m
return
x
}
func
(
me
*
XAttrTestFs
)
GetAttr
(
name
string
)
(
*
Attr
,
Status
)
{
a
:=
new
(
Attr
)
if
name
==
""
||
name
==
"/"
{
a
.
Mode
=
S_IFDIR
|
0700
return
a
,
OK
}
if
name
==
me
.
filename
{
a
.
Mode
=
S_IFREG
|
0600
return
a
,
OK
}
return
nil
,
ENOENT
}
func
(
me
*
XAttrTestFs
)
GetXAttr
(
name
string
,
attr
string
)
([]
byte
,
Status
)
{
if
name
!=
me
.
filename
{
return
nil
,
ENOENT
}
v
,
ok
:=
me
.
attrs
[
attr
]
if
!
ok
{
return
nil
,
syscall
.
ENODATA
}
return
v
,
OK
}
func
TestXAttr
(
t
*
testing
.
T
)
{
nm
:=
"filename"
xfs
:=
NewXAttrFs
(
nm
,
map
[
string
][]
byte
{
"user.attr1"
:
[]
byte
(
"val1"
),
"user.attr2"
:
[]
byte
(
"val2"
)})
connector
:=
NewPathFileSystemConnector
(
xfs
)
mountPoint
:=
MakeTempDir
()
state
:=
NewMountState
(
connector
)
state
.
Mount
(
mountPoint
)
defer
state
.
Unmount
()
go
state
.
Loop
(
false
)
mounted
:=
filepath
.
Join
(
mountPoint
,
nm
)
_
,
err
:=
os
.
Lstat
(
mounted
)
if
err
!=
nil
{
t
.
Error
(
"Unexpected stat error"
,
err
)
}
val
,
errno
:=
GetXAttr
(
mounted
,
"noexist"
)
if
errno
==
0
{
t
.
Error
(
"Expected GetXAttr error"
)
}
val
,
errno
=
GetXAttr
(
mounted
,
"user.attr1"
)
if
err
!=
nil
{
t
.
Error
(
"Unexpected GetXAttr error"
,
errno
)
}
if
string
(
val
)
!=
"val1"
{
t
.
Error
(
"Unexpected value"
,
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