Skip to content

Commit

Permalink
Fix DivideByZero exception when filesystem is completely full.
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianPugh committed Apr 17, 2024
1 parent 4dd30c1 commit 749a456
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ static int lfs_alloc(lfs_t *lfs, lfs_block_t *block) {
if (lfs->lookahead.ckpoint <= 0) {
LFS_ERROR("No more free space 0x%"PRIx32,
(lfs->lookahead.start + lfs->lookahead.next)
% lfs->cfg->block_count);
% lfs->block_count);
return LFS_ERR_NOSPC;
}

Expand Down
1 change: 1 addition & 0 deletions lfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ struct lfs_config {
lfs_size_t block_size;

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

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

0 comments on commit 749a456

Please sign in to comment.