Workaround for volume shadow copy in WSL1

This commit is contained in:
Reiko Asakura 2021-12-24 15:15:23 -05:00
parent bf392367f1
commit e38f0b26b0
No known key found for this signature in database
GPG key ID: 7BC27214C62DF4EE
2 changed files with 12 additions and 0 deletions

View file

@ -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"

View file

@ -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