/* 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 && errno!=EAGAIN) { 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 && errno!=EAGAIN) { caml_failwith(strerror(errno)); } CAMLreturn(Val_int(ret)); }