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
62dac3a2
Commit
62dac3a2
authored
Sep 08, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move path interface to notify to PathNodeFs.
parent
98d0cf6b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
39 deletions
+61
-39
fuse/cache_test.go
fuse/cache_test.go
+8
-6
fuse/fsconnector.go
fuse/fsconnector.go
+3
-23
fuse/notify_test.go
fuse/notify_test.go
+5
-3
fuse/pathfs.go
fuse/pathfs.go
+45
-7
No files found.
fuse/cache_test.go
View file @
62dac3a2
...
...
@@ -26,7 +26,7 @@ func (me *cacheFs) Open(name string, flags uint32, context *Context) (fuseFile F
}
func
setupCacheTest
()
(
string
,
*
FileSystemConnector
,
func
())
{
func
setupCacheTest
()
(
string
,
*
PathNodeFs
,
func
())
{
dir
:=
MakeTempDir
()
os
.
Mkdir
(
dir
+
"/mnt"
,
0755
)
os
.
Mkdir
(
dir
+
"/orig"
,
0755
)
...
...
@@ -34,13 +34,15 @@ func setupCacheTest() (string, *FileSystemConnector, func()) {
fs
:=
&
cacheFs
{
LoopbackFileSystem
:
NewLoopbackFileSystem
(
dir
+
"/orig"
),
}
state
,
conn
,
err
:=
MountPathFileSystem
(
dir
+
"/mnt"
,
fs
,
nil
)
pfs
:=
NewPathNodeFs
(
fs
)
state
,
conn
,
err
:=
MountNodeFileSystem
(
dir
+
"/mnt"
,
pfs
,
nil
)
CheckSuccess
(
err
)
state
.
Debug
=
true
conn
.
Debug
=
true
pfs
.
Debug
=
true
go
state
.
Loop
(
false
)
return
dir
,
conn
,
func
()
{
return
dir
,
pfs
,
func
()
{
err
:=
state
.
Unmount
()
if
err
==
nil
{
os
.
RemoveAll
(
dir
)
...
...
@@ -49,7 +51,7 @@ func setupCacheTest() (string, *FileSystemConnector, func()) {
}
func
TestCacheFs
(
t
*
testing
.
T
)
{
wd
,
conn
,
clean
:=
setupCacheTest
()
wd
,
pathfs
,
clean
:=
setupCacheTest
()
defer
clean
()
content1
:=
"hello"
...
...
@@ -74,7 +76,7 @@ func TestCacheFs(t *testing.T) {
t
.
Fatalf
(
"expect 'hello' %q"
,
string
(
c
))
}
code
:=
conn
.
EntryNotify
(
""
,
"file.txt"
)
code
:=
pathfs
.
EntryNotify
(
""
,
"file.txt"
)
if
!
code
.
Ok
()
{
t
.
Errorf
(
"Entry notify failed: %v"
,
code
)
}
...
...
@@ -82,7 +84,7 @@ func TestCacheFs(t *testing.T) {
c
,
err
=
ioutil
.
ReadFile
(
wd
+
"/mnt/file.txt"
)
CheckSuccess
(
err
)
if
string
(
c
)
!=
string
(
content2
)
{
t
.
Fatalf
(
"expect '%s' %q"
,
content2
,
string
(
c
))
t
.
Fatalf
(
"
Mismatch after notify
expect '%s' %q"
,
content2
,
string
(
c
))
}
}
...
...
fuse/fsconnector.go
View file @
62dac3a2
...
...
@@ -325,12 +325,7 @@ func (me *FileSystemConnector) Unmount(node *Inode) Status {
return
OK
}
func
(
me
*
FileSystemConnector
)
FileNotify
(
path
string
,
off
int64
,
length
int64
)
Status
{
node
:=
me
.
findInode
(
path
)
if
node
==
nil
{
return
ENOENT
}
func
(
me
*
FileSystemConnector
)
FileNotify
(
node
*
Inode
,
off
int64
,
length
int64
)
Status
{
out
:=
NotifyInvalInodeOut
{
Length
:
length
,
Off
:
off
,
...
...
@@ -339,22 +334,7 @@ func (me *FileSystemConnector) FileNotify(path string, off int64, length int64)
return
me
.
fsInit
.
InodeNotify
(
&
out
)
}
func
(
me
*
FileSystemConnector
)
EntryNotify
(
dir
string
,
name
string
)
Status
{
node
:=
me
.
findInode
(
dir
)
if
node
==
nil
{
return
ENOENT
}
return
me
.
fsInit
.
EntryNotify
(
node
.
nodeId
,
name
)
func
(
me
*
FileSystemConnector
)
EntryNotify
(
dir
*
Inode
,
name
string
)
Status
{
return
me
.
fsInit
.
EntryNotify
(
dir
.
nodeId
,
name
)
}
func
(
me
*
FileSystemConnector
)
Notify
(
path
string
)
Status
{
node
,
rest
:=
me
.
findLastKnownInode
(
path
)
if
len
(
rest
)
>
0
{
return
me
.
fsInit
.
EntryNotify
(
node
.
nodeId
,
rest
[
0
])
}
out
:=
NotifyInvalInodeOut
{
Ino
:
node
.
nodeId
,
}
return
me
.
fsInit
.
InodeNotify
(
&
out
)
}
fuse/notify_test.go
View file @
62dac3a2
...
...
@@ -33,6 +33,7 @@ func (me *NotifyFs) Open(name string, f uint32, context *Context) (File, Status)
type
NotifyTest
struct
{
fs
*
NotifyFs
pathfs
*
PathNodeFs
connector
*
FileSystemConnector
dir
string
state
*
MountState
...
...
@@ -50,7 +51,8 @@ func NewNotifyTest() *NotifyTest {
}
var
err
os
.
Error
me
.
state
,
me
.
connector
,
err
=
MountPathFileSystem
(
me
.
dir
,
me
.
fs
,
opts
)
me
.
pathfs
=
NewPathNodeFs
(
me
.
fs
)
me
.
state
,
me
.
connector
,
err
=
MountNodeFileSystem
(
me
.
dir
,
me
.
pathfs
,
opts
)
CheckSuccess
(
err
)
me
.
state
.
Debug
=
true
go
me
.
state
.
Loop
(
false
)
...
...
@@ -86,7 +88,7 @@ func TestInodeNotify(t *testing.T) {
t
.
Error
(
fi
)
}
code
:=
test
.
connector
.
FileNotify
(
"file"
,
-
1
,
0
)
code
:=
test
.
pathfs
.
FileNotify
(
"file"
,
-
1
,
0
)
if
!
code
.
Ok
()
{
t
.
Error
(
code
)
}
...
...
@@ -117,7 +119,7 @@ func TestEntryNotify(t *testing.T) {
t
.
Errorf
(
"negative entry should have been cached: %#v"
,
fi
)
}
code
:=
test
.
connector
.
EntryNotify
(
"dir"
,
"file"
)
code
:=
test
.
pathfs
.
EntryNotify
(
"dir"
,
"file"
)
if
!
code
.
Ok
()
{
t
.
Errorf
(
"EntryNotify returns error: %v"
,
code
)
}
...
...
fuse/pathfs.go
View file @
62dac3a2
...
...
@@ -17,6 +17,7 @@ type clientInodePath struct {
}
type
PathNodeFs
struct
{
Debug
bool
fs
FileSystem
root
*
pathInode
connector
*
FileSystemConnector
...
...
@@ -46,17 +47,55 @@ func (me *PathNodeFs) StatFs() *StatfsOut {
return
me
.
fs
.
StatFs
()
}
func
(
me
*
PathNodeFs
)
Node
(
name
string
)
*
Inode
{
func
(
me
*
PathNodeFs
)
Node
(
name
string
)
(
*
Inode
)
{
n
,
rest
:=
me
.
LastNode
(
name
)
if
len
(
rest
)
>
0
{
return
nil
}
return
n
}
func
(
me
*
PathNodeFs
)
LastNode
(
name
string
)
(
*
Inode
,
[]
string
)
{
if
name
==
""
{
return
me
.
Root
()
.
Inode
(),
nil
}
name
=
filepath
.
Clean
(
name
)
comps
:=
strings
.
Split
(
name
,
string
(
filepath
.
Separator
))
node
:=
me
.
root
.
Inode
()
for
_
,
c
:=
range
comps
{
n
ode
=
node
.
GetChild
(
c
)
if
n
ode
==
nil
{
break
for
i
,
c
:=
range
comps
{
n
ext
:
=
node
.
GetChild
(
c
)
if
n
ext
==
nil
{
return
node
,
comps
[
i
:
]
}
node
=
next
}
return
node
,
nil
}
func
(
me
*
PathNodeFs
)
FileNotify
(
path
string
,
off
int64
,
length
int64
)
Status
{
node
:=
me
.
Node
(
path
)
if
node
==
nil
{
return
ENOENT
}
return
me
.
connector
.
FileNotify
(
node
,
off
,
length
)
}
func
(
me
*
PathNodeFs
)
EntryNotify
(
dir
string
,
name
string
)
Status
{
node
:=
me
.
Node
(
dir
)
if
node
==
nil
{
return
ENOENT
}
return
node
return
me
.
connector
.
EntryNotify
(
node
,
name
)
}
func
(
me
*
PathNodeFs
)
Notify
(
path
string
)
Status
{
node
,
rest
:=
me
.
LastNode
(
path
)
if
len
(
rest
)
>
0
{
return
me
.
connector
.
EntryNotify
(
node
,
rest
[
0
])
}
return
me
.
connector
.
FileNotify
(
node
,
0
,
0
)
}
func
(
me
*
PathNodeFs
)
AllFiles
(
name
string
,
mask
uint32
)
[]
WithFlags
{
...
...
@@ -102,7 +141,6 @@ type pathInode struct {
DefaultFsNode
}
func
(
me
*
pathInode
)
fillNewChildAttr
(
path
string
,
child
*
pathInode
,
c
*
Context
)
(
fi
*
os
.
FileInfo
)
{
fi
,
_
=
me
.
fs
.
GetAttr
(
path
,
c
)
if
fi
!=
nil
&&
fi
.
Ino
>
0
{
...
...
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