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 <kzak@redhat.com> Reviewed-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Egor Chelak <egor.chelak@gmail.com>
This commit is contained in:
parent
a8b4e7cad1
commit
360cdaa6c7
|
@ -530,6 +530,7 @@ AC_CHECK_FUNCS([ \
|
|||
qsort_r \
|
||||
rpmatch \
|
||||
scandirat \
|
||||
sendfile \
|
||||
setprogname \
|
||||
setresgid \
|
||||
setresuid \
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue