mirror of
https://github.com/eledio-devices/thirdparty-littlefs.git
synced 2025-11-02 08:48:29 +01:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cb62bf2188 | ||
|
|
646b1b5a6c | ||
|
|
1b7a15599e | ||
|
|
e5a6938faf | ||
|
|
6ad544f3f3 | ||
|
|
3419284689 |
12
.travis.yml
12
.travis.yml
@@ -138,11 +138,13 @@ jobs:
|
|||||||
- LFS_VERSION=$(grep -ox '#define LFS_VERSION .*' lfs.h | cut -d ' ' -f3)
|
- LFS_VERSION=$(grep -ox '#define LFS_VERSION .*' lfs.h | cut -d ' ' -f3)
|
||||||
- LFS_VERSION_MAJOR=$((0xffff & ($LFS_VERSION >> 16)))
|
- LFS_VERSION_MAJOR=$((0xffff & ($LFS_VERSION >> 16)))
|
||||||
- LFS_VERSION_MINOR=$((0xffff & ($LFS_VERSION >> 0)))
|
- LFS_VERSION_MINOR=$((0xffff & ($LFS_VERSION >> 0)))
|
||||||
# Grab latests patch from repo tags, default to 0
|
# Grab latests patch from repo tags, default to 0, needs finagling to get past github's pagination api
|
||||||
- LFS_VERSION_PATCH=$(curl -f -u "$GEKY_BOT_RELEASES"
|
- PREV_URL=https://api.github.com/repos/$TRAVIS_REPO_SLUG/git/refs/tags/v$LFS_VERSION_MAJOR.$LFS_VERSION_MINOR.
|
||||||
https://api.github.com/repos/$TRAVIS_REPO_SLUG/git/refs
|
- PREV_URL=$(curl -f -u "$GEKY_BOT_RELEASES" "$PREV_URL" -I
|
||||||
| jq 'map(.ref | match(
|
| sed -n '/^Link/{s/.*<\(.*\)>; rel="last"/\1/;p;q0};$q1'
|
||||||
"refs/tags/v'"$LFS_VERSION_MAJOR"'\\.'"$LFS_VERSION_MINOR"'\\.(.*)$")
|
|| echo $PREV_URL)
|
||||||
|
- LFS_VERSION_PATCH=$(curl -f -u "$GEKY_BOT_RELEASES" "$PREV_URL"
|
||||||
|
| jq 'map(.ref | match("\\bv.*\\..*\\.(.*)$";"g")
|
||||||
.captures[].string | tonumber + 1) | max // 0')
|
.captures[].string | tonumber + 1) | max // 0')
|
||||||
# We have our new version
|
# We have our new version
|
||||||
- LFS_VERSION="v$LFS_VERSION_MAJOR.$LFS_VERSION_MINOR.$LFS_VERSION_PATCH"
|
- LFS_VERSION="v$LFS_VERSION_MAJOR.$LFS_VERSION_MINOR.$LFS_VERSION_PATCH"
|
||||||
|
|||||||
3
Makefile
3
Makefile
@@ -25,7 +25,8 @@ ifdef WORD
|
|||||||
override CFLAGS += -m$(WORD)
|
override CFLAGS += -m$(WORD)
|
||||||
endif
|
endif
|
||||||
override CFLAGS += -I.
|
override CFLAGS += -I.
|
||||||
override CFLAGS += -std=c99 -Wall -pedantic -Wshadow -Wunused-parameter
|
override CFLAGS += -std=c99 -Wall -pedantic
|
||||||
|
override CFLAGS += -Wshadow -Wunused-parameter -Wjump-misses-init
|
||||||
|
|
||||||
|
|
||||||
all: $(TARGET)
|
all: $(TARGET)
|
||||||
|
|||||||
@@ -47,11 +47,15 @@ int lfs_emubd_create(const struct lfs_config *cfg, const char *path) {
|
|||||||
|
|
||||||
// Load stats to continue incrementing
|
// Load stats to continue incrementing
|
||||||
snprintf(emu->child, LFS_NAME_MAX, "stats");
|
snprintf(emu->child, LFS_NAME_MAX, "stats");
|
||||||
|
|
||||||
FILE *f = fopen(emu->path, "r");
|
FILE *f = fopen(emu->path, "r");
|
||||||
if (!f) {
|
if (!f && errno != ENOENT) {
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (errno == ENOENT) {
|
||||||
|
memset(&emu->stats, 0x0, sizeof(emu->stats));
|
||||||
|
} else {
|
||||||
size_t res = fread(&emu->stats, sizeof(emu->stats), 1, f);
|
size_t res = fread(&emu->stats, sizeof(emu->stats), 1, f);
|
||||||
if (res < 1) {
|
if (res < 1) {
|
||||||
return -errno;
|
return -errno;
|
||||||
@@ -61,6 +65,7 @@ int lfs_emubd_create(const struct lfs_config *cfg, const char *path) {
|
|||||||
if (err) {
|
if (err) {
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
29
lfs.c
29
lfs.c
@@ -1373,7 +1373,10 @@ int lfs_file_opencfg(lfs_t *lfs, lfs_file_t *file,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// zero to avoid information leak
|
// zero to avoid information leak
|
||||||
|
lfs_cache_drop(lfs, &file->cache);
|
||||||
|
if ((file->flags & 3) != LFS_O_RDONLY) {
|
||||||
lfs_cache_zero(lfs, &file->cache);
|
lfs_cache_zero(lfs, &file->cache);
|
||||||
|
}
|
||||||
|
|
||||||
// add to list of files
|
// add to list of files
|
||||||
file->next = lfs->files;
|
file->next = lfs->files;
|
||||||
@@ -2055,8 +2058,8 @@ static int lfs_init(lfs_t *lfs, const struct lfs_config *cfg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// zero to avoid information leaks
|
// zero to avoid information leaks
|
||||||
lfs_cache_zero(lfs, &lfs->rcache);
|
|
||||||
lfs_cache_zero(lfs, &lfs->pcache);
|
lfs_cache_zero(lfs, &lfs->pcache);
|
||||||
|
lfs_cache_drop(lfs, &lfs->rcache);
|
||||||
|
|
||||||
// setup lookahead, round down to nearest 32-bits
|
// setup lookahead, round down to nearest 32-bits
|
||||||
LFS_ASSERT(lfs->cfg->lookahead % 32 == 0);
|
LFS_ASSERT(lfs->cfg->lookahead % 32 == 0);
|
||||||
@@ -2093,7 +2096,9 @@ cleanup:
|
|||||||
}
|
}
|
||||||
|
|
||||||
int lfs_format(lfs_t *lfs, const struct lfs_config *cfg) {
|
int lfs_format(lfs_t *lfs, const struct lfs_config *cfg) {
|
||||||
int err = lfs_init(lfs, cfg);
|
int err = 0;
|
||||||
|
if (true) {
|
||||||
|
err = lfs_init(lfs, cfg);
|
||||||
if (err) {
|
if (err) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@@ -2170,6 +2175,7 @@ int lfs_format(lfs_t *lfs, const struct lfs_config *cfg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
lfs_alloc_ack(lfs);
|
lfs_alloc_ack(lfs);
|
||||||
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
lfs_deinit(lfs);
|
lfs_deinit(lfs);
|
||||||
@@ -2177,7 +2183,9 @@ cleanup:
|
|||||||
}
|
}
|
||||||
|
|
||||||
int lfs_mount(lfs_t *lfs, const struct lfs_config *cfg) {
|
int lfs_mount(lfs_t *lfs, const struct lfs_config *cfg) {
|
||||||
int err = lfs_init(lfs, cfg);
|
int err = 0;
|
||||||
|
if (true) {
|
||||||
|
err = lfs_init(lfs, cfg);
|
||||||
if (err) {
|
if (err) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@@ -2224,6 +2232,7 @@ int lfs_mount(lfs_t *lfs, const struct lfs_config *cfg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
|
||||||
@@ -2472,7 +2481,11 @@ int lfs_deorphan(lfs_t *lfs) {
|
|||||||
lfs_dir_t cwd = {.d.tail[0] = 0, .d.tail[1] = 1};
|
lfs_dir_t cwd = {.d.tail[0] = 0, .d.tail[1] = 1};
|
||||||
|
|
||||||
// iterate over all directory directory entries
|
// iterate over all directory directory entries
|
||||||
while (!lfs_pairisnull(cwd.d.tail)) {
|
for (int i = 0; i < lfs->cfg->block_count; i++) {
|
||||||
|
if (lfs_pairisnull(cwd.d.tail)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int err = lfs_dir_fetch(lfs, &cwd, cwd.d.tail);
|
int err = lfs_dir_fetch(lfs, &cwd, cwd.d.tail);
|
||||||
if (err) {
|
if (err) {
|
||||||
return err;
|
return err;
|
||||||
@@ -2501,7 +2514,7 @@ int lfs_deorphan(lfs_t *lfs) {
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!lfs_pairsync(entry.d.u.dir, pdir.d.tail)) {
|
if (!lfs_pairsync(entry.d.u.dir, pdir.d.tail)) {
|
||||||
@@ -2517,7 +2530,7 @@ int lfs_deorphan(lfs_t *lfs) {
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2562,5 +2575,7 @@ int lfs_deorphan(lfs_t *lfs) {
|
|||||||
memcpy(&pdir, &cwd, sizeof(pdir));
|
memcpy(&pdir, &cwd, sizeof(pdir));
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
// If we reached here, we have more directory pairs than blocks in the
|
||||||
|
// filesystem... So something must be horribly wrong
|
||||||
|
return LFS_ERR_CORRUPT;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user