about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorDominique Martinet <asmadeus@codewreck.org>2021-12-09 11:50:51 +0900
committerEric Wong <e@80x24.org>2022-02-01 09:32:17 +0000
commitd8f1a9f189f0d74887cbb896caacaf7f1f256607 (patch)
tree63bef71ddb812a73d59e1ba73efcf6d662e87f1a
parent14fa0abdcc7b6513540e529375e53edd74ce13e8 (diff)
downloadpublic-inbox-d8f1a9f189f0d74887cbb896caacaf7f1f256607.tar.gz
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:
-rw-r--r--lib/PublicInbox/Syscall.pm4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/PublicInbox/Syscall.pm b/lib/PublicInbox/Syscall.pm
index bcfae2cb..2e3d9cb3 100644
--- a/lib/PublicInbox/Syscall.pm
+++ b/lib/PublicInbox/Syscall.pm
@@ -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 {