From 19c26cc2e84e0dd2cd19c63e6a147fb81eba7546 Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Tue, 17 Mar 2015 13:23:30 +1100 Subject: [PATCH] Implemented FooID. --- samples/cachingfs/caching_fs.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/samples/cachingfs/caching_fs.go b/samples/cachingfs/caching_fs.go index 7c48931..6d910d9 100644 --- a/samples/cachingfs/caching_fs.go +++ b/samples/cachingfs/caching_fs.go @@ -71,8 +71,8 @@ func NewCachingFS( lookupEntryTimeout time.Duration, getattrTimeout time.Duration) (fs CachingFS, err error) { cfs := &cachingFS{ - fooID: ((fuse.RootInodeID + 1 + numInodes - 1) / numInodes) + fooOffset, - mtime: time.Now(), + baseID: (fuse.RootInodeID + 1 + numInodes - 1) / numInodes, + mtime: time.Now(), } cfs.mu = syncutil.NewInvariantMutex(cfs.checkInvariants) @@ -94,7 +94,7 @@ type cachingFS struct { fuseutil.NotImplementedFileSystem mu syncutil.InvariantMutex - // The current ID of foo. + // The current ID of the lowest numbered non-root inode. // // INVARIANT: FooID() > fuse.RootInodeID // INVARIANT: DirID() > fuse.RootInodeID @@ -105,7 +105,7 @@ type cachingFS struct { // INVARIANT: BarID() % numInodes == barOffset // // GUARDED_BY(mu) - fooID fuse.InodeID + baseID fuse.InodeID // GUARDED_BY(mu) mtime time.Time @@ -114,7 +114,12 @@ type cachingFS struct { func (fs *cachingFS) checkInvariants() // LOCKS_EXCLUDED(fs.mu) -func (fs *cachingFS) FooID() fuse.InodeID +func (fs *cachingFS) FooID() fuse.InodeID { + fs.mu.Lock() + defer fs.mu.Unlock() + + return fs.baseID + fooOffset +} // LOCKS_EXCLUDED(fs.mu) func (fs *cachingFS) DirID() fuse.InodeID