Made CachingFS an interface, hiding a bunch of irrelevant stuff.
parent
f1fc462560
commit
3e8995eb7e
|
@ -40,19 +40,27 @@ const (
|
||||||
// inode entries and attributes to be cached, used when responding to fuse
|
// inode entries and attributes to be cached, used when responding to fuse
|
||||||
// requests. It also exposes methods for renumbering inodes and updating mtimes
|
// requests. It also exposes methods for renumbering inodes and updating mtimes
|
||||||
// that are useful in testing that these durations are honored.
|
// that are useful in testing that these durations are honored.
|
||||||
type CachingFS struct {
|
type CachingFS interface {
|
||||||
fuseutil.NotImplementedFileSystem
|
fuse.FileSystem
|
||||||
mu sync.Mutex
|
|
||||||
|
|
||||||
// GUARDED_BY(mu)
|
// Cause inodes to receive IDs according to the following rules in further
|
||||||
inodeIDBase fuse.InodeID
|
// 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)
|
// Cause further queries for the attributes of inodes to use the supplied
|
||||||
mtime time.Time
|
// 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
|
// Create a file system that issues cacheable responses according to the
|
||||||
// following rules:
|
// following rules:
|
||||||
//
|
//
|
||||||
|
@ -67,8 +75,8 @@ var _ fuse.FileSystem = &CachingFS{}
|
||||||
//
|
//
|
||||||
func NewCachingFS(
|
func NewCachingFS(
|
||||||
lookupEntryTimeout time.Duration,
|
lookupEntryTimeout time.Duration,
|
||||||
getattrTimeout time.Duration) (fs *CachingFS, err error) {
|
getattrTimeout time.Duration) (fs CachingFS, err error) {
|
||||||
fs = &CachingFS{
|
fs = &cachingFS{
|
||||||
inodeIDBase: fuse.RootInodeID + 1,
|
inodeIDBase: fuse.RootInodeID + 1,
|
||||||
mtime: time.Now(),
|
mtime: time.Now(),
|
||||||
}
|
}
|
||||||
|
@ -76,6 +84,17 @@ func NewCachingFS(
|
||||||
return
|
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
|
// Cause inodes to receive IDs according to the following rules in further
|
||||||
// responses to fuse:
|
// responses to fuse:
|
||||||
//
|
//
|
||||||
|
@ -87,7 +106,7 @@ func NewCachingFS(
|
||||||
// called with base set to fuse.RootInodeID + 1.
|
// called with base set to fuse.RootInodeID + 1.
|
||||||
//
|
//
|
||||||
// REQUIRES: base > fuse.RootInodeID
|
// REQUIRES: base > fuse.RootInodeID
|
||||||
func (fs *CachingFS) RenumberInodes(base fuse.InodeID) {
|
func (fs *cachingFS) RenumberInodes(base fuse.InodeID) {
|
||||||
fs.mu.Lock()
|
fs.mu.Lock()
|
||||||
defer fs.mu.Unlock()
|
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
|
// Cause further queries for the attributes of inodes to use the supplied time
|
||||||
// as the inode's mtime.
|
// as the inode's mtime.
|
||||||
func (fs *CachingFS) SetMtime(mtime time.Time) {
|
func (fs *cachingFS) SetMtime(mtime time.Time) {
|
||||||
fs.mu.Lock()
|
fs.mu.Lock()
|
||||||
defer fs.mu.Unlock()
|
defer fs.mu.Unlock()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue