diff options
author | Rob Landley <rob@landley.net> | 2022-03-17 18:25:38 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2022-03-17 18:25:38 -0500 |
commit | 9b368059deec8c9270bb0b384e894fc34ee07995 (patch) | |
tree | 1fa4e2df3a8d402cde28f2547227e163ef8d3ca6 /lib | |
parent | 613db35596e37c16063d531de6d635f0bd3b2f52 (diff) | |
download | toybox-9b368059deec8c9270bb0b384e894fc34ee07995.tar.gz |
Update comments and add "sanity check" from kernel commit f16acc9d9b376.
(The kernel's been doing this since 2019, but older kernels may not, so...)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/portability.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/portability.c b/lib/portability.c index d7648a8f..4d9313c6 100644 --- a/lib/portability.c +++ b/lib/portability.c @@ -623,9 +623,8 @@ int get_block_device_size(int fd, unsigned long long* size) } #endif -// TODO copy_file_range // Return bytes copied from in to out. If bytes <0 copy all of in to out. -// If consuemd isn't null, amount read saved there (return is written or error) +// If consumed isn't null, amount read saved there (return is written or error) long long sendfile_len(int in, int out, long long bytes, long long *consumed) { long long total = 0, len, ww; @@ -639,7 +638,7 @@ long long sendfile_len(int in, int out, long long bytes, long long *consumed) errno = 0; if (copy_file_range) { - if (bytes<0) len = INT_MAX; + if (bytes<0 || bytes>(1<<30)) len = (1<<30); len = syscall(__NR_copy_file_range, in, 0, out, 0, len, 0); if (len < 0 && errno == EINVAL) copy_file_range = 0; |