summaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorDenys Vlasenko2010-03-19 14:34:30 +0100
committerDenys Vlasenko2010-03-19 14:34:30 +0100
commitbcda0042e2313d65a835b874c78bf215d743a844 (patch)
tree774e7772ac513cd18ba8d394db44839ea9bfe2d9 /libbb
parent892d4b6b3d7e9950ff3708ca957e1e0590dd5a2d (diff)
downloadbusybox-bcda0042e2313d65a835b874c78bf215d743a844.zip
busybox-bcda0042e2313d65a835b874c78bf215d743a844.tar.gz
libbb/copyfd.c: don't mmap a largish buffer if we only want to copy a few kb
function old new delta bb_full_fd_action 283 295 +12 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb')
-rw-r--r--libbb/copyfd.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/libbb/copyfd.c b/libbb/copyfd.c
index c5f8b5b..f42eb76 100644
--- a/libbb/copyfd.c
+++ b/libbb/copyfd.c
@@ -22,6 +22,8 @@ static off_t bb_full_fd_action(int src_fd, int dst_fd, off_t size)
char *buffer;
int buffer_size;
+ if (size > 0 && size <= 4 * 1024)
+ goto use_small_buf;
/* We want page-aligned buffer, just in case kernel is clever
* and can do page-aligned io more efficiently */
buffer = mmap(NULL, CONFIG_FEATURE_COPYBUF_KB * 1024,
@@ -30,6 +32,7 @@ static off_t bb_full_fd_action(int src_fd, int dst_fd, off_t size)
/* ignored: */ -1, 0);
buffer_size = CONFIG_FEATURE_COPYBUF_KB * 1024;
if (buffer == MAP_FAILED) {
+ use_small_buf:
buffer = alloca(4 * 1024);
buffer_size = 4 * 1024;
}