Skip to content

Commit c6ee7bb

Browse files
committed
Squashed 'features/storage/filesystem/littlefs/littlefs/' changes from 510cd13..ec4d8b6
ec4d8b6 Changed release script to generate drafts c7894a6 Added a handful of links to related projects 1950758 Added 2GiB file size limit and EFBIG reporting 97d8d5e Fixed issue where a rename causes a split and pushes dir out of sync 0bb1f7a Modified release script to create notes only on minor releases 447d89c Merge pull request ARMmbed#109 from OTAkeys/pr/fix-sign-compare 28d2d96 Fix -Wsign-compare error cb62bf2 Fixed release script issue with fetching recent tags 646b1b5 Added -Wjump-misses-init and fixed uninitialized warnings 1b7a155 Merge pull request ARMmbed#106 from conkerkh/master e5a6938 Fixed possible infinite loop in deorphan step 6ad544f If stats file doesn't exist lfs_emubd_create will fail. 3419284 Fixed issue with corruption due to different cache sizes git-subtree-dir: features/storage/filesystem/littlefs/littlefs git-subtree-split: ec4d8b6
1 parent f5466c6 commit c6ee7bb

File tree

10 files changed

+306
-188
lines changed

10 files changed

+306
-188
lines changed

.travis.yml

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,15 @@ jobs:
138138
- LFS_VERSION=$(grep -ox '#define LFS_VERSION .*' lfs.h | cut -d ' ' -f3)
139139
- LFS_VERSION_MAJOR=$((0xffff & ($LFS_VERSION >> 16)))
140140
- LFS_VERSION_MINOR=$((0xffff & ($LFS_VERSION >> 0)))
141-
# Grab latests patch from repo tags, default to 0
142-
- LFS_VERSION_PATCH=$(curl -f -u "$GEKY_BOT_RELEASES"
143-
https://api.github.com/repos/$TRAVIS_REPO_SLUG/git/refs
144-
| jq 'map(.ref | match(
145-
"refs/tags/v'"$LFS_VERSION_MAJOR"'\\.'"$LFS_VERSION_MINOR"'\\.(.*)$")
146-
.captures[].string | tonumber + 1) | max // 0')
141+
# Grab latests patch from repo tags, default to 0, needs finagling to get past github's pagination api
142+
- PREV_URL=https://api.github.com/repos/$TRAVIS_REPO_SLUG/git/refs/tags/v$LFS_VERSION_MAJOR.$LFS_VERSION_MINOR.
143+
- PREV_URL=$(curl -u "$GEKY_BOT_RELEASES" "$PREV_URL" -I
144+
| sed -n '/^Link/{s/.*<\(.*\)>; rel="last"/\1/;p;q0};$q1'
145+
|| echo $PREV_URL)
146+
- LFS_VERSION_PATCH=$(curl -u "$GEKY_BOT_RELEASES" "$PREV_URL"
147+
| jq 'map(.ref | match("\\bv.*\\..*\\.(.*)$";"g")
148+
.captures[].string | tonumber) | max + 1'
149+
|| echo 0)
147150
# We have our new version
148151
- LFS_VERSION="v$LFS_VERSION_MAJOR.$LFS_VERSION_MINOR.$LFS_VERSION_PATCH"
149152
- echo "VERSION $LFS_VERSION"
@@ -154,24 +157,35 @@ jobs:
154157
| jq -re '.sha')
155158
if [ "$TRAVIS_COMMIT" == "$CURRENT_COMMIT" ]
156159
then
157-
# Build release notes
158-
PREV=$(git tag --sort=-v:refname -l "v*" | head -1)
159-
if [ ! -z "$PREV" ]
160-
then
161-
echo "PREV $PREV"
162-
CHANGES=$'### Changes\n\n'$( \
163-
git log --oneline $PREV.. --grep='^Merge' --invert-grep)
164-
printf "CHANGES\n%s\n\n" "$CHANGES"
165-
fi
166-
# Create the release
160+
# Create a simple tag
167161
curl -f -u "$GEKY_BOT_RELEASES" -X POST \
168-
https://api.github.com/repos/$TRAVIS_REPO_SLUG/releases \
162+
https://api.github.com/repos/$TRAVIS_REPO_SLUG/git/refs \
169163
-d "{
170-
\"tag_name\": \"$LFS_VERSION\",
171-
\"target_commitish\": \"$TRAVIS_COMMIT\",
172-
\"name\": \"${LFS_VERSION%.0}\",
173-
\"body\": $(jq -sR '.' <<< "$CHANGES")
164+
\"ref\": \"refs/tags/$LFS_VERSION\",
165+
\"sha\": \"$TRAVIS_COMMIT\"
174166
}"
167+
# Minor release?
168+
if [[ "$LFS_VERSION" == *.0 ]]
169+
then
170+
# Build release notes
171+
PREV=$(git tag --sort=-v:refname -l "v*.0" | head -1)
172+
if [ ! -z "$PREV" ]
173+
then
174+
echo "PREV $PREV"
175+
CHANGES=$'### Changes\n\n'$( \
176+
git log --oneline $PREV.. --grep='^Merge' --invert-grep)
177+
printf "CHANGES\n%s\n\n" "$CHANGES"
178+
fi
179+
# Create the release
180+
curl -f -u "$GEKY_BOT_RELEASES" -X POST \
181+
https://api.github.com/repos/$TRAVIS_REPO_SLUG/releases \
182+
-d "{
183+
\"tag_name\": \"$LFS_VERSION\",
184+
\"name\": \"${LFS_VERSION%.0}\",
185+
\"draft\": true,
186+
\"body\": $(jq -sR '.' <<< "$CHANGES")
187+
}"
188+
fi
175189
fi
176190
177191
# Manage statuses

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ ifdef WORD
2525
override CFLAGS += -m$(WORD)
2626
endif
2727
override CFLAGS += -I.
28-
override CFLAGS += -std=c99 -Wall -pedantic -Wshadow -Wunused-parameter
28+
override CFLAGS += -std=c99 -Wall -pedantic
29+
override CFLAGS += -Wshadow -Wunused-parameter -Wjump-misses-init -Wsign-compare
2930

