ソースを参照

Workaround for volume shadow copy in WSL1

Reiko Asakura 3 年 前
コミット
e38f0b26b0
2 ファイル変更12 行追加0 行削除
  1. 5 0
      docs/usage/general/environment.rst.inc
  2. 7 0
      src/borg/helpers/fs.py

+ 5 - 0
docs/usage/general/environment.rst.inc

@@ -99,6 +99,11 @@ General:
             Using this does not affect data safety, but might result in a more bursty
             write to disk behaviour (not continuously streaming to disk).
 
+        retry_erofs
+            Retry opening a file without O_NOATIME if opening a file with O_NOATIME
+            caused EROFS. You will need this to make archives from volume shadow copies
+            in WSL1 (Windows Subsystem for Linux 1).
+
 Some automatic "answerers" (if set, they automatically answer confirmation questions):
     BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK=no (or =yes)
         For "Warning: Attempting to access a previously unknown unencrypted repository"

+ 7 - 0
src/borg/helpers/fs.py

@@ -286,6 +286,13 @@ def os_open(*, flags, path=None, parent_fd=None, name=None, noatime=False):
                 raise
             # Was this EPERM due to the O_NOATIME flag? Try again without it:
             fd = os.open(fname, _flags_normal, dir_fd=parent_fd)
+        except OSError as exc:
+            # O_NOATIME causes EROFS when accessing a volume shadow copy in WSL1
+            from . import workarounds
+            if 'retry_erofs' in workarounds and exc.errno == errno.EROFS and _flags_noatime != _flags_normal:
+                fd = os.open(fname, _flags_normal, dir_fd=parent_fd)
+            else:
+                raise
     else:
         fd = os.open(fname, _flags_normal, dir_fd=parent_fd)
     return fd