func (f *fs) handleLookup(r *fuse.LookupRequest) { log.Println("Inside handleLookup") log.Printf("Running Lookup for %s", r.Name) log.Println(r) resp := &fuse.LookupResponse{} l, err := f.rpc.api.Lookup(f.getContext(), &pb.LookupRequest{Name: r.Name, Parent: uint64(r.Node)}) if err != nil { log.Fatalf("Lookup failed(%s): %v", r.Name, err) } // If there is no name then it wasn't found if l.Name != r.Name { log.Printf("ENOENT Lookup(%s)", r.Name) r.RespondError(fuse.ENOENT) return } resp.Node = fuse.NodeID(l.Attr.Inode) copyAttr(&resp.Attr, l.Attr) // TODO: should we make these configureable? resp.Attr.Valid = 5 * time.Second resp.EntryValid = 5 * time.Second log.Println(resp) r.Respond(resp) }
// Return a Dirent for all children of an inode, or ENOENT func (sc *serveConn) lookup(req *fuse.LookupRequest) { inode := uint64(req.Header.Node) resp := &fuse.LookupResponse{} var err error file, err := sc.db.FileByInode(inode) if err != nil { fuse.Debug(fmt.Sprintf("FileByInode lookup failure for %d: %v", inode, err)) req.RespondError(fuse.ENOENT) return } for _, cInode := range file.Children { cf, err := sc.db.FileByInode(cInode) if err != nil { fuse.Debug(fmt.Sprintf("FileByInode(%v): %v", cInode, err)) req.RespondError(fuse.EIO) return } if cf.Title == req.Name { resp.Node = fuse.NodeID(cInode) resp.EntryValid = *driveMetadataLatency resp.Attr = sc.attrFromFile(*cf) fuse.Debug(fmt.Sprintf("Lookup(%v in %v): %v", req.Name, inode, cInode)) req.Respond(resp) return } } fuse.Debug(fmt.Sprintf("Lookup(%v in %v): ENOENT", req.Name, inode)) req.RespondError(fuse.ENOENT) }