Commit 9c33490a authored by Aaron Jacobs's avatar Aaron Jacobs

Removed clocks from memfs.go.

parent de030d4a
...@@ -26,7 +26,6 @@ import ( ...@@ -26,7 +26,6 @@ import (
"github.com/jacobsa/fuse/fuseops" "github.com/jacobsa/fuse/fuseops"
"github.com/jacobsa/fuse/fuseutil" "github.com/jacobsa/fuse/fuseutil"
"github.com/jacobsa/syncutil" "github.com/jacobsa/syncutil"
"github.com/jacobsa/timeutil"
) )
type memFS struct { type memFS struct {
...@@ -36,12 +35,6 @@ type memFS struct { ...@@ -36,12 +35,6 @@ type memFS struct {
uid uint32 uid uint32
gid uint32 gid uint32
/////////////////////////
// Dependencies
/////////////////////////
clock timeutil.Clock
///////////////////////// /////////////////////////
// Mutable state // Mutable state
///////////////////////// /////////////////////////
...@@ -74,11 +67,9 @@ type memFS struct { ...@@ -74,11 +67,9 @@ type memFS struct {
// default_permissions option. // default_permissions option.
func NewMemFS( func NewMemFS(
uid uint32, uid uint32,
gid uint32, gid uint32) fuse.Server {
clock timeutil.Clock) fuse.Server {
// Set up the basic struct. // Set up the basic struct.
fs := &memFS{ fs := &memFS{
clock: clock,
inodes: make([]*inode, fuseops.RootInodeID+1), inodes: make([]*inode, fuseops.RootInodeID+1),
uid: uid, uid: uid,
gid: gid, gid: gid,
...@@ -91,7 +82,7 @@ func NewMemFS( ...@@ -91,7 +82,7 @@ func NewMemFS(
Gid: gid, Gid: gid,
} }
fs.inodes[fuseops.RootInodeID] = newInode(clock, rootAttrs) fs.inodes[fuseops.RootInodeID] = newInode(rootAttrs)
// Set up invariant checking. // Set up invariant checking.
fs.mu = syncutil.NewInvariantMutex(fs.checkInvariants) fs.mu = syncutil.NewInvariantMutex(fs.checkInvariants)
...@@ -165,7 +156,7 @@ func (fs *memFS) getInodeOrDie(id fuseops.InodeID) (inode *inode) { ...@@ -165,7 +156,7 @@ func (fs *memFS) getInodeOrDie(id fuseops.InodeID) (inode *inode) {
func (fs *memFS) allocateInode( func (fs *memFS) allocateInode(
attrs fuseops.InodeAttributes) (id fuseops.InodeID, inode *inode) { attrs fuseops.InodeAttributes) (id fuseops.InodeID, inode *inode) {
// Create the inode. // Create the inode.
inode = newInode(fs.clock, attrs) inode = newInode(attrs)
// Re-use a free ID if possible. Otherwise mint a new one. // Re-use a free ID if possible. Otherwise mint a new one.
numFree := len(fs.freeInodes) numFree := len(fs.freeInodes)
...@@ -216,7 +207,7 @@ func (fs *memFS) LookUpInode( ...@@ -216,7 +207,7 @@ func (fs *memFS) LookUpInode(
// We don't spontaneously mutate, so the kernel can cache as long as it wants // We don't spontaneously mutate, so the kernel can cache as long as it wants
// (since it also handles invalidation). // (since it also handles invalidation).
op.Entry.AttributesExpiration = fs.clock.Now().Add(365 * 24 * time.Hour) op.Entry.AttributesExpiration = time.Now().Add(365 * 24 * time.Hour)
op.Entry.EntryExpiration = op.Entry.EntryExpiration op.Entry.EntryExpiration = op.Entry.EntryExpiration
return return
...@@ -236,7 +227,7 @@ func (fs *memFS) GetInodeAttributes( ...@@ -236,7 +227,7 @@ func (fs *memFS) GetInodeAttributes(
// We don't spontaneously mutate, so the kernel can cache as long as it wants // We don't spontaneously mutate, so the kernel can cache as long as it wants
// (since it also handles invalidation). // (since it also handles invalidation).
op.AttributesExpiration = fs.clock.Now().Add(365 * 24 * time.Hour) op.AttributesExpiration = time.Now().Add(365 * 24 * time.Hour)
return return
} }
...@@ -258,7 +249,7 @@ func (fs *memFS) SetInodeAttributes( ...@@ -258,7 +249,7 @@ func (fs *memFS) SetInodeAttributes(
// We don't spontaneously mutate, so the kernel can cache as long as it wants // We don't spontaneously mutate, so the kernel can cache as long as it wants
// (since it also handles invalidation). // (since it also handles invalidation).
op.AttributesExpiration = fs.clock.Now().Add(365 * 24 * time.Hour) op.AttributesExpiration = time.Now().Add(365 * 24 * time.Hour)
return return
} }
...@@ -300,7 +291,7 @@ func (fs *memFS) MkDir( ...@@ -300,7 +291,7 @@ func (fs *memFS) MkDir(
// We don't spontaneously mutate, so the kernel can cache as long as it wants // We don't spontaneously mutate, so the kernel can cache as long as it wants
// (since it also handles invalidation). // (since it also handles invalidation).
op.Entry.AttributesExpiration = fs.clock.Now().Add(365 * 24 * time.Hour) op.Entry.AttributesExpiration = time.Now().Add(365 * 24 * time.Hour)
op.Entry.EntryExpiration = op.Entry.EntryExpiration op.Entry.EntryExpiration = op.Entry.EntryExpiration
return return
...@@ -324,7 +315,7 @@ func (fs *memFS) CreateFile( ...@@ -324,7 +315,7 @@ func (fs *memFS) CreateFile(
} }
// Set up attributes from the child. // Set up attributes from the child.
now := fs.clock.Now() now := time.Now()
childAttrs := fuseops.InodeAttributes{ childAttrs := fuseops.InodeAttributes{
Nlink: 1, Nlink: 1,
Mode: op.Mode, Mode: op.Mode,
...@@ -348,7 +339,7 @@ func (fs *memFS) CreateFile( ...@@ -348,7 +339,7 @@ func (fs *memFS) CreateFile(
// We don't spontaneously mutate, so the kernel can cache as long as it wants // We don't spontaneously mutate, so the kernel can cache as long as it wants
// (since it also handles invalidation). // (since it also handles invalidation).
op.Entry.AttributesExpiration = fs.clock.Now().Add(365 * 24 * time.Hour) op.Entry.AttributesExpiration = time.Now().Add(365 * 24 * time.Hour)
op.Entry.EntryExpiration = op.Entry.EntryExpiration op.Entry.EntryExpiration = op.Entry.EntryExpiration
// We have nothing interesting to put in the Handle field. // We have nothing interesting to put in the Handle field.
...@@ -374,7 +365,7 @@ func (fs *memFS) CreateSymlink( ...@@ -374,7 +365,7 @@ func (fs *memFS) CreateSymlink(
} }
// Set up attributes from the child. // Set up attributes from the child.
now := fs.clock.Now() now := time.Now()
childAttrs := fuseops.InodeAttributes{ childAttrs := fuseops.InodeAttributes{
Nlink: 1, Nlink: 1,
Mode: 0444 | os.ModeSymlink, Mode: 0444 | os.ModeSymlink,
...@@ -401,7 +392,7 @@ func (fs *memFS) CreateSymlink( ...@@ -401,7 +392,7 @@ func (fs *memFS) CreateSymlink(
// We don't spontaneously mutate, so the kernel can cache as long as it wants // We don't spontaneously mutate, so the kernel can cache as long as it wants
// (since it also handles invalidation). // (since it also handles invalidation).
op.Entry.AttributesExpiration = fs.clock.Now().Add(365 * 24 * time.Hour) op.Entry.AttributesExpiration = time.Now().Add(365 * 24 * time.Hour)
op.Entry.EntryExpiration = op.Entry.EntryExpiration op.Entry.EntryExpiration = op.Entry.EntryExpiration
return return
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment