Skip to content

Commit

Permalink
Squashed 'littlefs/' changes from 8b609ec..6bc415bc2a
Browse files Browse the repository at this point in the history
6bc415bc2a Added scripts/prefix.py for automatically prefixing version numbers
8cca1b6a86 Fixed several small issues found during wider testing
5fb8fa9f06 Fixed issue with global state updates being lost during relocates
916b308558 Fixed excessive waste from overly large inline files
e1f9d2bc09 Added support for RAM-independent reading of inline files
51b2c7e Changed custom attribute descriptors to used arrays
66d7515 Modified global state format to work with new tag format
b989b4a Cleaned up tag encoding, now with clear chunk field
a548ce6 Switched to traversal-based compact logic
dc507a7 Changed required alignment of lookahead_size to 64 bits
5b26c68 Tweaked tag endianness to catch power-loss after <1 word is written
4a1b8ae Fixed issues found by more aggressive rename tests
c8a39c4 Merge remote-tracking branch 'origin/master' into v2-rebase-part2
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
795dd8c Fixed mkdir when inserting into a non-end block
97a7191 Fixed issue with creating files named "littlefs"
aeca766 Switched to strongly ordered directories
7af8b81 Changed lookahead configuration unit to bytes instead of bits
ad96fca Changed attr_max to be specific to custom attributes
f010d2a Fixed issue with reads ignoring the pcache
d7e4aba Edited tag structure to balance size vs id count
cafe6ab Fixed issue with splitting metadata-pairs in full filesystem
29b8810 Revisited xored-globals and related logic
cf87ba5 Combined superblock scan and fetch of xored-globals during mount
7bacf9b Removed xored-globals from the mdir struct
5eeeb9d Revisited some generic concepts, callbacks, and some reorganization
617dd87 Added deletion to custom attributes
c67a41a Added support for deleting attributes
6046d85 Added support for entry insertion
6db5202 Modified valid bit to provide an early check on all tags
a43f9b3 Modified lfs_dir_compact to avoid redundant erases during split
478dcdd Revisited caching rules to optimize bus transactions
4db96d4 Changed unwritable superblock to ENOSPC for consistency
a2532a3 Fixed inline files when inline_max == cache_size
d5e8005 Collapsed recursive deorphans into a single pass
21217d7 Dropped lfs_fs_getattr for the more implicit lfs_getattr("/")
38011f4 Fixed minor memory leak
126ef8b Added allocation randomization for dynamic wear-leveling
e4a0d58 Added building blocks for dynamic wear-leveling
20b669a Fixed issue with big-endian CTZ lists intertwined in commit logic
10f45ac Changed lfs_crc to match more common API
3b3981e Fixed testing issues introduced by expanding superblocks
d8f930e Modified CTZ struct type to make space for erased files in the future
7c70068 Added root entry and expanding superblocks
c3e36bd Standardized naming for internal functions
6d0a6fc Merge remote-tracking branch 'origin/master' into v2-alpha
3186e89 Changed littlefs-fuse target for testing purposes
dbcbe4e Changed name of upper-limits from blah_size to blah_max
213530c Changed LFS_ERR_CORRUPT to match EILSEQ instead of EBADE
a88230a Updated custom attribute documentation and tweaked nonexistant attributes
f369f80 Added tests for global state stealing
1941bbd Cleaned up config options
3cfa086 Introduced cache_size as alternative to hardware read/write sizes
97f35c3 Simplified the internal xored-globals implementation
35f68d2 Squished in-flight files/dirs into single list
bd1e0c4 Cleaned up several TODOs
01d837e Removed redundant lfs_scan in lfs_init
112fefc Added back big-endian support again on the new metadata structures
64df0a5 Added orphan bit to xored-globals
1a58ba7 Fixed ENOSPC issues with zero-granularity blocks
105907b Cleaned up config usage in file logic
df1b607 Removed the implicit lfs_t parameter to lfs_traverse
2257060 Fixed test bugs around handling corruption
3e246da Fixed the orphan test to handle logging metadata-pairs
15d1560 Added support for custom attributes leveraging the new metadata logging
3914cdf Pulled in fixes for additional path corner cases
392b2ac Refactored the updates of in-flight files/dirs
d9a24d0 Fixed move handling when caught in a relocate
5d24e65 Cleaned up commit logic and function organization
d3f3711 Cleaned up attributes and related logic
5fc53bd Changed internal functions to return tags over pointers
2b35c36 Renamed tag functions and macros
7c88bc9 Restructured get/traverse functions
e3b8678 Modified results from find-like functions to use tags
67d9f88 Combined get functions into one
7ad9700 Integrated findscan into fetch as a built in side effect
fe31f79 Consolidated find/parent scanning functions
fd121dc Dropped "has id" bit encoding in favor of invalid id
b7bd34f Restructured types to use a more flexible bit encoding
c1103ef Changed type info to be retrieved from name tag instead of struct tag
d7b0652 Removed old move logic, now passing move tests
2ff32d2 Fixed bug where globals were poisoning move commits
b46fcac Fixed issues with finding wrong ids after bad commits
cebf7aa Switched back to simple deorphan-step on directory remove
3ffcedb Restructured tags to better support xored-globals
e39f7e9 Introduced xored-globals logic to fix fundamental problem with moves
116c1e7 Adopted EISDIR as internal error for root path as argument
f458da4 Added the internal meta-directory structure
eaa9220 Renamed lfs_entry_t -> lfs_mattr_t
9278b17 Trimmed old names and functions from the code base
85a9638 Fixed issues discovered around testing moves
483d41c Passing all of the basic functionality tests
11a3c8d Continued progress with reintroducing testing on the new metadata logging
0bdaeb7 More testing progress, combined dir/commit traversal
0405ceb Cleaned up enough things to pass basic file testing
a3c67d9 Reorganized the internal operations to make more sense
0695862 Completed transition of files with journalling metadata
fe553e8 More progress integrating journaling
87f3e01 Progressed integration of journaling metadata pairs
8070abe Added rudimentary framework for journaling metadata pairs
61f454b Added tests for resizable entries and custom attributes
ea4ded4 Fixed big-endian support again
2a8277b Added test coverage for filesystems with no inline files
746b909 Added lfs_fs_size for finding a count of used blocks
93244a3 Added file-level and fs-level custom attribute APIs
636c0ed Modified commit regions to work better with custom attributes
6c754c8 Added support for atomically committing custom attributes
6ffc8d3 Added simple custom attributes
65ea6b3 Bumped versions, cleaned up some TODOs and missing comments
6774276 Expanded inline files up to a limit of 1023 bytes
6362afa Added disk-backed limits on the name/attrs/inline sizes
9555458 Added internal lfs_dir_set, an umbrella to dir append/update/remove operations
ad74825 Added internal lfs_dir_get to consolidate logic for reading dir entries
d0e0453 Changed how we write out superblock to use append
701e4fa Fixed a handful of bugs as result of testing
d8cadec Better implementation of inline files, now with overflowing
836e238 Shoehorned in hacky implementation of inline files
fb23044 Fixed big-endian support for entry structures
9273ac7 Added size field to entry structure
03b262b Separated out version of dir remove/append for non-entries
362b0bb Minor improvement to from-memory commits
e4a0cd9 Take advantage of empty space early in dir search
f30ab67 Traded enum-based DSL for full callback-based DSL
ca3d6a5 Made implicity tag updates explicit
692f0c5 Naive implementation of resizable entries
e3daee2 Changed dir append to mirror commit DSL
73d29f0 Adopted a tiny LISP-like DSL for some extra flexibility
4c35c86 Added different sources for commits, now with disk->disk moves
49698e4 Separated type/struct fields in dir entries
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
510cd13 Bumped minor version to v1.6
f5e0539 Fixed issue with release script non-standard version tags
0664480 Moved SPDX and license info into README
d66723c Merge pull request ARMmbed#81 from ARMmbed/simple-versioning
0234c77 Simplified release process based on feedback
84adead Merge pull request ARMmbed#80 from FreddieChopin/fix-memory-leaks
0422c55 Fix memory leaks in lfs_mount and lfs_format
11ad3a2 Merge pull request ARMmbed#76 from ARMmbed/fix-corrupt-read
16318d0 Merge pull request ARMmbed#58 from dpgeorge/file-open-no-malloc
961fab7 Added file config structure and lfs_file_opencfg
041e90a Added handling for corrupt as initial state of blocks
f94d233 Merge pull request ARMmbed#74 from FreddieChopin/cxx-guards
577d777 Add C++ guards to public headers
c72d252 Merge pull request ARMmbed#73 from FreddieChopin/fix-format-specifiers
7e67f93 Use PRIu32 and PRIx32 format specifiers to fix warnings
5a17fa4 Fixed script issue with bash expansion inside makefile parameter
eed1eec Fixed information leaks through reused caches
4a86370 Added quality of life improvements for main.c/test.c issues
ba4f171 Merge pull request ARMmbed#57 from dpgeorge/fix-warnings
51346b8 Fixed shadowed variable warnings
93a2e0b Merge pull request ARMmbed#62 from ARMmbed/license-bsd-3
6beff50 Changed license to BSD-3-Clause
c5e2b33 Added error when opening multiple files with a statically allocated buffer
015b86b Fixed issue with trailing dots in file paths
9637b96 Fixed lookahead overflow and removed unbounded lookahead pointers
89a7630 Fixed issue with lookahead trusting old lookahead blocks
43eac30 Renamed test_parallel tests to test_interespersed
dbc3cb1 Fixed Travis rate-limit issue with Github requests
93ece2e Removed outdated note about moves and powerloss
d9c076d Removed the uninitialized read for invalid superblocks
58f3bb1 Merge pull request ARMmbed#37 from jrast/patch-1
f72f6d6 Removed out of date note about endianness
5c4ee21 Added a note about the callback functions
1552246 Fixed Travis issue with deploy stage in PRs
9ee112a Fixed issue updating dir struct when extended dir chain
d9c3637 Fixed handling of root as target for create operations
1476181 Added LFS_CONFIG for user provided configuration of the utils
b2124a5 Fixed multiple deploy steps in Travis
949015a Merge pull request ARMmbed#28 from geky/configurables
67daf9e Added cross-compile targets for testing
a3fd2d4 Added more configurable utils
a0a55fb Added conversion to/from little-endian on disk
4f08424 Added software implementations of bitwise instructions
59ce49f Merge pull request ARMmbed#26 from Sim4n6/master
2f8ae34 Added a git ignore file with .o .d blocks dir and lfs bin
e611cf5 Fix incorrect lookahead population before ack
a25743a Fixed some minor error code differences
6716b55 Fixed error check when truncating files to larger size
809ffde Merge pull request ARMmbed#24 from aldot/silence-shadow-warnings-1
dc513b1 Silenced more of aldot's warnings
aa50e03 Commentary typo fix
6d55755 tests: Silence warnings in template
029361e Silence shadow warnings
fd04ed4 Added autogenerated release notes from commits
3101bc9 Do not print command invocation if QUIET
d82e34c Merge pull request ARMmbed#21 from aldot/doc-tweaks
436707c doc: Editorial tweaks
3457252 doc: Spelling fixes
6d8e0e2 Moved -Werror flag to CI only
88f678f Fixed self-assign warning in tests
3ef4847 Added remove step in tests to force rebuild
f694b14 Merge pull request ARMmbed#16 from geky/versioning
5a38d00 Added deploy step in Travis to push new version as tags
035552a Add version info for software library and on-disk structures
997c2e5 Fixed incorrect reliance on errno in emubd
d88f0ac Added lfs_file_truncate
2ad435e Added files test to littlefs-fuse tests in Travis
1fb6a19 Reduced ctz traverse runtime by 2x
db88727 Added error code LFS_ERR_NOTEMPTY
c2fab8f Added asserts on geometry and updated config documentation
472ccc4 Fixed file truncation without writes
aea3d3d Fixed positive seek bounds checking
be22d34 Updated links to Mbed OS
425aa3c Fixed issue with immediate exhaustion and small unaligned storage
5ee20e8 Fixed pipefail issue that was preventing CI from reporting errors
bf78b09 Added directory list for synchronizing in flight directories
e169d06 Removed vestigial function declaration
996cd8a Revisited documentation
78c79ec Added QUIET flag to tests so CI is readable
f9f4f5c Fixed standard name mismatch LFS_ERR_EXISTS -> LFS_ERR_EXIST
843e3c6 Added sticky-bit for preventing file syncs after write errors
2612e1b Modified lfs_ctz_extend to be a little bit safer
6664723 Fixed issue with committing directories to bad-blocks that are stuck
3f31c8c Fixed corner case with immediate exhaustion and lookahead==block_count
f4aeb83 Fixed issue with aggressively rounding down lookahead configuration
db51a39 Removed stray newline in LFS_ERROR for version
2ab150c Removed toolchain specific warnings
0825d34 Adopted alternative implementation for lfs_ctz_index
46e22b2 Adopted lfs_ctz_index implementation using popcount
4fdca15 Slight name change with ctz skip-list functions
454b588 Updated SPEC.md and DESIGN.md based on recent changes
f3578e3 Removed clamping to block size in ctz linked-list
83d4c61 Updated copyright
539409e Refactored deduplicate/deorphan step to single deorphan step
2936514 Added atomic move using dirty tag in entry type
ac9766e Added self-hosting fuzz test using littlefs-fuse
9db1a86 Added specification document
9843402 Fixed incorrect return value from lfs_file_seek
273cb7c Fixed problem with lookaheads larger than block device
d9367e0 Fixed collection of multiblock directories
a83b2fe Added checks for out-of-bound seeks
a8fa5e6 Fixed some corner cases with paths
26dd49a Fixed issue with negative modulo with unaligned lookaheads
0982020 Fixed issue with cold-write after seek to block boundary
c2283a2 Extended entry tag to support attributes
8795f0e Added build size output to CI
47db7a7 Added sanity check for compiling example
476915f Removed a few "what"s from the documentation
663e953 Adopted the Apache 2.0 license
51c8b02 Updated .travis.yml to test multiple cache sizes
8a9b9ba Modified entry head to include name length
931442a Adopted redundant cache read in lfs_file_relocate
0e1022a Fixed missing erase during file relocation
a1138a4 Fixed dirty rcache during directory commit
1166416 Fixed relocation bug when a file is closed with lingering caches
fe28ea0 Added internal check of data written to disk
1eeb2a6 Shrinked on-disk directory program size
0d66f9f Cleaned up design documentation
d2bf2bb Added documentation over the underlying design
69294ac Added better documentation
fd1da60 Added support for handling corrupted blocks
b35d761 Removed words variable from lfs struct
63b52c9 Added proper handling for removing open files
8621b61 Adopted 0xffffffff as null pointer
4808e9a Added caching with managed caches at the file level
6869b14 Fixed memory leak for lookahead buffer
a30142e Fixed allocation bugs near the end of storage
210b487 Added file list for tracking in flight allocations
b55719b Adopted more conventional buffer parameter ordering
0406442 Fixed non-standard behaviour of rdwr streams
287b548 Standardized error values
5790ec2 Structured some of the bulk of the codebase
ba8afb9 Added support for full seek operations
a1d8a76 Added correct handling of file syncing around overwrites
a4e9132 Removed a layer of indirection for index-list lookup
aa87265 Cleaned up block allocator
7050922 Added optional block-level caching
789286a Simplified config
3b9d663 Restructured directory code
bd817ab Added support for renaming dirs/files
3b1bcbe Removed .. and . entries
1f13006 Added dir navigation without needing parent entries
c25c893 Moved to brute-force deorphan without parent pointers
96a4258 Added the lfs_stat function
a3734ee Added proper handling of orphans
8a67452 Added full dir list and rudimentary block allocator
ca01b72 Added path iteration and chained directories
390ca33 Added travis config
8a95fdf Added file read/write tests and some framework updates
a711675 Added dir tests, test fixes, config
afa4ad8 Added a rudimentary test framework
84a5764 Restructured the major interfaces of the filesystem
f566846 Revised free-list structure to adopt a lazy scanning allocator of sorts
ed674e8 Added support for the basic file operation
53674cb Added limited support for directories
106b06a Added better handling for metadata pairs
1d36fc6 Added initial superblock definition
c28a280 Adopted ctz skip-list structure earlier than expected
160299d Initial commit of progress, minimal formatting niave free list
02156cb Initial commit of block device interface and emulated block device
b113bba Created little config parser
REVERT: 8b609ec Split out littlefs mbed-os implementation from 'ca7b5e8eed574a7295280d9276de3f9bb7cb7f05'

