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
+2 -2
View File
@@ -7,7 +7,7 @@ code = '''
lfs_t lfs;
lfs_format(&lfs, cfg) => 0;
lfs_mount(&lfs, cfg) => 0;
lfs_fs_shrink(&lfs, AFTER_BLOCK_COUNT) => 0;
lfs_fs_grow(&lfs, AFTER_BLOCK_COUNT) => 0;
lfs_unmount(&lfs);
if (BLOCK_COUNT != AFTER_BLOCK_COUNT) {
lfs_mount(&lfs, cfg) => LFS_ERR_INVAL;
@@ -46,7 +46,7 @@ code = '''
lfs_file_close(&lfs, &file) => 0;
}
int err = lfs_fs_shrink(&lfs, AFTER_BLOCK_COUNT);
int err = lfs_fs_grow(&lfs, AFTER_BLOCK_COUNT);
if (err == 0) {
for (int i = 0; i < FILES_COUNT + 1; i++) {
lfs_file_t file;
+3 -3
View File
@@ -550,7 +550,7 @@ code = '''
// same size is a noop
lfs_mount(&lfs, cfg) => 0;
lfs_fs_shrink(&lfs, BLOCK_COUNT) => 0;
lfs_fs_grow(&lfs, BLOCK_COUNT) => 0;
lfs_fs_stat(&lfs, &fsinfo) => 0;
assert(fsinfo.block_size == BLOCK_SIZE);
assert(fsinfo.block_count == BLOCK_COUNT);
@@ -564,7 +564,7 @@ code = '''
// grow to new size
lfs_mount(&lfs, cfg) => 0;
lfs_fs_shrink(&lfs, BLOCK_COUNT_2) => 0;
lfs_fs_grow(&lfs, BLOCK_COUNT_2) => 0;
lfs_fs_stat(&lfs, &fsinfo) => 0;
assert(fsinfo.block_size == BLOCK_SIZE);
assert(fsinfo.block_count == BLOCK_COUNT_2);
@@ -594,7 +594,7 @@ code = '''
// same size is a noop
lfs_mount(&lfs, cfg) => 0;
lfs_fs_shrink(&lfs, BLOCK_COUNT_2) => 0;
lfs_fs_grow(&lfs, BLOCK_COUNT_2) => 0;
lfs_fs_stat(&lfs, &fsinfo) => 0;
assert(fsinfo.block_size == BLOCK_SIZE);
assert(fsinfo.block_count == BLOCK_COUNT_2);