X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=libatalk%2Fadouble%2Fad_sendfile.c;h=2730644b69adc1669868fe5d3da4bb6b4cd1971e;hb=ab6e6f8ed24667ced438afe4df5997469a2ff53b;hp=aabb61ce106eff5f80e69d09ab06149facbfdb51;hpb=08d710224e346b26227e08d5a044350198b1bbd9;p=netatalk.git diff --git a/libatalk/adouble/ad_sendfile.c b/libatalk/adouble/ad_sendfile.c index aabb61ce..2730644b 100644 --- a/libatalk/adouble/ad_sendfile.c +++ b/libatalk/adouble/ad_sendfile.c @@ -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. * @@ -32,18 +30,15 @@ #endif /* HAVE_CONFIG_H */ #ifdef WITH_SENDFILE - -#include - #include - #include #include - #include +#include #include -#include "ad_private.h" + +#include "ad_lock.h" #if defined(SENDFILE_FLAVOR_LINUX) #include @@ -67,7 +62,16 @@ ssize_t sys_sendfile(int tofd, int fromfd, off_t *offset, size_t count) #include 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 @@ -99,30 +103,4 @@ int ad_readfile_init(const struct adouble *ad, return fd; } - - -/* ------------------------ */ -#if 0 -#ifdef HAVE_SENDFILE_WRITE -/* read from a socket and write to an adouble file */ -ssize_t ad_writefile(struct adouble *ad, const int eid, - const int sock, off_t off, const int end, - const size_t len) -{ -#ifdef __linux__ - ssize_t cc; - int fd; - - fd = ad_sendfile_init(ad, eid, &off, end); - if ((cc = sys_sendfile(fd, sock, &off, len)) < 0) - return -1; - - if ((eid != ADEID_DFORK) && (off > ad_getentrylen(ad, eid))) - ad_setentrylen(ad, eid, off); - - return cc; -#endif /* __linux__ */ -} -#endif /* HAVE_SENDFILE_WRITE */ -#endif /* 0 */ #endif