fusefrontend_reverse: Use openBackingDir in GetAttr
Also fixes 48bd59f388
- the directory FD should
also be closed in case of an error.
This commit is contained in:
parent
ad0f110191
commit
3af51736f3
@ -146,22 +146,17 @@ func (rfs *ReverseFS) GetAttr(relPath string, context *fuse.Context) (*fuse.Attr
|
|||||||
}
|
}
|
||||||
return &a, status
|
return &a, status
|
||||||
}
|
}
|
||||||
// Decrypt path to "plaintext relative path"
|
dirfd, name, err := rfs.openBackingDir(relPath)
|
||||||
pRelPath, err := rfs.decryptPath(relPath)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fuse.ToStatus(err)
|
return nil, fuse.ToStatus(err)
|
||||||
}
|
}
|
||||||
// Stat the backing file/dir using Fstatat
|
// Stat the backing file/dir using Fstatat
|
||||||
var st unix.Stat_t
|
var st unix.Stat_t
|
||||||
dirFd, err := syscallcompat.OpenNofollow(rfs.args.Cipherdir, filepath.Dir(pRelPath), syscall.O_RDONLY|syscall.O_DIRECTORY, 0)
|
err = syscallcompat.Fstatat(dirfd, name, &st, unix.AT_SYMLINK_NOFOLLOW)
|
||||||
|
syscall.Close(dirfd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fuse.ToStatus(err)
|
return nil, fuse.ToStatus(err)
|
||||||
}
|
}
|
||||||
err = syscallcompat.Fstatat(dirFd, filepath.Base(pRelPath), &st, unix.AT_SYMLINK_NOFOLLOW)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fuse.ToStatus(err)
|
|
||||||
}
|
|
||||||
syscall.Close(dirFd)
|
|
||||||
// Instead of risking an inode number collision, we return an error.
|
// Instead of risking an inode number collision, we return an error.
|
||||||
if st.Ino > inoBaseMin {
|
if st.Ino > inoBaseMin {
|
||||||
tlog.Warn.Printf("GetAttr %q: backing file inode number %d crosses reserved space, max=%d. Returning EOVERFLOW.",
|
tlog.Warn.Printf("GetAttr %q: backing file inode number %d crosses reserved space, max=%d. Returning EOVERFLOW.",
|
||||||
|
Loading…
Reference in New Issue
Block a user