Page 1 of 1

How do 32-bit POSIX compliant systems access files > 4GB?

Posted: Sun Nov 25, 2007 4:53 am
by JamesM
Title really explains it all: I've been pondering this for a while.

The read/write functions defined by POSIX are all syscalls, and as such all the parameters *have* to be 32bits on a 32 bit system, right? So how do you access past 4GB of a file by using the standard read/write syscalls?

Posted: Sun Nov 25, 2007 6:34 am
by jnc100
Single Unix specification Large file support defines a file offset to be of 'extended signed integral type' i.e. signed long long int. This means the standard functions like fseek should support LFS by standard in a c library that supports it. How this translates into syscalls is up to you. I suppose functions in a small file only c library could call one syscall, and those in a large file one could call a different syscall (e.g. fstat/fstat64 in glibc). How you pass a 64-bit value to a syscall is a question you probably should have already answered, e.g. use EAX:EDX or use EAX to point to a 64 bit value in memory.

Regards,
John.

Posted: Sun Nov 25, 2007 2:51 pm
by Brynet-Inc
The Wikipedia article on LFS seems to be a good resource as well.. :)

http://en.wikipedia.org/wiki/Large_file_support