mirror of
https://github.com/eledio-devices/thirdparty-littlefs.git
synced 2025-11-02 08:48:29 +01:00
Compare commits
1 Commits
fix-tell-r
...
debug-allo
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
69b34644bd |
32
lfs.c
32
lfs.c
@@ -466,9 +466,15 @@ static int lfs_alloc(lfs_t *lfs, lfs_block_t *block) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// no free blocks in lookahead buffer, need to scan tree
|
||||||
|
LFS_DEBUG("Scanning for free blocks %"PRIx32"-%"PRIx32,
|
||||||
|
lfs->free.i + lfs->free.off,
|
||||||
|
(lfs->free.i + lfs->free.off + 8*lfs->cfg->lookahead_size)
|
||||||
|
% lfs->cfg->block_count);
|
||||||
|
|
||||||
// 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.ack == 0) {
|
if (lfs->free.ack == 0) {
|
||||||
LFS_ERROR("No more free space %"PRIu32,
|
LFS_ERROR("No more free space %"PRIx32,
|
||||||
lfs->free.i + lfs->free.off);
|
lfs->free.i + lfs->free.off);
|
||||||
return LFS_ERR_NOSPC;
|
return LFS_ERR_NOSPC;
|
||||||
}
|
}
|
||||||
@@ -1503,13 +1509,9 @@ static int lfs_dir_compact(lfs_t *lfs,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef LFS_MIGRATE
|
#ifdef LFS_MIGRATE
|
||||||
} else if (lfs->lfs1) {
|
} else if (lfs_pair_cmp(dir->pair, lfs->root) == 0 && lfs->lfs1) {
|
||||||
// do not proactively relocate blocks during migrations, this
|
// we can't relocate our root during migrations, as this would
|
||||||
// can cause a number of failure states such: clobbering the
|
// cause the superblock to get updated, which would clobber v1
|
||||||
// v1 superblock if we relocate root, and invalidating directory
|
|
||||||
// pointers if we relocate the head of a directory. On top of
|
|
||||||
// this, relocations increase the overall complexity of
|
|
||||||
// lfs_migration, which is already a delicate operation.
|
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
// we're writing too much, time to relocate
|
// we're writing too much, time to relocate
|
||||||
@@ -2068,14 +2070,10 @@ int lfs_dir_seek(lfs_t *lfs, lfs_dir_t *dir, lfs_off_t off) {
|
|||||||
dir->pos = lfs_min(2, off);
|
dir->pos = lfs_min(2, off);
|
||||||
off -= dir->pos;
|
off -= dir->pos;
|
||||||
|
|
||||||
// skip superblock entry
|
while (off != 0) {
|
||||||
dir->id = (off > 0 && lfs_pair_cmp(dir->head, lfs->root) == 0);
|
dir->id = lfs_min(dir->m.count, off);
|
||||||
|
dir->pos += dir->id;
|
||||||
while (off > 0) {
|
off -= dir->id;
|
||||||
int diff = lfs_min(dir->m.count - dir->id, off);
|
|
||||||
dir->id += diff;
|
|
||||||
dir->pos += diff;
|
|
||||||
off -= diff;
|
|
||||||
|
|
||||||
if (dir->id == dir->m.count) {
|
if (dir->id == dir->m.count) {
|
||||||
if (!dir->m.split) {
|
if (!dir->m.split) {
|
||||||
@@ -2088,8 +2086,6 @@ int lfs_dir_seek(lfs_t *lfs, lfs_dir_t *dir, lfs_off_t off) {
|
|||||||
LFS_TRACE("lfs_dir_seek -> %d", err);
|
LFS_TRACE("lfs_dir_seek -> %d", err);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
dir->id = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -428,78 +428,4 @@ scripts/test.py << TEST
|
|||||||
TEST
|
TEST
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "--- Root seek test ---"
|
|
||||||
./scripts/test.py << TEST
|
|
||||||
lfs_mount(&lfs, &cfg) => 0;
|
|
||||||
for (int i = 3; i < $MEDIUMSIZE; i++) {
|
|
||||||
sprintf(path, "hi%03d", i);
|
|
||||||
lfs_mkdir(&lfs, path) => 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
lfs_dir_open(&lfs, &dir, "/") => 0;
|
|
||||||
for (int i = 0; i < $MEDIUMSIZE; i++) {
|
|
||||||
if (i == 0) {
|
|
||||||
sprintf(path, ".");
|
|
||||||
} else if (i == 1) {
|
|
||||||
sprintf(path, "..");
|
|
||||||
} else if (i == 2) {
|
|
||||||
sprintf(path, "hello");
|
|
||||||
} else {
|
|
||||||
sprintf(path, "hi%03d", i);
|
|
||||||
}
|
|
||||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
|
||||||
strcmp(path, info.name) => 0;
|
|
||||||
}
|
|
||||||
lfs_dir_read(&lfs, &dir, &info) => 0;
|
|
||||||
lfs_dir_close(&lfs, &dir) => 0;
|
|
||||||
|
|
||||||
for (int j = 0; j < $MEDIUMSIZE; j++) {
|
|
||||||
lfs_soff_t off = -1;
|
|
||||||
|
|
||||||
lfs_dir_open(&lfs, &dir, "/") => 0;
|
|
||||||
for (int i = 0; i < $MEDIUMSIZE; i++) {
|
|
||||||
if (i == 0) {
|
|
||||||
sprintf(path, ".");
|
|
||||||
} else if (i == 1) {
|
|
||||||
sprintf(path, "..");
|
|
||||||
} else if (i == 2) {
|
|
||||||
sprintf(path, "hello");
|
|
||||||
} else {
|
|
||||||
sprintf(path, "hi%03d", i);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i == j) {
|
|
||||||
off = lfs_dir_tell(&lfs, &dir);
|
|
||||||
off >= 0 => true;
|
|
||||||
}
|
|
||||||
|
|
||||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
|
||||||
strcmp(path, info.name) => 0;
|
|
||||||
}
|
|
||||||
lfs_dir_read(&lfs, &dir, &info) => 0;
|
|
||||||
lfs_dir_close(&lfs, &dir) => 0;
|
|
||||||
|
|
||||||
lfs_dir_open(&lfs, &dir, "/") => 0;
|
|
||||||
lfs_dir_seek(&lfs, &dir, off) => 0;
|
|
||||||
for (int i = j; i < $MEDIUMSIZE; i++) {
|
|
||||||
if (i == 0) {
|
|
||||||
sprintf(path, ".");
|
|
||||||
} else if (i == 1) {
|
|
||||||
sprintf(path, "..");
|
|
||||||
} else if (i == 2) {
|
|
||||||
sprintf(path, "hello");
|
|
||||||
} else {
|
|
||||||
sprintf(path, "hi%03d", i);
|
|
||||||
}
|
|
||||||
|
|
||||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
|
||||||
strcmp(path, info.name) => 0;
|
|
||||||
}
|
|
||||||
lfs_dir_read(&lfs, &dir, &info) => 0;
|
|
||||||
lfs_dir_close(&lfs, &dir) => 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
lfs_unmount(&lfs) => 0;
|
|
||||||
TEST
|
|
||||||
|
|
||||||
scripts/results.py
|
scripts/results.py
|
||||||
|
|||||||
Reference in New Issue
Block a user