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

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

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

Post 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?
jnc100
Member
Member
Posts: 775
Joined: Mon Apr 09, 2007 12:10 pm
Location: London, UK
Contact:

Post 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.
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post by Brynet-Inc »

The Wikipedia article on LFS seems to be a good resource as well.. :)

http://en.wikipedia.org/wiki/Large_file_support
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
Post Reply