浏览代码

Fix DivideByZero exception when filesystem is completely full.

Brian Pugh 1 年之前
父节点
当前提交
749a45650f
共有 2 个文件被更改,包括 2 次插入1 次删除
  1. 1 1
      lfs.c
  2. 1 0
      lfs.h

+ 1 - 1
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;
         }
 

+ 1 - 0
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