/*
- * $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>
#elif defined(SENDFILE_FLAVOR_BSD )
#include <sys/types.h>
#include <sys/socket.h>
-#include <sys/uio.h><
+#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