1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-17 10:52:44 +01:00

littlefs2: fix return code in case of corruption

This commit is contained in:
Vincent Dupont 2020-08-31 16:06:17 +02:00 committed by crasbe
parent 61a03bb54a
commit 216a370e9a

View File

@ -84,7 +84,11 @@ static int _dev_write(const struct lfs_config *c, lfs_block_t block,
(void *)c, block, off, buffer, size);
uint32_t page = (fs->base_addr + block) * fs->sectors_per_block * mtd->pages_per_sector;
return mtd_write_page_raw(mtd, buffer, page, off, size);
int ret = mtd_write_page_raw(mtd, buffer, page, off, size);
if (ret == -EIO) {
ret = LFS_ERR_CORRUPT;
}
return ret;
}
static int _dev_erase(const struct lfs_config *c, lfs_block_t block)
@ -95,7 +99,12 @@ static int _dev_erase(const struct lfs_config *c, lfs_block_t block)
DEBUG("lfs_erase: c=%p, block=%" PRIu32 "\n", (void *)c, block);
uint32_t sector = (fs->base_addr + block) * fs->sectors_per_block;
return mtd_erase_sector(mtd, sector, fs->sectors_per_block);}
int ret = mtd_erase_sector(mtd, sector, fs->sectors_per_block);
if (ret == -EIO) {
ret = LFS_ERR_CORRUPT;
}
return ret;
}
static int _dev_sync(const struct lfs_config *c)
{