From aa2b50294710caba39c6b01ce99f2f6993a42ed2 Mon Sep 17 00:00:00 2001 From: Zhihao Cheng Date: Mon, 11 Nov 2024 17:01:02 +0800 Subject: fsck.ubifs: Add fsck support Add basic process code for fsck.ubifs. There are following modes for fsck: 1. normal mode: Check the filesystem, ask user whether or not to fix the problem as long as inconsistent data is found during fs checking. 2. safe mode: Check and safely repair the filesystem, if there are any data dropping operations needed by fixing, fsck will fail. 3. danger mode: Answer 'yes' to all questions. There two sub modes: a) Check and repair the filesystem according to TNC, data dropping will be reported. If TNC/master/log is corrupted, fsck will fail. b) Check and forcedly repair the filesystem according to TNC, turns to rebuild filesystem if TNC/master/log is corrupted. Always make fsck succeed. 4. check mode: Make no changes to the filesystem, only check the filesystem. 5. rebuild mode: Scan entire UBI volume to find all nodes, and rebuild filesystem, always make fsck success. Signed-off-by: Zhihao Cheng Signed-off-by: David Oberhollenzer --- ubifs-utils/libubifs/ubifs.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'ubifs-utils/libubifs/ubifs.h') diff --git a/ubifs-utils/libubifs/ubifs.h b/ubifs-utils/libubifs/ubifs.h index 2af9d87..babaae8 100644 --- a/ubifs-utils/libubifs/ubifs.h +++ b/ubifs-utils/libubifs/ubifs.h @@ -1026,6 +1026,9 @@ struct ubifs_budg_info { * * @new_ihead_lnum: used by debugging to check @c->ihead_lnum * @new_ihead_offs: used by debugging to check @c->ihead_offs + * + * @private: private information related to specific situation, eg. fsck. + * @assert_failed_cb: callback function to handle assertion failure */ struct ubifs_info { struct ubifs_sb_node *sup_node; @@ -1248,6 +1251,9 @@ struct ubifs_info { int new_ihead_lnum; int new_ihead_offs; + + void *private; + void (*assert_failed_cb)(const struct ubifs_info *c); }; extern atomic_long_t ubifs_clean_zn_cnt; @@ -1684,6 +1690,8 @@ int open_ubi(struct ubifs_info *c, const char *node); void close_ubi(struct ubifs_info *c); int open_target(struct ubifs_info *c); int close_target(struct ubifs_info *c); +int ubifs_open_volume(struct ubifs_info *c, const char *volume_name); +int ubifs_close_volume(struct ubifs_info *c); int check_volume_empty(struct ubifs_info *c); void init_ubifs_info(struct ubifs_info *c, int program_type); int init_constants_early(struct ubifs_info *c); -- cgit v1.2.3