mirror of
https://github.com/eledio-devices/thirdparty-littlefs.git
synced 2025-11-01 16:14:13 +01:00
Before, the tag format's type field was limited to 9-bits. This sounds
like a lot, but this field needed to encode up to 256 user-specified
types. This limited the flexibility of the encoded types. As time went
on, more bits in the type field were repurposed for various things,
leaving a rather fragile type field.
Here we make the jump to full 11-bit type fields. This comes at the cost
of a smaller length field, however the use of the length field was
always going to come with a RAM limitation. Rather than putting pressure
on RAM for inline files, the new type field lets us encode a chunk
number, splitting up inline files into multiple updatable units. This
actually pushes the theoretical inline max from 8KiB to 256KiB! (Note
that we only allow a single 1KiB chunk for now, chunky inline files
is just a theoretical future improvement).
Here is the new 32-bit tag format, note that there are multiple levels
of types which break down into more info:
[---- 32 ----]
[1|-- 11 --|-- 10 --|-- 10 --]
^. ^ . ^ ^- entry length
|. | . \------------ file id chunk info
|. \-----.------------------ type info (type3)
\.-----------.------------------ valid bit
[-3-|-- 8 --]
^ ^- chunk info
\------- type info (type1)
Additionally, I've split the CREATE tag into separate SPLICE and NAME
tags. This simplified the new compact logic a bit. For now, littlefs
still follows the rule that a NAME tag precedes any other tags related
to a file, but this can change in the future.
51 lines
1.0 KiB
Bash
Executable File
51 lines
1.0 KiB
Bash
Executable File
#!/bin/bash
|
|
set -eu
|
|
|
|
echo "=== Formatting tests ==="
|
|
rm -rf blocks
|
|
|
|
echo "--- Basic formatting ---"
|
|
tests/test.py << TEST
|
|
lfs_format(&lfs, &cfg) => 0;
|
|
TEST
|
|
|
|
echo "--- Basic mounting ---"
|
|
tests/test.py << TEST
|
|
lfs_format(&lfs, &cfg) => 0;
|
|
|
|
lfs_mount(&lfs, &cfg) => 0;
|
|
lfs_unmount(&lfs) => 0;
|
|
TEST
|
|
|
|
echo "--- Invalid superblocks ---"
|
|
ln -f -s /dev/zero blocks/0
|
|
ln -f -s /dev/zero blocks/1
|
|
tests/test.py << TEST
|
|
lfs_format(&lfs, &cfg) => LFS_ERR_NOSPC;
|
|
TEST
|
|
rm blocks/0 blocks/1
|
|
|
|
echo "--- Invalid mount ---"
|
|
tests/test.py << TEST
|
|
lfs_mount(&lfs, &cfg) => LFS_ERR_CORRUPT;
|
|
TEST
|
|
|
|
echo "--- Expanding superblock ---"
|
|
tests/test.py << TEST
|
|
lfs_format(&lfs, &cfg) => 0;
|
|
lfs_mount(&lfs, &cfg) => 0;
|
|
for (int i = 0; i < 100; i++) {
|
|
lfs_mkdir(&lfs, "dummy") => 0;
|
|
lfs_remove(&lfs, "dummy") => 0;
|
|
}
|
|
lfs_unmount(&lfs) => 0;
|
|
TEST
|
|
tests/test.py << TEST
|
|
lfs_mount(&lfs, &cfg) => 0;
|
|
lfs_mkdir(&lfs, "dummy") => 0;
|
|
lfs_unmount(&lfs) => 0;
|
|
TEST
|
|
|
|
echo "--- Results ---"
|
|
tests/stats.py
|