fixup! Add support for shrinking a filesystem

This commit is contained in:
Sosthène Guédon
2025-05-05 11:37:39 +02:00
parent 2105e502c5
commit 9b8f802b43
4 changed files with 40 additions and 69 deletions
+4 -11
View File
@@ -766,23 +766,16 @@ int lfs_fs_gc(lfs_t *lfs);
// Grows the filesystem to a new size, updating the superblock with the new
// block count.
//
// if LFS_SHRINKIFCHEAP is defined, this function will also accept
// block_counts smaller than the current configuration, after checking
// that none of the blocks that are being removed are in use.
//
// Note: This is irreversible.
//
// Returns a negative error code on failure.
int lfs_fs_grow(lfs_t *lfs, lfs_size_t block_count);
#endif
#ifndef LFS_READONLY
// Shrinks the filesystem to a new size, updating the superblock with the new
// block count.
//
// Note: This first checks that none of the blocks that are being removed are in use
// and will fail if it is the case
//
// Returns a negative error code on failure.
int lfs_fs_shrink(lfs_t *lfs, lfs_size_t block_count);
#endif
#ifndef LFS_READONLY
#ifdef LFS_MIGRATE
// Attempts to migrate a previous version of littlefs