git-subtree-dir: littlefs
git-subtree-split: 6bc415bc2aae647f09f3fae6c9382bf237a480fb
  • Loading branch information
geky committed Jan 29, 2019
1 parent 33cbcd7 commit bba45b3
Show file tree
Hide file tree
Showing 26 changed files with 4,019 additions and 1,648 deletions.
11 changes: 6 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ script:
- make test QUIET=1

# run tests with a few different configurations
- make test QUIET=1 CFLAGS+="-DLFS_READ_SIZE=1 -DLFS_PROG_SIZE=1"
- make test QUIET=1 CFLAGS+="-DLFS_READ_SIZE=512 -DLFS_PROG_SIZE=512"
- make test QUIET=1 CFLAGS+="-DLFS_BLOCK_COUNT=1023 -DLFS_LOOKAHEAD=2048"
- make test QUIET=1 CFLAGS+="-DLFS_READ_SIZE=1 -DLFS_CACHE_SIZE=4"
- make test QUIET=1 CFLAGS+="-DLFS_READ_SIZE=512 -DLFS_CACHE_SIZE=512 -DLFS_BLOCK_CYCLES=16"
- make test QUIET=1 CFLAGS+="-DLFS_BLOCK_COUNT=1023 -DLFS_LOOKAHEAD_SIZE=256"

