[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Emulation of sendfile().



Robert Millan <rmh@debian.org> wrote:
> If you can write a Linux-compatible sendfile() which uses BSD-ish SYS_sendfile
> as backend, I guess they'll have no problem exporting a new symbol in glibc?
> After all, it's glibc who claims to provide it (via <sys/sendfile.h>).

I emulate Linux sendfile on (non-Debian) FreeBSD that way in cmogstored.
Feel free to grab the linux_sendfile() wrapper from cmogstored:
	http://bogomips.org/cmogstored.git/plain/http_get.c
The linux_sendfile wrapper is trivial and I'm OK with relicensing from
the existing GPLv3+ to any DFSG-approved license

> > Otherwise
> > each and every software will need substantial patching on kFreeBSD
> > to achieve better throughput, since it would need to link to
> > freebsd-glue and rely on the FreeBSD signature of sendfile(),
> > or to be rewritten using bsd_sendfile.
> 
> You don't have to rewrite anything to use bsd_sendfile(). If you're trying
> to build BSD software, you can use freebsd-glue if you think this will ease your
> porting work.

Interesting, I didn't know about bsd_sendfile nor freebsd-glue, I was
using pread+write to emulate it on Debian kFreeBSD.

Can't seem to detect bsd_sendfile, though (maybe I'm missing something
obvious, this is on Debian sid x86_64, kFreeBSD):

$ gcc -o x x.c -Wall
/tmp/ccJILHMP.o: In function `main':
x.c:(.text+0x30): undefined reference to `bsd_sendfile'
collect2: error: ld returned 1 exit status
--------------------------- x.c -------------------------
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/uio.h>

int
bsd_sendfile(int fd, int s, off_t offset, size_t nbytes,
	struct sf_hdtr *hdtr, off_t *sbytes, int flags);

int main(void)
{
	int a = bsd_sendfile(0, 1, 0, 5, NULL, NULL, 0);
	return a;
}
--------------------------- x.c -------------------------


Reply to: