Hi all,
I have a file > 2GB, and my job is seeking the file to pos: 2.1G.
But, the lseek doesn't work.
Here is the sample code:
int main()
{
int fd = -1;
long long pos = (long long) 2*1024*1024*1024 + 10; // over 2G
fd = open(FILENAME, O_WRONLY);
if (fd < 0){
...
}
if (lseek(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, Invalid argument
Best Regards
Nicle Yang