system: reflink: workaround SIP error

Fixes #1515

Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
Ruslan Kuprieiev
2019-03-30 20:53:06 +02:00
parent b3addbd283
commit 5109d759f1
+16 -1
View File
@@ -3,6 +3,7 @@ from __future__ import unicode_literals
from dvc.utils.compat import str, open
import os
import errno
class System(object):
@@ -61,8 +62,22 @@ class System(object):
@staticmethod
def _reflink_darwin(src, dst):
import ctypes
import dvc.logger as logger
LIBC = "libc.dylib"
LIBC_FALLBACK = "/usr/lib/libSystem.dylib"
try:
clib = ctypes.CDLL(LIBC)
except OSError as exc:
logger.debug(
"unable to access '{}' (errno '{}'). "
"Falling back to '{}'.".format(LIBC, exc.errno, LIBC_FALLBACK)
)
if exc.errno != errno.ENOENT:
raise
# NOTE: trying to bypass System Integrity Protection (SIP)
clib = ctypes.CDLL(LIBC_FALLBACK)
clib = ctypes.CDLL("libc.dylib")
if not hasattr(clib, "clonefile"):
return -1