From: Martin Str|mberg Message-Id: <200101132117.WAA26339@father.ludd.luth.se> Subject: Re: FSEXTs and llseek() In-Reply-To: <3A60A7A3.88C0F733@phekda.freeserve.co.uk> from Richard Dawe at "Jan 13, 2001 07:08:19 pm" To: djgpp-workers AT delorie DOT com Date: Sat, 13 Jan 2001 22:17:30 +0100 (MET) X-Mailer: ELM [version 2.4ME+ PL54 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Reply-To: djgpp-workers AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp-workers AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk According to Richard Dawe: > Martin Str|mberg wrote: > [snip] > > > On Sat, 6 Jan 2001, Richard Dawe wrote: > [snip] > > > > I've just been reading about __FSEXT_llseek. 'offset_t' is > > > > described as being a 'long long'. This is OK for the input > > > > arguments to __FSEXT_llseek, but how do you return the offset > > > > to the caller? The return value variable for the FSEXT handler > > > > function is only an 'int'. > [snip] > > I'm not very good at the arithmetic in casting but wouldn't keeping > > the return value as an int and casting it to long long in the llseek > > hooker work and then convert anything < -1 to positive work? > > > > If this would work we would only punish the llseek() hooker. > > You can't really typecast the return value: 'int *' cast to 'long long *' > will lead to memory corruption, when assigning a return value. Of course you can't cast "int *" to "long long *" and expect anything to work. But you can cast "int" to "long long" (not necessarily the return value). > The problem is returning a good (int-sized) offset to the FSEXT caller for > __FSEXT_llseek. If you can't return a good offset, then it's broken. There is a good (well, sufficiently non-broken at least) int-sized return value: the range [-1, 2^32-2] which will be represented as the range [-2^31, 2^31-1]. Right, MartinS