// childLookup fills entry information for a newly created child inode func (c *rawBridge) childLookup(out *fuse.EntryOut, n *Inode, context *fuse.Context) { n.Node().GetAttr((*fuse.Attr)(&out.Attr), nil, context) n.mount.fillEntry(out) out.NodeId, out.Generation = c.fsConn().lookupUpdate(n) if out.Ino == 0 { out.Ino = out.NodeId } if out.Nlink == 0 { // With Nlink == 0, newer kernels will refuse link // operations. out.Nlink = 1 } }
func (c *rawBridge) Lookup(header *fuse.InHeader, name string, out *fuse.EntryOut) (code fuse.Status) { parent := c.toInode(header.NodeId) if !parent.IsDir() { log.Printf("Lookup %q called on non-Directory node %d", name, header.NodeId) return fuse.ENOTDIR } outAttr := (*fuse.Attr)(&out.Attr) child, code := c.fsConn().internalLookup(outAttr, parent, name, header) if code == fuse.ENOENT && parent.mount.negativeEntry(out) { return fuse.OK } if !code.Ok() { return code } if child == nil { log.Println("Lookup returned fuse.OK with nil child", name) } child.mount.fillEntry(out) out.NodeId, out.Generation = c.fsConn().lookupUpdate(child) if out.Ino == 0 { out.Ino = out.NodeId } return fuse.OK }
func (m *fileSystemMount) fillEntry(out *fuse.EntryOut) { splitDuration(m.options.EntryTimeout, &out.EntryValid, &out.EntryValidNsec) splitDuration(m.options.AttrTimeout, &out.AttrValid, &out.AttrValidNsec) m.setOwner(&out.Attr) if out.Mode&fuse.S_IFDIR == 0 && out.Nlink == 0 { out.Nlink = 1 } }
// Creates a return entry for a non-existent path. func (m *fileSystemMount) negativeEntry(out *fuse.EntryOut) bool { if m.options.NegativeTimeout > 0.0 { out.NodeId = 0 splitDuration(m.options.NegativeTimeout, &out.EntryValid, &out.EntryValidNsec) return true } return false }