summaryrefslogtreecommitdiff
path: root/src/basic
diff options
context:
space:
mode:
authorDaniel Mack <github@zonque.org>2015-08-28 08:56:08 +0200
committerDaniel Mack <github@zonque.org>2015-08-28 08:56:08 +0200
commit9f917da97765aa78a22b4cd37f5186f6ceaab3c1 (patch)
tree2d85164179b778025c94e80f27258381ca2d71b4 /src/basic
parent04b0752fb21e68295a6ef72f0503f81ed09a74b8 (diff)
parent8b5264aa65ea8f631990174a6f705d5a0d8e95fc (diff)
Merge pull request #1061 from poettering/pager
A few auto-pager improvements
Diffstat (limited to 'src/basic')
-rw-r--r--src/basic/copy.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/basic/copy.c b/src/basic/copy.c
index 33427c6a73..cc5faa80a1 100644
--- a/src/basic/copy.c
+++ b/src/basic/copy.c
@@ -30,7 +30,7 @@
#define COPY_BUFFER_SIZE (16*1024)
int copy_bytes(int fdf, int fdt, off_t max_bytes, bool try_reflink) {
- bool try_sendfile = true;
+ bool try_sendfile = true, try_splice = true;
int r;
assert(fdf >= 0);
@@ -69,7 +69,23 @@ int copy_bytes(int fdf, int fdt, off_t max_bytes, bool try_reflink) {
} else if (n == 0) /* EOF */
break;
else if (n > 0)
- /* Succcess! */
+ /* Success! */
+ goto next;
+ }
+
+ /* The try splice, unless we already tried */
+ if (try_splice) {
+ n = splice(fdf, NULL, fdt, NULL, m, 0);
+ if (n < 0) {
+ if (errno != EINVAL && errno != ENOSYS)
+ return -errno;
+
+ try_splice = false;
+ /* use fallback below */
+ } else if (n == 0) /* EOF */
+ break;
+ else if (n > 0)
+ /* Success! */
goto next;
}