fix dep, impl nonempty

This commit is contained in:
Barak Michener 2018-03-30 19:36:37 -07:00
parent c8c18403e4
commit a5d237df2a
24 changed files with 286 additions and 215 deletions

View file

@ -276,7 +276,6 @@ func (n *pathInode) GetPath() string {
// them, them, but since this is a hot path, we take some
// effort to avoid allocations.
n.pathFs.pathLock.RLock()
walkUp := n.Inode()
// TODO - guess depth?
@ -299,7 +298,6 @@ func (n *pathInode) GetPath() string {
pathBytes = append(pathBytes, '/')
}
}
n.pathFs.pathLock.RUnlock()
path := string(pathBytes)
if n.pathFs.debug {
@ -585,26 +583,34 @@ func (n *pathInode) GetAttr(out *fuse.Attr, file nodefs.File, context *fuse.Cont
// an open fd.
file = n.Inode().AnyFile()
}
// If we have found an open file, try to fstat it.
if file != nil {
code = file.GetAttr(out)
if code.Ok() {
return code
}
}
// If we don't have an open file, or fstat on it failed due to an internal
// error, stat by path.
if file == nil || code == fuse.ENOSYS || code == fuse.EBADF {
fi, code = n.fs.GetAttr(n.GetPath(), context)
if !code.Ok() {
return code
}
// This is a bug in the filesystem implementation, but let's not
// crash.
if fi == nil {
log.Printf("Bug: fs.GetAttr returned OK with nil data")
return fuse.EINVAL
}
}
if fi != nil {
n.setClientInode(fi.Ino)
}
if fi != nil && !fi.IsDir() && fi.Nlink == 0 {
// Set inode number (unless already set or disabled).
n.setClientInode(fi.Ino)
// Help filesystems that forget to set Nlink.
if !fi.IsDir() && fi.Nlink == 0 {
fi.Nlink = 1
}
if fi != nil {
*out = *fi
}
*out = *fi
return code
}