UBIFS recovery truncates file to zero size

Iram Shahzad iram.shahzad at jp.fujitsu.com
Thu Mar 12 04:49:08 EDT 2009


>> For the write back enabled case, I was expecting the
>> following behaviour:
>>     power went down before the file is sync-ed, so
>>     on the next booting the file will be in its old state,
>>     that is it will contain the contents which it had before
>>     this write.
>> 
>> But instead of being in the old state, it becomes empty file.
>> Is this really expected(correct) behaviour?
> 
> No.  How were you updating the file?

The file is updated by a Java application in the following way.

-----
FileOutputStream str = new FileOutputStream(aFilename);
// some write here
str.flush();
str.close();
-----

I switch off the power after confirming that the str.close() has been
executed.

P.S:
If I add str.getFD().sync(); after the str.flush(), the file looks good in
the next boot. However my question still remains for the case
when I do not call str.getFD().sync:
"why the file becomes empty rather than being in its old state?".

Thanks
Iram





More information about the linux-mtd mailing list