From 0d1cc10378c2a8f800ff78d79c93b39485d6ca14 Mon Sep 17 00:00:00 2001 From: Zhihao Cheng Date: Mon, 11 Nov 2024 17:08:01 +0800 Subject: fsck.ubifs: Traverse TNC and construct files This is the 6/18 step of fsck. Traverse TNC and construct files. There could be following steps and possible errors: Step 1. Traverse TNC, check whether the leaf node is valid, remove invalid nodes, construct file for valid node and insert file into file tree. a. corrupted node searched from TNC: remove corresponding TNC branch 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. Signed-off-by: Zhihao Cheng Signed-off-by: David Oberhollenzer --- ubifs-utils/libubifs/debug.c | 12 +++++++----- ubifs-utils/libubifs/debug.h | 1 + 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'ubifs-utils/libubifs') diff --git a/ubifs-utils/libubifs/debug.c b/ubifs-utils/libubifs/debug.c index eaf403f..836cbc7 100644 --- a/ubifs-utils/libubifs/debug.c +++ b/ubifs-utils/libubifs/debug.c @@ -51,7 +51,7 @@ static const char *get_key_hash(int hash) } } -static const char *get_key_type(int type) +const char *ubifs_get_key_name(int type) { switch (type) { case UBIFS_INO_KEY: @@ -102,23 +102,25 @@ const char *dbg_snprintf_key(const struct ubifs_info *c, case UBIFS_INO_KEY: len -= snprintf(p, len, "(%lu, %s)", (unsigned long)key_inum(c, key), - get_key_type(type)); + ubifs_get_key_name(type)); break; case UBIFS_DENT_KEY: case UBIFS_XENT_KEY: len -= snprintf(p, len, "(%lu, %s, %#08x)", (unsigned long)key_inum(c, key), - get_key_type(type), key_hash(c, key)); + ubifs_get_key_name(type), + key_hash(c, key)); break; case UBIFS_DATA_KEY: len -= snprintf(p, len, "(%lu, %s, %u)", (unsigned long)key_inum(c, key), - get_key_type(type), key_block(c, key)); + ubifs_get_key_name(type), + key_block(c, key)); break; case UBIFS_TRUN_KEY: len -= snprintf(p, len, "(%lu, %s)", (unsigned long)key_inum(c, key), - get_key_type(type)); + ubifs_get_key_name(type)); break; default: len -= snprintf(p, len, "(bad key type: %#08x, %#08x)", diff --git a/ubifs-utils/libubifs/debug.h b/ubifs-utils/libubifs/debug.h index 4b475a0..c4aa59d 100644 --- a/ubifs-utils/libubifs/debug.h +++ b/ubifs-utils/libubifs/debug.h @@ -84,6 +84,7 @@ static inline int dbg_is_chk_index(__unused const struct ubifs_info *c) { return 0; } /* Dump functions */ +const char *ubifs_get_key_name(int type); const char *ubifs_get_type_name(int type); const char *dbg_ntype(int type); const char *dbg_cstate(int cmt_state); -- cgit v1.2.3