From 360cdaa6c70094ba72bbf12b95f1bb5cb8fa7e29 Mon Sep 17 00:00:00 2001 From: Egor Chelak Date: Fri, 6 Nov 2020 12:15:36 +0200 Subject: [PATCH] configure.ac: check for sendfile Do note that according to man sendfile, "Other UNIX systems implement sendfile() with different semantics and prototypes." If this is something we care about, a better check is needed. Suggested-by: Karel Zak Reviewed-by: Sami Kerola Signed-off-by: Egor Chelak --- configure.ac | 1 + lib/fileutils.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/configure.ac b/configure.ac index 9d4785c95c..8390bc6ef4 100644 --- a/configure.ac +++ b/configure.ac @@ -530,6 +530,7 @@ AC_CHECK_FUNCS([ \ qsort_r \ rpmatch \ scandirat \ + sendfile \ setprogname \ setresgid \ setresuid \ diff --git a/lib/fileutils.c b/lib/fileutils.c index 557fae0414..4d023001f8 100644 --- a/lib/fileutils.c +++ b/lib/fileutils.c @@ -11,7 +11,9 @@ #include #include #include +#ifdef HAVE_SENDFILE #include +#endif #include #include "c.h" @@ -270,6 +272,7 @@ static int copy_file_simple(int from, int to) /* Copies the contents of a file. Returns -1 on read error, -2 on write error. */ int ul_copy_file(int from, int to) { +#ifdef HAVE_SENDFILE struct stat st; ssize_t nw; off_t left; @@ -290,4 +293,7 @@ int ul_copy_file(int from, int to) if (nw < 0) return copy_file_simple(from, to); return 0; +#else + return copy_file_simple(from, to); +#endif } -- 2.47.3