Commit d7fec860 authored by Aaron Jacobs's avatar Aaron Jacobs

flushFS.LookUpInode

parent 604281b1
......@@ -16,6 +16,7 @@ package flushfs
import (
"os"
"sync"
"github.com/jacobsa/fuse"
"github.com/jacobsa/fuse/fuseutil"
......@@ -34,13 +35,31 @@ func NewFileSystem(
return
}
const fooID = fuse.RootInodeID + 1
type flushFS struct {
fuseutil.NotImplementedFileSystem
mu sync.Mu
mu sync.Mutex
foo *os.File // GUARDED_BY(mu)
}
////////////////////////////////////////////////////////////////////////
// Helpers
////////////////////////////////////////////////////////////////////////
// LOCKS_REQUIRED(fs.mu)
func (fs *flushFS) fooAttributes() fuse.InodeAttributes {
return fuse.InodeAttributes{
Nlink: 1,
Mode: 0777,
}
}
////////////////////////////////////////////////////////////////////////
// File system methods
////////////////////////////////////////////////////////////////////////
func (fs *flushFS) Init(
ctx context.Context,
req *fuse.InitRequest) (
......@@ -48,3 +67,26 @@ func (fs *flushFS) Init(
resp = &fuse.InitResponse{}
return
}
func (fs *flushFS) LookUpInode(
ctx context.Context,
req *fuse.LookUpInodeRequest) (
resp *fuse.LookUpInodeResponse, err error) {
resp = &fuse.LookUpInodeResponse{}
fs.mu.Lock()
defer fs.mu.Unlock()
// Sanity check.
if req.Parent != fuse.RootInodeID || req.Name != "foo" {
err = fuse.ENOENT
return
}
resp.Entry = fuse.ChildInodeEntry{
Child: fooID,
Attributes: fs.fooAttributes(),
}
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