summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorJakob Unterwurzacher2021-04-03 11:19:04 +0200
committerJakob Unterwurzacher2021-04-03 11:19:04 +0200
commit6b28c0be2ce1a2a90a1d186adf91052d5192a55e (patch)
treec657c3381162923c77bdd0c7af8899aa0152a82d /internal
parentbeab7004f2556fec637ebe55a3aefad3d81c419f (diff)
fusefronted: replace last rn.openBackingDir() calls
Use the n.prepareAtSyscall() wrapper instead. Prepares for adding caching into n.prepareAtSyscall().
Diffstat (limited to 'internal')
-rw-r--r--internal/fusefrontend/node_dir_ops.go32
1 files changed, 13 insertions, 19 deletions
diff --git a/internal/fusefrontend/node_dir_ops.go b/internal/fusefrontend/node_dir_ops.go
index b8d4ec7..715b7aa 100644
--- a/internal/fusefrontend/node_dir_ops.go
+++ b/internal/fusefrontend/node_dir_ops.go
@@ -66,25 +66,21 @@ func (n *Node) mkdirWithIv(dirfd int, cName string, mode uint32, caller *fuse.Ca
//
// Symlink-safe through use of Mkdirat().
func (n *Node) Mkdir(ctx context.Context, name string, mode uint32, out *fuse.EntryOut) (*fs.Inode, syscall.Errno) {
- rn := n.rootNode()
- newPath := filepath.Join(n.Path(), name)
- if rn.isFiltered(newPath) {
- return nil, syscall.EPERM
- }
- dirfd, cName, err := rn.openBackingDir(newPath)
- if err != nil {
- return nil, fs.ToErrno(err)
+ dirfd, cName, errno := n.prepareAtSyscall(name)
+ if errno != 0 {
+ return nil, errno
}
defer syscall.Close(dirfd)
+
+ rn := n.rootNode()
var caller *fuse.Caller
if rn.args.PreserveOwner {
caller, _ = fuse.FromContext(ctx)
}
var st syscall.Stat_t
-
if rn.args.PlaintextNames {
- err = syscallcompat.MkdiratUser(dirfd, cName, mode, caller)
+ err := syscallcompat.MkdiratUser(dirfd, cName, mode, caller)
if err != nil {
return nil, fs.ToErrno(err)
}
@@ -104,7 +100,7 @@ func (n *Node) Mkdir(ctx context.Context, name string, mode uint32, out *fuse.En
// Handle long file name
if nametransform.IsLongContent(cName) {
// Create ".name"
- err = rn.nameTransform.WriteLongNameAt(dirfd, cName, newPath)
+ err := rn.nameTransform.WriteLongNameAt(dirfd, cName, name)
if err != nil {
return nil, fs.ToErrno(err)
}
@@ -116,7 +112,7 @@ func (n *Node) Mkdir(ctx context.Context, name string, mode uint32, out *fuse.En
return nil, fs.ToErrno(err)
}
} else {
- err = rn.mkdirWithIv(dirfd, cName, mode, caller)
+ err := rn.mkdirWithIv(dirfd, cName, mode, caller)
if err != nil {
return nil, fs.ToErrno(err)
}
@@ -158,12 +154,9 @@ func (n *Node) Mkdir(ctx context.Context, name string, mode uint32, out *fuse.En
// This function is symlink-safe through use of openBackingDir() and
// ReadDirIVAt().
func (n *Node) Readdir(ctx context.Context) (fs.DirStream, syscall.Errno) {
- rn := n.rootNode()
- p := n.Path()
- dirName := filepath.Base(p)
- parentDirFd, cDirName, err := rn.openBackingDir(p)
- if err != nil {
- return nil, fs.ToErrno(err)
+ parentDirFd, cDirName, errno := n.prepareAtSyscall("")
+ if errno != 0 {
+ return nil, errno
}
defer syscall.Close(parentDirFd)
@@ -180,6 +173,7 @@ func (n *Node) Readdir(ctx context.Context) (fs.DirStream, syscall.Errno) {
}
// Get DirIV (stays nil if PlaintextNames is used)
var cachedIV []byte
+ rn := n.rootNode()
if !rn.args.PlaintextNames {
// Read the DirIV from disk
cachedIV, err = nametransform.ReadDirIVAt(fd)
@@ -193,7 +187,7 @@ func (n *Node) Readdir(ctx context.Context) (fs.DirStream, syscall.Errno) {
// Filter and decrypt filenames
for i := range cipherEntries {
cName := cipherEntries[i].Name
- if dirName == "." && cName == configfile.ConfDefaultName {
+ if n.IsRoot() && cName == configfile.ConfDefaultName {
// silently ignore "gocryptfs.conf" in the top level dir
continue
}