mirror of
https://gitee.com/openharmony/third_party_littlefs
synced 2024-11-23 14:59:50 +00:00
12e464e9c3
The problem was not setting the file state correctly after the truncate. To truncate < size, we end up using the cache to traverse the ctz skip-list far away from where our file->pos is. We can leave the last block in the cache in case we're going to append to the file, but if we do this we need to set up file->block+file->off to tell use where we are in the file, and set the LFS_F_READING flag to indicate that our cache contains read data. Note this is different than the LFS_F_DIRTY, which we need also. The purpose of the flags are as follows: - LFS_F_DIRTY - file ctz skip-list branch is out of sync with filesystem, need to update metadata - LFS_F_READING - file cache is in use for reading, need to drop cache - LFS_F_WRITING - file cache is in use for writing, need to write out cache to disk The difference between flags is subtle but important because read/prog caches are handled differently. Prog caches have asserts in place to catch programs without erases (the infamous pcache->block == 0xffffffff assert). Though maybe the names deserve an update... Found by ebinans |
||
---|---|---|
.. | ||
corrupt.py | ||
debug.py | ||
stats.py | ||
template.fmt | ||
test_alloc.sh | ||
test_attrs.sh | ||
test_corrupt.sh | ||
test_dirs.sh | ||
test_entries.sh | ||
test_files.sh | ||
test_format.sh | ||
test_interspersed.sh | ||
test_move.sh | ||
test_orphan.sh | ||
test_paths.sh | ||
test_seek.sh | ||
test_truncate.sh | ||
test.py |