summaryrefslogtreecommitdiff
path: root/internal/fusefrontend
diff options
context:
space:
mode:
authorJakob Unterwurzacher2022-01-22 12:28:27 +0100
committerJakob Unterwurzacher2022-01-22 12:28:27 +0100
commitb7cac4ffd07733ab6bcd0d33345de3306a8a5a59 (patch)
treeac8d9f593bcdce3abd7a8bb4d62e4ca7e6b986c2 /internal/fusefrontend
parent3ca2b1983dbab14e3769efd126098cbca6fb2ffd (diff)
fusefrontend: support RENAME_WHITEOUT, RENAME_EXCHANGE
Both new internal test and xfstests generic/013 are happy. https://github.com/rfjakob/gocryptfs/issues/641
Diffstat (limited to 'internal/fusefrontend')
-rw-r--r--internal/fusefrontend/node.go23
1 files changed, 11 insertions, 12 deletions
diff --git a/internal/fusefrontend/node.go b/internal/fusefrontend/node.go
index ead77c9..688cc0d 100644
--- a/internal/fusefrontend/node.go
+++ b/internal/fusefrontend/node.go
@@ -391,23 +391,17 @@ func (n *Node) Symlink(ctx context.Context, target, name string, out *fuse.Entry
return inode, 0
}
-// xfstests generic/013 now also exercises RENAME_EXCHANGE and RENAME_WHITEOUT,
-// uncovering lots of problems with longnames
-//
-// Reject those flags with syscall.EINVAL.
// If we can handle the flags, this function returns 0.
func rejectRenameFlags(flags uint32) syscall.Errno {
- // Normal rename, we can handle that
- if flags == 0 {
+ switch flags {
+ case 0, syscallcompat.RENAME_NOREPLACE, syscallcompat.RENAME_EXCHANGE, syscallcompat.RENAME_WHITEOUT:
return 0
- }
- // We also can handle RENAME_NOREPLACE
- if flags == syscallcompat.RENAME_NOREPLACE {
+ case syscallcompat.RENAME_NOREPLACE | syscallcompat.RENAME_WHITEOUT:
return 0
+ default:
+ tlog.Warn.Printf("rejectRenameFlags: unknown flag combination 0x%x", flags)
+ return syscall.EINVAL
}
- // We cannot handle RENAME_EXCHANGE and RENAME_WHITEOUT yet.
- // Needs extra code for .name files.
- return syscall.EINVAL
}
// Rename - FUSE call.
@@ -472,6 +466,11 @@ func (n *Node) Rename(ctx context.Context, name string, newParent fs.InodeEmbedd
}
return fs.ToErrno(err)
}
+ if flags&syscallcompat.RENAME_EXCHANGE != 0 || flags&syscallcompat.RENAME_WHITEOUT != 0 {
+ // These flags mean that there is now a new file at cName and we
+ // should NOT delete its longname file.
+ return 0
+ }
if nametransform.IsLongContent(cName) {
nametransform.DeleteLongNameAt(dirfd, cName)
}