[ECOS] fseek on JFFS2

Jonathan Larmour jifl@eCosCentric.com
Tue Sep 26 15:00:00 GMT 2006


Andrew Lunn wrote:
> On Fri, Sep 22, 2006 at 03:25:09PM +0200, Andrew Lunn wrote:
>> On Fri, Sep 22, 2006 at 02:26:30PM +0200, Paluch Sebastian wrote:
>>> hi,
>>> here you have some test file 'fseek_test.c', and my output.
>> I tried running the code on the ramfs. It also fails there as
>> well. Attached is the code.
> 
> Hi Sebastian
> 
> I spent some time looking at this yesterday. There is definitely a
> problem with the stdio stream implementation of buffered IO. The file
> position as kept by the stream layer and the file system get out of
> sync and so writes are made to the wrong position. 
> 
> What i don't understand is how it is supposed to work. The stream
> layer does not make any lseek()s when reading/writing blocks to the
> file system. It seems to assume that synchronisation will just be
> kept.  When just doing simple linear fread()s or linear fwrite()s
> maybe this is true, but as soon as you start fseek()ing around this
> does not hold. Either i'm missing something in how the code is
> supposed to work, or maybe the basic design did not implement fseek()
> and it was incorrectly added later?

It was subsequently added (the stdio package predates filesystem support by 
many years - before then it only used to work on streams), but this is all 
meant to be handled in Cyg_StdioStream::set_position and I thought was 
being used in various places so I didn't think was completely broken.

> Jifl, this seems to be your code.

Some of, less so this bit in fact. Although scanning through the code, 
nothing seems obviously wrong either.

> I know you wrote it a long time ago,
> but do you remember how this is supposed to work?

set_position() calculates the new absolute position and calls 
cyg_stdio_lseek() which (with CYGPKG_FILEIO) is meant to be just a thin 
veneer over lseek().

Jifl
-- 
eCosCentric    http://www.eCosCentric.com/    The eCos and RedBoot experts
------["The best things in life aren't things."]------      Opinions==mine

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss



More information about the Ecos-discuss mailing list