diff options
author | Zac Medico <zmedico@gentoo.org> | 2021-12-11 12:40:04 -0800 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2021-12-11 17:14:13 -0800 |
commit | fe2e58325ffd1d4424564998f64bed4cb4ab8ffa (patch) | |
tree | 561debb117b99ffa60fcf1c772923087dbec300b /src | |
parent | lib/portage/package/ebuild/doebuild.py: use 'eerror' for blank PROVIDES message (diff) | |
download | portage-fe2e58325ffd1d4424564998f64bed4cb4ab8ffa.tar.gz portage-fe2e58325ffd1d4424564998f64bed4cb4ab8ffa.tar.bz2 portage-fe2e58325ffd1d4424564998f64bed4cb4ab8ffa.zip |
file_copy: handle zero bytes copied by copy_file_range (bug 828844)
When copy_file_range copied zero bytes, fall back to sendfile,
so that we don't call copy_file_range in an infinite loop.
Bug: https://bugs.gentoo.org/828844
Tested-by: John Helmert III <ajak@gentoo.org>
Signed-off-by: Zac Medico <zmedico@gentoo.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/portage_util_file_copy_reflink_linux.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/portage_util_file_copy_reflink_linux.c b/src/portage_util_file_copy_reflink_linux.c index c6affe57a..b00b57952 100644 --- a/src/portage_util_file_copy_reflink_linux.c +++ b/src/portage_util_file_copy_reflink_linux.c @@ -261,13 +261,14 @@ _reflink_linux_file_copy(PyObject *self, PyObject *args) &offset_out, len); - if (copyfunc_ret < 0) { + if (copyfunc_ret <= 0) { error = errno; - if ((errno == EXDEV || errno == ENOSYS || errno == EOPNOTSUPP) && + if ((errno == EXDEV || errno == ENOSYS || errno == EOPNOTSUPP || copyfunc_ret == 0) && copyfunc == cfr_wrapper) { /* Use sendfile instead of copy_file_range for * cross-device copies, or when the copy_file_range - * syscall is not available (less than Linux 4.5). + * syscall is not available (less than Linux 4.5), + * or when copy_file_range copies zero bytes. */ error = 0; copyfunc = sf_wrapper; |