Guest User

Untitled

a guest
Jul 8th, 2017
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.44 KB | None | 0 0
  1. extern crate libc;
  2. use libc::vmsplice;
  3. use libc::c_void;
  4.  
  5. fn main() {
  6.     let bufsize = 16 * 1024 * 1024;
  7.     let mut buf = "y\n".repeat(bufsize / 2).into_bytes();
  8.  
  9.     let iovec = libc::iovec {
  10.         iov_base: buf.as_mut_ptr() as *mut c_void,
  11.         iov_len: bufsize,
  12.     };
  13.     let iov_max = libc::_SC_IOV_MAX as usize;
  14.     unsafe {
  15.         loop {
  16.             vmsplice(1, &iovec, iov_max, libc::SPLICE_F_GIFT);
  17.         }
  18.     }
  19. }
Add Comment
Please, Sign In to add comment