From 47c1cfd5e8ec289597f7342f88e103811511f0a8 Mon Sep 17 00:00:00 2001 From: Zhihao Cheng Date: Mon, 11 Nov 2024 17:08:08 +0800 Subject: fsck.ubifs: Move common functions and data structures into check_space.c This is a preparation for adding LPT checking support. Move some data structures and functions into check_space.c, also factor out some common functions in libubifs: 1. Move 'lpts' from rebuild module, make it resuable for non-rebuild_fs modes. 2. Move function 'get_free_leb' from rebuild_fs.c, it could be reused in building LPT. 3. Move function 'build_lpt' from rebuild_fs.c, it could be reused in building LPT. 4. Factor out lpt nodes freeing into a new function ubifs_free_lpt_nodes. 5. Factor out nnode dirty marking implementations into a new function ubifs_make_nnode_dirty. 5. Export the function of nnode number calculation, calc_nnode_num is renamed as ubifs_calc_nnode_num. 6. Export the function of making pnode dirty, do_make_pnode_dirty is renamed as ubifs_make_pnode_dirty. 7. Rename next_pnode_to_dirty to ubifs_find_next_pnode and export it. 8. Export free_buds and expend its parameters. Signed-off-by: Zhihao Cheng Signed-off-by: David Oberhollenzer --- ubifs-utils/libubifs/super.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'ubifs-utils/libubifs/super.c') diff --git a/ubifs-utils/libubifs/super.c b/ubifs-utils/libubifs/super.c index 155489d..559623f 100644 --- a/ubifs-utils/libubifs/super.c +++ b/ubifs-utils/libubifs/super.c @@ -654,15 +654,20 @@ void free_orphans(struct ubifs_info *c) /** * free_buds - free per-bud objects. * @c: UBIFS file-system description object + * @delete_from_list: whether to delete the bud from list */ -static void free_buds(struct ubifs_info *c) +void free_buds(struct ubifs_info *c, bool delete_from_list) { struct ubifs_bud *bud, *n; rbtree_postorder_for_each_entry_safe(bud, n, &c->buds, rb) { + if (delete_from_list) + list_del(&bud->list); kfree(bud->log_hash); kfree(bud); } + + c->buds = RB_ROOT; } /** @@ -693,5 +698,5 @@ void destroy_journal(struct ubifs_info *c) ubifs_destroy_idx_gc(c); ubifs_destroy_size_tree(c); ubifs_tnc_close(c); - free_buds(c); + free_buds(c, false); } -- cgit v1.2.3