title: Linux set end of file (shrink, truncate, cut out some data @ end)
body: <p>In windows there is SetEndOfFile() API to cut out some data in the end.</p>
  
  <p>How do I do this in Linux?</p>
  
  <p>The pseudo-code sample of what I'm looking for (Linux-specific):</p>
  
  <pre><code>int fd = open("/path/to/file",O_RDWR);
  // file contents: "0123456789ABCDEF", 16 bytes
  lseek(fd,10,SEEK_CUR);
  // what's in the next line? (imaginary code)
  syscall(what,fd,FD_SET_EOF);
  
  close(fd);
  //sync();
  // now file on disk looks like "0123456789", 10 bytes
  </code></pre>