mirror of
https://github.com/eledio-devices/thirdparty-littlefs.git
synced 2025-11-01 08:48:31 +01:00
Compare commits
5 Commits
v2.2.0
...
fix-alloc-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b8dcf10974 | ||
|
|
d04c1392c0 | ||
|
|
4c9146ea53 | ||
|
|
5a9f38df01 | ||
|
|
1b033e9ab6 |
2
Makefile
2
Makefile
@@ -26,8 +26,6 @@ endif
|
|||||||
override CFLAGS += -I.
|
override CFLAGS += -I.
|
||||||
override CFLAGS += -std=c99 -Wall -pedantic
|
override CFLAGS += -std=c99 -Wall -pedantic
|
||||||
override CFLAGS += -Wextra -Wshadow -Wjump-misses-init -Wundef
|
override CFLAGS += -Wextra -Wshadow -Wjump-misses-init -Wundef
|
||||||
# Remove missing-field-initializers because of GCC bug
|
|
||||||
override CFLAGS += -Wno-missing-field-initializers
|
|
||||||
|
|
||||||
ifdef VERBOSE
|
ifdef VERBOSE
|
||||||
override TFLAGS += -v
|
override TFLAGS += -v
|
||||||
|
|||||||
30
lfs.c
30
lfs.c
@@ -1375,8 +1375,12 @@ static int lfs_dir_alloc(lfs_t *lfs, lfs_mdir_t *dir) {
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
// make sure we don't immediately evict
|
// to make sure we don't immediately evict, align the new revision count
|
||||||
dir->rev += dir->rev & 1;
|
// to our block_cycles modulus, see lfs_dir_compact for why our modulus
|
||||||
|
// is tweaked this way
|
||||||
|
if (lfs->cfg->block_cycles > 0) {
|
||||||
|
dir->rev = lfs_alignup(dir->rev, ((lfs->cfg->block_cycles+1)|1));
|
||||||
|
}
|
||||||
|
|
||||||
// set defaults
|
// set defaults
|
||||||
dir->off = sizeof(dir->rev);
|
dir->off = sizeof(dir->rev);
|
||||||
@@ -2432,9 +2436,9 @@ int lfs_file_opencfg(lfs_t *lfs, lfs_file_t *file,
|
|||||||
|
|
||||||
// get next slot and create entry to remember name
|
// get next slot and create entry to remember name
|
||||||
err = lfs_dir_commit(lfs, &file->m, LFS_MKATTRS(
|
err = lfs_dir_commit(lfs, &file->m, LFS_MKATTRS(
|
||||||
{LFS_MKTAG(LFS_TYPE_CREATE, file->id, 0)},
|
{LFS_MKTAG(LFS_TYPE_CREATE, file->id, 0), NULL},
|
||||||
{LFS_MKTAG(LFS_TYPE_REG, file->id, nlen), path},
|
{LFS_MKTAG(LFS_TYPE_REG, file->id, nlen), path},
|
||||||
{LFS_MKTAG(LFS_TYPE_INLINESTRUCT, file->id, 0)}));
|
{LFS_MKTAG(LFS_TYPE_INLINESTRUCT, file->id, 0), NULL}));
|
||||||
if (err) {
|
if (err) {
|
||||||
err = LFS_ERR_NAMETOOLONG;
|
err = LFS_ERR_NAMETOOLONG;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@@ -3200,7 +3204,7 @@ int lfs_remove(lfs_t *lfs, const char *path) {
|
|||||||
|
|
||||||
// delete the entry
|
// delete the entry
|
||||||
err = lfs_dir_commit(lfs, &cwd, LFS_MKATTRS(
|
err = lfs_dir_commit(lfs, &cwd, LFS_MKATTRS(
|
||||||
{LFS_MKTAG(LFS_TYPE_DELETE, lfs_tag_id(tag), 0)}));
|
{LFS_MKTAG(LFS_TYPE_DELETE, lfs_tag_id(tag), 0), NULL}));
|
||||||
if (err) {
|
if (err) {
|
||||||
lfs->mlist = dir.next;
|
lfs->mlist = dir.next;
|
||||||
LFS_TRACE("lfs_remove -> %d", err);
|
LFS_TRACE("lfs_remove -> %d", err);
|
||||||
@@ -3326,12 +3330,12 @@ int lfs_rename(lfs_t *lfs, const char *oldpath, const char *newpath) {
|
|||||||
// move over all attributes
|
// move over all attributes
|
||||||
err = lfs_dir_commit(lfs, &newcwd, LFS_MKATTRS(
|
err = lfs_dir_commit(lfs, &newcwd, LFS_MKATTRS(
|
||||||
{LFS_MKTAG_IF(prevtag != LFS_ERR_NOENT,
|
{LFS_MKTAG_IF(prevtag != LFS_ERR_NOENT,
|
||||||
LFS_TYPE_DELETE, newid, 0)},
|
LFS_TYPE_DELETE, newid, 0), NULL},
|
||||||
{LFS_MKTAG(LFS_TYPE_CREATE, newid, 0)},
|
{LFS_MKTAG(LFS_TYPE_CREATE, newid, 0), NULL},
|
||||||
{LFS_MKTAG(lfs_tag_type3(oldtag), newid, strlen(newpath)), newpath},
|
{LFS_MKTAG(lfs_tag_type3(oldtag), newid, strlen(newpath)), newpath},
|
||||||
{LFS_MKTAG(LFS_FROM_MOVE, newid, lfs_tag_id(oldtag)), &oldcwd},
|
{LFS_MKTAG(LFS_FROM_MOVE, newid, lfs_tag_id(oldtag)), &oldcwd},
|
||||||
{LFS_MKTAG_IF(samepair,
|
{LFS_MKTAG_IF(samepair,
|
||||||
LFS_TYPE_DELETE, newoldid, 0)}));
|
LFS_TYPE_DELETE, newoldid, 0), NULL}));
|
||||||
if (err) {
|
if (err) {
|
||||||
lfs->mlist = prevdir.next;
|
lfs->mlist = prevdir.next;
|
||||||
LFS_TRACE("lfs_rename -> %d", err);
|
LFS_TRACE("lfs_rename -> %d", err);
|
||||||
@@ -3344,7 +3348,7 @@ int lfs_rename(lfs_t *lfs, const char *oldpath, const char *newpath) {
|
|||||||
// prep gstate and delete move id
|
// prep gstate and delete move id
|
||||||
lfs_fs_prepmove(lfs, 0x3ff, NULL);
|
lfs_fs_prepmove(lfs, 0x3ff, NULL);
|
||||||
err = lfs_dir_commit(lfs, &oldcwd, LFS_MKATTRS(
|
err = lfs_dir_commit(lfs, &oldcwd, LFS_MKATTRS(
|
||||||
{LFS_MKTAG(LFS_TYPE_DELETE, lfs_tag_id(oldtag), 0)}));
|
{LFS_MKTAG(LFS_TYPE_DELETE, lfs_tag_id(oldtag), 0), NULL}));
|
||||||
if (err) {
|
if (err) {
|
||||||
lfs->mlist = prevdir.next;
|
lfs->mlist = prevdir.next;
|
||||||
LFS_TRACE("lfs_rename -> %d", err);
|
LFS_TRACE("lfs_rename -> %d", err);
|
||||||
@@ -3636,7 +3640,7 @@ int lfs_format(lfs_t *lfs, const struct lfs_config *cfg) {
|
|||||||
|
|
||||||
lfs_superblock_tole32(&superblock);
|
lfs_superblock_tole32(&superblock);
|
||||||
err = lfs_dir_commit(lfs, &root, LFS_MKATTRS(
|
err = lfs_dir_commit(lfs, &root, LFS_MKATTRS(
|
||||||
{LFS_MKTAG(LFS_TYPE_CREATE, 0, 0)},
|
{LFS_MKTAG(LFS_TYPE_CREATE, 0, 0), NULL},
|
||||||
{LFS_MKTAG(LFS_TYPE_SUPERBLOCK, 0, 8), "littlefs"},
|
{LFS_MKTAG(LFS_TYPE_SUPERBLOCK, 0, 8), "littlefs"},
|
||||||
{LFS_MKTAG(LFS_TYPE_INLINESTRUCT, 0, sizeof(superblock)),
|
{LFS_MKTAG(LFS_TYPE_INLINESTRUCT, 0, sizeof(superblock)),
|
||||||
&superblock}));
|
&superblock}));
|
||||||
@@ -4050,7 +4054,7 @@ static int lfs_fs_relocate(lfs_t *lfs,
|
|||||||
lfs_pair_tole32(newpair);
|
lfs_pair_tole32(newpair);
|
||||||
int err = lfs_dir_commit(lfs, &parent, LFS_MKATTRS(
|
int err = lfs_dir_commit(lfs, &parent, LFS_MKATTRS(
|
||||||
{LFS_MKTAG_IF(moveid != 0x3ff,
|
{LFS_MKTAG_IF(moveid != 0x3ff,
|
||||||
LFS_TYPE_DELETE, moveid, 0)},
|
LFS_TYPE_DELETE, moveid, 0), NULL},
|
||||||
{tag, newpair}));
|
{tag, newpair}));
|
||||||
lfs_pair_fromle32(newpair);
|
lfs_pair_fromle32(newpair);
|
||||||
if (err) {
|
if (err) {
|
||||||
@@ -4084,7 +4088,7 @@ static int lfs_fs_relocate(lfs_t *lfs,
|
|||||||
lfs_pair_tole32(newpair);
|
lfs_pair_tole32(newpair);
|
||||||
err = lfs_dir_commit(lfs, &parent, LFS_MKATTRS(
|
err = lfs_dir_commit(lfs, &parent, LFS_MKATTRS(
|
||||||
{LFS_MKTAG_IF(moveid != 0x3ff,
|
{LFS_MKTAG_IF(moveid != 0x3ff,
|
||||||
LFS_TYPE_DELETE, moveid, 0)},
|
LFS_TYPE_DELETE, moveid, 0), NULL},
|
||||||
{LFS_MKTAG(LFS_TYPE_TAIL + parent.split, 0x3ff, 8), newpair}));
|
{LFS_MKTAG(LFS_TYPE_TAIL + parent.split, 0x3ff, 8), newpair}));
|
||||||
lfs_pair_fromle32(newpair);
|
lfs_pair_fromle32(newpair);
|
||||||
if (err) {
|
if (err) {
|
||||||
@@ -4132,7 +4136,7 @@ static int lfs_fs_demove(lfs_t *lfs) {
|
|||||||
uint16_t moveid = lfs_tag_id(lfs->gdisk.tag);
|
uint16_t moveid = lfs_tag_id(lfs->gdisk.tag);
|
||||||
lfs_fs_prepmove(lfs, 0x3ff, NULL);
|
lfs_fs_prepmove(lfs, 0x3ff, NULL);
|
||||||
err = lfs_dir_commit(lfs, &movedir, LFS_MKATTRS(
|
err = lfs_dir_commit(lfs, &movedir, LFS_MKATTRS(
|
||||||
{LFS_MKTAG(LFS_TYPE_DELETE, moveid, 0)}));
|
{LFS_MKTAG(LFS_TYPE_DELETE, moveid, 0), NULL}));
|
||||||
if (err) {
|
if (err) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user