From 7e6ae3a8dcbedf0e65c091e985aff56f293cf8ec Mon Sep 17 00:00:00 2001 From: Zhihao Cheng Date: Mon, 11 Nov 2024 17:08:11 +0800 Subject: fsck.ubifs: Check and correct the index size This is the 14/18 step of fsck. Check and correct the index size by traversing TNC just like dbg_check_idx_size does. This step should be executed after first committing, because 'c->calc_idx_sz' can be changed in 'ubifs_tnc_start_commit' and the initial value of 'c->calc_idx_sz' read from disk is untrusted. Signed-off-by: Zhihao Cheng Signed-off-by: David Oberhollenzer --- ubifs-utils/fsck.ubifs/fsck.ubifs.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'ubifs-utils/fsck.ubifs/fsck.ubifs.c') diff --git a/ubifs-utils/fsck.ubifs/fsck.ubifs.c b/ubifs-utils/fsck.ubifs/fsck.ubifs.c index 07ed817..80205aa 100644 --- a/ubifs-utils/fsck.ubifs/fsck.ubifs.c +++ b/ubifs-utils/fsck.ubifs/fsck.ubifs.c @@ -512,6 +512,13 @@ static int do_fsck(void) } err = commit_fix_modifications(c); + if (err) { + exit_code |= FSCK_ERROR; + goto free_disconnected_files_2; + } + + log_out(c, "Check and correct the index size"); + err = check_and_correct_index_size(c); if (err) exit_code |= FSCK_ERROR; @@ -567,6 +574,7 @@ int main(int argc, char *argv[]) * Step 11: Check whether the TNC is empty * Step 12: Check and correct the space statistics * Step 13: Commit problem fixing modifications + * Step 14: Check and correct the index size */ err = do_fsck(); if (err && FSCK(c)->try_rebuild) { -- cgit v1.2.3