1 |
When copy_file_range copied zero bytes, fall back to sendfile, |
2 |
so that we don't call copy_file_range in an infinite loop. |
3 |
|
4 |
Bug: https://bugs.gentoo.org/828844 |
5 |
Tested-by: John Helmert III <ajak@g.o> |
6 |
Signed-off-by: Zac Medico <zmedico@g.o> |
7 |
--- |
8 |
src/portage_util_file_copy_reflink_linux.c | 7 ++++--- |
9 |
1 file changed, 4 insertions(+), 3 deletions(-) |
10 |
|
11 |
diff --git a/src/portage_util_file_copy_reflink_linux.c b/src/portage_util_file_copy_reflink_linux.c |
12 |
index c6affe57a..b00b57952 100644 |
13 |
--- a/src/portage_util_file_copy_reflink_linux.c |
14 |
+++ b/src/portage_util_file_copy_reflink_linux.c |
15 |
@@ -261,13 +261,14 @@ _reflink_linux_file_copy(PyObject *self, PyObject *args) |
16 |
&offset_out, |
17 |
len); |
18 |
|
19 |
- if (copyfunc_ret < 0) { |
20 |
+ if (copyfunc_ret <= 0) { |
21 |
error = errno; |
22 |
- if ((errno == EXDEV || errno == ENOSYS || errno == EOPNOTSUPP) && |
23 |
+ if ((errno == EXDEV || errno == ENOSYS || errno == EOPNOTSUPP || copyfunc_ret == 0) && |
24 |
copyfunc == cfr_wrapper) { |
25 |
/* Use sendfile instead of copy_file_range for |
26 |
* cross-device copies, or when the copy_file_range |
27 |
- * syscall is not available (less than Linux 4.5). |
28 |
+ * syscall is not available (less than Linux 4.5), |
29 |
+ * or when copy_file_range copies zero bytes. |
30 |
*/ |
31 |
error = 0; |
32 |
copyfunc = sf_wrapper; |
33 |
-- |
34 |
2.32.0 |