title: pread for very large files
body: <p>I am reading a large file using <code>pread</code> as follows:</p>
  
  <pre><code>ssize_t s = pread(fd, buff, count, offset);
  if (s != (ssize_t) count)
    fprintf(stderr, "s = %ld != count = %ld\n", s, count);
  assert(s == (ssize_t ) count);
  </code></pre>
  
  <p>The above code has been working fine for small files (upto 1.5GB). However, for large file sizes, the returned number of bytes is different than the expected count. </p>
  
  <p>In particular, for 2.4GB file size, my <code>count</code> is set to 2520133890 and the assertion fails with the <code>fprintf</code> saying:</p>
  
  <p><code>s = 2147479552 != count = 2520133890</code></p>
  
  <p>What makes this puzzling is that I am working on a 64-bit system and hence, <code>sizeof(ssize_t) = 8</code>. </p>
  
  <p>What is the cause of this failure and how do I resolve this so that I can read the whole file in one go?</p>