Lookup looks up a specific entry in the receiver. Lookup should return a Node corresponding to the entry. If the name does not exist in the directory, Lookup should return ENOENT. Lookup need not to handle the names "." and "..".
(ctx context.Context, req *fuse.LookupRequest, resp *fuse.LookupResponse)
| 73 | // |
| 74 | // Lookup need not to handle the names "." and "..". |
| 75 | func (d *Dir) Lookup(ctx context.Context, req *fuse.LookupRequest, resp *fuse.LookupResponse) (node fusefs.Node, err error) { |
| 76 | defer log.Trace(d, "name=%q", req.Name)("node=%+v, err=%v", &node, &err) |
| 77 | mnode, err := d.Dir.Stat(req.Name) |
| 78 | if err != nil { |
| 79 | return nil, translateError(err) |
| 80 | } |
| 81 | resp.EntryValid = time.Duration(d.fsys.opt.AttrTimeout) |
| 82 | // Check the mnode to see if it has a fuse Node cached |
| 83 | // We must return the same fuse nodes for vfs Nodes |
| 84 | node, ok := mnode.Sys().(fusefs.Node) |
| 85 | if ok { |
| 86 | return node, nil |
| 87 | } |
| 88 | switch x := mnode.(type) { |
| 89 | case *vfs.File: |
| 90 | node = &File{x, d.fsys} |
| 91 | case *vfs.Dir: |
| 92 | node = &Dir{x, d.fsys} |
| 93 | default: |
| 94 | panic("bad type") |
| 95 | } |
| 96 | // Cache the node for later |
| 97 | mnode.SetSys(node) |
| 98 | return node, nil |
| 99 | } |
| 100 | |
| 101 | // Check interface satisfied |
| 102 | var _ fusefs.HandleReadDirAller = (*Dir)(nil) |
no test coverage detected