From: Egor Chelak Date: Fri, 6 Nov 2020 10:15:36 +0000 (+0200) Subject: configure.ac: check for sendfile X-Git-Tag: v2.37-rc1~393^2~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=360cdaa6c70094ba72bbf12b95f1bb5cb8fa7e29;p=thirdparty%2Futil-linux.git 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 --- 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 }