X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=netatalk.git;a=blobdiff_plain;f=libatalk%2Fadouble%2Fad_sendfile.c;h=2730644b69adc1669868fe5d3da4bb6b4cd1971e;hp=5452b271860174ddfe1cd03736c7636f83ba652c;hb=42a0a094b72577aee3fee7f186da52dc83db001d;hpb=15c1fc2f2328736dd428ec3be37c893d8ee2e065 diff --git a/libatalk/adouble/ad_sendfile.c b/libatalk/adouble/ad_sendfile.c index 5452b271..2730644b 100644 --- a/libatalk/adouble/ad_sendfile.c +++ b/libatalk/adouble/ad_sendfile.c @@ -57,24 +57,21 @@ ssize_t sys_sendfile(int tofd, int fromfd, off_t *offset, size_t count) } #elif defined(SENDFILE_FLAVOR_BSD ) -#include +#include +#include +#include ssize_t sys_sendfile(int tofd, int fromfd, off_t *offset, size_t count) { -size_t total=0; -int ret; - - total = count; - while (total) { - ssize_t nwritten; - do { - ret = sendfile(fromfd, tofd, offset, count, NULL, &nwritten, 0); - while (ret == -1 && errno == EINTR); - if (ret == -1) - return -1; - total -= nwritten; - offset += nwritten; - } - return count; + off_t len; + int ret; + + ret = sendfile(fromfd, tofd, *offset, count, NULL, &len, 0); + + *offset += len; + + if (ret != 0) + return -1; + return len; } #else @@ -106,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