Invalid argument when calling linux splice()
Posted
by benny wallace
on Stack Overflow
See other posts from Stack Overflow
or by benny wallace
Published on 2010-04-05T18:57:05Z
Indexed on
2010/04/05
19:13 UTC
Read the original article
Hit count: 344
Hi
I wanted to try out the splice syscall. I have this function - it should copy content of one file to another:
static void test_splice( int in, int out ) {
int i = 0, rcvd = 0;
int filedes[2];
off_t off = 0;
if ( pipe( filedes ) < 0 ) {
perror( "Kicha pipe" );
exit( EXIT_FAILURE );
}
for ( i = 0; i < NUMLOOPS; ++i ) {
if ( ( rcvd = splice( in, NULL, filedes[1], NULL, BUFSIZE, SPLICE_F_MORE | SPLICE_F_MOVE ) ) < 0 ) {
perror( "splice" );
exit( EXIT_FAILURE );
}
if ( splice( filedes[0], NULL, out, NULL, rcvd, SPLICE_F_MORE | SPLICE_F_MOVE ) < 0 ) {
perror( "splice" );
exit( EXIT_FAILURE );
}
}
}
The second call to splice in first iteration returns EINVAL ( invalid argument from perror ) everytime - what could be the reason?
© Stack Overflow or respective owner