|
|
|
@ -95,3 +95,24 @@ void mufs_free_page(struct mufs *fs, struct mufs_tree *tree, uint32_t va) |
|
|
|
|
{ |
|
|
|
|
mufs_do_free_page(fs, tree->root, tree->depth, va); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int mufs_extend_tree(struct mufs *fs, struct mufs_tree *tree, uint8_t depth) |
|
|
|
|
{ |
|
|
|
|
uint32_t root; |
|
|
|
|
|
|
|
|
|
for (; tree->depth < depth; ++tree->depth) { |
|
|
|
|
if (mufs_alloc_block(fs, &root) < 0) |
|
|
|
|
return -1; |
|
|
|
|
|
|
|
|
|
if (!root) |
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
if (flash_write(fs->dev, root << fs->dev->log2_block_size, &tree->root, |
|
|
|
|
sizeof tree->root) == 0) { |
|
|
|
|
mufs_free_block(fs, root); |
|
|
|
|
return -1; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|