Yes , I have done this before. But I got some strange results!
Here is sample code:

#define _LARGEFILE64_SOURCE
#include ...

int main()
{
  int fd = -1;
  long long pos = (long long) 2*1024*1024*1024 + 10; // over 2G

  fd = open(FILENAME, O_WRONLY|O_LARGEFILE);
  if (fd < 0){
    ...
  }

  if (lseek64(fd, pos, SEEK_SET) < 0) {
      fprintf(stderr, "Failed seeking to %lld, %s\n", pos, strerror(errno));
  }

  return 0;
}

 Then the building cmd:
     gcc -o test test.c -D_FILE_OFFSET_BITS=64

 Output:
     Failed seeking to 2147483658, Success.

The return val of lseek64  was "<0", but the strerror told me "Success".

Best Regards
Nicle Yang



2009/5/17, John Matthews <[email protected]>:
> --- In [email protected], Nicle <yni...@...> wrote:
>>
>>  I have a file > 2GB, and my job is seeking the file to pos: 2.1G.
>> But, the lseek doesn't work.
>
> Try lseek64()?
>
>

Reply via email to