Implemented memFS.OpenDir.

geesefs-0-30-9
Aaron Jacobs 2015-03-02 14:22:59 +11:00
parent 2f98fdd29d
commit 9d4fcebedf
1 changed files with 24 additions and 0 deletions

View File

@ -4,6 +4,8 @@
package memfs
import (
"fmt"
"github.com/jacobsa/fuse"
"github.com/jacobsa/fuse/fuseutil"
"github.com/jacobsa/gcloud/syncutil"
@ -64,3 +66,25 @@ func (fs *memFS) Init(
resp = &fuse.InitResponse{}
return
}
func (fs *memFS) OpenDir(
ctx context.Context,
req *fuse.OpenDirRequest) (resp *fuse.OpenDirResponse, err error) {
fs.mu.RLock()
defer fs.mu.RUnlock()
// We don't mutate spontaneosuly, so if the VFS layer has asked for an
// inode that doesn't exist, something screwed up earlier (a lookup, a
// cache invalidation, etc.).
if req.Inode >= fuse.InodeID(len(fs.inodes)) {
panic(fmt.Sprintf("Inode out of range: %v vs. %v", req.Inode, len(fs.inodes)))
}
var inode *inode = &fs.inodes[req.Inode]
if inode.impl == nil {
panic(fmt.Sprintf("Dead inode requested: %v", req.Inode))
}
// All is good.
return
}