1 |
On Tue, 9 May 2017 23:59:34 -0700 |
2 |
Zac Medico <zmedico@g.o> wrote: |
3 |
|
4 |
> Fix the lseek offset for the plain read/write loop to account |
5 |
> for buffered data that has not been written to to the output |
6 |
> file yet (due to previous interruption by EINTR). This code |
7 |
> only affects Linux 2.6.32 and earlier (newer kernels use |
8 |
> copy_file_range or sendfile). |
9 |
> |
10 |
> X-Gentoo-bug: 618086 |
11 |
> X-Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=618086 |
12 |
> --- |
13 |
> src/portage_util_file_copy_reflink_linux.c | 13 ++++++++----- |
14 |
> 1 file changed, 8 insertions(+), 5 deletions(-) |
15 |
> |
16 |
> diff --git a/src/portage_util_file_copy_reflink_linux.c |
17 |
> b/src/portage_util_file_copy_reflink_linux.c index 2fb17a0..4be9e05 |
18 |
> 100644 --- a/src/portage_util_file_copy_reflink_linux.c |
19 |
> +++ b/src/portage_util_file_copy_reflink_linux.c |
20 |
> @@ -323,12 +323,14 @@ _reflink_linux_file_copy(PyObject *self, |
21 |
> PyObject *args) if (buf == NULL) { |
22 |
> error = errno; |
23 |
> |
24 |
> - /* For the read call, the fd_in file offset must be |
25 |
> - * exactly equal to offset_out. Use lseek to ensure |
26 |
> - * correct state, in case an EINTR retry caused it to |
27 |
> - * get out of sync somewhow. |
28 |
> + /* For the read call, the fd_in file offset must be |
29 |
> exactly |
30 |
> + * equal to offset_out + buf_bytes, where buf_bytes |
31 |
> is the |
32 |
> + * amount of buffered data that has not been written |
33 |
> to |
34 |
> + * to the output file yet. Use lseek to ensure |
35 |
> correct state, |
36 |
> + * in case an EINTR retry caused it to get out of |
37 |
> sync |
38 |
> + * somewhow. |
39 |
> */ |
40 |
> - } else if (lseek(fd_in, offset_out, SEEK_SET) < 0) { |
41 |
> + } else if (lseek(fd_in, offset_out + buf_bytes, |
42 |
> SEEK_SET) < 0) { error = errno; |
43 |
> } else { |
44 |
> while (1) { |
45 |
> @@ -345,6 +347,7 @@ _reflink_linux_file_copy(PyObject *self, PyObject |
46 |
> *args) |
47 |
> } else if (buf_bytes < 0) { |
48 |
> error = errno; |
49 |
> + buf_bytes = 0; |
50 |
> break; |
51 |
> } |
52 |
> } |
53 |
|
54 |
looks fine :) |
55 |
|
56 |
-- |
57 |
Brian Dolbec <dolsen> |