Subject: Re: sendfile support in NetBSD
To: NetBSD Users's Discussion List <netbsd-users@netbsd.org>
From: Greg A. Woods <woods@planix.com>
List: netbsd-users
Date: 03/01/2007 16:00:57
At Thu, 01 Mar 2007 10:59:40 +1100,
Simon Burge wrote:
> 
> At least FreeBSD uses the following:
> 
>      int
>      sendfile(int fd, int s, off_t offset, size_t nbytes,
>          struct sf_hdtr *hdtr, off_t *sbytes, int flags);
> 
> which seems remarkably painful ...  Solaris and Linux both
> use:
> 
>      ssize_t sendfile(int out_fd, int in_fd, off_t *off, size_t len);
> 
> Back to that good ol' saying about standards....

Since sendfile(2) is clearly not portable even in a "de facto" manner,
and since it's not necessary on NetBSD for performance in the first
place, the only right thing for NetBSD to do is to give application
authors and maintainers the hint of making the portable variant of their
code use only the _standard_ interfaces that NetBSD already provides and
does so with the maximum possible performance.  I.e. NetBSD should _not_
provide any form of sendfile(2), especially not as a system call.

Now if someone wrote a properly designed utility library function that
would do the mmap() and write() calls with appropriate error checking,
etc., then maybe with the help of some key applications using it, this
better interface could also be implemented as a wrapper for the various
sendfile(2) hacks on those backwards systems which require sendfile(2).

Could the Apache folks, for example, be convinced to promote such a
wrapper as a portable solution to avoid direct use of non-portable
system calls?  Would support of a portable library wrapper perhaps even
convice other OS vendords to provide their own library wrapper
implementation?

-- 
						Greg A. Woods

H:+1 416 218-0098 W:+1 416 489-5852 x122 VE3TCP RoboHack <woods@robohack.ca>
Planix, Inc. <woods@planix.com>       Secrets of the Weird <woods@weird.com>