Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/littlefs-project/littlefs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lfs.h
diff options
context:
space:
mode:
authorChristopher Haster <chaster@utexas.edu>2018-04-10 23:14:27 +0300
committerChristopher Haster <chaster@utexas.edu>2018-04-11 22:38:25 +0300
commit9637b9606965d40692724e9a5a742e8e87d6c602 (patch)
tree5221d9e2107d3a5ad3c9a90bd324a80d2b4719e1 /lfs.h
parent89a7630d84f1529549f6aa2528fb7b22f4edf1b2 (diff)
Fixed lookahead overflow and removed unbounded lookahead pointers
As pointed out by davidefer, the lookahead pointer modular arithmetic does not work around integer overflow when the pointer size is not a multiple of the block count. To avoid overflow problems, the easy solution is to stop trying to work around integer overflows and keep the lookahead offset inside the block device. To make this work, the ack was modified into a resetable counter that is decremented every block allocation. As a plus, quite a bit of the allocation logic ended up simplified.
Diffstat (limited to 'lfs.h')
-rw-r--r--lfs.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/lfs.h b/lfs.h
index 1d65733..376776f 100644
--- a/lfs.h
+++ b/lfs.h
@@ -259,9 +259,9 @@ typedef struct lfs_superblock {
} lfs_superblock_t;
typedef struct lfs_free {
- lfs_block_t begin;
- lfs_block_t size;
lfs_block_t off;
+ lfs_block_t size;
+ lfs_block_t i;
lfs_block_t ack;
uint32_t *buffer;
} lfs_free_t;