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
1229efb2
Commit
1229efb2
authored
Sep 26, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add FileSystemConnector.LookupNode().
parent
68e591c4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
30 deletions
+49
-30
fuse/fsconnector.go
fuse/fsconnector.go
+17
-0
fuse/fsmount.go
fuse/fsmount.go
+8
-5
fuse/fsops.go
fuse/fsops.go
+24
-25
No files found.
fuse/fsconnector.go
View file @
1229efb2
...
...
@@ -212,6 +212,23 @@ func (me *FileSystemConnector) findInode(fullPath string) *Inode {
return
n
}
func
(
me
*
FileSystemConnector
)
LookupNode
(
parent
*
Inode
,
path
string
)
*
Inode
{
if
path
==
""
{
return
parent
}
components
:=
strings
.
Split
(
path
,
"/"
)
for
_
,
r
:=
range
components
{
_
,
child
,
_
:=
me
.
internalLookup
(
parent
,
r
,
nil
)
if
child
==
nil
{
return
nil
}
parent
=
child
}
return
parent
}
////////////////////////////////////////////////////////////////
func
(
me
*
FileSystemConnector
)
MountRoot
(
nodeFs
NodeFileSystem
,
opts
*
FileSystemOptions
)
{
...
...
fuse/fsmount.go
View file @
1229efb2
...
...
@@ -142,9 +142,12 @@ func (me *fileSystemMount) registerFileHandle(node *Inode, dir rawDir, f File, f
}
// Creates a return entry for a non-existent path.
func
(
me
*
fileSystemMount
)
negativeEntry
()
*
EntryOut
{
out
:=
new
(
EntryOut
)
out
.
NodeId
=
0
splitNs
(
me
.
options
.
NegativeTimeout
,
&
out
.
EntryValid
,
&
out
.
EntryValidNsec
)
return
out
func
(
me
*
fileSystemMount
)
negativeEntry
()
(
*
EntryOut
,
Status
)
{
if
me
.
options
.
NegativeTimeout
>
0.0
{
out
:=
new
(
EntryOut
)
out
.
NodeId
=
0
splitNs
(
me
.
options
.
NegativeTimeout
,
&
out
.
EntryValid
,
&
out
.
EntryValidNsec
)
return
out
,
OK
}
return
nil
,
ENOENT
}
fuse/fsops.go
View file @
1229efb2
...
...
@@ -15,37 +15,25 @@ func (me *FileSystemConnector) Init(fsInit *RawFsInit) {
me
.
fsInit
=
*
fsInit
}
func
(
me
*
FileSystemConnector
)
lookupMountUpdate
(
mount
*
fileSystemMount
)
(
out
*
EntryOut
,
status
Status
)
{
fi
,
err
:=
mount
.
fs
.
Root
()
.
GetAttr
(
nil
,
nil
)
if
err
==
ENOENT
&&
mount
.
options
.
NegativeTimeout
>
0.0
{
return
mount
.
negativeEntry
(),
OK
}
if
!
err
.
Ok
()
{
return
nil
,
err
func
(
me
*
FileSystemConnector
)
lookupMountUpdate
(
mount
*
fileSystemMount
)
(
fi
*
os
.
FileInfo
,
node
*
Inode
,
code
Status
)
{
fi
,
code
=
mount
.
fs
.
Root
()
.
GetAttr
(
nil
,
nil
)
if
!
code
.
Ok
()
{
log
.
Println
(
"Root getattr should not return error"
,
code
)
return
&
os
.
FileInfo
{
Mode
:
S_IFDIR
|
0755
},
mount
.
mountInode
,
OK
}
out
=
mount
.
fileInfoToEntry
(
fi
)
out
.
NodeId
=
me
.
lookupUpdate
(
mount
.
mountInode
)
out
.
Ino
=
out
.
NodeId
// We don't do NFS.
out
.
Generation
=
1
return
out
,
OK
return
fi
,
mount
.
mountInode
,
OK
}
func
(
me
*
FileSystemConnector
)
Lookup
(
header
*
InHeader
,
name
string
)
(
out
*
EntryOut
,
code
Status
)
{
parent
:=
me
.
toInode
(
header
.
NodeId
)
context
:=
&
header
.
Context
func
(
me
*
FileSystemConnector
)
internalLookup
(
parent
*
Inode
,
name
string
,
context
*
Context
)
(
fi
*
os
.
FileInfo
,
node
*
Inode
,
code
Status
)
{
if
subMount
:=
me
.
findMount
(
parent
,
name
);
subMount
!=
nil
{
return
me
.
lookupMountUpdate
(
subMount
)
}
mount
:=
parent
.
mount
child
:=
parent
.
GetChild
(
name
)
if
child
!=
nil
{
parent
=
nil
}
var
fi
*
os
.
FileInfo
var
fsNode
FsNode
if
child
!=
nil
{
fi
,
code
=
child
.
fsInode
.
GetAttr
(
nil
,
context
)
...
...
@@ -54,20 +42,31 @@ func (me *FileSystemConnector) Lookup(header *InHeader, name string) (out *Entry
fi
,
fsNode
,
code
=
parent
.
fsInode
.
Lookup
(
name
,
context
)
}
if
child
==
nil
&&
fsNode
!=
nil
{
child
=
fsNode
.
Inode
()
}
return
fi
,
child
,
code
}
func
(
me
*
FileSystemConnector
)
Lookup
(
header
*
InHeader
,
name
string
)
(
out
*
EntryOut
,
code
Status
)
{
parent
:=
me
.
toInode
(
header
.
NodeId
)
context
:=
&
header
.
Context
fi
,
child
,
code
:=
me
.
internalLookup
(
parent
,
name
,
context
)
if
!
code
.
Ok
()
{
if
code
==
ENOENT
&&
mount
.
options
.
NegativeTimeout
>
0.0
{
return
mount
.
negativeEntry
(),
OK
if
code
==
ENOENT
{
return
parent
.
mount
.
negativeEntry
()
}
return
nil
,
code
}
out
=
mount
.
fileInfoToEntry
(
fi
)
out
.
Generation
=
1
if
child
==
nil
{
child
=
fsNode
.
Inode
(
)
log
.
Println
(
"HUH"
,
name
)
}
out
=
child
.
mount
.
fileInfoToEntry
(
fi
)
out
.
NodeId
=
me
.
lookupUpdate
(
child
)
out
.
Generation
=
1
out
.
Ino
=
out
.
NodeId
return
out
,
OK
}
...
...
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