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=113f30c9bf0f130b122ce732c7c03f3b1c639bff;hpb=056d3ef4c88ba09eabb1fcbf06bdd9fe6e7af4cf;p=netatalk.git diff --git a/libatalk/adouble/ad_sendfile.c b/libatalk/adouble/ad_sendfile.c index 113f30c9..2730644b 100644 --- a/libatalk/adouble/ad_sendfile.c +++ b/libatalk/adouble/ad_sendfile.c @@ -59,10 +59,19 @@ 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) { - 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 @@ -94,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