Regression after ChanFS update: Due to parameter changes in the f_mkfs
function, the option to use a separate block for MBR (FDISK) was turned
back on. This should be off as it conflicts with an explicit MBR when
using the MBRBlockDevice.
deepikabhavnani did the hard work in tracking this issue down. Block
addresses are not cast to the correct type until after multiplying to
convert to byte addresses. This results in an overflow when the storage
is larger than 4 GB.
FATFilesystem declares sector count and size as uint32_t and block
device class arguments are addr and size which is uint64_t
While passing arguments to program/read/write API's of block device,
multiplication of uint32_t*uint32_t was not typecasted properly to
uint64_t which resulted in MSB truncation.
Eg. If block 0x800000 is accessed with block size 0x200, addr to be
passed (0x800000*0x200)0x100000000, but actual address passed was 0x0
which resulted in over-writting the root directory, and hence corrupted
filesystem
In the open call, the LFS_O_TRUNC flag was correctly zeroing the file, but
it wasn't actually writing the change out to disk. This went unnoticed because
in the cases where the truncate was followed by a file write, the
updated contents would be written out correctly.
Marking the file as dirty if the file isn't already truncated fixes the
problem with the least impact. Also added better test cases around
truncating files.
A COMMON folder allows code reuse across different test cases. This
avoids code duplication or code enterying the application space.
The COMMON folder is uppercase to match naming conventions in Mbed OS.
This was a small hole in the logic that handles initializing the
lookahead buffer. To imitate exhaustion (so the block allocator
will trigger a scan), the lookahead buffer is rewound a full
lookahead and set up to look like it is exhausted. However,
unlike normal allocation, this rewind was not kept aligned to
a multiple of the scan size, which is limited by both the
lookahead buffer and the total storage size.
This bug went unnoticed for so long because it only causes
problems when the block device is both:
1. Not aligned to the lookahead buffer (not a power of 2)
2. Smaller than the lookahead buffer
While this seems like a strange corner case for a block device,
this turned out to be very common for internal flash, especially
when a handleful of blocks are reserved for code.
This bug was a result of an annoying corner case around intermingling
signed and unsigned offsets. The boundary check that prevents seeking
a file to a position before the file was preventing valid seeks with
positive offsets.
This corner case is a bit more complicated than it looks because the
offset is signed, while the size of the file is unsigned. Simply
casting both to signed or unsigned offsets won't handle large files.
The API is as per posix standard, but does not provide stats for file/directory.
Stats buffer (block size, total block count, free block count) is filled for
entire mounted filesystem.
ExhaustibleBlockDevice.h
- Fix typos for consistent spelling.
ObservingBlockDevice.h
- Fix typos for consistent spelling.
ReadOnlyBlockDevice.h
- Fix typos for consistent spelling.
README.md
- Fix typos, mostly for branding.
DESIGN.md
- Make minor changes for consistent spelling and precise language.
SPEC.md
- Make minor changes for consistent spelling and precise language.
README.md
- Make minor changes for consistent spelling and precise language.
Not all devices have enough heap to fit a simulated heap block device,
however using a simulated heap block device is preferred if available
(reduced flash wear, faster testing).
Added MBED_TEST_SIM_BLOCKDEVICE for tests that only need a simulated
block device (wear_leveling + resilience), and added support for targets
that are known to have enough heap.
Unfortunately there are several issues colluding to force the timeout
this high.
1. The tests push littlefs to the limits of how many errors it can
handle before failing. As a side effect this causes a massive amount
of debug/warn/error logging about the situation.
2. The logging can't be turned off for specific tests. Note: This might
change with the introduction of test-configs.
3. Logging is fixed to a baud rate of 9600. Previous testing was carried
out with a baud rate of 115200, which is the reason for the original
timeout.
The index field of FATFS_DIR does not encapsulate all the context
required to reposition the directory traversal. ChaN provides
f_rewinddir() but no directory seek, so rewind if necessary then step
through until the desired index is reached.