- make clean test QUIET=1 CFLAGS+="-DLFS_INLINE_MAX=0"
- make clean test QUIET=1 CFLAGS+="-DLFS_NO_INTRINSICS"

# compile and find the code size with the smallest configuration
Expand Down Expand Up @@ -102,7 +103,7 @@ jobs:
- NAME=littlefs-fuse
install:
- sudo apt-get install libfuse-dev
- git clone --depth 1 https://github.com/geky/littlefs-fuse
- git clone --depth 1 https://github.com/geky/littlefs-fuse -b v2-alpha
- fusermount -V
- gcc --version
before_script:
Expand All @@ -125,7 +126,7 @@ jobs:
- mkdir mount/littlefs
- cp -r $(git ls-tree --name-only HEAD) mount/littlefs
- cd mount/littlefs
- ls
- ls -flh
- make -B test_dirs test_files QUIET=1

# Automatically update releases
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ size: $(OBJ)

.SUFFIXES:
test: test_format test_dirs test_files test_seek test_truncate \
test_interspersed test_alloc test_paths test_orphan test_move test_corrupt
test_entries test_interspersed test_alloc test_paths test_attrs \
test_move test_orphan test_corrupt
@rm test.c
test_%: tests/test_%.sh

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ const struct lfs_config cfg = {
.prog_size = 16,
.block_size = 4096,
.block_count = 128,
.lookahead = 128,
.cache_size = 16,
.lookahead_size = 16,
};

