static int do_splice(int infd, int outfd, unsigned int len, char *msg)
{
while (len) {
- int written = splice(infd, NULL, outfd, NULL, len, 0);
+ int written = ssplice(infd, NULL, outfd, NULL, len, 0);
if (written <= 0)
return error(msg);
return error("connect");
do {
- int tee_len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, 0);
+ int tee_len = stee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, 0);
if (tee_len < 0) {
if (errno == EAGAIN) {
static int do_splice(int infd, int outfd, unsigned int len, char *msg)
{
while (len) {
- int written = splice(infd, NULL, outfd, NULL, len, splice_flags);
+ int written = ssplice(infd, NULL, outfd, NULL, len, splice_flags);
if (written <= 0)
return error(msg);
return error("open output");
do {
- int tee_len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, 0);
+ int tee_len = stee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, 0);
if (tee_len < 0) {
if (errno == EAGAIN) {
off = 0;
do {
- int ret = splice(fd, &off, pfd[1], NULL, min(size, (unsigned long long) splice_size), 0);
+ int ret = ssplice(fd, &off, pfd[1], NULL, min(size, (unsigned long long) splice_size), 0);
if (ret <= 0)
return error("splice-in");
size -= ret;
while (ret > 0) {
int flags = size ? SPLICE_F_MORE : 0;
- int written = splice(pfd[0], NULL, out_fd, NULL, ret, flags);
+ int written = ssplice(pfd[0], NULL, out_fd, NULL, ret, flags);
if (written <= 0)
return error("splice-out");
do {
int this_len = min((off_t) BS, sb.st_size);
- int ret = splice(in_fd, NULL, pfds[1], NULL, this_len, 0);
+ int ret = ssplice(in_fd, NULL, pfds[1], NULL, this_len, 0);
if (ret <= 0)
return error("splice-in");
sb.st_size -= ret;
while (ret > 0) {
- int written = splice(pfds[0], NULL, out_fd, NULL, ret, splice_flags);
+ int written = ssplice(pfds[0], NULL, out_fd, NULL, ret, splice_flags);
if (written <= 0)
return error("splice-out");
ret -= written;
if (!(pfd.revents & POLLIN))
continue;
- ret = splice(fd, NULL, STDOUT_FILENO, NULL, SPLICE_SIZE, 0);
+ ret = ssplice(fd, NULL, STDOUT_FILENO, NULL, SPLICE_SIZE, 0);
if (ret < 0)
return error("splice");
return isize;
while (isize) {
- int ret = splice(fd, NULL, STDOUT_FILENO, NULL, isize, 0);
+ int ret = ssplice(fd, NULL, STDOUT_FILENO, NULL, isize, 0);
if (ret < 0)
return error("splice");
return error("open");
do {
- int ret = splice(STDIN_FILENO, NULL, fd, NULL, SPLICE_SIZE, splice_flags);
+ int ret = ssplice(STDIN_FILENO, NULL, fd, NULL, SPLICE_SIZE, splice_flags);
if (ret < 0)
return error("splice");
i = NR*BUFSIZE;
off = 0;
do {
- int ret = splice(fd, &off, pipefd[1], NULL, min(i, BUFSIZE), SPLICE_F_NONBLOCK);
+ int ret = ssplice(fd, &off, pipefd[1], NULL, min(i, BUFSIZE), SPLICE_F_NONBLOCK);
if (ret <= 0)
return error("splice-pipe-in");
i -= ret;
while (ret > 0) {
int flags = i ? SPLICE_F_MORE : 0;
- int written = splice(pipefd[0], NULL, sk, NULL, ret, flags);
+ int written = ssplice(pipefd[0], NULL, sk, NULL, ret, flags);
if (written <= 0)
return error("splice-pipe-out");
ret -= written;
int flags = BUFSIZE < i ? SPLICE_F_MORE : 0;
int ret;
- ret = splice(fd, &off, sk, NULL, min(i, BUFSIZE), flags);
+ ret = ssplice(fd, &off, sk, NULL, min(i, BUFSIZE), flags);
if (ret <= 0)
return error("splice");
return error("connect");
do {
- ret = splice(STDIN_FILENO, NULL, fd, NULL, SPLICE_SIZE, SPLICE_F_NONBLOCK);
+ ret = ssplice(STDIN_FILENO, NULL, fd, NULL, SPLICE_SIZE, SPLICE_F_NONBLOCK);
if (ret < 0) {
if (errno == EAGAIN) {
usleep(100);
#define SPLICE_F_MORE (0x04) /* expect more data */
#define SPLICE_F_GIFT (0x08) /* pages passed in are a gift */
-static inline int splice(int fdin, loff_t *off_in, int fdout, loff_t *off_out,
- size_t len, unsigned long flags)
+#endif /* SPLICE_F_MOVE defined */
+
+static inline int ssplice(int fdin, loff_t *off_in, int fdout, loff_t *off_out,
+ size_t len, unsigned long flags)
{
return syscall(__NR_sys_splice, fdin, off_in, fdout, off_out, len, flags);
}
-static inline int tee(int fdin, int fdout, size_t len, unsigned int flags)
+static inline int stee(int fdin, int fdout, size_t len, unsigned int flags)
{
return syscall(__NR_sys_tee, fdin, fdout, len, flags);
}
-static inline int vmsplice(int fd, const struct iovec *iov,
- unsigned long nr_segs, unsigned int flags)
+static inline int svmsplice(int fd, const struct iovec *iov,
+ unsigned long nr_segs, unsigned int flags)
{
return syscall(__NR_sys_vmsplice, fd, iov, nr_segs, flags);
}
-#endif /* SPLICE_F_MOVE defined */
-
#define SPLICE_SIZE (64*1024)
#define BUG_ON(c) assert(!(c))
if (poll(&pfd, 1, -1) < 0)
return error("poll");
- written = vmsplice(fd, &iov, 1, splice_flags);
+ written = svmsplice(fd, &iov, 1, splice_flags);
if (written < 0)
return error("vmsplice");
if (poll(&pfd, 1, -1) < 0)
return error("poll");
- written = vmsplice(fd, &iov[idx], 2 - idx, splice_flags);
+ written = svmsplice(fd, &iov[idx], 2 - idx, splice_flags);
if (written <= 0)
return error("vmsplice");
if (poll(&pfd, 1, -1) < 0)
return error("poll");
- written = vmsplice(fd, iov, nr_vecs, gift ? SPLICE_F_GIFT : 0);
+ written = svmsplice(fd, iov, nr_vecs, gift ? SPLICE_F_GIFT : 0);
if (written <= 0)
return error("vmsplice");