Example #1
0
func (c *rawBridge) GetAttr(input *fuse.GetAttrIn, out *fuse.AttrOut) (code fuse.Status) {
	node := c.toInode(input.NodeId)

	var f File
	if input.Flags()&fuse.FUSE_GETATTR_FH != 0 {
		if opened := node.mount.getOpenedFile(input.Fh()); opened != nil {
			f = opened.WithFlags.File
		}
	}

	dest := (*fuse.Attr)(&out.Attr)
	code = node.fsInode.GetAttr(dest, f, &input.Context)
	if !code.Ok() {
		return code
	}

	if out.Nlink == 0 {
		// With Nlink == 0, newer kernels will refuse link
		// operations.
		out.Nlink = 1
	}

	node.mount.fillAttr(out, input.NodeId)
	return fuse.OK
}
Example #2
0
func (m *fileSystemMount) fillAttr(out *fuse.AttrOut, nodeId uint64) {
	splitDuration(m.options.AttrTimeout, &out.AttrValid, &out.AttrValidNsec)
	m.setOwner(&out.Attr)
	if out.Ino == 0 {
		out.Ino = nodeId
	}
}
Example #3
0
func (constor *Constor) GetAttr(input *fuse.GetAttrIn, out *fuse.AttrOut) (code fuse.Status) {
	stat := syscall.Stat_t{}
	inode := constor.inodemap.findInodePtr(input.NodeId)
	if inode == nil {
		constor.error("%d not in inodemap", input.NodeId)
		return fuse.ENOENT
	}
	if inode.id == ROOTID && inode.layer == -1 {
		inode.layer = constor.getLayer(inode.id)
		if inode.layer == -1 {
			constor.error("Unable to find root inode")
			return fuse.ENOENT
		}
	}
	F := constor.fdlookup(inode.id, input.Pid)
	var err error
	// FIXME check to see if F.layer needs to be changed
	if F == nil {
		if inode.layer == -1 {
			constor.error("layer is -1 for %s", inode.id)
			return fuse.ENOENT
		}
		constor.log("Lstat on %s", inode.id)
		err = constor.Lstat(inode.layer, inode.id, &stat)
	} else {
		constor.log("Fstat on %s", inode.id)
		err = syscall.Fstat(F.fd, &stat)
		stat.Ino = idtoino(F.id)
		// FIXME take care of hard links too
	}
	if err != nil {
		constor.error("%s: %s", inode.id, err)
		return fuse.ToStatus(err)
	}
	attr := (*fuse.Attr)(&out.Attr)
	attr.FromStat(&stat)
	out.AttrValid = 1000
	constor.log("%s", inode.id)
	return fuse.OK
}