AnsweredAssumed Answered

Bug Report: MQX 4.1.1 MFS write does not update MQX_FILE size so fseek IO_SEEK_END does not work.

Question asked by Chris Solomon on Oct 5, 2014
Latest reply on Sep 8, 2015 by Rui Faria


I have been doing some testing of the new MFS, verifying the functionality.

I think I have found a bug:


When a file is opened, the file MQX_FILE structure SIZE field is set to the current file size, however when the file is written to this field is not updated.

Here is an example of how this problem manifests:

Open a new file.

Write 100 bytes.

ftell will report 100

fseek IO_SEEK_END -10   -> Should position you at 90, but will actually fail with IO_ERROR since size is 0

ftell will still report 100, instead of 90.


I believe the problem is around line 821 of mfs_init.c.

There is an if statement checking for the case where the MFS_Write has returned MFS_NO_ERROR and errcode == MFS_EOF.

This is fine, except MFS_Write returns the number of bytes written, so if the file size is increased the file ptr is not updated.


Any suggestions?