Esempio n. 1
0
func (m *MaggieFuse) GetAttr(input *fuse.GetAttrIn, out *fuse.AttrOut) (code fuse.Status) {
	// optimized path for open files
	if input.Fh_ > 0 {
		log.Printf("Fetching ino for GetAttr from openFileMap for fh %d", input.Fh_)
		_, i, err := m.openFiles.getInode(input.Fh_)
		if err != nil {
			return fuse.ENOSYS
		}
		if i != nil {
			log.Printf("Got ino for GetAttr from openFileMap")
			fillAttrOut(out, i)
			out.AttrValid = uint64(1) // hold onto it for a second
			out.AttrValidNsec = uint32(1e9)
			return fuse.OK
		}
	}
	// normal case for files that aren't currently open
	i, err := m.names.GetInode(input.InHeader.NodeId)
	if err != nil {
		return fuse.EROFS
	}
	fillAttrOut(out, i)
	return fuse.OK
}
Esempio n. 2
0
func fillAttrOut(out *fuse.AttrOut, i *maggiefs.Inode) {
	// fuse.Attr
	out.Ino = i.Inodeid
	out.Size = i.Length
	out.Blocks = numBlocks(i.Length, maggiefs.PAGESIZE)
	out.Atime = uint64(0)
	out.Mtime = uint64(i.Mtime) // Mtime is user modifiable and is the last time data changed
	out.Ctime = uint64(i.Ctime) // Ctime is tracked by the FS and changes when attrs or data change
	out.Atimensec = uint32(0)
	out.Mtimensec = uint32(0)
	out.Ctimensec = uint32(0)
	out.Mode = i.FullMode()
	out.Nlink = i.Nlink
	out.Uid = i.Uid
	out.Gid = i.Gid
	out.Rdev = uint32(0) // regular file, not block dvice
	out.Blksize = maggiefs.PAGESIZE
	// fuse.AttrOut
	out.AttrValid = uint64(0)
	out.AttrValidNsec = uint32(100)
}