This is the mail archive of the
ecos-patches@sources.redhat.com
mailing list for the eCos project.
Re: [ECOS] fatfs lseek EOF bug
- From: Andrew Lunn <andrew at lunn dot ch>
- To: Savin Zlobec <savin at elatec dot si>
- Cc: Gratian Crisan <nelu at iv dot ro>, ecos-patches at ecos dot sourceware dot org
- Date: Tue, 7 Jun 2005 11:47:40 +0200
- Subject: Re: [ECOS] fatfs lseek EOF bug
- References: <200505091228.04579.nelu@iv.ro> <4280594B.4070703@elatec.si> <200505101258.48354.nelu@iv.ro> <428091CE.20300@elatec.si>
On Tue, May 10, 2005 at 12:49:50PM +0200, Savin Zlobec wrote:
> Gratian Crisan wrote:
>
> >Hi,
> >
> >please see my answers below:
> >
> >On Tuesday 10 May 2005 09:48, Savin Zlobec wrote:
> >
> >
> >>Gratian Crisan wrote:
> >>
> >>
> >>>Hi all,
> >>>
> >>>I think I've found a bug in the ecos FAT implementation for lseek
> >>>function. (fatfs_fo_lseek).
> >>>When calling the function like this 'lseek(fd, 0, SEEK_CUR)' to get the
> >>>current file position and the postion is right at the end of the file the
> >>>fat lseek function returns end of file error EEOF. I've looked at the
> >>>other filesystems from ecos and did a test in linux and the correct
> >>>behavior seems to be to return the current position of the end of file if
> >>>the read/write pointer is at the end of file (equal with the file size).
> >>>This bug occurs for example when creating a new file, writing some data
> >>>in
> >>>it and calling lseek(fd, 0, SEEK_CUR) to get the current file position.
> >>>
> >>>Suggestions?
> >>>
> [snip]
>
> > See the file attached. The test is for an MMC driver but should be
> > pretty straight forward to adapt (only the mount command should be
> >changed).
> >The test creates a file and writes blocks of data into it while printing
> >the current file offset. In a new file after writing the first block, for
> >which the value returned is 0, the value returned by lseek function is -1.
> >The strange thing is that if you overwrite an existing file the lseek
> >function correctly returns the current file offset (equal to EOF).
> >
> >
> Found the BUG -- Please try the attached patch and let me know if it works.
I've committed the patch, along with a suitable ChangeLog.
Andrew