Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jacobsa-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
jacobsa-fuse
Commits
621df57d
Commit
621df57d
authored
Mar 03, 2015
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored inode.LookUpChild.
parent
57cb4ccd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
10 deletions
+23
-10
samples/memfs/inode.go
samples/memfs/inode.go
+23
-10
No files found.
samples/memfs/inode.go
View file @
621df57d
...
...
@@ -116,22 +116,18 @@ func (inode *inode) checkInvariants() {
}
}
////////////////////////////////////////////////////////////////////////
// Public methods
////////////////////////////////////////////////////////////////////////
// Find an entry for the given child name and return its inode ID.
// Return the index of the child within inode.entries, if it exists.
//
// REQUIRES: inode.dir
// SHARED_LOCKS_REQUIRED(inode.mu)
func
(
inode
*
inode
)
LookUpChild
(
name
string
)
(
id
fuse
.
InodeID
,
ok
bool
)
{
func
(
inode
*
inode
)
findChild
(
name
string
)
(
i
int
,
ok
bool
)
{
if
!
inode
.
dir
{
panic
(
"
LookUp
Child called on non-directory."
)
panic
(
"
find
Child called on non-directory."
)
}
for
_
,
e
:=
range
inode
.
entries
{
var
e
fuseutil
.
Dirent
for
i
,
e
=
range
inode
.
entries
{
if
e
.
Name
==
name
{
id
=
e
.
Inode
ok
=
true
return
}
...
...
@@ -140,6 +136,23 @@ func (inode *inode) LookUpChild(name string) (id fuse.InodeID, ok bool) {
return
}
////////////////////////////////////////////////////////////////////////
// Public methods
////////////////////////////////////////////////////////////////////////
// Find an entry for the given child name and return its inode ID.
//
// REQUIRES: inode.dir
// SHARED_LOCKS_REQUIRED(inode.mu)
func
(
inode
*
inode
)
LookUpChild
(
name
string
)
(
id
fuse
.
InodeID
,
ok
bool
)
{
index
,
ok
:=
inode
.
findChild
(
name
)
if
ok
{
id
=
inode
.
entries
[
index
]
.
Inode
}
return
}
// Add an entry for a child.
//
// REQUIRES: inode.dir
...
...
@@ -167,7 +180,7 @@ func (inode *inode) RemoveChild(name string)
// Serve a ReadDir request.
//
// REQUIRE
D
: inode.dir
// REQUIRE
S
: inode.dir
// SHARED_LOCKS_REQUIRED(inode.mu)
func
(
inode
*
inode
)
ReadDir
(
offset
int
,
size
int
)
(
data
[]
byte
,
err
error
)
{
if
!
inode
.
dir
{
...
...
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