]> Sergey Matveev's repositories - public-inbox.git/commitdiff
syscall: fallback to rename on renameat2 EINVAL
authorDominique Martinet <asmadeus@codewreck.org>
Thu, 9 Dec 2021 02:50:51 +0000 (11:50 +0900)
committerEric Wong <e@80x24.org>
Tue, 1 Feb 2022 09:32:17 +0000 (09:32 +0000)
ZFS appears to incorrectly return EINVAL on renameat2 when the operation is not
supported:
renameat2(AT_FDCWD, "...", AT_FDCWD, "...", RENAME_NOREPLACE) = -1 EINVAL

Fall back to the racy rename in this case as well:

lib/PublicInbox/Syscall.pm

index bcfae2cbcae423ef70171c90f3e52be3932c00ad..2e3d9cb32c548a340835127f8e4c5f4757fa9fa0 100644 (file)
@@ -15,7 +15,7 @@ package PublicInbox::Syscall;
 use strict;
 use v5.10.1;
 use parent qw(Exporter);
-use POSIX qw(ENOENT EEXIST ENOSYS O_NONBLOCK);
+use POSIX qw(ENOENT EEXIST ENOSYS EINVAL O_NONBLOCK);
 use Config;
 
 # $VERSION = '0.25'; # Sys::Syscall version
@@ -324,7 +324,7 @@ sub rename_noreplace ($$) {
                my $ret = syscall($SYS_renameat2, -100, $old, -100, $new, 1);
                if ($ret == 0) {
                        1; # like rename() perlop
-               } elsif ($! == ENOSYS) {
+               } elsif ($! == ENOSYS || $! == EINVAL) {
                        undef $SYS_renameat2;
                        _rename_noreplace_racy($old, $new);
                } else {