From da6d967504a36d686689fcb7f086a00c6198c215 Mon Sep 17 00:00:00 2001
From: Eric Wong <e@80x24.org>
Date: Sat, 15 Dec 2018 00:01:57 +0000
Subject: [PATCH] fileutils (mv): fall back to copy + unlink on EPERM

With ext4 encrypted directories, renaming a file from an
unencrypted directory to an encrypted directory gives EPERM.
Fall back to copying and unlink in that case, since it's
similar in spirit to dealing with EXDEV.
---
 lib/fileutils.rb | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/fileutils.rb b/lib/fileutils.rb
index dc7261857b..98460ba5dd 100644
--- a/lib/fileutils.rb
+++ b/lib/fileutils.rb
@@ -527,7 +527,8 @@ def mv(src, dest, force: nil, noop: nil, verbose: nil, secure: nil)
         end
         begin
           File.rename s, d
-        rescue Errno::EXDEV
+        rescue Errno::EXDEV,
+               Errno::EPERM # move from unencrypted to encrypted dir (ext4)
           copy_entry s, d, true
           if secure
             remove_entry_secure s, force
-- 
EW

