From 1b3c0d148959a61c2cc8481b9b45920593fcbe81 Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Fri, 27 Feb 2015 13:56:51 +1100 Subject: [PATCH] Implemented HelloFS.LookUpInode. --- samples/hello_fs.go | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/samples/hello_fs.go b/samples/hello_fs.go index 6c6548c..5324839 100644 --- a/samples/hello_fs.go +++ b/samples/hello_fs.go @@ -77,6 +77,46 @@ var gInodeInfo = map[fuse.InodeID]inodeInfo{ }, } +func findChildInode( + name string, + children []fuseutil.Dirent) (inode fuse.InodeID, err error) { + for _, e := range children { + if e.Name == name { + inode = e.Inode + return + } + } + + err = fuse.ENOENT + return +} + +func (fs *HelloFS) LookUpInode( + ctx context.Context, + req *fuse.LookUpInodeRequest) ( + resp *fuse.LookUpInodeResponse, err error) { + resp = &fuse.LookUpInodeResponse{} + + // Find the info for the parent. + parentInfo, ok := gInodeInfo[req.Parent] + if !ok { + err = fuse.ENOENT + return + } + + // Find the child within the parent. + childInode, err := findChildInode(req.Name, parentInfo.children) + if err != nil { + return + } + + // Copy over information. + resp.Child = childInode + resp.Attributes = gInodeInfo[childInode].attributes + + return +} + func (fs *HelloFS) GetInodeAttributes( ctx context.Context, req *fuse.GetInodeAttributesRequest) (