mirror of
https://github.com/eledio-devices/thirdparty-littlefs.git
synced 2025-11-02 00:38:28 +01:00
Compare commits
2 Commits
fix-multi-
...
fix-lookah
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f935fc0be6 | ||
|
|
6a89ecba39 |
5
lfs.c
5
lfs.c
@@ -305,6 +305,7 @@ static int lfs_alloc(lfs_t *lfs, lfs_block_t *block) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check if we have looked at all blocks since last ack
|
// check if we have looked at all blocks since last ack
|
||||||
|
//if (lfs->free.i == lfs->free.ack - lfs->free.off) {
|
||||||
if (lfs->free.ack == 0) {
|
if (lfs->free.ack == 0) {
|
||||||
LFS_WARN("No more free space %d", lfs->free.i + lfs->free.off);
|
LFS_WARN("No more free space %d", lfs->free.i + lfs->free.off);
|
||||||
return LFS_ERR_NOSPC;
|
return LFS_ERR_NOSPC;
|
||||||
@@ -1355,10 +1356,6 @@ int lfs_file_open(lfs_t *lfs, lfs_file_t *file,
|
|||||||
// allocate buffer if needed
|
// allocate buffer if needed
|
||||||
file->cache.block = 0xffffffff;
|
file->cache.block = 0xffffffff;
|
||||||
if (lfs->cfg->file_buffer) {
|
if (lfs->cfg->file_buffer) {
|
||||||
if (lfs->files) {
|
|
||||||
// already in use
|
|
||||||
return LFS_ERR_NOMEM;
|
|
||||||
}
|
|
||||||
file->cache.buffer = lfs->cfg->file_buffer;
|
file->cache.buffer = lfs->cfg->file_buffer;
|
||||||
} else if ((file->flags & 3) == LFS_O_RDONLY) {
|
} else if ((file->flags & 3) == LFS_O_RDONLY) {
|
||||||
file->cache.buffer = lfs_malloc(lfs->cfg->read_size);
|
file->cache.buffer = lfs_malloc(lfs->cfg->read_size);
|
||||||
|
|||||||
@@ -110,10 +110,35 @@ lfs_alloc_singleproc multiprocreuse
|
|||||||
lfs_verify multiprocreuse
|
lfs_verify multiprocreuse
|
||||||
lfs_verify singleprocreuse
|
lfs_verify singleprocreuse
|
||||||
|
|
||||||
echo "--- Cleanup ---"
|
|
||||||
lfs_remove multiprocreuse
|
lfs_remove multiprocreuse
|
||||||
lfs_remove singleprocreuse
|
lfs_remove singleprocreuse
|
||||||
|
|
||||||
|
echo "--- Lookahead overflow test ---"
|
||||||
|
lfs_mkdir overflow
|
||||||
|
for name in bacon eggs pancakes
|
||||||
|
do
|
||||||
|
tests/test.py << TEST
|
||||||
|
lfs_mount(&lfs, &cfg) => 0;
|
||||||
|
|
||||||
|
// // setup lookahead to almost overflow
|
||||||
|
// lfs.free.begin = ((lfs_size_t)-1) - 2*$SIZE;
|
||||||
|
// lfs.free.size = 0;
|
||||||
|
// lfs.free.off = 0;
|
||||||
|
|
||||||
|
lfs_file_open(&lfs, &file[0], "overflow/$name",
|
||||||
|
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_APPEND) => 0;
|
||||||
|
size = strlen("$name");
|
||||||
|
memcpy(buffer, "$name", size);
|
||||||
|
for (int i = 0; i < $SIZE; i++) {
|
||||||
|
lfs_file_write(&lfs, &file[0], buffer, size) => size;
|
||||||
|
}
|
||||||
|
lfs_file_close(&lfs, &file[0]) => 0;
|
||||||
|
lfs_unmount(&lfs) => 0;
|
||||||
|
TEST
|
||||||
|
done
|
||||||
|
lfs_verify overflow
|
||||||
|
lfs_remove overflow
|
||||||
|
|
||||||
echo "--- Exhaustion test ---"
|
echo "--- Exhaustion test ---"
|
||||||
tests/test.py << TEST
|
tests/test.py << TEST
|
||||||
lfs_mount(&lfs, &cfg) => 0;
|
lfs_mount(&lfs, &cfg) => 0;
|
||||||
@@ -368,7 +393,6 @@ echo "--- Outdated lookahead and split dir test ---"
|
|||||||
rm -rf blocks
|
rm -rf blocks
|
||||||
tests/test.py << TEST
|
tests/test.py << TEST
|
||||||
lfs_format(&lfs, &cfg) => 0;
|
lfs_format(&lfs, &cfg) => 0;
|
||||||
|
|
||||||
lfs_mount(&lfs, &cfg) => 0;
|
lfs_mount(&lfs, &cfg) => 0;
|
||||||
|
|
||||||
// fill completely with two files
|
// fill completely with two files
|
||||||
@@ -424,5 +448,8 @@ tests/test.py << TEST
|
|||||||
lfs_unmount(&lfs) => 0;
|
lfs_unmount(&lfs) => 0;
|
||||||
TEST
|
TEST
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
echo "--- Results ---"
|
echo "--- Results ---"
|
||||||
tests/stats.py
|
tests/stats.py
|
||||||
|
|||||||
Reference in New Issue
Block a user