From cf844f788d34e1facf142910b955554c69eb8f9b Mon Sep 17 00:00:00 2001 From: Zhihao Cheng Date: Mon, 11 Nov 2024 17:01:22 +0800 Subject: fsck.ubifs: Replay journal This is the 2/18 step of fsck. Replay journal, update TNC & LPT. There could be following steps and possible errors: Step 1. scan log LEB, get all bud LEBs a. corrupted scanning data in log area: danger mode with rebuild_fs and normal mode with 'yes' answer will turn to rebuild filesystem, other modes will exit. Step 2. scan bud LEBs, get all nodes a. corrupted scanning data in bud LEB: danger mode and normal mode with 'yes' answer will drop bud LEB and set %FR_LPT_INCORRECT for lpt status, other modes will exit. Step 3. apply nodes, record latest isize into size_tree Step 4. apply nodes, update TNC & LPT a. corrupted data searched from TNC: skip node and set %FR_LPT_INCORRECT lpt status for danger mode and normal mode with 'yes' answer, other modes will exit. b. corrupted index node read from TNC: danger mode with rebuild_fs and normal mode with 'yes' answer will turn to rebuild filesystem, other modes will exit. c. corrupted lpt: Set %FR_LPT_CORRUPTED for lpt status. Ignore the error. d. incorrect lpt: Set %FR_LPT_INCORRECT for lpt status. Ignore the error. e. If lpt status is not empty, skip updating lpt. Signed-off-by: Zhihao Cheng Signed-off-by: David Oberhollenzer --- ubifs-utils/fsck.ubifs/fsck.ubifs.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (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 2fd68df..85175cf 100644 --- a/ubifs-utils/fsck.ubifs/fsck.ubifs.c +++ b/ubifs-utils/fsck.ubifs/fsck.ubifs.c @@ -325,13 +325,17 @@ static bool fsck_can_ignore_failure(const struct ubifs_info *c, return false; } -static const unsigned int reason_mapping_table[] = {}; +static const unsigned int reason_mapping_table[] = { + BUD_CORRUPTED, /* FR_H_BUD_CORRUPTED */ + TNC_DATA_CORRUPTED, /* FR_H_TNC_DATA_CORRUPTED */ +}; -static bool fsck_handle_failure(const struct ubifs_info *c, unsigned int reason) +static bool fsck_handle_failure(const struct ubifs_info *c, unsigned int reason, + void *priv) { ubifs_assert(c, FSCK(c)->mode != REBUILD_MODE); - return fix_problem(c, reason_mapping_table[reason]); + return fix_problem(c, reason_mapping_table[reason], priv); } static void signal_cancel(int sig) @@ -426,6 +430,7 @@ int main(int argc, char *argv[]) /* * Init: Read superblock * Step 1: Read master & init lpt + * Step 2: Replay journal */ err = ubifs_load_filesystem(c); if (err) { -- cgit v1.2.3