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
51e8ea2f
Commit
51e8ea2f
authored
Sep 26, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add FileSystemConnector.Node and use them for PathNodeFs notify methods.
parent
04a0abbf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
21 deletions
+22
-21
fuse/fsconnector.go
fuse/fsconnector.go
+16
-15
fuse/pathfs.go
fuse/pathfs.go
+6
-6
No files found.
fuse/fsconnector.go
View file @
51e8ea2f
...
@@ -173,25 +173,34 @@ func (me *FileSystemConnector) recursiveConsiderDropInode(n *Inode) (drop bool)
...
@@ -173,25 +173,34 @@ func (me *FileSystemConnector) recursiveConsiderDropInode(n *Inode) (drop bool)
return
len
(
n
.
openFiles
)
==
0
return
len
(
n
.
openFiles
)
==
0
}
}
// Walk the file system starting from the root. Will return nil if
// Finds a node within the currently known inodes, returns the last
// node not found.
// known node and the remaining unknown path components. If parent is
func
(
me
*
FileSystemConnector
)
findLastKnownInode
(
fullPath
string
)
(
*
Inode
,
[]
string
)
{
// nil, start from FUSE mountpoint.
func
(
me
*
FileSystemConnector
)
Node
(
parent
*
Inode
,
fullPath
string
)
(
*
Inode
,
[]
string
)
{
if
parent
==
nil
{
parent
=
me
.
rootNode
}
if
fullPath
==
""
{
if
fullPath
==
""
{
return
me
.
rootNode
,
nil
return
parent
,
nil
}
}
fullPath
=
strings
.
TrimLeft
(
filepath
.
Clean
(
fullPath
),
"/"
)
fullPath
=
strings
.
TrimLeft
(
filepath
.
Clean
(
fullPath
),
"/"
)
comps
:=
strings
.
Split
(
fullPath
,
"/"
)
comps
:=
strings
.
Split
(
fullPath
,
"/"
)
node
:=
me
.
rootNode
node
:=
parent
if
node
.
mountPoint
==
nil
{
node
.
treeLock
.
RLock
()
defer
node
.
treeLock
.
RUnlock
()
}
for
i
,
component
:=
range
comps
{
for
i
,
component
:=
range
comps
{
if
len
(
component
)
==
0
{
if
len
(
component
)
==
0
{
continue
continue
}
}
if
node
.
mountPoint
!=
nil
{
if
node
.
mountPoint
!=
nil
{
node
.
mountPoint
.
treeLock
.
RLock
()
node
.
treeLock
.
RLock
()
defer
node
.
mountPoint
.
treeLock
.
RUnlock
()
defer
node
.
treeLock
.
RUnlock
()
}
}
next
:=
node
.
children
[
component
]
next
:=
node
.
children
[
component
]
...
@@ -204,14 +213,6 @@ func (me *FileSystemConnector) findLastKnownInode(fullPath string) (*Inode, []st
...
@@ -204,14 +213,6 @@ func (me *FileSystemConnector) findLastKnownInode(fullPath string) (*Inode, []st
return
node
,
nil
return
node
,
nil
}
}
func
(
me
*
FileSystemConnector
)
findInode
(
fullPath
string
)
*
Inode
{
n
,
rest
:=
me
.
findLastKnownInode
(
fullPath
)
if
len
(
rest
)
>
0
{
return
nil
}
return
n
}
func
(
me
*
FileSystemConnector
)
LookupNode
(
parent
*
Inode
,
path
string
)
*
Inode
{
func
(
me
*
FileSystemConnector
)
LookupNode
(
parent
*
Inode
,
path
string
)
*
Inode
{
if
path
==
""
{
if
path
==
""
{
return
parent
return
parent
...
...
fuse/pathfs.go
View file @
51e8ea2f
...
@@ -146,23 +146,23 @@ func (me *PathNodeFs) LastNode(name string) (*Inode, []string) {
...
@@ -146,23 +146,23 @@ func (me *PathNodeFs) LastNode(name string) (*Inode, []string) {
}
}
func
(
me
*
PathNodeFs
)
FileNotify
(
path
string
,
off
int64
,
length
int64
)
Status
{
func
(
me
*
PathNodeFs
)
FileNotify
(
path
string
,
off
int64
,
length
int64
)
Status
{
node
:=
me
.
Node
(
path
)
node
,
r
:=
me
.
connector
.
Node
(
me
.
root
.
Inode
(),
path
)
if
node
==
nil
{
if
len
(
r
)
>
0
{
return
ENOENT
return
ENOENT
}
}
return
me
.
connector
.
FileNotify
(
node
,
off
,
length
)
return
me
.
connector
.
FileNotify
(
node
,
off
,
length
)
}
}
func
(
me
*
PathNodeFs
)
EntryNotify
(
dir
string
,
name
string
)
Status
{
func
(
me
*
PathNodeFs
)
EntryNotify
(
dir
string
,
name
string
)
Status
{
node
:=
me
.
Node
(
dir
)
node
,
rest
:=
me
.
connector
.
Node
(
me
.
root
.
Inode
(),
dir
)
if
node
==
nil
{
if
len
(
rest
)
>
0
{
return
ENOENT
return
ENOENT
}
}
return
me
.
connector
.
EntryNotify
(
node
,
name
)
return
me
.
connector
.
EntryNotify
(
node
,
name
)
}
}
func
(
me
*
PathNodeFs
)
Notify
(
path
string
)
Status
{
func
(
me
*
PathNodeFs
)
Notify
(
path
string
)
Status
{
node
,
rest
:=
me
.
LastNode
(
path
)
node
,
rest
:=
me
.
connector
.
Node
(
me
.
root
.
Inode
(),
path
)
if
len
(
rest
)
>
0
{
if
len
(
rest
)
>
0
{
return
me
.
connector
.
EntryNotify
(
node
,
rest
[
0
])
return
me
.
connector
.
EntryNotify
(
node
,
rest
[
0
])
}
}
...
@@ -272,7 +272,7 @@ func (me *pathInode) GetPath() (path string) {
...
@@ -272,7 +272,7 @@ func (me *pathInode) GetPath() (path string) {
}
}
p
:=
ReverseJoin
(
rev_components
,
"/"
)
p
:=
ReverseJoin
(
rev_components
,
"/"
)
if
me
.
pathFs
.
Debug
{
if
me
.
pathFs
.
Debug
{
log
.
Printf
(
"Inode %d = %q
"
,
me
.
Inode
()
.
nodeId
,
p
)
log
.
Printf
(
"Inode %d = %q
(%s)"
,
me
.
Inode
()
.
nodeId
,
p
,
me
.
fs
.
String
()
)
}
}
return
p
return
p
...
...
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