]> arthur.barton.de Git - netatalk.git/blobdiff - libatalk/adouble/ad_sendfile.c
Portability fix, preventing crash on FreeBSD
[netatalk.git] / libatalk / adouble / ad_sendfile.c
index aabb61ce106eff5f80e69d09ab06149facbfdb51..3cb28e7802c935db16ab4acf80645db577b43816 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * $Id: ad_sendfile.c,v 1.11 2010-01-21 14:14:49 didg Exp $
- *
  * Copyright (c) 1999 Adrian Sun (asun@zoology.washington.edu)
  * All rights reserved. See COPYRIGHT.
  *
 #endif /* HAVE_CONFIG_H */
 
 #ifdef WITH_SENDFILE
-
-#include <atalk/adouble.h>
-
 #include <stdio.h>
-
 #include <sys/socket.h>
 #include <sys/uio.h>
-
 #include <errno.h>  
 
+#include <atalk/adouble.h>
 #include <atalk/logger.h>
-#include "ad_private.h"
+
+#include "ad_lock.h"
 
 #if defined(SENDFILE_FLAVOR_LINUX)
 #include <sys/sendfile.h>
@@ -67,7 +62,16 @@ ssize_t sys_sendfile(int tofd, int fromfd, off_t *offset, size_t count)
 #include <sys/uio.h>
 ssize_t sys_sendfile(int tofd, int fromfd, off_t *offset, size_t count)
 {
-  return sendfile(fromfd, tofd, *offset, count, NULL, offset, 0);
+    off_t len;
+    int ret;
+
+    ret = sendfile(fromfd, tofd, *offset, count, NULL, &len, 0);
+
+    *offset += len;
+
+    if (ret != 0)
+        return -1;
+    return len;
 }
 
 #else