This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

bug in fseek


hi,
There is an inconsistency between
(CYG_StdioStream) real_stream.position
and "fp->f_offset" in the ramfs operation of fseek when the whence flag is set to SEEK_CUR, so the right position of the offset from the opened file is not obtained so some fix should be made to make the inconsitency vanish,
i have comeup with some solution which will circumvent this problem.
The fseek function has been moddified as such in fseek.cxx

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;
}

real_stream->get_position should be done to find out the current position bcos fp->f_offset could be different if opened in r+ mode, this bug is still there in the latest ecos cvs i checked out before a week and my fix makes that work correctly as expected.

with regards
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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]