// entry point
Expand Down
95 changes: 86 additions & 9 deletions emubd/lfs_emubd.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,40 @@
#include <inttypes.h>


// Emulated block device utils
static inline void lfs_emubd_tole32(lfs_emubd_t *emu) {
emu->cfg.read_size = lfs_tole32(emu->cfg.read_size);
emu->cfg.prog_size = lfs_tole32(emu->cfg.prog_size);
emu->cfg.block_size = lfs_tole32(emu->cfg.block_size);
emu->cfg.block_count = lfs_tole32(emu->cfg.block_count);

emu->stats.read_count = lfs_tole32(emu->stats.read_count);
emu->stats.prog_count = lfs_tole32(emu->stats.prog_count);
emu->stats.erase_count = lfs_tole32(emu->stats.erase_count);

for (unsigned i = 0; i < sizeof(emu->history.blocks) /
sizeof(emu->history.blocks[0]); i++) {
emu->history.blocks[i] = lfs_tole32(emu->history.blocks[i]);
}
}

static inline void lfs_emubd_fromle32(lfs_emubd_t *emu) {
emu->cfg.read_size = lfs_fromle32(emu->cfg.read_size);
emu->cfg.prog_size = lfs_fromle32(emu->cfg.prog_size);
emu->cfg.block_size = lfs_fromle32(emu->cfg.block_size);
emu->cfg.block_count = lfs_fromle32(emu->cfg.block_count);

emu->stats.read_count = lfs_fromle32(emu->stats.read_count);
emu->stats.prog_count = lfs_fromle32(emu->stats.prog_count);
emu->stats.erase_count = lfs_fromle32(emu->stats.erase_count);

for (unsigned i = 0; i < sizeof(emu->history.blocks) /
sizeof(emu->history.blocks[0]); i++) {
emu->history.blocks[i] = lfs_fromle32(emu->history.blocks[i]);
}
}


