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
9b069ce5
Commit
9b069ce5
authored
Sep 08, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use path interface for PathNodeFs.Mount/Unmount
parent
485ecd0f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
6 deletions
+20
-6
fuse/mount_test.go
fuse/mount_test.go
+8
-4
fuse/pathfs.go
fuse/pathfs.go
+12
-2
No files found.
fuse/mount_test.go
View file @
9b069ce5
...
...
@@ -27,6 +27,8 @@ func TestMountOnExisting(t *testing.T) {
if
!
code
.
Ok
()
{
t
.
Fatal
(
"expect OK:"
,
code
)
}
ts
.
nodeFs
.
Unmount
(
"mnt"
)
}
func
TestMountRename
(
t
*
testing
.
T
)
{
...
...
@@ -42,6 +44,7 @@ func TestMountRename(t *testing.T) {
if
OsErrorToErrno
(
err
)
!=
EBUSY
{
t
.
Fatal
(
"rename mount point should fail with EBUSY:"
,
err
)
}
ts
.
nodeFs
.
Unmount
(
"mnt"
)
}
func
TestMountReaddir
(
t
*
testing
.
T
)
{
...
...
@@ -59,6 +62,7 @@ func TestMountReaddir(t *testing.T) {
if
len
(
entries
)
!=
1
||
entries
[
0
]
.
Name
!=
"mnt"
{
t
.
Error
(
"wrong readdir result"
,
entries
)
}
ts
.
nodeFs
.
Unmount
(
"mnt"
)
}
func
TestRecursiveMount
(
t
*
testing
.
T
)
{
...
...
@@ -83,7 +87,7 @@ func TestRecursiveMount(t *testing.T) {
f
,
err
:=
os
.
Open
(
filepath
.
Join
(
submnt
,
"hello.txt"
))
CheckSuccess
(
err
)
log
.
Println
(
"Attempting unmount, should fail"
)
code
=
ts
.
connector
.
Unmount
(
ts
.
nodeFs
.
Node
(
"mnt"
)
)
code
=
ts
.
nodeFs
.
Unmount
(
"mnt"
)
if
code
!=
EBUSY
{
t
.
Error
(
"expect EBUSY"
)
}
...
...
@@ -94,7 +98,7 @@ func TestRecursiveMount(t *testing.T) {
time
.
Sleep
(
1.5e9
*
testTtl
)
log
.
Println
(
"Attempting unmount, should succeed"
)
code
=
ts
.
connector
.
Unmount
(
ts
.
nodeFs
.
Node
(
"mnt"
)
)
code
=
ts
.
nodeFs
.
Unmount
(
"mnt"
)
if
code
!=
OK
{
t
.
Error
(
"umount failed."
,
code
)
}
...
...
@@ -121,14 +125,14 @@ func TestDeletedUnmount(t *testing.T) {
_
,
err
=
f
.
Write
([]
byte
(
"bla"
))
CheckSuccess
(
err
)
code
=
ts
.
connector
.
Unmount
(
ts
.
nodeFs
.
Node
(
"mnt"
)
)
code
=
ts
.
nodeFs
.
Unmount
(
"mnt"
)
if
code
!=
EBUSY
{
t
.
Error
(
"expect EBUSY for unmount with open files"
,
code
)
}
f
.
Close
()
time
.
Sleep
(
1.5e9
*
testTtl
)
code
=
ts
.
connector
.
Unmount
(
ts
.
nodeFs
.
Node
(
"mnt"
)
)
code
=
ts
.
nodeFs
.
Unmount
(
"mnt"
)
if
!
code
.
Ok
()
{
t
.
Error
(
"should succeed"
,
code
)
}
...
...
fuse/pathfs.go
View file @
9b069ce5
...
...
@@ -27,11 +27,21 @@ type PathNodeFs struct {
clientInodeMap
map
[
uint64
][]
*
clientInodePath
}
func
(
me
*
PathNodeFs
)
Mount
(
parent
*
Inode
,
name
string
,
nodeFs
NodeFileSystem
,
opts
*
FileSystemOptions
)
Status
{
func
(
me
*
PathNodeFs
)
Mount
(
path
string
,
nodeFs
NodeFileSystem
,
opts
*
FileSystemOptions
)
Status
{
dir
,
name
:=
filepath
.
Split
(
path
)
dir
=
filepath
.
Clean
(
dir
)
parent
:=
me
.
Node
(
dir
)
if
parent
==
nil
{
return
ENOENT
}
return
me
.
connector
.
Mount
(
parent
,
name
,
nodeFs
,
opts
)
}
func
(
me
*
PathNodeFs
)
Unmount
(
node
*
Inode
)
Status
{
func
(
me
*
PathNodeFs
)
Unmount
(
path
string
)
Status
{
node
:=
me
.
Node
(
path
)
if
node
==
nil
{
return
ENOENT
}
return
me
.
connector
.
Unmount
(
node
)
}
...
...
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