I need to add LFS to a C process which uses fseek()
.
gcc and glibc are of version 3.2.3 and 2.5, respectively.
I made the following alterations:
- added
CFLAGS += -D_FILE_OFFSET_BITS=64
to the makefile. - I replaced the call to
fseek()
with a call tofseeko()
(I also need MSVC6 support, but one step at a time). - I've changed the 2nd argument's type to
off_t
.sizeof()
on the variable returns 8.
Here is as good a sample main()
as I can get past our DLP and its output:
fd = fopen("large_file", "rb");
off_t offset = 1ULL << 32;
rc = fseeko(fd, offset, SEEK_SET);
rc = -1 sizeof(offset)=8 errno=22 offset=2147483648
The below program, compiled with
CFLAGS = -g2 -Wall -D_LARGEFILE64_SOURCE
works here (3.13.0-43-generic #72-Ubuntu SMP Mon Dec 8 19:35:06 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux)(compiling with
CFLAGS = -g2 -Wall -D_FILE_OFFSET_BITS=64
ands/off64_t/off_t/
works equally well)