3031

3132
all: $(TARGET)

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,3 +175,18 @@ handy.
175175
[littlefs-js](https://github.com/geky/littlefs-js) - A javascript wrapper for
176176
littlefs. I'm not sure why you would want this, but it is handy for demos.
177177
You can see it in action [here](http://littlefs.geky.net/demo.html).
178+
179+
[mklfs](https://github.com/whitecatboard/Lua-RTOS-ESP32/tree/master/components/mklfs/src) -
180+
A command line tool built by the [Lua RTOS](https://github.com/whitecatboard/Lua-RTOS-ESP32)
181+
guys for making littlefs images from a host PC. Supports Windows, Mac OS,
182+
and Linux.
183+
184+
[SPIFFS](https://github.com/pellepl/spiffs) - Another excellent embedded
185+
filesystem for NOR flash. As a more traditional logging filesystem with full
186+
static wear-leveling, SPIFFS will likely outperform littlefs on small
187+
memories such as the internal flash on microcontrollers.
188+
189+
[Dhara](https://github.com/dlbeer/dhara) - An interesting NAND flash
190+
translation layer designed for small MCUs. It offers static wear-leveling and
191+
power-resilience with only a fixed O(|address|) pointer structure stored on
192+
each block and in RAM.

emubd/lfs_emubd.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,24 @@ int lfs_emubd_create(const struct lfs_config *cfg, const char *path) {
4747

4848
// Load stats to continue incrementing
4949
snprintf(emu->child, LFS_NAME_MAX, "stats");
50+
5051
FILE *f = fopen(emu->path, "r");
51-
if (!f) {
52+
if (!f && errno != ENOENT) {
5253
return -errno;
5354
}
5455

55-
size_t res = fread(&emu->stats, sizeof(emu->stats), 1, f);
56-
if (res < 1) {
57-
return -errno;
58-
}
56+
if (errno == ENOENT) {
57+
memset(&emu->stats, 0x0, sizeof(emu->stats));
58+
} else {
59+
size_t res = fread(&emu->stats, sizeof(emu->stats), 1, f);
60+
if (res < 1) {
61+
return -errno;
62+
}
5963

60-
err = fclose(f);
61-
if (err) {
62-
return -errno;
64+
err = fclose(f);
65+
if (err) {
66+
return -errno;
67+
}
6368
}
6469

6570
return 0;

0 commit comments

Comments
 (0)