src/server/util/io.c

changeset 69
4a10bc0ee80d
parent 66
74babc0082b7
child 70
4e6e812c1d97
--- a/src/server/util/io.c	Mon May 27 12:28:56 2013 +0200
+++ b/src/server/util/io.c	Thu Jun 20 13:27:07 2013 +0200
@@ -33,7 +33,10 @@
 #include <unistd.h>
 #include <stdlib.h>
 #include <sys/uio.h>
+#include <sys/uio.h>
+#ifndef BSD
 #include <sys/sendfile.h>
+#endif
 #include <limits.h> /* asprintf */
 
 #include "../daemon/vfs.h"
@@ -134,7 +137,23 @@
     ssize_t ret = 0;
     off_t fileoffset = sfd->offset;
     if(sfd->fd->fd != -1) {
+#ifdef OSX
+        struct iovec hdvec;
+        hdvec.iov_base = (void*)sfd->header;
+        hdvec.iov_len = sfd->hlen;
+        struct iovec trvec;
+        trvec.iov_base = (void*)sfd->trailer;
+        trvec.iov_len = sfd->tlen;
+        struct sf_hdtr hdtr;
+        hdtr.headers = &hdvec;
+        hdtr.hdr_cnt = 1;
+        hdtr.trailers = &trvec;
+        hdtr.trl_cnt = 1;
+        
+        ret = sendfile(sfd->fd->fd, st->fd, sfd->offset, (off_t*)&sfd->len, &hdtr, 0);
+#else
         ret = sendfile(st->fd, sfd->fd->fd, &fileoffset, sfd->len);
+#endif
     } else {
         // TODO: regular copy
         fprintf(stderr, "sendfile not implemented for SYS_FILE\n");

mercurial