Skip to content

Commit 749a456

Browse files
committed
Fix DivideByZero exception when filesystem is completely full.
1 parent 4dd30c1 commit 749a456

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

lfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ static int lfs_alloc(lfs_t *lfs, lfs_block_t *block) {
688688
if (lfs->lookahead.ckpoint <= 0) {
689689
LFS_ERROR("No more free space 0x%"PRIx32,
690690
(lfs->lookahead.start + lfs->lookahead.next)
691-
% lfs->cfg->block_count);
691+
% lfs->block_count);
692692
return LFS_ERR_NOSPC;
693693
}
694694

lfs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ struct lfs_config {
204204
lfs_size_t block_size;
205205

206206
// Number of erasable blocks on the device.
207+
// If 0, will attempt to infer block_count from existing filesystem.
207208
lfs_size_t block_count;
208209

209210
// Number of erase cycles before littlefs evicts metadata logs and moves

0 commit comments

Comments
 (0)