From b7cac4ffd07733ab6bcd0d33345de3306a8a5a59 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sat, 22 Jan 2022 12:28:27 +0100 Subject: fusefrontend: support RENAME_WHITEOUT, RENAME_EXCHANGE Both new internal test and xfstests generic/013 are happy. https://github.com/rfjakob/gocryptfs/issues/641 --- internal/fusefrontend/node.go | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'internal/fusefrontend') 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) } -- cgit v1.2.3