Example #1
0
func (d Dir) Lookup(ctx context.Context, req *fuse.LookupRequest, res *fuse.LookupResponse) (fs.Node, error) {
	log.Debug("Lookup(%s,%d,%s)", d.GetPath(), req.Node, req.Name)
	lock.Lock()
	defer lock.Unlock()

	node, err := d.lookup(ctx, req.Name)
	if err != nil {
		return nil, err
	}

	res.Node = fuse.NodeID(d.Fs.GenerateInode(uint64(req.Node), req.Name))
	return node, nil
}
Example #2
0
func (d *Dir) Lookup(ctx context.Context, req *fuse.LookupRequest, resp *fuse.LookupResponse) (fusefs.Node, error) {
	if skipDirEntry(req.Name) {
		return nil, fuse.ENOENT
	}
	path := filepath.Join(d.path, req.Name)
	isDir := false
	defer trace(NewLookupOp(req, path, isDir))
	var st syscall.Stat_t
	if err := syscall.Lstat(path, &st); err != nil {
		return nil, fuse.ENOENT
	}
	resp.Attr = statToFuseAttr(st)
	resp.Node = fuse.NodeID(resp.Attr.Inode)
	// TODO: should we overwrite resp.EntryValid?
	// resp.EntryValid = time.Duration(500) * time.Millisecond
	if isDir = resp.Attr.Mode.IsDir(); isDir {
		return NewDir(d.path, req.Name, d.fs), nil
	}
	return NewFile(d.path, req.Name, d.fs), nil
}