Show More
@@ -1060,6 +1060,18 b' def checksignature(func):' | |||||
1060 | # This is a variable so extensions can opt-in to using them. |
|
1060 | # This is a variable so extensions can opt-in to using them. | |
1061 | allowhardlinks = False |
|
1061 | allowhardlinks = False | |
1062 |
|
1062 | |||
|
1063 | # a whilelist of known filesystems where hardlink works reliably | |||
|
1064 | _hardlinkfswhitelist = set([ | |||
|
1065 | 'btrfs', | |||
|
1066 | 'ext2', | |||
|
1067 | 'ext3', | |||
|
1068 | 'ext4', | |||
|
1069 | 'jfs', | |||
|
1070 | 'reiserfs', | |||
|
1071 | 'tmpfs', | |||
|
1072 | 'xfs', | |||
|
1073 | ]) | |||
|
1074 | ||||
1063 | def copyfile(src, dest, hardlink=False, copystat=False, checkambig=False): |
|
1075 | def copyfile(src, dest, hardlink=False, copystat=False, checkambig=False): | |
1064 | '''copy a file, preserving mode and optionally other stat info like |
|
1076 | '''copy a file, preserving mode and optionally other stat info like | |
1065 | atime/mtime |
|
1077 | atime/mtime | |
@@ -1076,6 +1088,13 b' def copyfile(src, dest, hardlink=False, ' | |||||
1076 | if checkambig: |
|
1088 | if checkambig: | |
1077 | oldstat = checkambig and filestat(dest) |
|
1089 | oldstat = checkambig and filestat(dest) | |
1078 | unlink(dest) |
|
1090 | unlink(dest) | |
|
1091 | if hardlink: | |||
|
1092 | # Hardlinks are problematic on CIFS (issue4546), do not allow hardlinks | |||
|
1093 | # unless we are confident that dest is on a whitelisted filesystem. | |||
|
1094 | destdir = os.path.dirname(dest) | |||
|
1095 | fstype = getattr(osutil, 'getfstype', lambda x: None)(destdir) | |||
|
1096 | if fstype not in _hardlinkfswhitelist: | |||
|
1097 | hardlink = False | |||
1079 | if allowhardlinks and hardlink: |
|
1098 | if allowhardlinks and hardlink: | |
1080 | try: |
|
1099 | try: | |
1081 | oslink(src, dest) |
|
1100 | oslink(src, dest) |
General Comments 0
You need to be logged in to leave comments.
Login now