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
11724230
Commit
11724230
authored
Mar 17, 2015
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented LookUpInode.
parent
1b71593b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
87 additions
and
0 deletions
+87
-0
samples/cachingfs/caching_fs.go
samples/cachingfs/caching_fs.go
+87
-0
No files found.
samples/cachingfs/caching_fs.go
View file @
11724230
...
...
@@ -107,6 +107,10 @@ type cachingFS struct {
mtime
time
.
Time
}
////////////////////////////////////////////////////////////////////////
// Helpers
////////////////////////////////////////////////////////////////////////
func
(
fs
*
cachingFS
)
checkInvariants
()
{
// INVARIANT: baseID > fuse.RootInodeID
// INVARIANT: baseID % numInodes == 0
...
...
@@ -115,6 +119,28 @@ func (fs *cachingFS) checkInvariants() {
}
}
// LOCKS_REQUIRED(fs.mu)
func
(
fs
*
cachingFS
)
fooID
()
fuse
.
InodeID
// LOCKS_REQUIRED(fs.mu)
func
(
fs
*
cachingFS
)
dirID
()
fuse
.
InodeID
// LOCKS_REQUIRED(fs.mu)
func
(
fs
*
cachingFS
)
barID
()
fuse
.
InodeID
// LOCKS_REQUIRED(fs.mu)
func
(
fs
*
cachingFS
)
fooAttrs
()
fuse
.
InodeAttributes
// LOCKS_REQUIRED(fs.mu)
func
(
fs
*
cachingFS
)
dirAttrs
()
fuse
.
InodeAttributes
// LOCKS_REQUIRED(fs.mu)
func
(
fs
*
cachingFS
)
barAttrs
()
fuse
.
InodeAttributes
////////////////////////////////////////////////////////////////////////
// Public interface
////////////////////////////////////////////////////////////////////////
// LOCKS_EXCLUDED(fs.mu)
func
(
fs
*
cachingFS
)
FooID
()
fuse
.
InodeID
{
fs
.
mu
.
Lock
()
...
...
@@ -155,9 +181,70 @@ func (fs *cachingFS) SetMtime(mtime time.Time) {
fs
.
mtime
=
mtime
}
////////////////////////////////////////////////////////////////////////
// FileSystem methods
////////////////////////////////////////////////////////////////////////
func
(
fs
*
cachingFS
)
Init
(
ctx
context
.
Context
,
req
*
fuse
.
InitRequest
)
(
resp
*
fuse
.
InitResponse
,
err
error
)
{
resp
=
&
fuse
.
InitResponse
{}
return
}
// LOCKS_EXCLUDED(fs.mu)
func
(
fs
*
cachingFS
)
LookUpInode
(
ctx
context
.
Context
,
req
*
fuse
.
LookUpInodeRequest
)
(
resp
*
fuse
.
LookUpInodeResponse
,
err
error
)
{
resp
=
&
fuse
.
LookUpInodeResponse
{}
fs
.
mu
.
Lock
()
defer
fs
.
mu
.
Unlock
()
// Find the ID and attributes.
var
id
fuse
.
InodeID
var
attrs
fuse
.
InodeAttributes
switch
req
.
Name
{
case
"foo"
:
// Parent must be the root.
if
req
.
Parent
!=
fuse
.
RootInodeID
{
err
=
fuse
.
ENOENT
return
}
id
=
fs
.
fooID
()
attrs
=
fs
.
fooAttrs
()
case
"dir"
:
// Parent must be the root.
if
req
.
Parent
!=
fuse
.
RootInodeID
{
err
=
fuse
.
ENOENT
return
}
id
=
fs
.
dirID
()
attrs
=
fs
.
dirAttrs
()
case
"bar"
:
// Parent must be dir.
if
req
.
Parent
%
numInodes
!=
dirOffset
{
err
=
fuse
.
ENOENT
return
}
id
=
fs
.
barID
()
attrs
=
fs
.
barAttrs
()
default
:
err
=
fuse
.
ENOENT
return
}
// Fill in the response.
resp
.
Entry
.
Child
=
id
resp
.
Entry
.
Attributes
=
attrs
resp
.
Entry
.
EntryExpiration
=
fs
.
entryExpiration
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