mirror of
https://github.com/littlefs-project/littlefs.git
synced 2025-11-16 04:24:35 +00:00
Add support for shrinking a filesystem
This PR adds a new `lfs_fs_shrink`, which functions similarly to `lfs_fs_grow`, but supports reducing the block count. This functions first checks that none of the removed block are in use. If it is the case, it will fail.
This commit is contained in:
11
lfs.h
11
lfs.h
@@ -772,6 +772,17 @@ int lfs_fs_gc(lfs_t *lfs);
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user