forked from Imagelibrary/littlefs
Compare commits
39 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f53a0cc961 | ||
|
|
42910bc8e5 | ||
|
|
a3e1d12ce1 | ||
|
|
a70870c628 | ||
|
|
ceb17a0f4a | ||
|
|
a8a0905777 | ||
|
|
13d78616fe | ||
|
|
8b8fd14187 | ||
|
|
09972a1710 | ||
|
|
ed7bd05435 | ||
|
|
b5cd957f42 | ||
|
|
1195d606ae | ||
|
|
1711bdef76 | ||
|
|
f522ed907a | ||
|
|
4f32738cd6 | ||
|
|
6691718b18 | ||
|
|
1fefcbbcba | ||
|
|
60567677b9 | ||
|
|
897b571318 | ||
|
|
3513ff1afc | ||
|
|
8a22bd6e67 | ||
|
|
9b82db72d8 | ||
|
|
99b84ee3db | ||
|
|
b1b10c0e75 | ||
|
|
1f9c3c04b1 | ||
|
|
7b68441888 | ||
|
|
e91a29d2b5 | ||
|
|
b9b95ab4bc | ||
|
|
9a620c730c | ||
|
|
a0c6c54345 | ||
|
|
10bcff1af8 | ||
|
|
c733d9ec57 | ||
|
|
c531a5e88f | ||
|
|
8f9427dd53 | ||
|
|
8f3f32d1f3 | ||
|
|
92fc780f71 | ||
|
|
f77214d1f0 | ||
|
|
f91c5bd687 | ||
|
|
0eb52a2df1 |
2
.github/workflows/post-release.yml
vendored
2
.github/workflows/post-release.yml
vendored
@@ -10,7 +10,7 @@ defaults:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
post-release:
|
post-release:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
# trigger post-release in dependency repo, this indirection allows the
|
# trigger post-release in dependency repo, this indirection allows the
|
||||||
# dependency repo to be updated often without affecting this repo. At
|
# dependency repo to be updated often without affecting this repo. At
|
||||||
|
|||||||
4
.github/workflows/release.yml
vendored
4
.github/workflows/release.yml
vendored
@@ -11,7 +11,7 @@ defaults:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
release:
|
release:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
# need to manually check for a couple things
|
# need to manually check for a couple things
|
||||||
# - tests passed?
|
# - tests passed?
|
||||||
@@ -112,7 +112,7 @@ jobs:
|
|||||||
table[$i,$j]=$c_camel
|
table[$i,$j]=$c_camel
|
||||||
((j+=1))
|
((j+=1))
|
||||||
|
|
||||||
for s in code stack struct
|
for s in code stack structs
|
||||||
do
|
do
|
||||||
f=sizes/thumb${c:+-$c}.$s.csv
|
f=sizes/thumb${c:+-$c}.$s.csv
|
||||||
[ -e $f ] && table[$i,$j]=$( \
|
[ -e $f ] && table[$i,$j]=$( \
|
||||||
|
|||||||
4
.github/workflows/status.yml
vendored
4
.github/workflows/status.yml
vendored
@@ -11,7 +11,7 @@ defaults:
|
|||||||
jobs:
|
jobs:
|
||||||
# forward custom statuses
|
# forward custom statuses
|
||||||
status:
|
status:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: dawidd6/action-download-artifact@v2
|
- uses: dawidd6/action-download-artifact@v2
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
@@ -60,7 +60,7 @@ jobs:
|
|||||||
|
|
||||||
# forward custom pr-comments
|
# forward custom pr-comments
|
||||||
comment:
|
comment:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
# only run on success (we don't want garbage comments!)
|
# only run on success (we don't want garbage comments!)
|
||||||
if: ${{github.event.workflow_run.conclusion == 'success'}}
|
if: ${{github.event.workflow_run.conclusion == 'success'}}
|
||||||
|
|||||||
24
.github/workflows/test.yml
vendored
24
.github/workflows/test.yml
vendored
@@ -14,7 +14,7 @@ env:
|
|||||||
jobs:
|
jobs:
|
||||||
# run tests
|
# run tests
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@@ -329,7 +329,7 @@ jobs:
|
|||||||
#
|
#
|
||||||
# this grows exponentially, so it doesn't turn out to be that many
|
# this grows exponentially, so it doesn't turn out to be that many
|
||||||
test-pls:
|
test-pls:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@@ -359,7 +359,7 @@ jobs:
|
|||||||
|
|
||||||
# run with LFS_NO_INTRINSICS to make sure that works
|
# run with LFS_NO_INTRINSICS to make sure that works
|
||||||
test-no-intrinsics:
|
test-no-intrinsics:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: install
|
- name: install
|
||||||
@@ -376,7 +376,7 @@ jobs:
|
|||||||
|
|
||||||
# run LFS_MULTIVERSION tests
|
# run LFS_MULTIVERSION tests
|
||||||
test-multiversion:
|
test-multiversion:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: install
|
- name: install
|
||||||
@@ -393,7 +393,7 @@ jobs:
|
|||||||
|
|
||||||
# run tests on the older version lfs2.0
|
# run tests on the older version lfs2.0
|
||||||
test-lfs2_0:
|
test-lfs2_0:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: install
|
- name: install
|
||||||
@@ -412,7 +412,7 @@ jobs:
|
|||||||
|
|
||||||
# run under Valgrind to check for memory errors
|
# run under Valgrind to check for memory errors
|
||||||
test-valgrind:
|
test-valgrind:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: install
|
- name: install
|
||||||
@@ -434,7 +434,7 @@ jobs:
|
|||||||
# test that compilation is warning free under clang
|
# test that compilation is warning free under clang
|
||||||
# run with Clang, mostly to check for Clang-specific warnings
|
# run with Clang, mostly to check for Clang-specific warnings
|
||||||
test-clang:
|
test-clang:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: install
|
- name: install
|
||||||
@@ -457,7 +457,7 @@ jobs:
|
|||||||
#
|
#
|
||||||
# note there's no real benefit to running these on multiple archs
|
# note there's no real benefit to running these on multiple archs
|
||||||
bench:
|
bench:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: install
|
- name: install
|
||||||
@@ -533,7 +533,7 @@ jobs:
|
|||||||
|
|
||||||
# run compatibility tests using the current master as the previous version
|
# run compatibility tests using the current master as the previous version
|
||||||
test-compat:
|
test-compat:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
if: ${{github.event_name == 'pull_request'}}
|
if: ${{github.event_name == 'pull_request'}}
|
||||||
@@ -569,7 +569,7 @@ jobs:
|
|||||||
|
|
||||||
# self-host with littlefs-fuse for a fuzz-like test
|
# self-host with littlefs-fuse for a fuzz-like test
|
||||||
fuse:
|
fuse:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-latest
|
||||||
if: ${{!endsWith(github.ref, '-prefix')}}
|
if: ${{!endsWith(github.ref, '-prefix')}}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
@@ -619,7 +619,7 @@ jobs:
|
|||||||
|
|
||||||
# test migration using littlefs-fuse
|
# test migration using littlefs-fuse
|
||||||
migrate:
|
migrate:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-latest
|
||||||
if: ${{!endsWith(github.ref, '-prefix')}}
|
if: ${{!endsWith(github.ref, '-prefix')}}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
@@ -691,7 +691,7 @@ jobs:
|
|||||||
|
|
||||||
# status related tasks that run after tests
|
# status related tasks that run after tests
|
||||||
status:
|
status:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-latest
|
||||||
needs: [test, bench]
|
needs: [test, bench]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ This leaves us with three major requirements for an embedded filesystem.
|
|||||||
RAM to temporarily store filesystem metadata.
|
RAM to temporarily store filesystem metadata.
|
||||||
|
|
||||||
For ROM, this means we need to keep our design simple and reuse code paths
|
For ROM, this means we need to keep our design simple and reuse code paths
|
||||||
were possible. For RAM we have a stronger requirement, all RAM usage is
|
where possible. For RAM we have a stronger requirement, all RAM usage is
|
||||||
bounded. This means RAM usage does not grow as the filesystem changes in
|
bounded. This means RAM usage does not grow as the filesystem changes in
|
||||||
size or number of files. This creates a unique challenge as even presumably
|
size or number of files. This creates a unique challenge as even presumably
|
||||||
simple operations, such as traversing the filesystem, become surprisingly
|
simple operations, such as traversing the filesystem, become surprisingly
|
||||||
@@ -626,7 +626,7 @@ log₂_n_ pointers that skip to different preceding elements of the
|
|||||||
skip-list.
|
skip-list.
|
||||||
|
|
||||||
The name comes from heavy use of the [CTZ instruction][wikipedia-ctz], which
|
The name comes from heavy use of the [CTZ instruction][wikipedia-ctz], which
|
||||||
lets us calculate the power-of-two factors efficiently. For a give block _n_,
|
lets us calculate the power-of-two factors efficiently. For a given block _n_,
|
||||||
that block contains ctz(_n_)+1 pointers.
|
that block contains ctz(_n_)+1 pointers.
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|||||||
3
Makefile
3
Makefile
@@ -63,6 +63,7 @@ CFLAGS += -fcallgraph-info=su
|
|||||||
CFLAGS += -g3
|
CFLAGS += -g3
|
||||||
CFLAGS += -I.
|
CFLAGS += -I.
|
||||||
CFLAGS += -std=c99 -Wall -Wextra -pedantic
|
CFLAGS += -std=c99 -Wall -Wextra -pedantic
|
||||||
|
CFLAGS += -Wmissing-prototypes
|
||||||
CFLAGS += -ftrack-macro-expansion=0
|
CFLAGS += -ftrack-macro-expansion=0
|
||||||
ifdef DEBUG
|
ifdef DEBUG
|
||||||
CFLAGS += -O0
|
CFLAGS += -O0
|
||||||
@@ -354,6 +355,7 @@ summary-diff sizes-diff: $(OBJ) $(CI)
|
|||||||
|
|
||||||
## Build the test-runner
|
## Build the test-runner
|
||||||
.PHONY: test-runner build-test
|
.PHONY: test-runner build-test
|
||||||
|
test-runner build-test: CFLAGS+=-Wno-missing-prototypes
|
||||||
ifndef NO_COV
|
ifndef NO_COV
|
||||||
test-runner build-test: CFLAGS+=--coverage
|
test-runner build-test: CFLAGS+=--coverage
|
||||||
endif
|
endif
|
||||||
@@ -405,6 +407,7 @@ testmarks-diff: $(TEST_CSV)
|
|||||||
|
|
||||||
## Build the bench-runner
|
## Build the bench-runner
|
||||||
.PHONY: bench-runner build-bench
|
.PHONY: bench-runner build-bench
|
||||||
|
bench-runner build-bench: CFLAGS+=-Wno-missing-prototypes
|
||||||
ifdef YES_COV
|
ifdef YES_COV
|
||||||
bench-runner build-bench: CFLAGS+=--coverage
|
bench-runner build-bench: CFLAGS+=--coverage
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -451,7 +451,7 @@ int lfs_emubd_sync(const struct lfs_config *cfg) {
|
|||||||
|
|
||||||
/// Additional extended API for driving test features ///
|
/// Additional extended API for driving test features ///
|
||||||
|
|
||||||
static int lfs_emubd_rawcrc(const struct lfs_config *cfg,
|
static int lfs_emubd_crc_(const struct lfs_config *cfg,
|
||||||
lfs_block_t block, uint32_t *crc) {
|
lfs_block_t block, uint32_t *crc) {
|
||||||
lfs_emubd_t *bd = cfg->context;
|
lfs_emubd_t *bd = cfg->context;
|
||||||
|
|
||||||
@@ -480,7 +480,7 @@ int lfs_emubd_crc(const struct lfs_config *cfg,
|
|||||||
lfs_block_t block, uint32_t *crc) {
|
lfs_block_t block, uint32_t *crc) {
|
||||||
LFS_EMUBD_TRACE("lfs_emubd_crc(%p, %"PRIu32", %p)",
|
LFS_EMUBD_TRACE("lfs_emubd_crc(%p, %"PRIu32", %p)",
|
||||||
(void*)cfg, block, crc);
|
(void*)cfg, block, crc);
|
||||||
int err = lfs_emubd_rawcrc(cfg, block, crc);
|
int err = lfs_emubd_crc_(cfg, block, crc);
|
||||||
LFS_EMUBD_TRACE("lfs_emubd_crc -> %d", err);
|
LFS_EMUBD_TRACE("lfs_emubd_crc -> %d", err);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@@ -491,7 +491,7 @@ int lfs_emubd_bdcrc(const struct lfs_config *cfg, uint32_t *crc) {
|
|||||||
uint32_t crc_ = 0xffffffff;
|
uint32_t crc_ = 0xffffffff;
|
||||||
for (lfs_block_t i = 0; i < cfg->block_count; i++) {
|
for (lfs_block_t i = 0; i < cfg->block_count; i++) {
|
||||||
uint32_t i_crc;
|
uint32_t i_crc;
|
||||||
int err = lfs_emubd_rawcrc(cfg, i, &i_crc);
|
int err = lfs_emubd_crc_(cfg, i, &i_crc);
|
||||||
if (err) {
|
if (err) {
|
||||||
LFS_EMUBD_TRACE("lfs_emubd_bdcrc -> %d", err);
|
LFS_EMUBD_TRACE("lfs_emubd_bdcrc -> %d", err);
|
||||||
return err;
|
return err;
|
||||||
|
|||||||
78
lfs.h
78
lfs.h
@@ -21,7 +21,7 @@ extern "C"
|
|||||||
// Software library version
|
// Software library version
|
||||||
// Major (top-nibble), incremented on backwards incompatible changes
|
// Major (top-nibble), incremented on backwards incompatible changes
|
||||||
// Minor (bottom-nibble), incremented on feature additions
|
// Minor (bottom-nibble), incremented on feature additions
|
||||||
#define LFS_VERSION 0x00020007
|
#define LFS_VERSION 0x00020009
|
||||||
#define LFS_VERSION_MAJOR (0xffff & (LFS_VERSION >> 16))
|
#define LFS_VERSION_MAJOR (0xffff & (LFS_VERSION >> 16))
|
||||||
#define LFS_VERSION_MINOR (0xffff & (LFS_VERSION >> 0))
|
#define LFS_VERSION_MINOR (0xffff & (LFS_VERSION >> 0))
|
||||||
|
|
||||||
@@ -52,10 +52,8 @@ typedef uint32_t lfs_block_t;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Maximum size of a file in bytes, may be redefined to limit to support other
|
// Maximum size of a file in bytes, may be redefined to limit to support other
|
||||||
// drivers. Limited on disk to <= 4294967296. However, above 2147483647 the
|
// drivers. Limited on disk to <= 2147483647. Stored in superblock and must be
|
||||||
// functions lfs_file_seek, lfs_file_size, and lfs_file_tell will return
|
// respected by other littlefs drivers.
|
||||||
// incorrect values due to using signed integers. Stored in superblock and
|
|
||||||
// must be respected by other littlefs drivers.
|
|
||||||
#ifndef LFS_FILE_MAX
|
#ifndef LFS_FILE_MAX
|
||||||
#define LFS_FILE_MAX 2147483647
|
#define LFS_FILE_MAX 2147483647
|
||||||
#endif
|
#endif
|
||||||
@@ -226,9 +224,20 @@ struct lfs_config {
|
|||||||
// Size of the lookahead buffer in bytes. A larger lookahead buffer
|
// Size of the lookahead buffer in bytes. A larger lookahead buffer
|
||||||
// increases the number of blocks found during an allocation pass. The
|
// increases the number of blocks found during an allocation pass. The
|
||||||
// lookahead buffer is stored as a compact bitmap, so each byte of RAM
|
// lookahead buffer is stored as a compact bitmap, so each byte of RAM
|
||||||
// can track 8 blocks. Must be a multiple of 8.
|
// can track 8 blocks.
|
||||||
lfs_size_t lookahead_size;
|
lfs_size_t lookahead_size;
|
||||||
|
|
||||||
|
// Threshold for metadata compaction during lfs_fs_gc in bytes. Metadata
|
||||||
|
// pairs that exceed this threshold will be compacted during lfs_fs_gc.
|
||||||
|
// Defaults to ~88% block_size when zero, though the default may change
|
||||||
|
// in the future.
|
||||||
|
//
|
||||||
|
// Note this only affects lfs_fs_gc. Normal compactions still only occur
|
||||||
|
// when full.
|
||||||
|
//
|
||||||
|
// Set to -1 to disable metadata compaction during lfs_fs_gc.
|
||||||
|
lfs_size_t compact_thresh;
|
||||||
|
|
||||||
// Optional statically allocated read buffer. Must be cache_size.
|
// Optional statically allocated read buffer. Must be cache_size.
|
||||||
// By default lfs_malloc is used to allocate this buffer.
|
// By default lfs_malloc is used to allocate this buffer.
|
||||||
void *read_buffer;
|
void *read_buffer;
|
||||||
@@ -237,9 +246,8 @@ struct lfs_config {
|
|||||||
// By default lfs_malloc is used to allocate this buffer.
|
// By default lfs_malloc is used to allocate this buffer.
|
||||||
void *prog_buffer;
|
void *prog_buffer;
|
||||||
|
|
||||||
// Optional statically allocated lookahead buffer. Must be lookahead_size
|
// Optional statically allocated lookahead buffer. Must be lookahead_size.
|
||||||
// and aligned to a 32-bit boundary. By default lfs_malloc is used to
|
// By default lfs_malloc is used to allocate this buffer.
|
||||||
// allocate this buffer.
|
|
||||||
void *lookahead_buffer;
|
void *lookahead_buffer;
|
||||||
|
|
||||||
// Optional upper limit on length of file names in bytes. No downside for
|
// Optional upper limit on length of file names in bytes. No downside for
|
||||||
@@ -264,6 +272,15 @@ struct lfs_config {
|
|||||||
// Defaults to block_size when zero.
|
// Defaults to block_size when zero.
|
||||||
lfs_size_t metadata_max;
|
lfs_size_t metadata_max;
|
||||||
|
|
||||||
|
// Optional upper limit on inlined files in bytes. Inlined files live in
|
||||||
|
// metadata and decrease storage requirements, but may be limited to
|
||||||
|
// improve metadata-related performance. Must be <= cache_size, <=
|
||||||
|
// attr_max, and <= block_size/8. Defaults to the largest possible
|
||||||
|
// inline_max when zero.
|
||||||
|
//
|
||||||
|
// Set to -1 to disable inlined files.
|
||||||
|
lfs_size_t inline_max;
|
||||||
|
|
||||||
#ifdef LFS_MULTIVERSION
|
#ifdef LFS_MULTIVERSION
|
||||||
// On-disk version to use when writing in the form of 16-bit major version
|
// On-disk version to use when writing in the form of 16-bit major version
|
||||||
// + 16-bit minor version. This limiting metadata to what is supported by
|
// + 16-bit minor version. This limiting metadata to what is supported by
|
||||||
@@ -430,19 +447,20 @@ typedef struct lfs {
|
|||||||
lfs_gstate_t gdisk;
|
lfs_gstate_t gdisk;
|
||||||
lfs_gstate_t gdelta;
|
lfs_gstate_t gdelta;
|
||||||
|
|
||||||
struct lfs_free {
|
struct lfs_lookahead {
|
||||||
lfs_block_t off;
|
lfs_block_t start;
|
||||||
lfs_block_t size;
|
lfs_block_t size;
|
||||||
lfs_block_t i;
|
lfs_block_t next;
|
||||||
lfs_block_t ack;
|
lfs_block_t ckpoint;
|
||||||
uint32_t *buffer;
|
uint8_t *buffer;
|
||||||
} free;
|
} lookahead;
|
||||||
|
|
||||||
const struct lfs_config *cfg;
|
const struct lfs_config *cfg;
|
||||||
lfs_size_t block_count;
|
lfs_size_t block_count;
|
||||||
lfs_size_t name_max;
|
lfs_size_t name_max;
|
||||||
lfs_size_t file_max;
|
lfs_size_t file_max;
|
||||||
lfs_size_t attr_max;
|
lfs_size_t attr_max;
|
||||||
|
lfs_size_t inline_max;
|
||||||
|
|
||||||
#ifdef LFS_MIGRATE
|
#ifdef LFS_MIGRATE
|
||||||
struct lfs1 *lfs1;
|
struct lfs1 *lfs1;
|
||||||
@@ -712,18 +730,6 @@ lfs_ssize_t lfs_fs_size(lfs_t *lfs);
|
|||||||
// Returns a negative error code on failure.
|
// Returns a negative error code on failure.
|
||||||
int lfs_fs_traverse(lfs_t *lfs, int (*cb)(void*, lfs_block_t), void *data);
|
int lfs_fs_traverse(lfs_t *lfs, int (*cb)(void*, lfs_block_t), void *data);
|
||||||
|
|
||||||
// Attempt to proactively find free blocks
|
|
||||||
//
|
|
||||||
// Calling this function is not required, but may allowing the offloading of
|
|
||||||
// the expensive block allocation scan to a less time-critical code path.
|
|
||||||
//
|
|
||||||
// Note: littlefs currently does not persist any found free blocks to disk.
|
|
||||||
// This may change in the future.
|
|
||||||
//
|
|
||||||
// Returns a negative error code on failure. Finding no free blocks is
|
|
||||||
// not an error.
|
|
||||||
int lfs_fs_gc(lfs_t *lfs);
|
|
||||||
|
|
||||||
#ifndef LFS_READONLY
|
#ifndef LFS_READONLY
|
||||||
// Attempt to make the filesystem consistent and ready for writing
|
// Attempt to make the filesystem consistent and ready for writing
|
||||||
//
|
//
|
||||||
@@ -736,6 +742,24 @@ int lfs_fs_gc(lfs_t *lfs);
|
|||||||
int lfs_fs_mkconsistent(lfs_t *lfs);
|
int lfs_fs_mkconsistent(lfs_t *lfs);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef LFS_READONLY
|
||||||
|
// Attempt any janitorial work
|
||||||
|
//
|
||||||
|
// This currently:
|
||||||
|
// 1. Calls mkconsistent if not already consistent
|
||||||
|
// 2. Compacts metadata > compact_thresh
|
||||||
|
// 3. Populates the block allocator
|
||||||
|
//
|
||||||
|
// Though additional janitorial work may be added in the future.
|
||||||
|
//
|
||||||
|
// Calling this function is not required, but may allow the offloading of
|
||||||
|
// expensive janitorial work to a less time-critical code path.
|
||||||
|
//
|
||||||
|
// Returns a negative error code on failure. Accomplishing nothing is not
|
||||||
|
// an error.
|
||||||
|
int lfs_fs_gc(lfs_t *lfs);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef LFS_READONLY
|
#ifndef LFS_READONLY
|
||||||
// Grows the filesystem to a new size, updating the superblock with the new
|
// Grows the filesystem to a new size, updating the superblock with the new
|
||||||
// block count.
|
// block count.
|
||||||
|
|||||||
@@ -11,6 +11,8 @@
|
|||||||
#ifndef LFS_CONFIG
|
#ifndef LFS_CONFIG
|
||||||
|
|
||||||
|
|
||||||
|
// If user provides their own CRC impl we don't need this
|
||||||
|
#ifndef LFS_CRC
|
||||||
// Software CRC implementation with small lookup table
|
// Software CRC implementation with small lookup table
|
||||||
uint32_t lfs_crc(uint32_t crc, const void *buffer, size_t size) {
|
uint32_t lfs_crc(uint32_t crc, const void *buffer, size_t size) {
|
||||||
static const uint32_t rtable[16] = {
|
static const uint32_t rtable[16] = {
|
||||||
@@ -29,6 +31,7 @@ uint32_t lfs_crc(uint32_t crc, const void *buffer, size_t size) {
|
|||||||
|
|
||||||
return crc;
|
return crc;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
18
lfs_util.h
18
lfs_util.h
@@ -212,12 +212,22 @@ static inline uint32_t lfs_tobe32(uint32_t a) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Calculate CRC-32 with polynomial = 0x04c11db7
|
// Calculate CRC-32 with polynomial = 0x04c11db7
|
||||||
|
#ifdef LFS_CRC
|
||||||
|
uint32_t lfs_crc(uint32_t crc, const void *buffer, size_t size) {
|
||||||
|
return LFS_CRC(crc, buffer, size)
|
||||||
|
}
|
||||||
|
#else
|
||||||
uint32_t lfs_crc(uint32_t crc, const void *buffer, size_t size);
|
uint32_t lfs_crc(uint32_t crc, const void *buffer, size_t size);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Allocate memory, only used if buffers are not provided to littlefs
|
// Allocate memory, only used if buffers are not provided to littlefs
|
||||||
// Note, memory must be 64-bit aligned
|
//
|
||||||
|
// littlefs current has no alignment requirements, as it only allocates
|
||||||
|
// byte-level buffers.
|
||||||
static inline void *lfs_malloc(size_t size) {
|
static inline void *lfs_malloc(size_t size) {
|
||||||
#ifndef LFS_NO_MALLOC
|
#if defined(LFS_MALLOC)
|
||||||
|
return LFS_MALLOC(size);
|
||||||
|
#elif !defined(LFS_NO_MALLOC)
|
||||||
return malloc(size);
|
return malloc(size);
|
||||||
#else
|
#else
|
||||||
(void)size;
|
(void)size;
|
||||||
@@ -227,7 +237,9 @@ static inline void *lfs_malloc(size_t size) {
|
|||||||
|
|
||||||
// Deallocate memory, only used if buffers are not provided to littlefs
|
// Deallocate memory, only used if buffers are not provided to littlefs
|
||||||
static inline void lfs_free(void *p) {
|
static inline void lfs_free(void *p) {
|
||||||
#ifndef LFS_NO_MALLOC
|
#if defined(LFS_FREE)
|
||||||
|
LFS_FREE(p);
|
||||||
|
#elif !defined(LFS_NO_MALLOC)
|
||||||
free(p);
|
free(p);
|
||||||
#else
|
#else
|
||||||
(void)p;
|
(void)p;
|
||||||
|
|||||||
@@ -1321,6 +1321,8 @@ void perm_run(
|
|||||||
.block_cycles = BLOCK_CYCLES,
|
.block_cycles = BLOCK_CYCLES,
|
||||||
.cache_size = CACHE_SIZE,
|
.cache_size = CACHE_SIZE,
|
||||||
.lookahead_size = LOOKAHEAD_SIZE,
|
.lookahead_size = LOOKAHEAD_SIZE,
|
||||||
|
.compact_thresh = COMPACT_THRESH,
|
||||||
|
.inline_max = INLINE_MAX,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct lfs_emubd_config bdcfg = {
|
struct lfs_emubd_config bdcfg = {
|
||||||
|
|||||||
@@ -95,11 +95,13 @@ intmax_t bench_define(size_t define);
|
|||||||
#define BLOCK_COUNT_i 5
|
#define BLOCK_COUNT_i 5
|
||||||
#define CACHE_SIZE_i 6
|
#define CACHE_SIZE_i 6
|
||||||
#define LOOKAHEAD_SIZE_i 7
|
#define LOOKAHEAD_SIZE_i 7
|
||||||
#define BLOCK_CYCLES_i 8
|
#define COMPACT_THRESH_i 8
|
||||||
#define ERASE_VALUE_i 9
|
#define INLINE_MAX_i 9
|
||||||
#define ERASE_CYCLES_i 10
|
#define BLOCK_CYCLES_i 10
|
||||||
#define BADBLOCK_BEHAVIOR_i 11
|
#define ERASE_VALUE_i 11
|
||||||
#define POWERLOSS_BEHAVIOR_i 12
|
#define ERASE_CYCLES_i 12
|
||||||
|
#define BADBLOCK_BEHAVIOR_i 13
|
||||||
|
#define POWERLOSS_BEHAVIOR_i 14
|
||||||
|
|
||||||
#define READ_SIZE bench_define(READ_SIZE_i)
|
#define READ_SIZE bench_define(READ_SIZE_i)
|
||||||
#define PROG_SIZE bench_define(PROG_SIZE_i)
|
#define PROG_SIZE bench_define(PROG_SIZE_i)
|
||||||
@@ -109,6 +111,8 @@ intmax_t bench_define(size_t define);
|
|||||||
#define BLOCK_COUNT bench_define(BLOCK_COUNT_i)
|
#define BLOCK_COUNT bench_define(BLOCK_COUNT_i)
|
||||||
#define CACHE_SIZE bench_define(CACHE_SIZE_i)
|
#define CACHE_SIZE bench_define(CACHE_SIZE_i)
|
||||||
#define LOOKAHEAD_SIZE bench_define(LOOKAHEAD_SIZE_i)
|
#define LOOKAHEAD_SIZE bench_define(LOOKAHEAD_SIZE_i)
|
||||||
|
#define COMPACT_THRESH bench_define(COMPACT_THRESH_i)
|
||||||
|
#define INLINE_MAX bench_define(INLINE_MAX_i)
|
||||||
#define BLOCK_CYCLES bench_define(BLOCK_CYCLES_i)
|
#define BLOCK_CYCLES bench_define(BLOCK_CYCLES_i)
|
||||||
#define ERASE_VALUE bench_define(ERASE_VALUE_i)
|
#define ERASE_VALUE bench_define(ERASE_VALUE_i)
|
||||||
#define ERASE_CYCLES bench_define(ERASE_CYCLES_i)
|
#define ERASE_CYCLES bench_define(ERASE_CYCLES_i)
|
||||||
@@ -124,6 +128,8 @@ intmax_t bench_define(size_t define);
|
|||||||
BENCH_DEF(BLOCK_COUNT, ERASE_COUNT/lfs_max(BLOCK_SIZE/ERASE_SIZE,1))\
|
BENCH_DEF(BLOCK_COUNT, ERASE_COUNT/lfs_max(BLOCK_SIZE/ERASE_SIZE,1))\
|
||||||
BENCH_DEF(CACHE_SIZE, lfs_max(64,lfs_max(READ_SIZE,PROG_SIZE))) \
|
BENCH_DEF(CACHE_SIZE, lfs_max(64,lfs_max(READ_SIZE,PROG_SIZE))) \
|
||||||
BENCH_DEF(LOOKAHEAD_SIZE, 16) \
|
BENCH_DEF(LOOKAHEAD_SIZE, 16) \
|
||||||
|
BENCH_DEF(COMPACT_THRESH, 0) \
|
||||||
|
BENCH_DEF(INLINE_MAX, 0) \
|
||||||
BENCH_DEF(BLOCK_CYCLES, -1) \
|
BENCH_DEF(BLOCK_CYCLES, -1) \
|
||||||
BENCH_DEF(ERASE_VALUE, 0xff) \
|
BENCH_DEF(ERASE_VALUE, 0xff) \
|
||||||
BENCH_DEF(ERASE_CYCLES, 0) \
|
BENCH_DEF(ERASE_CYCLES, 0) \
|
||||||
@@ -131,7 +137,7 @@ intmax_t bench_define(size_t define);
|
|||||||
BENCH_DEF(POWERLOSS_BEHAVIOR, LFS_EMUBD_POWERLOSS_NOOP)
|
BENCH_DEF(POWERLOSS_BEHAVIOR, LFS_EMUBD_POWERLOSS_NOOP)
|
||||||
|
|
||||||
#define BENCH_GEOMETRY_DEFINE_COUNT 4
|
#define BENCH_GEOMETRY_DEFINE_COUNT 4
|
||||||
#define BENCH_IMPLICIT_DEFINE_COUNT 13
|
#define BENCH_IMPLICIT_DEFINE_COUNT 15
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1346,6 +1346,8 @@ static void run_powerloss_none(
|
|||||||
.block_cycles = BLOCK_CYCLES,
|
.block_cycles = BLOCK_CYCLES,
|
||||||
.cache_size = CACHE_SIZE,
|
.cache_size = CACHE_SIZE,
|
||||||
.lookahead_size = LOOKAHEAD_SIZE,
|
.lookahead_size = LOOKAHEAD_SIZE,
|
||||||
|
.compact_thresh = COMPACT_THRESH,
|
||||||
|
.inline_max = INLINE_MAX,
|
||||||
#ifdef LFS_MULTIVERSION
|
#ifdef LFS_MULTIVERSION
|
||||||
.disk_version = DISK_VERSION,
|
.disk_version = DISK_VERSION,
|
||||||
#endif
|
#endif
|
||||||
@@ -1422,6 +1424,8 @@ static void run_powerloss_linear(
|
|||||||
.block_cycles = BLOCK_CYCLES,
|
.block_cycles = BLOCK_CYCLES,
|
||||||
.cache_size = CACHE_SIZE,
|
.cache_size = CACHE_SIZE,
|
||||||
.lookahead_size = LOOKAHEAD_SIZE,
|
.lookahead_size = LOOKAHEAD_SIZE,
|
||||||
|
.compact_thresh = COMPACT_THRESH,
|
||||||
|
.inline_max = INLINE_MAX,
|
||||||
#ifdef LFS_MULTIVERSION
|
#ifdef LFS_MULTIVERSION
|
||||||
.disk_version = DISK_VERSION,
|
.disk_version = DISK_VERSION,
|
||||||
#endif
|
#endif
|
||||||
@@ -1515,6 +1519,8 @@ static void run_powerloss_log(
|
|||||||
.block_cycles = BLOCK_CYCLES,
|
.block_cycles = BLOCK_CYCLES,
|
||||||
.cache_size = CACHE_SIZE,
|
.cache_size = CACHE_SIZE,
|
||||||
.lookahead_size = LOOKAHEAD_SIZE,
|
.lookahead_size = LOOKAHEAD_SIZE,
|
||||||
|
.compact_thresh = COMPACT_THRESH,
|
||||||
|
.inline_max = INLINE_MAX,
|
||||||
#ifdef LFS_MULTIVERSION
|
#ifdef LFS_MULTIVERSION
|
||||||
.disk_version = DISK_VERSION,
|
.disk_version = DISK_VERSION,
|
||||||
#endif
|
#endif
|
||||||
@@ -1606,6 +1612,8 @@ static void run_powerloss_cycles(
|
|||||||
.block_cycles = BLOCK_CYCLES,
|
.block_cycles = BLOCK_CYCLES,
|
||||||
.cache_size = CACHE_SIZE,
|
.cache_size = CACHE_SIZE,
|
||||||
.lookahead_size = LOOKAHEAD_SIZE,
|
.lookahead_size = LOOKAHEAD_SIZE,
|
||||||
|
.compact_thresh = COMPACT_THRESH,
|
||||||
|
.inline_max = INLINE_MAX,
|
||||||
#ifdef LFS_MULTIVERSION
|
#ifdef LFS_MULTIVERSION
|
||||||
.disk_version = DISK_VERSION,
|
.disk_version = DISK_VERSION,
|
||||||
#endif
|
#endif
|
||||||
@@ -1795,6 +1803,8 @@ static void run_powerloss_exhaustive(
|
|||||||
.block_cycles = BLOCK_CYCLES,
|
.block_cycles = BLOCK_CYCLES,
|
||||||
.cache_size = CACHE_SIZE,
|
.cache_size = CACHE_SIZE,
|
||||||
.lookahead_size = LOOKAHEAD_SIZE,
|
.lookahead_size = LOOKAHEAD_SIZE,
|
||||||
|
.compact_thresh = COMPACT_THRESH,
|
||||||
|
.inline_max = INLINE_MAX,
|
||||||
#ifdef LFS_MULTIVERSION
|
#ifdef LFS_MULTIVERSION
|
||||||
.disk_version = DISK_VERSION,
|
.disk_version = DISK_VERSION,
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -88,12 +88,14 @@ intmax_t test_define(size_t define);
|
|||||||
#define BLOCK_COUNT_i 5
|
#define BLOCK_COUNT_i 5
|
||||||
#define CACHE_SIZE_i 6
|
#define CACHE_SIZE_i 6
|
||||||
#define LOOKAHEAD_SIZE_i 7
|
#define LOOKAHEAD_SIZE_i 7
|
||||||
#define BLOCK_CYCLES_i 8
|
#define COMPACT_THRESH_i 8
|
||||||
#define ERASE_VALUE_i 9
|
#define INLINE_MAX_i 9
|
||||||
#define ERASE_CYCLES_i 10
|
#define BLOCK_CYCLES_i 10
|
||||||
#define BADBLOCK_BEHAVIOR_i 11
|
#define ERASE_VALUE_i 11
|
||||||
#define POWERLOSS_BEHAVIOR_i 12
|
#define ERASE_CYCLES_i 12
|
||||||
#define DISK_VERSION_i 13
|
#define BADBLOCK_BEHAVIOR_i 13
|
||||||
|
#define POWERLOSS_BEHAVIOR_i 14
|
||||||
|
#define DISK_VERSION_i 15
|
||||||
|
|
||||||
#define READ_SIZE TEST_DEFINE(READ_SIZE_i)
|
#define READ_SIZE TEST_DEFINE(READ_SIZE_i)
|
||||||
#define PROG_SIZE TEST_DEFINE(PROG_SIZE_i)
|
#define PROG_SIZE TEST_DEFINE(PROG_SIZE_i)
|
||||||
@@ -103,6 +105,8 @@ intmax_t test_define(size_t define);
|
|||||||
#define BLOCK_COUNT TEST_DEFINE(BLOCK_COUNT_i)
|
#define BLOCK_COUNT TEST_DEFINE(BLOCK_COUNT_i)
|
||||||
#define CACHE_SIZE TEST_DEFINE(CACHE_SIZE_i)
|
#define CACHE_SIZE TEST_DEFINE(CACHE_SIZE_i)
|
||||||
#define LOOKAHEAD_SIZE TEST_DEFINE(LOOKAHEAD_SIZE_i)
|
#define LOOKAHEAD_SIZE TEST_DEFINE(LOOKAHEAD_SIZE_i)
|
||||||
|
#define COMPACT_THRESH TEST_DEFINE(COMPACT_THRESH_i)
|
||||||
|
#define INLINE_MAX TEST_DEFINE(INLINE_MAX_i)
|
||||||
#define BLOCK_CYCLES TEST_DEFINE(BLOCK_CYCLES_i)
|
#define BLOCK_CYCLES TEST_DEFINE(BLOCK_CYCLES_i)
|
||||||
#define ERASE_VALUE TEST_DEFINE(ERASE_VALUE_i)
|
#define ERASE_VALUE TEST_DEFINE(ERASE_VALUE_i)
|
||||||
#define ERASE_CYCLES TEST_DEFINE(ERASE_CYCLES_i)
|
#define ERASE_CYCLES TEST_DEFINE(ERASE_CYCLES_i)
|
||||||
@@ -119,6 +123,8 @@ intmax_t test_define(size_t define);
|
|||||||
TEST_DEF(BLOCK_COUNT, ERASE_COUNT/lfs_max(BLOCK_SIZE/ERASE_SIZE,1)) \
|
TEST_DEF(BLOCK_COUNT, ERASE_COUNT/lfs_max(BLOCK_SIZE/ERASE_SIZE,1)) \
|
||||||
TEST_DEF(CACHE_SIZE, lfs_max(64,lfs_max(READ_SIZE,PROG_SIZE))) \
|
TEST_DEF(CACHE_SIZE, lfs_max(64,lfs_max(READ_SIZE,PROG_SIZE))) \
|
||||||
TEST_DEF(LOOKAHEAD_SIZE, 16) \
|
TEST_DEF(LOOKAHEAD_SIZE, 16) \
|
||||||
|
TEST_DEF(COMPACT_THRESH, 0) \
|
||||||
|
TEST_DEF(INLINE_MAX, 0) \
|
||||||
TEST_DEF(BLOCK_CYCLES, -1) \
|
TEST_DEF(BLOCK_CYCLES, -1) \
|
||||||
TEST_DEF(ERASE_VALUE, 0xff) \
|
TEST_DEF(ERASE_VALUE, 0xff) \
|
||||||
TEST_DEF(ERASE_CYCLES, 0) \
|
TEST_DEF(ERASE_CYCLES, 0) \
|
||||||
@@ -127,7 +133,7 @@ intmax_t test_define(size_t define);
|
|||||||
TEST_DEF(DISK_VERSION, 0)
|
TEST_DEF(DISK_VERSION, 0)
|
||||||
|
|
||||||
#define TEST_GEOMETRY_DEFINE_COUNT 4
|
#define TEST_GEOMETRY_DEFINE_COUNT 4
|
||||||
#define TEST_IMPLICIT_DEFINE_COUNT 14
|
#define TEST_IMPLICIT_DEFINE_COUNT 16
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ if = 'BLOCK_CYCLES == -1'
|
|||||||
defines.FILES = 3
|
defines.FILES = 3
|
||||||
defines.SIZE = '(((BLOCK_SIZE-8)*(BLOCK_COUNT-6)) / FILES)'
|
defines.SIZE = '(((BLOCK_SIZE-8)*(BLOCK_COUNT-6)) / FILES)'
|
||||||
defines.GC = [false, true]
|
defines.GC = [false, true]
|
||||||
|
defines.COMPACT_THRESH = ['-1', '0', 'BLOCK_SIZE/2']
|
||||||
code = '''
|
code = '''
|
||||||
const char *names[] = {"bacon", "eggs", "pancakes"};
|
const char *names[] = {"bacon", "eggs", "pancakes"};
|
||||||
lfs_file_t files[FILES];
|
lfs_file_t files[FILES];
|
||||||
@@ -60,6 +61,7 @@ code = '''
|
|||||||
defines.FILES = 3
|
defines.FILES = 3
|
||||||
defines.SIZE = '(((BLOCK_SIZE-8)*(BLOCK_COUNT-6)) / FILES)'
|
defines.SIZE = '(((BLOCK_SIZE-8)*(BLOCK_COUNT-6)) / FILES)'
|
||||||
defines.GC = [false, true]
|
defines.GC = [false, true]
|
||||||
|
defines.COMPACT_THRESH = ['-1', '0', 'BLOCK_SIZE/2']
|
||||||
code = '''
|
code = '''
|
||||||
const char *names[] = {"bacon", "eggs", "pancakes"};
|
const char *names[] = {"bacon", "eggs", "pancakes"};
|
||||||
|
|
||||||
|
|||||||
@@ -747,6 +747,11 @@ code = '''
|
|||||||
lfs_file_open(&lfs, &file, "potato",
|
lfs_file_open(&lfs, &file, "potato",
|
||||||
LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
|
LFS_O_WRONLY | LFS_O_CREAT) => LFS_ERR_ISDIR;
|
||||||
|
|
||||||
|
lfs_file_open(&lfs, &file, "tacoto", LFS_O_WRONLY | LFS_O_CREAT) => 0;
|
||||||
|
lfs_file_close(&lfs, &file) => 0;
|
||||||
|
lfs_rename(&lfs, "tacoto", "potato") => LFS_ERR_ISDIR;
|
||||||
|
lfs_rename(&lfs, "potato", "tacoto") => LFS_ERR_NOTDIR;
|
||||||
|
|
||||||
lfs_mkdir(&lfs, "/") => LFS_ERR_EXIST;
|
lfs_mkdir(&lfs, "/") => LFS_ERR_EXIST;
|
||||||
lfs_file_open(&lfs, &file, "/",
|
lfs_file_open(&lfs, &file, "/",
|
||||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
|
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => LFS_ERR_EXIST;
|
||||||
@@ -770,6 +775,10 @@ code = '''
|
|||||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||||
assert(info.type == LFS_TYPE_DIR);
|
assert(info.type == LFS_TYPE_DIR);
|
||||||
assert(strcmp(info.name, "potato") == 0);
|
assert(strcmp(info.name, "potato") == 0);
|
||||||
|
lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||||
|
assert(info.type == LFS_TYPE_REG);
|
||||||
|
assert(strcmp(info.name, "tacoto") == 0);
|
||||||
|
assert(info.size == 0);
|
||||||
lfs_dir_read(&lfs, &dir, &info) => 0;
|
lfs_dir_read(&lfs, &dir, &info) => 0;
|
||||||
lfs_dir_close(&lfs, &dir) => 0;
|
lfs_dir_close(&lfs, &dir) => 0;
|
||||||
|
|
||||||
@@ -790,6 +799,10 @@ code = '''
|
|||||||
lfs_dir_read(&lfs, &dir, &info) => 1;
|
lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||||
assert(info.type == LFS_TYPE_DIR);
|
assert(info.type == LFS_TYPE_DIR);
|
||||||
assert(strcmp(info.name, "potato") == 0);
|
assert(strcmp(info.name, "potato") == 0);
|
||||||
|
lfs_dir_read(&lfs, &dir, &info) => 1;
|
||||||
|
assert(info.type == LFS_TYPE_REG);
|
||||||
|
assert(strcmp(info.name, "tacoto") == 0);
|
||||||
|
assert(info.size == 0);
|
||||||
lfs_dir_read(&lfs, &dir, &info) => 0;
|
lfs_dir_read(&lfs, &dir, &info) => 0;
|
||||||
lfs_dir_close(&lfs, &dir) => 0;
|
lfs_dir_close(&lfs, &dir) => 0;
|
||||||
lfs_unmount(&lfs) => 0;
|
lfs_unmount(&lfs) => 0;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
[cases.test_files_simple]
|
[cases.test_files_simple]
|
||||||
|
defines.INLINE_MAX = [0, -1, 8]
|
||||||
code = '''
|
code = '''
|
||||||
lfs_t lfs;
|
lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
lfs_format(&lfs, cfg) => 0;
|
||||||
@@ -25,6 +26,7 @@ code = '''
|
|||||||
[cases.test_files_large]
|
[cases.test_files_large]
|
||||||
defines.SIZE = [32, 8192, 262144, 0, 7, 8193]
|
defines.SIZE = [32, 8192, 262144, 0, 7, 8193]
|
||||||
defines.CHUNKSIZE = [31, 16, 33, 1, 1023]
|
defines.CHUNKSIZE = [31, 16, 33, 1, 1023]
|
||||||
|
defines.INLINE_MAX = [0, -1, 8]
|
||||||
code = '''
|
code = '''
|
||||||
lfs_t lfs;
|
lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
lfs_format(&lfs, cfg) => 0;
|
||||||
@@ -67,6 +69,7 @@ code = '''
|
|||||||
defines.SIZE1 = [32, 8192, 131072, 0, 7, 8193]
|
defines.SIZE1 = [32, 8192, 131072, 0, 7, 8193]
|
||||||
defines.SIZE2 = [32, 8192, 131072, 0, 7, 8193]
|
defines.SIZE2 = [32, 8192, 131072, 0, 7, 8193]
|
||||||
defines.CHUNKSIZE = [31, 16, 1]
|
defines.CHUNKSIZE = [31, 16, 1]
|
||||||
|
defines.INLINE_MAX = [0, -1, 8]
|
||||||
code = '''
|
code = '''
|
||||||
lfs_t lfs;
|
lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
lfs_format(&lfs, cfg) => 0;
|
||||||
@@ -152,6 +155,7 @@ code = '''
|
|||||||
defines.SIZE1 = [32, 8192, 131072, 0, 7, 8193]
|
defines.SIZE1 = [32, 8192, 131072, 0, 7, 8193]
|
||||||
defines.SIZE2 = [32, 8192, 131072, 0, 7, 8193]
|
defines.SIZE2 = [32, 8192, 131072, 0, 7, 8193]
|
||||||
defines.CHUNKSIZE = [31, 16, 1]
|
defines.CHUNKSIZE = [31, 16, 1]
|
||||||
|
defines.INLINE_MAX = [0, -1, 8]
|
||||||
code = '''
|
code = '''
|
||||||
lfs_t lfs;
|
lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
lfs_format(&lfs, cfg) => 0;
|
||||||
@@ -232,6 +236,7 @@ code = '''
|
|||||||
defines.SIZE1 = [32, 8192, 131072, 0, 7, 8193]
|
defines.SIZE1 = [32, 8192, 131072, 0, 7, 8193]
|
||||||
defines.SIZE2 = [32, 8192, 131072, 0, 7, 8193]
|
defines.SIZE2 = [32, 8192, 131072, 0, 7, 8193]
|
||||||
defines.CHUNKSIZE = [31, 16, 1]
|
defines.CHUNKSIZE = [31, 16, 1]
|
||||||
|
defines.INLINE_MAX = [0, -1, 8]
|
||||||
code = '''
|
code = '''
|
||||||
lfs_t lfs;
|
lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
lfs_format(&lfs, cfg) => 0;
|
||||||
@@ -303,6 +308,7 @@ code = '''
|
|||||||
[cases.test_files_reentrant_write]
|
[cases.test_files_reentrant_write]
|
||||||
defines.SIZE = [32, 0, 7, 2049]
|
defines.SIZE = [32, 0, 7, 2049]
|
||||||
defines.CHUNKSIZE = [31, 16, 65]
|
defines.CHUNKSIZE = [31, 16, 65]
|
||||||
|
defines.INLINE_MAX = [0, -1, 8]
|
||||||
reentrant = true
|
reentrant = true
|
||||||
code = '''
|
code = '''
|
||||||
lfs_t lfs;
|
lfs_t lfs;
|
||||||
@@ -354,11 +360,20 @@ code = '''
|
|||||||
[cases.test_files_reentrant_write_sync]
|
[cases.test_files_reentrant_write_sync]
|
||||||
defines = [
|
defines = [
|
||||||
# append (O(n))
|
# append (O(n))
|
||||||
{MODE='LFS_O_APPEND', SIZE=[32, 0, 7, 2049], CHUNKSIZE=[31, 16, 65]},
|
{MODE='LFS_O_APPEND',
|
||||||
|
SIZE=[32, 0, 7, 2049],
|
||||||
|
CHUNKSIZE=[31, 16, 65],
|
||||||
|
INLINE_MAX=[0, -1, 8]},
|
||||||
# truncate (O(n^2))
|
# truncate (O(n^2))
|
||||||
{MODE='LFS_O_TRUNC', SIZE=[32, 0, 7, 200], CHUNKSIZE=[31, 16, 65]},
|
{MODE='LFS_O_TRUNC',
|
||||||
|
SIZE=[32, 0, 7, 200],
|
||||||
|
CHUNKSIZE=[31, 16, 65],
|
||||||
|
INLINE_MAX=[0, -1, 8]},
|
||||||
# rewrite (O(n^2))
|
# rewrite (O(n^2))
|
||||||
{MODE=0, SIZE=[32, 0, 7, 200], CHUNKSIZE=[31, 16, 65]},
|
{MODE=0,
|
||||||
|
SIZE=[32, 0, 7, 200],
|
||||||
|
CHUNKSIZE=[31, 16, 65],
|
||||||
|
INLINE_MAX=[0, -1, 8]},
|
||||||
]
|
]
|
||||||
reentrant = true
|
reentrant = true
|
||||||
code = '''
|
code = '''
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ code = '''
|
|||||||
lfs_mount(&lfs, cfg) => 0;
|
lfs_mount(&lfs, cfg) => 0;
|
||||||
// create an orphan
|
// create an orphan
|
||||||
lfs_mdir_t orphan;
|
lfs_mdir_t orphan;
|
||||||
lfs_alloc_ack(&lfs);
|
lfs_alloc_ckpoint(&lfs);
|
||||||
lfs_dir_alloc(&lfs, &orphan) => 0;
|
lfs_dir_alloc(&lfs, &orphan) => 0;
|
||||||
lfs_dir_commit(&lfs, &orphan, NULL, 0) => 0;
|
lfs_dir_commit(&lfs, &orphan, NULL, 0) => 0;
|
||||||
|
|
||||||
@@ -170,7 +170,7 @@ code = '''
|
|||||||
lfs_mount(&lfs, cfg) => 0;
|
lfs_mount(&lfs, cfg) => 0;
|
||||||
// create an orphan
|
// create an orphan
|
||||||
lfs_mdir_t orphan;
|
lfs_mdir_t orphan;
|
||||||
lfs_alloc_ack(&lfs);
|
lfs_alloc_ckpoint(&lfs);
|
||||||
lfs_dir_alloc(&lfs, &orphan) => 0;
|
lfs_dir_alloc(&lfs, &orphan) => 0;
|
||||||
lfs_dir_commit(&lfs, &orphan, NULL, 0) => 0;
|
lfs_dir_commit(&lfs, &orphan, NULL, 0) => 0;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user