title: pwrite() on OSX 10.6 not honoring 64-bit offsets
body: <p>I seem to be having an odd problem with <code>pwrite()</code> on OSX 10.6.8 when attempting to write to an offset beyond 2GB. I keep catching a <code>SIGXFSZ</code> signal, meaning that the file-size limit has been exceeded.  Ignoring the signal doesn't help because <code>pwrite()</code> will then simply return <code>EFBIG</code>.</p>
  
  <p>It seems that OSX does not support the explicit <code>open64()</code> and <code>pwrite64()</code> functions.  It also seems that <code>sizeof(off_t)</code> is a proper 8-bytes in size, meaning that <code>pwrite()</code> should take a 64-bit offset.  Is there a flag I'm missing when calling <code>open()</code>, or some OSX-specific setting I should be passing for my file-descriptor to <code>fcntl()</code> to enable large-file support?</p>
  
  <p>Finally, when I check <code>getrlimit()</code>, with the <code>RLIMIT_FSIZE</code> option, it says that both the current and the max file-size limit is <code>9223372036854775807</code> bytes.  So that doesn't seem to be preventing me from writing large files via <code>pwrite()</code>.</p>
  
  <p>Has anyone else had problems with <code>pwrite()</code> under 64-bit OSX?</p>
  
  <hr>
  
  <p><strong>EDIT:</strong> Per request, I'm adding the code that calls <code>pwrite()</code> ... note that this code is inside a write-thread:</p>
  
  <pre><code>for (int i=0; i &lt; data-&gt;iterations; i++)
  {
      unsigned char* ptr = data-&gt;buffer;
      int temp_buff_size = data-&gt;buff_size;
      int offset = i * data-&gt;buff_size;
  
      while(temp_buff_size &gt; 0)
      {
          int temp_bytes_written = pwrite(data-&gt;fd, ptr, temp_buff_size, offset);
  
          if (temp_bytes_written &gt;= 0)
          {
              temp_buff_size -= temp_bytes_written;
              ptr += temp_bytes_written;
              offset += temp_bytes_written;
          }
          else if (errno == EINTR)
          {
              continue;
          }
          else
          {
              perror("Write thread exiting");
              write_thread_finished = 1;
                  return (void*)-1;
          }
      }
  }
  </code></pre>
  
  <p>I'm calling it inside a loop since it's my understanding that <code>pwrite()</code> is not guaranteed to write all the data requested, and so I need to make sure that the data I am requesting be written is actually written to disk, and if less bytes are written, then I properly offset into the buffer I'm writing to get the rest of the buffer onto the disk.  The role of <code>data-&gt;iterations</code> is just passing to the thread information on how many times to write the buffer to disk ... this is part of a bandwidth test, so I'm trying to write a large file to see how fast it can be written to disk.  The only problem is I'm not able to pass an offset larger than 2GB to <code>pwrite()</code>.</p>