1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-02-25 15:33:39 +00:00

Merge pull request #4317 from ThomasWaldmann/workaround-wsl-sync_file_range-issue

work around some Microsoft WSL issues
This commit is contained in:
TW 2019-02-05 04:44:37 +01:00 committed by GitHub
commit 94851b0c5f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 56 additions and 34 deletions

View file

@ -139,7 +139,7 @@ def check_extension_modules():
raise ExtensionModuleError
if borg.crypto.low_level.API_VERSION != '1.1_02':
raise ExtensionModuleError
if platform.API_VERSION != platform.OS_API_VERSION or platform.API_VERSION != '1.1_03':
if platform.API_VERSION != platform.OS_API_VERSION or platform.API_VERSION != '1.1_04':
raise ExtensionModuleError
if item.API_VERSION != '1.1_02':
raise ExtensionModuleError

View file

@ -17,7 +17,7 @@
are correctly composed into the base functionality.
"""
API_VERSION = '1.1_03'
API_VERSION = '1.1_04'
fdatasync = getattr(os, 'fdatasync', os.fsync)

View file

@ -6,7 +6,7 @@ from ..helpers import user2uid, group2gid
from ..helpers import safe_decode, safe_encode
from .posix import swidth
API_VERSION = '1.1_03'
API_VERSION = '1.1_04'
cdef extern from "sys/acl.h":
ctypedef struct _acl_t:

View file

@ -6,7 +6,7 @@ from ..helpers import posix_acl_use_stored_uid_gid
from ..helpers import safe_encode, safe_decode
from .posix import swidth
API_VERSION = '1.1_03'
API_VERSION = '1.1_04'
cdef extern from "errno.h":
int errno

View file

@ -15,7 +15,7 @@ from .posix import swidth
from libc cimport errno
from libc.stdint cimport int64_t
API_VERSION = '1.1_03'
API_VERSION = '1.1_04'
cdef extern from "sys/types.h":
int ACL_TYPE_ACCESS
@ -228,6 +228,7 @@ def acl_set(path, item, numeric_owner=False):
finally:
acl_free(default_acl)
cdef _sync_file_range(fd, offset, length, flags):
assert offset & PAGE_MASK == 0, "offset %d not page-aligned" % offset
assert length & PAGE_MASK == 0, "length %d not page-aligned" % length
@ -235,9 +236,30 @@ cdef _sync_file_range(fd, offset, length, flags):
raise OSError(errno.errno, os.strerror(errno.errno))
safe_fadvise(fd, offset, length, 'DONTNEED')
cdef unsigned PAGE_MASK = sysconf(_SC_PAGESIZE) - 1
def _is_WSL():
"""detect Windows Subsystem for Linux"""
try:
with open('/proc/version') as fd:
linux_version = fd.read()
# hopefully no non-WSL Linux will ever mention 'Microsoft' in the kernel version:
return 'Microsoft' in linux_version
except: # noqa
# make sure to never ever crash due to this check.
return False
if _is_WSL():
class SyncFile(BaseSyncFile):
# if we are on Microsoft's "Windows Subsytem for Linux", use the
# more generic BaseSyncFile to avoid issues like seen there:
# https://github.com/borgbackup/borg/issues/1961
pass
else:
# a real Linux, so we can do better. :)
class SyncFile(BaseSyncFile):
"""
Implemented using sync_file_range for asynchronous write-out and fdatasync for actual durability.