]> git.ipfire.org Git - thirdparty/man-pages.git/blobdiff - man2/sendfile.2
proc.5: Note kernel version for /proc/PID/smaps VmFlags "dd" flag
[thirdparty/man-pages.git] / man2 / sendfile.2
index 5b1e7db8e08f2063cb0b27668e3109f5b92de95e..f0ead4a9b4e39b72a514f427e558b7395d395cfe 100644 (file)
 .\"
 .\" 2005-03-31 Martin Pool <mbp@sourcefrog.net> mmap() improvements
 .\"
-.TH SENDFILE 2 2015-05-07 "Linux" "Linux Programmer's Manual"
+.TH SENDFILE 2 2017-09-15 "Linux" "Linux Programmer's Manual"
 .SH NAME
 sendfile \- transfer data between file descriptors
 .SH SYNOPSIS
 .B #include <sys/sendfile.h>
-.sp
+.PP
 .BI "ssize_t sendfile(int" " out_fd" ", int" " in_fd" ", off_t *" \
                       offset ", size_t" " count" );
 .\" The below is too ugly. Comments about glibc versions belong
@@ -54,12 +54,12 @@ is more efficient than the combination of
 and
 .BR write (2),
 which would require transferring data to and from user space.
-
+.PP
 .I in_fd
 should be a file descriptor opened for reading and
 .I out_fd
 should be a descriptor opened for writing.
-
+.PP
 If
 .I offset
 is not NULL, then it points
@@ -75,29 +75,29 @@ If
 .I offset
 is not NULL, then
 .BR sendfile ()
-does not modify the current file offset of
+does not modify the file offset of
 .IR in_fd ;
-otherwise the current file offset is adjusted to reflect
+otherwise the file offset is adjusted to reflect
 the number of bytes read from
 .IR in_fd .
-
+.PP
 If
 .I offset
 is NULL, then data will be read from
 .IR in_fd
-starting at the current file offset,
+starting at the file offset,
 and the file offset will be updated by the call.
-
+.PP
 .I count
 is the number of bytes to copy between the file descriptors.
-
+.PP
 The
 .IR in_fd
 argument must correspond to a file which supports
 .BR mmap (2)-like
 operations
 (i.e., it cannot be a socket).
-
+.PP
 In Linux kernels before 2.6.33,
 .I out_fd
 must refer to a socket.
@@ -114,7 +114,7 @@ Note that a successful call to
 may write fewer bytes than requested;
 the caller should be prepared to retry the call if there were unsent bytes.
 See also NOTES.
-
+.PP
 On error, \-1 is returned, and
 .I errno
 is set appropriately.
@@ -164,8 +164,7 @@ the input file or the output file.
 .TP
 .B ESPIPE
 .I offset
-is not NULL but the input file is not
-.BR seek (2)-able.
+is not NULL but the input file is not seekable.
 .SH VERSIONS
 .BR sendfile ()
 first appeared in Linux 2.2.
@@ -174,7 +173,7 @@ The include file
 is present since glibc 2.1.
 .SH CONFORMING TO
 Not specified in POSIX.1-2001, nor in other standards.
-
+.PP
 Other UNIX systems implement
 .BR sendfile ()
 with different semantics and prototypes.
@@ -185,7 +184,7 @@ will transfer at most 0x7ffff000 (2,147,479,552) bytes,
 returning the number of bytes actually transferred.
 .\" commit e28cc71572da38a5a12c1cfe4d7032017adccf69
 (This is true on both 32-bit and 64-bit systems.)
-
+.PP
 If you plan to use
 .BR sendfile ()
 for sending files to a TCP socket, but need
@@ -195,13 +194,13 @@ it useful to employ the
 option, described in
 .BR tcp (7),
 to minimize the number of packets and to tune performance.
-
+.PP
 In Linux 2.4 and earlier,
 .I out_fd
 could also refer to a regular file;
 this possibility went away in the Linux 2.6.x kernel series,
 but was restored in Linux 2.6.33.
-
+.PP
 The original Linux
 .BR sendfile ()
 system call was not designed to handle large file offsets.
@@ -213,7 +212,7 @@ argument.
 The glibc
 .BR sendfile ()
 wrapper function transparently deals with the kernel differences.
-
+.PP
 Applications may wish to fall back to
 .BR read (2)/ write (2)
 in the case where
@@ -222,7 +221,7 @@ fails with
 .B EINVAL
 or
 .BR ENOSYS .
-
+.PP
 If
 .I out_fd
 refers to a socket or pipe with zero-copy support, callers must ensure the
@@ -231,12 +230,13 @@ transferred portions of the file referred to by
 remain unmodified until the reader on the other end of
 .I out_fd
 has consumed the transferred data.
-
+.PP
 The Linux-specific
 .BR splice (2)
-call supports transferring data between arbitrary files
-(e.g., a pair of sockets).
+call supports transferring data between arbitrary file descriptors
+provided one (or both) of them is a pipe.
 .SH SEE ALSO
+.BR copy_file_range (2),
 .BR mmap (2),
 .BR open (2),
 .BR socket (2),