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
3e8995eb
Commit
3e8995eb
authored
Mar 17, 2015
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made CachingFS an interface, hiding a bunch of irrelevant stuff.
parent
f1fc4625
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
13 deletions
+32
-13
samples/cachingfs/caching_fs.go
samples/cachingfs/caching_fs.go
+32
-13
No files found.
samples/cachingfs/caching_fs.go
View file @
3e8995eb
...
...
@@ -40,19 +40,27 @@ const (
// inode entries and attributes to be cached, used when responding to fuse
// requests. It also exposes methods for renumbering inodes and updating mtimes
// that are useful in testing that these durations are honored.
type
CachingFS
struct
{
fuseutil
.
NotImplementedFileSystem
mu
sync
.
Mutex
type
CachingFS
interface
{
fuse
.
FileSystem
// GUARDED_BY(mu)
inodeIDBase
fuse
.
InodeID
// Cause inodes to receive IDs according to the following rules in further
// responses to fuse:
//
// * The ID of "foo" is base + FooInodeOffset.
// * The ID of "dir" is base + DirInodeOffset.
// * The ID of "dir/bar" is base + BarInodeOffset.
//
// If this method has never been called, the file system behaves as if it
// were called with base set to fuse.RootInodeID + 1.
//
// REQUIRES: base > fuse.RootInodeID
RenumberInodes
(
base
fuse
.
InodeID
)
// GUARDED_BY(mu)
mtime
time
.
Time
// Cause further queries for the attributes of inodes to use the supplied
// time as the inode's mtime.
SetMtime
(
mtime
time
.
Time
)
}
var
_
fuse
.
FileSystem
=
&
CachingFS
{}
// Create a file system that issues cacheable responses according to the
// following rules:
//
...
...
@@ -67,8 +75,8 @@ var _ fuse.FileSystem = &CachingFS{}
//
func
NewCachingFS
(
lookupEntryTimeout
time
.
Duration
,
getattrTimeout
time
.
Duration
)
(
fs
*
CachingFS
,
err
error
)
{
fs
=
&
C
achingFS
{
getattrTimeout
time
.
Duration
)
(
fs
CachingFS
,
err
error
)
{
fs
=
&
c
achingFS
{
inodeIDBase
:
fuse
.
RootInodeID
+
1
,
mtime
:
time
.
Now
(),
}
...
...
@@ -76,6 +84,17 @@ func NewCachingFS(
return
}
type
cachingFS
struct
{
fuseutil
.
NotImplementedFileSystem
mu
sync
.
Mutex
// GUARDED_BY(mu)
inodeIDBase
fuse
.
InodeID
// GUARDED_BY(mu)
mtime
time
.
Time
}
// Cause inodes to receive IDs according to the following rules in further
// responses to fuse:
//
...
...
@@ -87,7 +106,7 @@ func NewCachingFS(
// called with base set to fuse.RootInodeID + 1.
//
// REQUIRES: base > fuse.RootInodeID
func
(
fs
*
C
achingFS
)
RenumberInodes
(
base
fuse
.
InodeID
)
{
func
(
fs
*
c
achingFS
)
RenumberInodes
(
base
fuse
.
InodeID
)
{
fs
.
mu
.
Lock
()
defer
fs
.
mu
.
Unlock
()
...
...
@@ -96,7 +115,7 @@ func (fs *CachingFS) RenumberInodes(base fuse.InodeID) {
// Cause further queries for the attributes of inodes to use the supplied time
// as the inode's mtime.
func
(
fs
*
C
achingFS
)
SetMtime
(
mtime
time
.
Time
)
{
func
(
fs
*
c
achingFS
)
SetMtime
(
mtime
time
.
Time
)
{
fs
.
mu
.
Lock
()
defer
fs
.
mu
.
Unlock
()
...
...
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