##// END OF EJS Templates
statfs: make getfstype() raise OSError...
Yuya Nishihara -
r31678:1ed57a7d default
parent child Browse files
Show More
@@ -1106,7 +1106,7 static PyObject *getfstype(PyObject *sel
1106 1106 memset(&buf, 0, sizeof(buf));
1107 1107 r = statfs(path, &buf);
1108 1108 if (r != 0)
1109 Py_RETURN_NONE;
1109 return PyErr_SetFromErrno(PyExc_OSError);
1110 1110 return Py_BuildValue("s", describefstype(&buf));
1111 1111 }
1112 1112 #endif /* defined(HAVE_LINUX_STATFS) || defined(HAVE_BSD_STATFS) */
@@ -1089,7 +1089,10 def copyfile(src, dest, hardlink=False,
1089 1089 if hardlink:
1090 1090 # Hardlinks are problematic on CIFS (issue4546), do not allow hardlinks
1091 1091 # unless we are confident that dest is on a whitelisted filesystem.
1092 try:
1092 1093 fstype = getfstype(os.path.dirname(dest))
1094 except OSError:
1095 fstype = None
1093 1096 if fstype not in _hardlinkfswhitelist:
1094 1097 hardlink = False
1095 1098 if hardlink:
@@ -1372,7 +1375,7 def fspath(name, root):
1372 1375 def getfstype(dirpath):
1373 1376 '''Get the filesystem type name from a directory (best-effort)
1374 1377
1375 Returns None if we are unsure, or errors like ENOENT, EPERM happen.
1378 Returns None if we are unsure. Raises OSError on ENOENT, EPERM, etc.
1376 1379 '''
1377 1380 return getattr(osutil, 'getfstype', lambda x: None)(dirpath)
1378 1381
@@ -349,7 +349,10 def has_hardlink():
349 349 @check("hardlink-whitelisted", "hardlinks on whitelisted filesystems")
350 350 def has_hardlink_whitelisted():
351 351 from mercurial import util
352 try:
352 353 fstype = util.getfstype('.')
354 except OSError:
355 return False
353 356 return fstype in util._hardlinkfswhitelist
354 357
355 358 @check("rmcwd", "can remove current working directory")
General Comments 0
You need to be logged in to leave comments. Login now