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
44b62ac9
Commit
44b62ac9
authored
Mar 02, 2015
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Filled in some inode implementation.
parent
830f272a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
15 deletions
+42
-15
samples/memfs/fs.go
samples/memfs/fs.go
+5
-13
samples/memfs/inode.go
samples/memfs/inode.go
+37
-2
No files found.
samples/memfs/fs.go
View file @
44b62ac9
...
...
@@ -137,10 +137,6 @@ func (fs *memFS) LookUpInode(
inode
:=
fs
.
getInodeForReadingOrDie
(
req
.
Parent
)
defer
inode
.
mu
.
RUnlock
()
if
!
inode
.
dir
{
panic
(
"Found non-dir."
)
}
// Does the directory have an entry with the given name?
childID
,
ok
:=
inode
.
LookUpChild
(
req
.
Name
)
if
!
ok
{
...
...
@@ -223,15 +219,11 @@ func (fs *memFS) ReadDir(
panic
(
"Found non-dir."
)
}
// Return the entries requested.
for
i
:=
int
(
req
.
Offset
);
i
<
len
(
inode
.
entries
);
i
++
{
resp
.
Data
=
fuseutil
.
AppendDirent
(
resp
.
Data
,
inode
.
entries
[
i
])
// Trim and stop early if we've exceeded the requested size.
if
len
(
resp
.
Data
)
>
req
.
Size
{
resp
.
Data
=
resp
.
Data
[
:
req
.
Size
]
break
}
// Serve the request.
resp
.
Data
,
err
=
inode
.
ReadDir
(
int
(
req
.
Offset
),
req
.
Size
)
if
err
!=
nil
{
err
=
fmt
.
Errorf
(
"inode.ReadDir: %v"
,
err
)
return
}
return
...
...
samples/memfs/inode.go
View file @
44b62ac9
...
...
@@ -55,7 +55,14 @@ type inode struct {
contents
[]
byte
// GUARDED_BY(mu)
}
func
newInode
(
dir
bool
)
(
inode
*
inode
)
func
newInode
(
dir
bool
)
(
in
*
inode
)
{
in
=
&
inode
{
dir
:
dir
,
}
in
.
mu
=
syncutil
.
NewInvariantMutex
(
in
.
checkInvariants
)
return
}
func
(
inode
*
inode
)
checkInvariants
()
...
...
@@ -63,4 +70,32 @@ func (inode *inode) checkInvariants()
//
// REQUIRES: inode.dir
// SHARED_LOCKS_REQUIRED(inode.mu)
func
(
inode
*
inode
)
LookUpChild
(
name
string
)
(
id
fuse
.
InodeID
,
ok
bool
)
func
(
inode
*
inode
)
LookUpChild
(
name
string
)
(
id
fuse
.
InodeID
,
ok
bool
)
{
if
!
inode
.
dir
{
panic
(
"LookUpChild called on non-directory."
)
}
panic
(
"TODO"
)
}
// Serve a ReadDir request.
//
// REQUIRED: inode.dir
// SHARED_LOCKS_REQUIRED(inode.mu)
func
(
inode
*
inode
)
ReadDir
(
offset
int
,
size
int
)
(
data
[]
byte
,
err
error
)
{
if
!
inode
.
dir
{
panic
(
"ReadDir called on non-directory."
)
}
for
i
:=
offset
;
i
<
len
(
inode
.
entries
);
i
++
{
data
=
fuseutil
.
AppendDirent
(
data
,
inode
.
entries
[
i
])
// Trim and stop early if we've exceeded the requested size.
if
len
(
data
)
>
size
{
data
=
data
[
:
size
]
break
}
}
return
}
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