From 278c42abc509d5dcef5c74ac1611ec471281ffe1 Mon Sep 17 00:00:00 2001 From: Glenn Strauss Date: Mon, 22 Apr 2019 02:18:56 -0400 Subject: [PATCH] [mod_webdav] platform portability fixes --- src/mod_webdav.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/mod_webdav.c b/src/mod_webdav.c index 8f4a56e8..7b1d80e1 100644 --- a/src/mod_webdav.c +++ b/src/mod_webdav.c @@ -2012,8 +2012,11 @@ webdav_prop_select_propnames (const plugin_config * const pconf, } -#if (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD__) -#include /* fcopyfile() *//* FreeBSD and OS X 10.5+ */ +#if defined(__APPLE__) && defined(__MACH__) +#include /* fcopyfile() *//* OS X 10.5+ */ +#endif +#ifdef __FreeBSD__ +#include /* elftc_copyfile() */ #endif #ifdef __linux__ #include /* sendfile() */ @@ -2039,7 +2042,7 @@ webdav_fcopyfile_sz (int ifd, int ofd, off_t isz) /*fcntl(ofd, F_SETFL, fcntl(ofd, F_GETFL, 0) & ~O_NONBLOCK);*/ #endif - #if (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD__) + #if defined(__APPLE__) && defined(__MACH__) if (0 == fcopyfile(ifd, ofd, NULL, COPYFILE_ALL)) return 0; @@ -2047,6 +2050,14 @@ webdav_fcopyfile_sz (int ifd, int ofd, off_t isz) lseek(ofd, 0, SEEK_SET); #endif + #ifdef __FreeBSD__ + if (0 == elftc_copyfile(ifd, ofd)) + return 0; + + lseek(ifd, 0, SEEK_SET); + lseek(ofd, 0, SEEK_SET); + #endif + #ifdef __linux__ /* Linux 2.6.33+ sendfile() supports file-to-file copy */ off_t offset = 0; while (offset < isz && sendfile(ifd,ofd,&offset,(size_t)(isz-offset)) >= 0); @@ -4038,6 +4049,7 @@ mod_webdav_write_cq (connection* const con, chunkqueue* const cq, const int fd) } +#if (defined(__linux__) || defined(__CYGWIN__)) && defined(O_TMPFILE) static int mod_webdav_write_single_file_chunk (connection* const con, chunkqueue* const cq) { @@ -4060,6 +4072,7 @@ mod_webdav_write_single_file_chunk (connection* const con, chunkqueue* const cq) return 0; } } +#endif static handler_t