mirror of
https://github.com/eledio-devices/thirdparty-littlefs.git
synced 2025-11-02 00:38:28 +01:00
Compare commits
12 Commits
v1.3
...
resizable-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
04b1103de1 | ||
|
|
87df75d009 | ||
|
|
1ea3d04d9c | ||
|
|
126f6d334e | ||
|
|
385b74944d | ||
|
|
3a10f5c29b | ||
|
|
96cca2f5b6 | ||
|
|
32f43462ea | ||
|
|
efc634f3ed | ||
|
|
2f7adc3461 | ||
|
|
e934a22c3a | ||
|
|
5937fd79dd |
@@ -35,7 +35,7 @@ script:
|
|||||||
if [ "$TRAVIS_TEST_RESULT" -eq 0 ]
|
if [ "$TRAVIS_TEST_RESULT" -eq 0 ]
|
||||||
then
|
then
|
||||||
CURR=$(tail -n1 sizes | awk '{print $1}')
|
CURR=$(tail -n1 sizes | awk '{print $1}')
|
||||||
PREV=$(curl -u $GEKY_BOT_STATUSES https://api.github.com/repos/$TRAVIS_REPO_SLUG/status/master \
|
PREV=$(curl https://api.github.com/repos/$TRAVIS_REPO_SLUG/status/master \
|
||||||
| jq -re "select(.sha != \"$TRAVIS_COMMIT\")
|
| jq -re "select(.sha != \"$TRAVIS_COMMIT\")
|
||||||
| .statuses[] | select(.context == \"$STAGE/$NAME\").description
|
| .statuses[] | select(.context == \"$STAGE/$NAME\").description
|
||||||
| capture(\"code size is (?<size>[0-9]+)\").size" \
|
| capture(\"code size is (?<size>[0-9]+)\").size" \
|
||||||
@@ -165,8 +165,7 @@ jobs:
|
|||||||
\"name\": \"$LFS_VERSION\"
|
\"name\": \"$LFS_VERSION\"
|
||||||
}"
|
}"
|
||||||
RELEASE=$(
|
RELEASE=$(
|
||||||
curl -f -u $GEKY_BOT_RELEASES \
|
curl -f https://api.github.com/repos/$TRAVIS_REPO_SLUG/releases/tags/$LFS_VERSION
|
||||||
https://api.github.com/repos/$TRAVIS_REPO_SLUG/releases/tags/$LFS_VERSION
|
|
||||||
)
|
)
|
||||||
CHANGES=$(
|
CHANGES=$(
|
||||||
git log --oneline $LFS_PREV_VERSION.. --grep='^Merge' --invert-grep
|
git log --oneline $LFS_PREV_VERSION.. --grep='^Merge' --invert-grep
|
||||||
|
|||||||
4
Makefile
4
Makefile
@@ -33,8 +33,8 @@ size: $(OBJ)
|
|||||||
$(SIZE) -t $^
|
$(SIZE) -t $^
|
||||||
|
|
||||||
.SUFFIXES:
|
.SUFFIXES:
|
||||||
test: test_format test_dirs test_files test_seek test_truncate \
|
test: test_format test_dirs test_files test_seek test_truncate test_parallel \
|
||||||
test_interspersed test_alloc test_paths test_orphan test_move test_corrupt
|
test_alloc test_paths test_orphan test_move test_corrupt
|
||||||
test_%: tests/test_%.sh
|
test_%: tests/test_%.sh
|
||||||
ifdef QUIET
|
ifdef QUIET
|
||||||
@./$< | sed -n '/^[-=]/p'
|
@./$< | sed -n '/^[-=]/p'
|
||||||
|
|||||||
23
lfs.h
23
lfs.h
@@ -74,9 +74,15 @@ enum lfs_error {
|
|||||||
|
|
||||||
// File types
|
// File types
|
||||||
enum lfs_type {
|
enum lfs_type {
|
||||||
LFS_TYPE_REG = 0x11,
|
// file type
|
||||||
LFS_TYPE_DIR = 0x22,
|
LFS_TYPE_REG = 0x01,
|
||||||
LFS_TYPE_SUPERBLOCK = 0x2e,
|
LFS_TYPE_DIR = 0x02,
|
||||||
|
LFS_TYPE_SUPERBLOCK = 0x0e,
|
||||||
|
|
||||||
|
// on disk structure
|
||||||
|
LFS_STRUCT_CTZ = 0x10,
|
||||||
|
LFS_STRUCT_DIR = 0x20,
|
||||||
|
LFS_STRUCT_MOVED = 0x80,
|
||||||
};
|
};
|
||||||
|
|
||||||
// File open flags
|
// File open flags
|
||||||
@@ -190,6 +196,7 @@ struct lfs_info {
|
|||||||
/// littlefs data structures ///
|
/// littlefs data structures ///
|
||||||
typedef struct lfs_entry {
|
typedef struct lfs_entry {
|
||||||
lfs_off_t off;
|
lfs_off_t off;
|
||||||
|
lfs_size_t size;
|
||||||
|
|
||||||
struct lfs_disk_entry {
|
struct lfs_disk_entry {
|
||||||
uint8_t type;
|
uint8_t type;
|
||||||
@@ -243,8 +250,6 @@ typedef struct lfs_dir {
|
|||||||
} lfs_dir_t;
|
} lfs_dir_t;
|
||||||
|
|
||||||
typedef struct lfs_superblock {
|
typedef struct lfs_superblock {
|
||||||
lfs_off_t off;
|
|
||||||
|
|
||||||
struct lfs_disk_superblock {
|
struct lfs_disk_superblock {
|
||||||
uint8_t type;
|
uint8_t type;
|
||||||
uint8_t elen;
|
uint8_t elen;
|
||||||
@@ -259,9 +264,9 @@ typedef struct lfs_superblock {
|
|||||||
} lfs_superblock_t;
|
} lfs_superblock_t;
|
||||||
|
|
||||||
typedef struct lfs_free {
|
typedef struct lfs_free {
|
||||||
lfs_block_t off;
|
lfs_block_t begin;
|
||||||
lfs_block_t size;
|
lfs_block_t size;
|
||||||
lfs_block_t i;
|
lfs_block_t off;
|
||||||
lfs_block_t ack;
|
lfs_block_t ack;
|
||||||
uint32_t *buffer;
|
uint32_t *buffer;
|
||||||
} lfs_free_t;
|
} lfs_free_t;
|
||||||
@@ -320,6 +325,10 @@ int lfs_remove(lfs_t *lfs, const char *path);
|
|||||||
// If the destination exists, it must match the source in type.
|
// If the destination exists, it must match the source in type.
|
||||||
// If the destination is a directory, the directory must be empty.
|
// If the destination is a directory, the directory must be empty.
|
||||||
//
|
//
|
||||||
|
// Note: If power loss occurs, it is possible that the file or directory
|
||||||
|
// will exist in both the oldpath and newpath simultaneously after the
|
||||||
|
// next mount.
|
||||||
|
//
|
||||||
// Returns a negative error code on failure.
|
// Returns a negative error code on failure.
|
||||||
int lfs_rename(lfs_t *lfs, const char *oldpath, const char *newpath);
|
int lfs_rename(lfs_t *lfs, const char *oldpath, const char *newpath);
|
||||||
|
|
||||||
|
|||||||
@@ -289,7 +289,7 @@ tests/test.py << TEST
|
|||||||
}
|
}
|
||||||
lfs_file_close(&lfs, &file[0]) => 0;
|
lfs_file_close(&lfs, &file[0]) => 0;
|
||||||
|
|
||||||
// open hole
|
// open whole
|
||||||
lfs_remove(&lfs, "bump") => 0;
|
lfs_remove(&lfs, "bump") => 0;
|
||||||
|
|
||||||
lfs_mkdir(&lfs, "splitdir") => 0;
|
lfs_mkdir(&lfs, "splitdir") => 0;
|
||||||
@@ -301,128 +301,5 @@ tests/test.py << TEST
|
|||||||
lfs_unmount(&lfs) => 0;
|
lfs_unmount(&lfs) => 0;
|
||||||
TEST
|
TEST
|
||||||
|
|
||||||
echo "--- Outdated lookahead test ---"
|
|
||||||
rm -rf blocks
|
|
||||||
tests/test.py << TEST
|
|
||||||
lfs_format(&lfs, &cfg) => 0;
|
|
||||||
|
|
||||||
lfs_mount(&lfs, &cfg) => 0;
|
|
||||||
|
|
||||||
// fill completely with two files
|
|
||||||
lfs_file_open(&lfs, &file[0], "exhaustion1",
|
|
||||||
LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
|
||||||
size = strlen("blahblahblahblah");
|
|
||||||
memcpy(buffer, "blahblahblahblah", size);
|
|
||||||
for (lfs_size_t i = 0;
|
|
||||||
i < ((cfg.block_count-4)/2)*(cfg.block_size-8);
|
|
||||||
i += size) {
|
|
||||||
lfs_file_write(&lfs, &file[0], buffer, size) => size;
|
|
||||||
}
|
|
||||||
lfs_file_close(&lfs, &file[0]) => 0;
|
|
||||||
|
|
||||||
lfs_file_open(&lfs, &file[0], "exhaustion2",
|
|
||||||
LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
|
||||||
size = strlen("blahblahblahblah");
|
|
||||||
memcpy(buffer, "blahblahblahblah", size);
|
|
||||||
for (lfs_size_t i = 0;
|
|
||||||
i < ((cfg.block_count-4+1)/2)*(cfg.block_size-8);
|
|
||||||
i += size) {
|
|
||||||
lfs_file_write(&lfs, &file[0], buffer, size) => size;
|
|
||||||
}
|
|
||||||
lfs_file_close(&lfs, &file[0]) => 0;
|
|
||||||
|
|
||||||
// remount to force reset of lookahead
|
|
||||||
lfs_unmount(&lfs) => 0;
|
|
||||||
|
|
||||||
lfs_mount(&lfs, &cfg) => 0;
|
|
||||||
|
|
||||||
// rewrite one file
|
|
||||||
lfs_file_open(&lfs, &file[0], "exhaustion1",
|
|
||||||
LFS_O_WRONLY | LFS_O_TRUNC) => 0;
|
|
||||||
lfs_file_sync(&lfs, &file[0]) => 0;
|
|
||||||
size = strlen("blahblahblahblah");
|
|
||||||
memcpy(buffer, "blahblahblahblah", size);
|
|
||||||
for (lfs_size_t i = 0;
|
|
||||||
i < ((cfg.block_count-4)/2)*(cfg.block_size-8);
|
|
||||||
i += size) {
|
|
||||||
lfs_file_write(&lfs, &file[0], buffer, size) => size;
|
|
||||||
}
|
|
||||||
lfs_file_close(&lfs, &file[0]) => 0;
|
|
||||||
|
|
||||||
// rewrite second file, this requires lookahead does not
|
|
||||||
// use old population
|
|
||||||
lfs_file_open(&lfs, &file[0], "exhaustion2",
|
|
||||||
LFS_O_WRONLY | LFS_O_TRUNC) => 0;
|
|
||||||
lfs_file_sync(&lfs, &file[0]) => 0;
|
|
||||||
size = strlen("blahblahblahblah");
|
|
||||||
memcpy(buffer, "blahblahblahblah", size);
|
|
||||||
for (lfs_size_t i = 0;
|
|
||||||
i < ((cfg.block_count-4+1)/2)*(cfg.block_size-8);
|
|
||||||
i += size) {
|
|
||||||
lfs_file_write(&lfs, &file[0], buffer, size) => size;
|
|
||||||
}
|
|
||||||
lfs_file_close(&lfs, &file[0]) => 0;
|
|
||||||
TEST
|
|
||||||
|
|
||||||
echo "--- Outdated lookahead and split dir test ---"
|
|
||||||
rm -rf blocks
|
|
||||||
tests/test.py << TEST
|
|
||||||
lfs_format(&lfs, &cfg) => 0;
|
|
||||||
|
|
||||||
lfs_mount(&lfs, &cfg) => 0;
|
|
||||||
|
|
||||||
// fill completely with two files
|
|
||||||
lfs_file_open(&lfs, &file[0], "exhaustion1",
|
|
||||||
LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
|
||||||
size = strlen("blahblahblahblah");
|
|
||||||
memcpy(buffer, "blahblahblahblah", size);
|
|
||||||
for (lfs_size_t i = 0;
|
|
||||||
i < ((cfg.block_count-4)/2)*(cfg.block_size-8);
|
|
||||||
i += size) {
|
|
||||||
lfs_file_write(&lfs, &file[0], buffer, size) => size;
|
|
||||||
}
|
|
||||||
lfs_file_close(&lfs, &file[0]) => 0;
|
|
||||||
|
|
||||||
lfs_file_open(&lfs, &file[0], "exhaustion2",
|
|
||||||
LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
|
||||||
size = strlen("blahblahblahblah");
|
|
||||||
memcpy(buffer, "blahblahblahblah", size);
|
|
||||||
for (lfs_size_t i = 0;
|
|
||||||
i < ((cfg.block_count-4+1)/2)*(cfg.block_size-8);
|
|
||||||
i += size) {
|
|
||||||
lfs_file_write(&lfs, &file[0], buffer, size) => size;
|
|
||||||
}
|
|
||||||
lfs_file_close(&lfs, &file[0]) => 0;
|
|
||||||
|
|
||||||
// remount to force reset of lookahead
|
|
||||||
lfs_unmount(&lfs) => 0;
|
|
||||||
|
|
||||||
lfs_mount(&lfs, &cfg) => 0;
|
|
||||||
|
|
||||||
// rewrite one file with a hole of one block
|
|
||||||
lfs_file_open(&lfs, &file[0], "exhaustion1",
|
|
||||||
LFS_O_WRONLY | LFS_O_TRUNC) => 0;
|
|
||||||
lfs_file_sync(&lfs, &file[0]) => 0;
|
|
||||||
size = strlen("blahblahblahblah");
|
|
||||||
memcpy(buffer, "blahblahblahblah", size);
|
|
||||||
for (lfs_size_t i = 0;
|
|
||||||
i < ((cfg.block_count-4)/2 - 1)*(cfg.block_size-8);
|
|
||||||
i += size) {
|
|
||||||
lfs_file_write(&lfs, &file[0], buffer, size) => size;
|
|
||||||
}
|
|
||||||
lfs_file_close(&lfs, &file[0]) => 0;
|
|
||||||
|
|
||||||
// try to allocate a directory, should fail!
|
|
||||||
lfs_mkdir(&lfs, "split") => LFS_ERR_NOSPC;
|
|
||||||
|
|
||||||
// file should not fail
|
|
||||||
lfs_file_open(&lfs, &file[0], "notasplit",
|
|
||||||
LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
|
||||||
lfs_file_write(&lfs, &file[0], "hi", 2) => 2;
|
|
||||||
lfs_file_close(&lfs, &file[0]) => 0;
|
|
||||||
|
|
||||||
lfs_unmount(&lfs) => 0;
|
|
||||||
TEST
|
|
||||||
|
|
||||||
echo "--- Results ---"
|
echo "--- Results ---"
|
||||||
tests/stats.py
|
tests/stats.py
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
echo "=== Interspersed tests ==="
|
echo "=== Parallel tests ==="
|
||||||
rm -rf blocks
|
rm -rf blocks
|
||||||
tests/test.py << TEST
|
tests/test.py << TEST
|
||||||
lfs_format(&lfs, &cfg) => 0;
|
lfs_format(&lfs, &cfg) => 0;
|
||||||
TEST
|
TEST
|
||||||
|
|
||||||
echo "--- Interspersed file test ---"
|
echo "--- Parallel file test ---"
|
||||||
tests/test.py << TEST
|
tests/test.py << TEST
|
||||||
lfs_mount(&lfs, &cfg) => 0;
|
lfs_mount(&lfs, &cfg) => 0;
|
||||||
lfs_file_open(&lfs, &file[0], "a", LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
lfs_file_open(&lfs, &file[0], "a", LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
||||||
@@ -77,7 +77,7 @@ tests/test.py << TEST
|
|||||||
lfs_unmount(&lfs) => 0;
|
lfs_unmount(&lfs) => 0;
|
||||||
TEST
|
TEST
|
||||||
|
|
||||||
echo "--- Interspersed remove file test ---"
|
echo "--- Parallel remove file test ---"
|
||||||
tests/test.py << TEST
|
tests/test.py << TEST
|
||||||
lfs_mount(&lfs, &cfg) => 0;
|
lfs_mount(&lfs, &cfg) => 0;
|
||||||
lfs_file_open(&lfs, &file[0], "e", LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
lfs_file_open(&lfs, &file[0], "e", LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
||||||
@@ -90,22 +90,6 @@ tests/test.py << TEST
|
|||||||
lfs_unmount(&lfs) => 0;
|
lfs_unmount(&lfs) => 0;
|
||||||
TEST
|
TEST
|
||||||
|
|
||||||
echo "--- Trailing dot path tests ---"
|
|
||||||
tests/test.py << TEST
|
|
||||||
lfs_mount(&lfs, &cfg) => 0;
|
|
||||||
lfs_stat(&lfs, "tea/hottea/", &info) => 0;
|
|
||||||
strcmp(info.name, "hottea") => 0;
|
|
||||||
lfs_stat(&lfs, "tea/hottea/.", &info) => 0;
|
|
||||||
strcmp(info.name, "hottea") => 0;
|
|
||||||
lfs_stat(&lfs, "tea/hottea/./.", &info) => 0;
|
|
||||||
strcmp(info.name, "hottea") => 0;
|
|
||||||
lfs_stat(&lfs, "tea/hottea/..", &info) => 0;
|
|
||||||
strcmp(info.name, "tea") => 0;
|
|
||||||
lfs_stat(&lfs, "tea/hottea/../.", &info) => 0;
|
|
||||||
strcmp(info.name, "tea") => 0;
|
|
||||||
lfs_unmount(&lfs) => 0;
|
|
||||||
TEST
|
|
||||||
|
|
||||||
echo "--- Root dot dot path tests ---"
|
echo "--- Root dot dot path tests ---"
|
||||||
tests/test.py << TEST
|
tests/test.py << TEST
|
||||||
lfs_mount(&lfs, &cfg) => 0;
|
lfs_mount(&lfs, &cfg) => 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user