func (n *pathInode) GetAttr(out *fuse.Attr, file nodefs.File, context *fuse.Context) (code fuse.Status) { var fi *fuse.Attr if file == nil { // called on a deleted files. file = n.Inode().AnyFile() } if file != nil { code = file.GetAttr(out) } if file == nil || code == fuse.ENOSYS || code == fuse.EBADF { fi, code = n.fs.GetAttr(n.GetPath(), context) } if fi != nil { n.setClientInode(fi.Ino) } if fi != nil && !fi.IsDir() && fi.Nlink == 0 { fi.Nlink = 1 } if fi != nil { *out = *fi } return code }
func (n *pathInode) GetAttr(out *fuse.Attr, file nodefs.File, context *fuse.Context) (code fuse.Status) { var fi *fuse.Attr if file == nil { // Linux currently (tested on v4.4) does not pass a file descriptor for // fstat. To be able to stat a deleted file we have to find ourselves // an open fd. file = n.Inode().AnyFile() } if file != nil { code = file.GetAttr(out) } if file == nil || code == fuse.ENOSYS || code == fuse.EBADF { fi, code = n.fs.GetAttr(n.GetPath(), context) } if fi != nil { n.setClientInode(fi.Ino) } if fi != nil && !fi.IsDir() && fi.Nlink == 0 { fi.Nlink = 1 } if fi != nil { *out = *fi } return code }
func (me *memNode) GetAttr(out *fuse.Attr, file nodefs.File, context *fuse.Context) (code fuse.Status) { var sz uint64 if file != nil { code := file.GetAttr(out) if code.Ok() { sz = out.Size } else { msg := fmt.Sprintf("File.GetAttr(%s) = %v, %v", file.String(), out, code) panic(msg) } } me.mutex.RLock() defer me.mutex.RUnlock() *out = me.info if file != nil { out.Size = sz } return fuse.OK }
// GetAttr - FUSE call func (rfs *ReverseFS) GetAttr(relPath string, context *fuse.Context) (*fuse.Attr, fuse.Status) { if rfs.isTranslatedConfig(relPath) { return rfs.inoAwareStat(configfile.ConfReverseName) } // Handle virtual files var f nodefs.File var status fuse.Status virtual := false if rfs.isDirIV(relPath) { virtual = true f, status = rfs.newDirIVFile(relPath) } if rfs.isNameFile(relPath) { virtual = true f, status = rfs.newNameFile(relPath) } if virtual { if !status.Ok() { fmt.Printf("GetAttr %q: newXFile failed: %v\n", relPath, status) return nil, status } var a fuse.Attr status = f.GetAttr(&a) return &a, status } cPath, err := rfs.decryptPath(relPath) if err != nil { return nil, fuse.ToStatus(err) } a, status := rfs.inoAwareStat(cPath) if !status.Ok() { return nil, status } // Calculate encrypted file size if a.IsRegular() { a.Size = rfs.contentEnc.PlainSizeToCipherSize(a.Size) } return a, fuse.OK }