Sender: rich AT phekda DOT freeserve DOT co DOT uk Message-ID: <3D0C85B3.146E1AC1@phekda.freeserve.co.uk> Date: Sun, 16 Jun 2002 13:33:55 +0100 From: Richard Dawe X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.2.19 i586) X-Accept-Language: de,fr MIME-Version: 1.0 To: djgpp-workers AT delorie DOT com Subject: Re: DJGPP and the Large File Summit (LFS) References: <10206142111 DOT AA17751 AT clio DOT rice DOT edu> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp-workers AT delorie DOT com Hello. Charles Sandmann wrote: [snip] > One thing I've always thought is that lseek and llseek should be the > same code, either with a compile define or a common stub routine. We > also have many places in the libc which do seeks via int calls instead > of calling a common low level seek. There is at least one other routine > I've seen that was essentially a clone of another routine (and should > be fixed, but I can't remember right now). [snip] Combining lseek and llseek into a common stub routine isn't quite as straightforward as it sounds. What do you do, when you have to call an FSEXT handler? Which do you pass in: __FSEXT_lseek or __FSEXT_llseek? As part of implementing LFS, it seems like a common stub routine is the only way forward, because of the possibilities of small file vs. large file and small file-only function vs. large file-supporting function. What I currently have in my tree is this: lseek -\ +-> __lseek64_internal lseek64 -/ __lseek64_internal does all the work - checking that the maximum offset will not be exceeded, calling the appropriate FSEXT handler (lseek vs. lseek64 (aka llseek)). __lseek64_internal takes a flag which indicates whether large-file operations are allowed (allow_large_file). There are three cases: 1. lseek calls __lseek64_internal; allow_large_file == 0: maximum offset is LONG_MAX; 2. lseek64 calls __lseek64_internal; allow_large_file == 1; the file was opened in small-file mode: maximum offset is LONG_MAX; 3. lseek64 calls __lseek64_internal; allow_large_file == 1; the file was opened in large-file mode: maximum offset is ULONG_MAX. Cases 1 & 2 call the __FSEXT_lseek handler. Case 3 calls the __FSEXT_lseek64 (aka __FSEXT_llseek) handler. There is a similar hierarchy for fseek, fseeko64. These use __lseek64_internal as well: fseeko -> fseek -\ +-> __fseeko64_internal -> __lseek64_internal fseeko64 --------/ __fseeko64_internal is just fseek modified to use *64 functions and pass the allow_large_file flag to __lseek64_internal. Bye, Rich =] -- Richard Dawe [ http://www.phekda.freeserve.co.uk/richdawe/ ]