Copyright © tutorialspoint.com
#define _GNU_SOURCE #include <fcntl.h> |
If fd_in refers to a pipe, then off_in must be NULL. If fd_in does not refer to a pipe and off_in is NULL, then bytes are read from fd_in starting from the current file offset, and the current file offset is adjusted appropriately. If fd_in does not refer to a pipe and off_in is not NULL, then off_in must point to a buffer which specifies the starting offset from which bytes will be read from fd_in; in this case, the current file offset of fd_in is not changed. Analogous statements apply for out_fd and off_out.
The flags argument is a bit mask that is composed by ORing together zero or more of the following values:
Tag | Description |
---|---|
SPLICE_F_MOVE | Attempt to move pages instead of copying. This is only a hint to the kernel: pages may still be copied if the kernel cannot move the pages from the pipe, or if the pipe buffers dont refer to full pages. |
SPLICE_F_NONBLOCK | Do not block on I/O. This makes the splice pipe operations non-blocking, but splice() may nevertheless block because the file descriptors that are spliced to/from may block (unless they have the O_NONBLOCK flag set). |
SPLICE_F_MORE | More data will be coming in a subsequent splice. This is a helpful hint when the fd_out refers to a socket (see also the description of MSG_MORE in send(2), and the description of TCP_CORK in tcp(7)) |
SPLICE_F_GIFT | Unused for splice(); see vmsplice(2). |
On error, splice() returns -1 and errno is set to indicate the error.
Tag | Description |
---|---|
EBADF | One or both file descriptors are not valid, or do not have proper read-write mode. |
EINVAL | Target file system doesnt support splicing; neither of the descriptors refers to a pipe; or offset given for non-seekable device. |
ENOMEM | Out of memory. |
ESPIPE | Either off_in or off_out was not NULL, but the corresponding file descriptor refers to a pipe. |
Tag | Description |
---|---|
splice() | moves data from the buffer to an arbitrary file descriptor, or vice versa, or from one buffer to another. |
tee(2) | "copies" the data from one buffer to another. |
vmsplice(2) | "copies" data from user space into the buffer. |
Copyright © tutorialspoint.com