]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
configure.ac: check for sendfile
authorEgor Chelak <egor.chelak@gmail.com>
Fri, 6 Nov 2020 10:15:36 +0000 (12:15 +0200)
committerEgor Chelak <egor.chelak@gmail.com>
Mon, 9 Nov 2020 05:19:00 +0000 (07:19 +0200)
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 <kzak@redhat.com>
Reviewed-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Egor Chelak <egor.chelak@gmail.com>
configure.ac
lib/fileutils.c

index 9d4785c95c5383d1d7d9e5ba1d603c55265d4dbc..8390bc6ef4671e6a60bf8ca93ba38f08713baceb 100644 (file)
@@ -530,6 +530,7 @@ AC_CHECK_FUNCS([ \
        qsort_r \
        rpmatch \
        scandirat \
+       sendfile \
        setprogname \
        setresgid \
        setresuid \
index 557fae0414a972e7b019dd7c394d0b593242a6ec..4d023001f820ddffe47bf69dfc289b919563b403 100644 (file)
@@ -11,7 +11,9 @@
 #include <unistd.h>
 #include <sys/time.h>
 #include <sys/resource.h>
+#ifdef HAVE_SENDFILE
 #include <sys/sendfile.h>
+#endif
 #include <string.h>
 
 #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
 }