flushFS.LookUpInode

geesefs-0-30-9
Aaron Jacobs 2015-03-20 11:38:40 +11:00
parent 604281b157
commit d7fec86069
1 changed files with 43 additions and 1 deletions

View File

@ -16,6 +16,7 @@ package flushfs
import ( import (
"os" "os"
"sync"
"github.com/jacobsa/fuse" "github.com/jacobsa/fuse"
"github.com/jacobsa/fuse/fuseutil" "github.com/jacobsa/fuse/fuseutil"
@ -34,13 +35,31 @@ func NewFileSystem(
return return
} }
const fooID = fuse.RootInodeID + 1
type flushFS struct { type flushFS struct {
fuseutil.NotImplementedFileSystem fuseutil.NotImplementedFileSystem
mu sync.Mu mu sync.Mutex
foo *os.File // GUARDED_BY(mu) 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( func (fs *flushFS) Init(
ctx context.Context, ctx context.Context,
req *fuse.InitRequest) ( req *fuse.InitRequest) (
@ -48,3 +67,26 @@ func (fs *flushFS) Init(
resp = &fuse.InitResponse{} resp = &fuse.InitResponse{}
return 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
}