Author: Bob Lee Date: To: yaffs Subject: [Yaffs] Weird RandomAccessFile behavior on Android
YAFFS team,
After investigating some corrupt files in our Android app, I think I've
narrowed the problem down to YAFFS. The same code on a FAT fs performs as
expected.
First, it looks like RandomAccessFile.setLength(), which translates to
ftruncate(), can fail silently. For example, I can set the file length to
much more space than is available, and I don't get an error. I'm not sure
why else ftruncate() fails, but we've seen cases where the actual file
length (as reported by "ls -l") is less than it should
be. RandomAccessFile.length(), which seeks to the end of the file, returns
the requested value, which is much longer than the available space. I even
tried writing and reading the last byte, and I still didn't get an error.
Finally, File.length(), which uses stat, returns 0 for the length, and the
available space reported by "df" doesn't go down. :-(
As a workaround, I'm going to append bytes to the end of the file instead of
using ftruncate(), but I thought I should bring these issues to your
attention.