Skip to content

Instantly share code, notes, and snippets.

@mathiasuk
Last active August 29, 2015 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mathiasuk/cf46d0f0caf1dd597e59 to your computer and use it in GitHub Desktop.
Save mathiasuk/cf46d0f0caf1dd597e59 to your computer and use it in GitHub Desktop.
#include <sys/types.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <sys/sendfile.h>
int main() {
int input, output;
ssize_t count, written;
count = 4294967296;
input = open("/tmp/bigfile", O_RDONLY);
output = open("/tmp/output", O_WRONLY | O_CREAT);
written = sendfile(output, input, NULL, count);
if (written == -1) {
perror("Sendfile error");
}
else {
printf("Success, asked for: %zu, written: %zu\n", count, written);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment