Transfers data between file descriptors. This is a LFS version of sys_sendfile.
Because the data transfer is done within the kernel, sys_sendfile is more efficient than the combination of sys_read and sys_write, which would require transferring data to and from user space.
Arguments
eax |
239 |
ebx |
Output file descriptor opened for writing. |
ecx |
Input file descriptor opened for reading. |
edx |
Pointer to a 64bit variable holding the file offset from which sys_sendfile will start reading data from input. When sys_sendfile returns, this variable will be set to the offset of the byte following the last byte that was read.
If edx is null, then current file offset of input is used and adjusted accordingly. |
esi |
Number of bytes to copy between the file descriptors. |
Return values
If the system call succeeds the return value is the number of bytes written.
If the system call fails the return value is one of the following errno values:
-EAGAIN |
Non-blocking I/O has been selected using O_NONBLOCK and the write would block. |
-EBADF |
The input file was not opened for reading or the output file was not opened for writing. |
-EFAULT |
Bad address. |
-EINVAL |
Descriptor is not valid or locked, or an sys_mmap-like operation is not available for input. |
-EIO |
Unspecified error while reading from input. |
-ENOMEM |
Insufficient memory to read from input. |
|
Remarks
If you plan to use sys_sendfile for sending files to a TCP socket, but need to send some header data in front of the file contents, you will find it useful to employ the TCP_CORK option, described in man 7 tcp, to minimize the number of packets and to tune performance.
"Presently (Linux 2.6.9): ecx, must correspond to a file which supports sys_mmap-like operations (i.e., it cannot be a socket); and ebx must refer to a socket. *to be verified*"
Compatibility
n/a |