Fix DivideByZero exception when filesystem is completely full.

This commit is contained in:
Brian Pugh
2024-04-16 20:32:12 -07:00
parent 4dd30c1b8f
commit 749a45650f
2 changed files with 2 additions and 1 deletions
+1 -1
View File
@@ -688,7 +688,7 @@ static int lfs_alloc(lfs_t *lfs, lfs_block_t *block) {
if (lfs->lookahead.ckpoint <= 0) { if (lfs->lookahead.ckpoint <= 0) {
LFS_ERROR("No more free space 0x%"PRIx32, LFS_ERROR("No more free space 0x%"PRIx32,
(lfs->lookahead.start + lfs->lookahead.next) (lfs->lookahead.start + lfs->lookahead.next)
% lfs->cfg->block_count); % lfs->block_count);
return LFS_ERR_NOSPC; return LFS_ERR_NOSPC;
} }
+1
View File
@@ -204,6 +204,7 @@ struct lfs_config {
lfs_size_t block_size; lfs_size_t block_size;
// Number of erasable blocks on the device. // Number of erasable blocks on the device.
// If 0, will attempt to infer block_count from existing filesystem.
lfs_size_t block_count; lfs_size_t block_count;
// Number of erase cycles before littlefs evicts metadata logs and moves // Number of erase cycles before littlefs evicts metadata logs and moves