From 749a45650fc2d723b3cfe1748266c95105323987 Mon Sep 17 00:00:00 2001 From: Brian Pugh Date: Tue, 16 Apr 2024 20:32:12 -0700 Subject: [PATCH] Fix DivideByZero exception when filesystem is completely full. --- lfs.c | 2 +- lfs.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lfs.c b/lfs.c index a0bd76fd..c14efaac 100644 --- a/lfs.c +++ b/lfs.c @@ -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; } diff --git a/lfs.h b/lfs.h index 99145022..274259e2 100644 --- a/lfs.h +++ b/lfs.h @@ -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