// Block device emulated on existing filesystem
int lfs_emubd_create(const struct lfs_config *cfg, const char *path) {
lfs_emubd_t *emu = cfg->context;
Expand Down Expand Up @@ -46,17 +80,31 @@ int lfs_emubd_create(const struct lfs_config *cfg, const char *path) {
}

// 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");
if (!f && errno != ENOENT) {
return -errno;
if (!f) {
memset(&emu->stats, 0, sizeof(emu->stats));
} else {
size_t res = fread(&emu->stats, sizeof(emu->stats), 1, f);
lfs_emubd_fromle32(emu);
if (res < 1) {
return -errno;
}

err = fclose(f);
if (err) {
return -errno;
}
}

if (errno == ENOENT) {
memset(&emu->stats, 0x0, sizeof(emu->stats));
// Load history
snprintf(emu->child, LFS_NAME_MAX, ".history");
f = fopen(emu->path, "r");
if (!f) {
memset(&emu->history, 0, sizeof(emu->history));
} else {
size_t res = fread(&emu->stats, sizeof(emu->stats), 1, f);
size_t res = fread(&emu->history, sizeof(emu->history), 1, f);
lfs_emubd_fromle32(emu);
if (res < 1) {
return -errno;
}
Expand Down Expand Up @@ -166,6 +214,13 @@ int lfs_emubd_prog(const struct lfs_config *cfg, lfs_block_t block,
return -errno;
}

// update history and stats
if (block != emu->history.blocks[0]) {
memcpy(&emu->history.blocks[1], &emu->history.blocks[0],
sizeof(emu->history) - sizeof(emu->history.blocks[0]));
emu->history.blocks[0] = block;
}

emu->stats.prog_count += 1;
return 0;
}
Expand Down Expand Up @@ -211,13 +266,15 @@ int lfs_emubd_sync(const struct lfs_config *cfg) {
lfs_emubd_t *emu = cfg->context;

// Just write out info/stats for later lookup
snprintf(emu->child, LFS_NAME_MAX, "config");
snprintf(emu->child, LFS_NAME_MAX, ".config");
FILE *f = fopen(emu->path, "w");
if (!f) {
return -errno;
}

lfs_emubd_tole32(emu);
size_t res = fwrite(&emu->cfg, sizeof(emu->cfg), 1, f);
lfs_emubd_fromle32(emu);
if (res < 1) {
return -errno;
}
Expand All @@ -227,13 +284,33 @@ int lfs_emubd_sync(const struct lfs_config *cfg) {
return -errno;
}

snprintf(emu->child, LFS_NAME_MAX, "stats");
snprintf(emu->child, LFS_NAME_MAX, ".stats");
f = fopen(emu->path, "w");
if (!f) {
return -errno;
}

lfs_emubd_tole32(emu);
res = fwrite(&emu->stats, sizeof(emu->stats), 1, f);
lfs_emubd_fromle32(emu);
if (res < 1) {
return -errno;
}

err = fclose(f);
if (err) {
return -errno;
}

snprintf(emu->child, LFS_NAME_MAX, ".history");
f = fopen(emu->path, "w");
if (!f) {
return -errno;
}

lfs_emubd_tole32(emu);
res = fwrite(&emu->history, sizeof(emu->history), 1, f);
lfs_emubd_fromle32(emu);
if (res < 1) {
return -errno;
}
Expand Down
4 changes: 4 additions & 0 deletions emubd/lfs_emubd.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ typedef struct lfs_emubd {
uint64_t erase_count;
} stats;

struct {
lfs_block_t blocks[4];
} history;

struct {
uint32_t read_size;
uint32_t prog_size;
Expand Down
Loading

0 comments on commit bba45b3

Please sign in to comment.