Hi Chris,
Ok…you got me on that one. Saw results eyes wanted and didn’t let the brain do the work!
I do believe you first assessment is correct. If you change mfs_init.c at line 817 to following:
/* Check for EOF. The MFS EOF must be translated to the standard EOF */
#if 0 //DES 0=test, 1=default code
if (result == MFS_NO_ERROR && errcode == MFS_EOF)
#else
if (result == num && errcode != MFS_EOF) //DES should have been TRUE so file_ptr parameters get updated. Why not? The result==MFS_NO_ERROR makes no sense. Why not result==num? errcode deosn't make sense either.
#endif
{
file_ptr->FLAGS |= IO_FLAG_AT_EOF;
/* Update the file size in the old IO structure */
file_ptr->SIZE = handle->SIZE;
}
My test code seems to work for the various IO_SEEK #defines:
#define IO_SEEK_SET (1) /* Seek from start */
#define IO_SEEK_CUR (2) /* Seek from current location */
#define IO_SEEK_END (3) /* Seek from end */
My updated sh_write_ftell_fseek_ftell_test.c code has following update:
#if 1 //DES 1=test of ftell/fseek/ftell, 0=default code
result = ftell(fd); //DES find file position
printf("\nftell result = %d", result);
printf("\nBacking up file pointer 10 bytes");
result = fseek(fd, -10, IO_SEEK_END); //DES works...back up 10 bytes from EOF
if(result != MQX_OK) {
printf("\nERROR fseek'ing\n");
}
result = ftell(fd); //DES find file position
printf("\nupdated ftell result = %d", result);
result = fseek(fd, -10, IO_SEEK_CUR); //DES works...back up 10 bytes from current location
if(result != MQX_OK) {
printf("\nERROR fseek'ing\n");
}
result = ftell(fd); //DES find file position
printf("\nupdated ftell result = %d", result);
result = fseek(fd, +90, IO_SEEK_SET); //DES works...move 90 bytes from beginning of file
if(result != MQX_OK) {
printf("\nERROR fseek'ing\n");
}
result = ftell(fd); //DES find file position
printf("\nupdated ftell result = %d\n", result);
#endif
When I looked at the “fd” parameters all looked OK.
I will submit this to our MQX Development team to get confirmation this is correct and respond back.
Please give it a try and let me know.
Regards,
David