xref: /freebsd/lib/libsys/sendfile.2 (revision 8269e7673cf033aba67dab8264fe719920c70f87)
1*8269e767SBrooks Davis.\" Copyright (c) 2003, David G. Lawrence
2*8269e767SBrooks Davis.\" All rights reserved.
3*8269e767SBrooks Davis.\"
4*8269e767SBrooks Davis.\" Redistribution and use in source and binary forms, with or without
5*8269e767SBrooks Davis.\" modification, are permitted provided that the following conditions
6*8269e767SBrooks Davis.\" are met:
7*8269e767SBrooks Davis.\" 1. Redistributions of source code must retain the above copyright
8*8269e767SBrooks Davis.\"    notice unmodified, this list of conditions, and the following
9*8269e767SBrooks Davis.\"    disclaimer.
10*8269e767SBrooks Davis.\" 2. Redistributions in binary form must reproduce the above copyright
11*8269e767SBrooks Davis.\"    notice, this list of conditions and the following disclaimer in the
12*8269e767SBrooks Davis.\"    documentation and/or other materials provided with the distribution.
13*8269e767SBrooks Davis.\"
14*8269e767SBrooks Davis.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15*8269e767SBrooks Davis.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16*8269e767SBrooks Davis.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17*8269e767SBrooks Davis.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18*8269e767SBrooks Davis.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19*8269e767SBrooks Davis.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20*8269e767SBrooks Davis.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21*8269e767SBrooks Davis.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22*8269e767SBrooks Davis.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23*8269e767SBrooks Davis.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24*8269e767SBrooks Davis.\" SUCH DAMAGE.
25*8269e767SBrooks Davis.\"
26*8269e767SBrooks Davis.Dd March 30, 2020
27*8269e767SBrooks Davis.Dt SENDFILE 2
28*8269e767SBrooks Davis.Os
29*8269e767SBrooks Davis.Sh NAME
30*8269e767SBrooks Davis.Nm sendfile
31*8269e767SBrooks Davis.Nd send a file to a socket
32*8269e767SBrooks Davis.Sh LIBRARY
33*8269e767SBrooks Davis.Lb libc
34*8269e767SBrooks Davis.Sh SYNOPSIS
35*8269e767SBrooks Davis.In sys/types.h
36*8269e767SBrooks Davis.In sys/socket.h
37*8269e767SBrooks Davis.In sys/uio.h
38*8269e767SBrooks Davis.Ft int
39*8269e767SBrooks Davis.Fo sendfile
40*8269e767SBrooks Davis.Fa "int fd" "int s" "off_t offset" "size_t nbytes"
41*8269e767SBrooks Davis.Fa "struct sf_hdtr *hdtr" "off_t *sbytes" "int flags"
42*8269e767SBrooks Davis.Fc
43*8269e767SBrooks Davis.Sh DESCRIPTION
44*8269e767SBrooks DavisThe
45*8269e767SBrooks Davis.Fn sendfile
46*8269e767SBrooks Davissystem call
47*8269e767SBrooks Davissends a regular file or shared memory object specified by descriptor
48*8269e767SBrooks Davis.Fa fd
49*8269e767SBrooks Davisout a stream socket specified by descriptor
50*8269e767SBrooks Davis.Fa s .
51*8269e767SBrooks Davis.Pp
52*8269e767SBrooks DavisThe
53*8269e767SBrooks Davis.Fa offset
54*8269e767SBrooks Davisargument specifies where to begin in the file.
55*8269e767SBrooks DavisShould
56*8269e767SBrooks Davis.Fa offset
57*8269e767SBrooks Davisfall beyond the end of file, the system will return
58*8269e767SBrooks Davissuccess and report 0 bytes sent as described below.
59*8269e767SBrooks DavisThe
60*8269e767SBrooks Davis.Fa nbytes
61*8269e767SBrooks Davisargument specifies how many bytes of the file should be sent, with 0 having the special
62*8269e767SBrooks Davismeaning of send until the end of file has been reached.
63*8269e767SBrooks Davis.Pp
64*8269e767SBrooks DavisAn optional header and/or trailer can be sent before and after the file data by specifying
65*8269e767SBrooks Davisa pointer to a
66*8269e767SBrooks Davis.Vt "struct sf_hdtr" ,
67*8269e767SBrooks Daviswhich has the following structure:
68*8269e767SBrooks Davis.Pp
69*8269e767SBrooks Davis.Bd -literal -offset indent -compact
70*8269e767SBrooks Davisstruct sf_hdtr {
71*8269e767SBrooks Davis	struct iovec *headers;	/* pointer to header iovecs */
72*8269e767SBrooks Davis	int hdr_cnt;		/* number of header iovecs */
73*8269e767SBrooks Davis	struct iovec *trailers;	/* pointer to trailer iovecs */
74*8269e767SBrooks Davis	int trl_cnt;		/* number of trailer iovecs */
75*8269e767SBrooks Davis};
76*8269e767SBrooks Davis.Ed
77*8269e767SBrooks Davis.Pp
78*8269e767SBrooks DavisThe
79*8269e767SBrooks Davis.Fa headers
80*8269e767SBrooks Davisand
81*8269e767SBrooks Davis.Fa trailers
82*8269e767SBrooks Davispointers, if
83*8269e767SBrooks Davis.Pf non- Dv NULL ,
84*8269e767SBrooks Davispoint to arrays of
85*8269e767SBrooks Davis.Vt "struct iovec"
86*8269e767SBrooks Davisstructures.
87*8269e767SBrooks DavisSee the
88*8269e767SBrooks Davis.Fn writev
89*8269e767SBrooks Davissystem call for information on the iovec structure.
90*8269e767SBrooks DavisThe number of iovecs in these
91*8269e767SBrooks Davisarrays is specified by
92*8269e767SBrooks Davis.Fa hdr_cnt
93*8269e767SBrooks Davisand
94*8269e767SBrooks Davis.Fa trl_cnt .
95*8269e767SBrooks Davis.Pp
96*8269e767SBrooks DavisIf
97*8269e767SBrooks Davis.Pf non- Dv NULL ,
98*8269e767SBrooks Davisthe system will write the total number of bytes sent on the socket to the
99*8269e767SBrooks Davisvariable pointed to by
100*8269e767SBrooks Davis.Fa sbytes .
101*8269e767SBrooks Davis.Pp
102*8269e767SBrooks DavisThe least significant 16 bits of
103*8269e767SBrooks Davis.Fa flags
104*8269e767SBrooks Davisargument is a bitmap of these values:
105*8269e767SBrooks Davis.Bl -tag -offset indent -width "SF_USER_READAHEAD"
106*8269e767SBrooks Davis.It Dv SF_NODISKIO
107*8269e767SBrooks DavisThis flag causes
108*8269e767SBrooks Davis.Nm
109*8269e767SBrooks Davisto return
110*8269e767SBrooks Davis.Er EBUSY
111*8269e767SBrooks Davisinstead of blocking when a busy page is encountered.
112*8269e767SBrooks DavisThis rare situation can happen if some other process is now working
113*8269e767SBrooks Daviswith the same region of the file.
114*8269e767SBrooks DavisIt is advised to retry the operation after a short period.
115*8269e767SBrooks Davis.Pp
116*8269e767SBrooks DavisNote that in older
117*8269e767SBrooks Davis.Fx
118*8269e767SBrooks Davisversions the
119*8269e767SBrooks Davis.Dv SF_NODISKIO
120*8269e767SBrooks Davishad slightly different notion.
121*8269e767SBrooks DavisThe flag prevented
122*8269e767SBrooks Davis.Nm
123*8269e767SBrooks Davisto run I/O operations in case if an invalid (not cached) page is encountered,
124*8269e767SBrooks Davisthus avoiding blocking on I/O.
125*8269e767SBrooks DavisStarting with
126*8269e767SBrooks Davis.Fx 11
127*8269e767SBrooks Davis.Nm
128*8269e767SBrooks Davissending files off the
129*8269e767SBrooks Davis.Xr ffs 7
130*8269e767SBrooks Davisfilesystem does not block on I/O
131*8269e767SBrooks Davis(see
132*8269e767SBrooks Davis.Sx IMPLEMENTATION NOTES
133*8269e767SBrooks Davis), so the condition no longer applies.
134*8269e767SBrooks DavisHowever, it is safe if an application utilizes
135*8269e767SBrooks Davis.Dv SF_NODISKIO
136*8269e767SBrooks Davisand on
137*8269e767SBrooks Davis.Er EBUSY
138*8269e767SBrooks Davisperforms the same action as it did in
139*8269e767SBrooks Davisolder
140*8269e767SBrooks Davis.Fx
141*8269e767SBrooks Davisversions, e.g.,
142*8269e767SBrooks Davis.Xr aio_read 2 ,
143*8269e767SBrooks Davis.Xr read 2
144*8269e767SBrooks Davisor
145*8269e767SBrooks Davis.Nm
146*8269e767SBrooks Davisin a different context.
147*8269e767SBrooks Davis.It Dv SF_NOCACHE
148*8269e767SBrooks DavisThe data sent to socket will not be cached by the virtual memory system,
149*8269e767SBrooks Davisand will be freed directly to the pool of free pages.
150*8269e767SBrooks Davis.It Dv SF_SYNC
151*8269e767SBrooks Davis.Nm
152*8269e767SBrooks Davissleeps until the network stack no longer references the VM pages
153*8269e767SBrooks Davisof the file, making subsequent modifications to it safe.
154*8269e767SBrooks DavisPlease note that this is not a guarantee that the data has actually
155*8269e767SBrooks Davisbeen sent.
156*8269e767SBrooks Davis.It Dv SF_USER_READAHEAD
157*8269e767SBrooks Davis.Nm
158*8269e767SBrooks Davishas some internal heuristics to do readahead when sending data.
159*8269e767SBrooks DavisThis flag forces
160*8269e767SBrooks Davis.Nm
161*8269e767SBrooks Davisto override any heuristically calculated readahead and use exactly the
162*8269e767SBrooks Davisapplication specified readahead.
163*8269e767SBrooks DavisSee
164*8269e767SBrooks Davis.Sx SETTING READAHEAD
165*8269e767SBrooks Davisfor more details on readahead.
166*8269e767SBrooks Davis.El
167*8269e767SBrooks Davis.Pp
168*8269e767SBrooks DavisWhen using a socket marked for non-blocking I/O,
169*8269e767SBrooks Davis.Fn sendfile
170*8269e767SBrooks Davismay send fewer bytes than requested.
171*8269e767SBrooks DavisIn this case, the number of bytes successfully
172*8269e767SBrooks Daviswritten is returned in
173*8269e767SBrooks Davis.Fa *sbytes
174*8269e767SBrooks Davis(if specified),
175*8269e767SBrooks Davisand the error
176*8269e767SBrooks Davis.Er EAGAIN
177*8269e767SBrooks Davisis returned.
178*8269e767SBrooks Davis.Sh SETTING READAHEAD
179*8269e767SBrooks Davis.Nm
180*8269e767SBrooks Davisuses internal heuristics based on request size and file system layout
181*8269e767SBrooks Davisto do readahead.
182*8269e767SBrooks DavisAdditionally application may request extra readahead.
183*8269e767SBrooks DavisThe most significant 16 bits of
184*8269e767SBrooks Davis.Fa flags
185*8269e767SBrooks Davisspecify amount of pages that
186*8269e767SBrooks Davis.Nm
187*8269e767SBrooks Davismay read ahead when reading the file.
188*8269e767SBrooks DavisA macro
189*8269e767SBrooks Davis.Fn SF_FLAGS
190*8269e767SBrooks Davisis provided to combine readahead amount and flags.
191*8269e767SBrooks DavisAn example showing specifying readahead of 16 pages and
192*8269e767SBrooks Davis.Dv SF_NOCACHE
193*8269e767SBrooks Davisflag:
194*8269e767SBrooks Davis.Pp
195*8269e767SBrooks Davis.Bd -literal -offset indent -compact
196*8269e767SBrooks Davis	SF_FLAGS(16, SF_NOCACHE)
197*8269e767SBrooks Davis.Ed
198*8269e767SBrooks Davis.Pp
199*8269e767SBrooks Davis.Nm
200*8269e767SBrooks Daviswill use either application specified readahead or internally calculated,
201*8269e767SBrooks Daviswhichever is bigger.
202*8269e767SBrooks DavisSetting flag
203*8269e767SBrooks Davis.Dv SF_USER_READAHEAD
204*8269e767SBrooks Daviswould turn off any heuristics and set maximum possible readahead length to
205*8269e767SBrooks Davisthe number of pages specified via flags.
206*8269e767SBrooks Davis.Sh IMPLEMENTATION NOTES
207*8269e767SBrooks DavisThe
208*8269e767SBrooks Davis.Fx
209*8269e767SBrooks Davisimplementation of
210*8269e767SBrooks Davis.Fn sendfile
211*8269e767SBrooks Davisdoes not block on disk I/O when it sends a file off the
212*8269e767SBrooks Davis.Xr ffs 7
213*8269e767SBrooks Davisfilesystem.
214*8269e767SBrooks DavisThe syscall returns success before the actual I/O completes, and data
215*8269e767SBrooks Davisis put into the socket later unattended.
216*8269e767SBrooks DavisHowever, the order of data in the socket is preserved, so it is safe
217*8269e767SBrooks Davisto do further writes to the socket.
218*8269e767SBrooks Davis.Pp
219*8269e767SBrooks DavisThe
220*8269e767SBrooks Davis.Fx
221*8269e767SBrooks Davisimplementation of
222*8269e767SBrooks Davis.Fn sendfile
223*8269e767SBrooks Davisis "zero-copy", meaning that it has been optimized so that copying of the file data is avoided.
224*8269e767SBrooks Davis.Sh TUNING
225*8269e767SBrooks Davis.Ss physical paging buffers
226*8269e767SBrooks Davis.Fn sendfile
227*8269e767SBrooks Davisuses vnode pager to read file pages into memory.
228*8269e767SBrooks DavisThe pager uses a pool of physical buffers to run its I/O operations.
229*8269e767SBrooks DavisWhen system runs out of pbufs, sendfile will block and report state
230*8269e767SBrooks Davis.Dq Li zonelimit .
231*8269e767SBrooks DavisSize of the pool can be tuned with
232*8269e767SBrooks Davis.Va vm.vnode_pbufs
233*8269e767SBrooks Davis.Xr loader.conf 5
234*8269e767SBrooks Davistunable and can be checked with
235*8269e767SBrooks Davis.Xr sysctl 8
236*8269e767SBrooks DavisOID of the same name at runtime.
237*8269e767SBrooks Davis.Ss sendfile(2) buffers
238*8269e767SBrooks DavisOn some architectures, this system call internally uses a special
239*8269e767SBrooks Davis.Fn sendfile
240*8269e767SBrooks Davisbuffer
241*8269e767SBrooks Davis.Pq Vt "struct sf_buf"
242*8269e767SBrooks Davisto handle sending file data to the client.
243*8269e767SBrooks DavisIf the sending socket is
244*8269e767SBrooks Davisblocking, and there are not enough
245*8269e767SBrooks Davis.Fn sendfile
246*8269e767SBrooks Davisbuffers available,
247*8269e767SBrooks Davis.Fn sendfile
248*8269e767SBrooks Daviswill block and report a state of
249*8269e767SBrooks Davis.Dq Li sfbufa .
250*8269e767SBrooks DavisIf the sending socket is non-blocking and there are not enough
251*8269e767SBrooks Davis.Fn sendfile
252*8269e767SBrooks Davisbuffers available, the call will block and wait for the
253*8269e767SBrooks Davisnecessary buffers to become available before finishing the call.
254*8269e767SBrooks Davis.Pp
255*8269e767SBrooks DavisThe number of
256*8269e767SBrooks Davis.Vt sf_buf Ns 's
257*8269e767SBrooks Davisallocated should be proportional to the number of nmbclusters used to
258*8269e767SBrooks Davissend data to a client via
259*8269e767SBrooks Davis.Fn sendfile .
260*8269e767SBrooks DavisTune accordingly to avoid blocking!
261*8269e767SBrooks DavisBusy installations that make extensive use of
262*8269e767SBrooks Davis.Fn sendfile
263*8269e767SBrooks Davismay want to increase these values to be inline with their
264*8269e767SBrooks Davis.Va kern.ipc.nmbclusters
265*8269e767SBrooks Davis(see
266*8269e767SBrooks Davis.Xr tuning 7
267*8269e767SBrooks Davisfor details).
268*8269e767SBrooks Davis.Pp
269*8269e767SBrooks DavisThe number of
270*8269e767SBrooks Davis.Fn sendfile
271*8269e767SBrooks Davisbuffers available is determined at boot time by either the
272*8269e767SBrooks Davis.Va kern.ipc.nsfbufs
273*8269e767SBrooks Davis.Xr loader.conf 5
274*8269e767SBrooks Davisvariable or the
275*8269e767SBrooks Davis.Dv NSFBUFS
276*8269e767SBrooks Daviskernel configuration tunable.
277*8269e767SBrooks DavisThe number of
278*8269e767SBrooks Davis.Fn sendfile
279*8269e767SBrooks Davisbuffers scales with
280*8269e767SBrooks Davis.Va kern.maxusers .
281*8269e767SBrooks DavisThe
282*8269e767SBrooks Davis.Va kern.ipc.nsfbufsused
283*8269e767SBrooks Davisand
284*8269e767SBrooks Davis.Va kern.ipc.nsfbufspeak
285*8269e767SBrooks Davisread-only
286*8269e767SBrooks Davis.Xr sysctl 8
287*8269e767SBrooks Davisvariables show current and peak
288*8269e767SBrooks Davis.Fn sendfile
289*8269e767SBrooks Davisbuffers usage respectively.
290*8269e767SBrooks DavisThese values may also be viewed through
291*8269e767SBrooks Davis.Nm netstat Fl m .
292*8269e767SBrooks Davis.Pp
293*8269e767SBrooks DavisIf
294*8269e767SBrooks Davis.Xr sysctl 8
295*8269e767SBrooks DavisOID
296*8269e767SBrooks Davis.Va kern.ipc.nsfbufs
297*8269e767SBrooks Davisdoesn't exist, your architecture does not need to use
298*8269e767SBrooks Davis.Fn sendfile
299*8269e767SBrooks Davisbuffers because their task can be efficiently performed
300*8269e767SBrooks Davisby the generic virtual memory structures.
301*8269e767SBrooks Davis.Sh RETURN VALUES
302*8269e767SBrooks Davis.Rv -std sendfile
303*8269e767SBrooks Davis.Sh ERRORS
304*8269e767SBrooks Davis.Bl -tag -width Er
305*8269e767SBrooks Davis.It Bq Er EAGAIN
306*8269e767SBrooks DavisThe socket is marked for non-blocking I/O and not all data was sent due to
307*8269e767SBrooks Davisthe socket buffer being filled.
308*8269e767SBrooks DavisIf specified, the number of bytes successfully sent will be returned in
309*8269e767SBrooks Davis.Fa *sbytes .
310*8269e767SBrooks Davis.It Bq Er EBADF
311*8269e767SBrooks DavisThe
312*8269e767SBrooks Davis.Fa fd
313*8269e767SBrooks Davisargument
314*8269e767SBrooks Davisis not a valid file descriptor.
315*8269e767SBrooks Davis.It Bq Er EBADF
316*8269e767SBrooks DavisThe
317*8269e767SBrooks Davis.Fa s
318*8269e767SBrooks Davisargument
319*8269e767SBrooks Davisis not a valid socket descriptor.
320*8269e767SBrooks Davis.It Bq Er EBUSY
321*8269e767SBrooks DavisA busy page was encountered and
322*8269e767SBrooks Davis.Dv SF_NODISKIO
323*8269e767SBrooks Davishad been specified.
324*8269e767SBrooks DavisPartial data may have been sent.
325*8269e767SBrooks Davis.It Bq Er EFAULT
326*8269e767SBrooks DavisAn invalid address was specified for an argument.
327*8269e767SBrooks Davis.It Bq Er EINTR
328*8269e767SBrooks DavisA signal interrupted
329*8269e767SBrooks Davis.Fn sendfile
330*8269e767SBrooks Davisbefore it could be completed.
331*8269e767SBrooks DavisIf specified, the number
332*8269e767SBrooks Davisof bytes successfully sent will be returned in
333*8269e767SBrooks Davis.Fa *sbytes .
334*8269e767SBrooks Davis.It Bq Er EINVAL
335*8269e767SBrooks DavisThe
336*8269e767SBrooks Davis.Fa fd
337*8269e767SBrooks Davisargument
338*8269e767SBrooks Davisis not a regular file.
339*8269e767SBrooks Davis.It Bq Er EINVAL
340*8269e767SBrooks DavisThe
341*8269e767SBrooks Davis.Fa s
342*8269e767SBrooks Davisargument
343*8269e767SBrooks Davisis not a SOCK_STREAM type socket.
344*8269e767SBrooks Davis.It Bq Er EINVAL
345*8269e767SBrooks DavisThe
346*8269e767SBrooks Davis.Fa offset
347*8269e767SBrooks Davisargument
348*8269e767SBrooks Davisis negative.
349*8269e767SBrooks Davis.It Bq Er EIO
350*8269e767SBrooks DavisAn error occurred while reading from
351*8269e767SBrooks Davis.Fa fd .
352*8269e767SBrooks Davis.It Bq Er EINTEGRITY
353*8269e767SBrooks DavisCorrupted data was detected while reading from
354*8269e767SBrooks Davis.Fa fd .
355*8269e767SBrooks Davis.It Bq Er ENOTCAPABLE
356*8269e767SBrooks DavisThe
357*8269e767SBrooks Davis.Fa fd
358*8269e767SBrooks Davisor the
359*8269e767SBrooks Davis.Fa s
360*8269e767SBrooks Davisargument has insufficient rights.
361*8269e767SBrooks Davis.It Bq Er ENOBUFS
362*8269e767SBrooks DavisThe system was unable to allocate an internal buffer.
363*8269e767SBrooks Davis.It Bq Er ENOTCONN
364*8269e767SBrooks DavisThe
365*8269e767SBrooks Davis.Fa s
366*8269e767SBrooks Davisargument
367*8269e767SBrooks Davispoints to an unconnected socket.
368*8269e767SBrooks Davis.It Bq Er ENOTSOCK
369*8269e767SBrooks DavisThe
370*8269e767SBrooks Davis.Fa s
371*8269e767SBrooks Davisargument
372*8269e767SBrooks Davisis not a socket.
373*8269e767SBrooks Davis.It Bq Er EOPNOTSUPP
374*8269e767SBrooks DavisThe file system for descriptor
375*8269e767SBrooks Davis.Fa fd
376*8269e767SBrooks Davisdoes not support
377*8269e767SBrooks Davis.Fn sendfile .
378*8269e767SBrooks Davis.It Bq Er EPIPE
379*8269e767SBrooks DavisThe socket peer has closed the connection.
380*8269e767SBrooks Davis.El
381*8269e767SBrooks Davis.Sh SEE ALSO
382*8269e767SBrooks Davis.Xr netstat 1 ,
383*8269e767SBrooks Davis.Xr open 2 ,
384*8269e767SBrooks Davis.Xr send 2 ,
385*8269e767SBrooks Davis.Xr socket 2 ,
386*8269e767SBrooks Davis.Xr writev 2 ,
387*8269e767SBrooks Davis.Xr loader.conf 5 ,
388*8269e767SBrooks Davis.Xr tuning 7 ,
389*8269e767SBrooks Davis.Xr sysctl 8
390*8269e767SBrooks Davis.Rs
391*8269e767SBrooks Davis.%A K. Elmeleegy
392*8269e767SBrooks Davis.%A A. Chanda
393*8269e767SBrooks Davis.%A A. L. Cox
394*8269e767SBrooks Davis.%A W. Zwaenepoel
395*8269e767SBrooks Davis.%T A Portable Kernel Abstraction for Low-Overhead Ephemeral Mapping Management
396*8269e767SBrooks Davis.%J The Proceedings of the 2005 USENIX Annual Technical Conference
397*8269e767SBrooks Davis.%P pp 223-236
398*8269e767SBrooks Davis.%D 2005
399*8269e767SBrooks Davis.Re
400*8269e767SBrooks Davis.Sh HISTORY
401*8269e767SBrooks DavisThe
402*8269e767SBrooks Davis.Fn sendfile
403*8269e767SBrooks Davissystem call
404*8269e767SBrooks Davisfirst appeared in
405*8269e767SBrooks Davis.Fx 3.0 .
406*8269e767SBrooks DavisThis manual page first appeared in
407*8269e767SBrooks Davis.Fx 3.1 .
408*8269e767SBrooks DavisIn
409*8269e767SBrooks Davis.Fx 10
410*8269e767SBrooks Davissupport for sending shared memory descriptors had been introduced.
411*8269e767SBrooks DavisIn
412*8269e767SBrooks Davis.Fx 11
413*8269e767SBrooks Davisa non-blocking implementation had been introduced.
414*8269e767SBrooks Davis.Sh AUTHORS
415*8269e767SBrooks DavisThe initial implementation of
416*8269e767SBrooks Davis.Fn sendfile
417*8269e767SBrooks Davissystem call
418*8269e767SBrooks Davisand this manual page were written by
419*8269e767SBrooks Davis.An David G. Lawrence Aq Mt dg@dglawrence.com .
420*8269e767SBrooks DavisThe
421*8269e767SBrooks Davis.Fx 11
422*8269e767SBrooks Davisimplementation was written by
423*8269e767SBrooks Davis.An Gleb Smirnoff Aq Mt glebius@FreeBSD.org .
424*8269e767SBrooks Davis.Sh BUGS
425*8269e767SBrooks DavisThe
426*8269e767SBrooks Davis.Fn sendfile
427*8269e767SBrooks Davissystem call will not fail, i.e., return
428*8269e767SBrooks Davis.Dv -1
429*8269e767SBrooks Davisand set
430*8269e767SBrooks Davis.Va errno
431*8269e767SBrooks Davisto
432*8269e767SBrooks Davis.Er EFAULT ,
433*8269e767SBrooks Davisif provided an invalid address for
434*8269e767SBrooks Davis.Fa sbytes .
435*8269e767SBrooks DavisThe
436*8269e767SBrooks Davis.Fn sendfile
437*8269e767SBrooks Davissystem call does not support SCTP sockets,
438*8269e767SBrooks Davisit will return
439*8269e767SBrooks Davis.Dv -1
440*8269e767SBrooks Davisand set
441*8269e767SBrooks Davis.Va errno
442*8269e767SBrooks Davisto
443*8269e767SBrooks Davis.Er EINVAL .
444