fusefrontend: convert last callers from openBackingDir to prepareAtSyscall
This commit is contained in:
parent
1f29542b39
commit
5306fc345b
@ -4,7 +4,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"path/filepath"
|
|
||||||
"runtime"
|
"runtime"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
@ -239,15 +238,14 @@ func (n *Node) Readdir(ctx context.Context) (fs.DirStream, syscall.Errno) {
|
|||||||
// Symlink-safe through Unlinkat() + AT_REMOVEDIR.
|
// Symlink-safe through Unlinkat() + AT_REMOVEDIR.
|
||||||
func (n *Node) Rmdir(ctx context.Context, name string) (code syscall.Errno) {
|
func (n *Node) Rmdir(ctx context.Context, name string) (code syscall.Errno) {
|
||||||
rn := n.rootNode()
|
rn := n.rootNode()
|
||||||
p := filepath.Join(n.Path(), name)
|
parentDirFd, cName, errno := n.prepareAtSyscall(name)
|
||||||
parentDirFd, cName, err := rn.openBackingDir(p)
|
if errno != 0 {
|
||||||
if err != nil {
|
return errno
|
||||||
return fs.ToErrno(err)
|
|
||||||
}
|
}
|
||||||
defer syscall.Close(parentDirFd)
|
defer syscall.Close(parentDirFd)
|
||||||
if rn.args.PlaintextNames {
|
if rn.args.PlaintextNames {
|
||||||
// Unlinkat with AT_REMOVEDIR is equivalent to Rmdir
|
// Unlinkat with AT_REMOVEDIR is equivalent to Rmdir
|
||||||
err = unix.Unlinkat(parentDirFd, cName, unix.AT_REMOVEDIR)
|
err := unix.Unlinkat(parentDirFd, cName, unix.AT_REMOVEDIR)
|
||||||
return fs.ToErrno(err)
|
return fs.ToErrno(err)
|
||||||
}
|
}
|
||||||
// Unless we are running as root, we need read, write and execute permissions
|
// Unless we are running as root, we need read, write and execute permissions
|
||||||
@ -256,7 +254,7 @@ func (n *Node) Rmdir(ctx context.Context, name string) (code syscall.Errno) {
|
|||||||
var origMode uint32
|
var origMode uint32
|
||||||
if !rn.args.PreserveOwner {
|
if !rn.args.PreserveOwner {
|
||||||
var st unix.Stat_t
|
var st unix.Stat_t
|
||||||
err = syscallcompat.Fstatat(parentDirFd, cName, &st, unix.AT_SYMLINK_NOFOLLOW)
|
err := syscallcompat.Fstatat(parentDirFd, cName, &st, unix.AT_SYMLINK_NOFOLLOW)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fs.ToErrno(err)
|
return fs.ToErrno(err)
|
||||||
}
|
}
|
||||||
|
@ -98,11 +98,12 @@ func (n *Node) prepareAtSyscallMyself() (dirfd int, cName string, errno syscall.
|
|||||||
if n.IsRoot() {
|
if n.IsRoot() {
|
||||||
var err error
|
var err error
|
||||||
rn := n.rootNode()
|
rn := n.rootNode()
|
||||||
dirfd, cName, err = rn.openBackingDir("")
|
// Open cipherdir (following symlinks)
|
||||||
|
dirfd, err = syscallcompat.Open(rn.args.Cipherdir, syscall.O_DIRECTORY|syscallcompat.O_PATH, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errno = fs.ToErrno(err)
|
return -1, "", fs.ToErrno(err)
|
||||||
}
|
}
|
||||||
return
|
return dirfd, ".", 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise convert to prepareAtSyscall of parent node
|
// Otherwise convert to prepareAtSyscall of parent node
|
||||||
|
Loading…
Reference in New Issue
Block a user