This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
fseek +ramfs +SEEK_CUR problems
- From: "senthil kumar t" <senthilnow at rediffmail dot com>
- To: ecos-discuss at sources dot redhat dot com
- Date: 29 Aug 2002 13:55:44 -0000
- Subject: [ECOS] fseek +ramfs +SEEK_CUR problems
- Reply-to: "senthil kumar t" <senthilnow at rediffmail dot com>
hi,
with reference to the thread "a question about romfs" dated 16
jul 2001 from jjtsai i am writing this mail, i saw the following
lines in one of the mails in that thread
" A fseek(,,SEEK_CUR) after fread() will cause inconsistency
between
(CYG_StdioStream) real_stream.position
and "fp->f_offset". See also stream.inl and rom_fs.c"
i also observed similar condition in the case of ramfs also when
a file is opened is r+ mode and when fseek is done with SEEK_CUR
flag the fp->f_offset doesn't exactly reflect the right offset, so
i have made some change in the fseek.cxx which fixes this problem,
basically i am doing a real_stream->get_position and initialising
the offset correctly.
i have modified the fseek function as such.
externC int
fseek( FILE * stream , long int offset , int whence )
{
Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream;
Cyg_ErrNo err;
int ret = 0;
fpos_t seekcur_pos;// ADDED FOR FIX
CYG_REPORT_FUNCNAME( "fgetpos" );
//START_FIX
if (whence==SEEK_CUR)
{
err= real_stream->get_position(&seekcur_pos);
offset+=seekcur_pos;
whence=SEEK_SET;
}
//END_FIX
err = real_stream->set_position( (fpos_t)offset, whence );
if( err != ENOERR )
{
errno = err;
ret = -1;
}
CYG_REPORT_RETVAL( ret );
return ret;
}
i have 2 questions
1) is this the right place for the fix?
2) what is the better way of resolving that inconsistency?
thankx in advance
senthil kumar
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss