Fixed problem with lookaheads larger than block device

Simply limiting the lookahead region to the size of
the block device fixes the problem.

Also added logic to limit the allocated region and
floor to nearest word, since the additional memory
couldn't really be used effectively.
This commit is contained in:
Christopher Haster
2017-09-18 21:20:33 -05:00
parent d9367e05ce
commit 273cb7c9c8
3 changed files with 29 additions and 24 deletions

7
lfs.h
View File

@@ -225,10 +225,11 @@ typedef struct lfs_superblock {
} lfs_superblock_t;
typedef struct lfs_free {
lfs_size_t lookahead;
lfs_block_t begin;
lfs_block_t end;
lfs_block_t start;
lfs_block_t off;
uint32_t *lookahead;
uint32_t *buffer;
} lfs_free_t;
// The littlefs type
@@ -237,12 +238,12 @@ typedef struct lfs {
lfs_block_t root[2];
lfs_file_t *files;
bool deorphaned;
lfs_cache_t rcache;
lfs_cache_t pcache;
lfs_free_t free;
bool deorphaned;
} lfs_t;