X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=splice_stub.c;fp=splice_stub.c;h=a8da686069bfe381c47136b2d4a6104cd9b3e506;hb=e8c4b9ece4508acb51bf6184f04e66a6a97324d4;hp=0000000000000000000000000000000000000000;hpb=7e6d4cb025ff03b9fee5337b0d87f6849bf1f21c;p=vsys.git diff --git a/splice_stub.c b/splice_stub.c new file mode 100644 index 0000000..a8da686 --- /dev/null +++ b/splice_stub.c @@ -0,0 +1,42 @@ +/* This module allows data between vsys clients and servers to be copied in kernel - + * and some of these copies to be eliminated through page rewrites */ + +#define SPLICE_SYSCALL 313 +#define TEE_SYSCALL 315 +#define SPLICE_F_NONBLOCK 0x02 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +CAMLprim value stub_splice(value fd_in, value fd_out, value len) +{ + CAMLparam3(fd_in, fd_out, len); + long ret; + ret = syscall(SPLICE_SYSCALL, Int_val(fd_in), NULL, Int_val(fd_out),NULL, Int_val(len), SPLICE_F_NONBLOCK); + if (ret == -1) { + printf ("Splice error: %s\n", strerror(errno)); + caml_failwith("Splice system call returned -1"); + } + CAMLreturn(Val_int(ret)); +} + +CAMLprim value stub_tee(value fd_in, value fd_out, value len) +{ + CAMLparam3(fd_in, fd_out, len); + long ret; + ret = syscall(TEE_SYSCALL,Int_val(fd_in), Int_val(fd_out), Int_val(len), SPLICE_F_NONBLOCK); + if (ret == -1) { + printf ("Sendfile error: %s\n", strerror(errno)); + caml_failwith("Splice system call returned -1"); + } + CAMLreturn(Val_int(ret)); +}