From e789f23a78be047f0894c4476aa0b6fde369cf7a Mon Sep 17 00:00:00 2001 From: Zhihao Cheng Date: Mon, 11 Nov 2024 17:01:11 +0800 Subject: fsck.ubifs: rebuild_fs: Filter invalid files This is the 4/12 step of rebuilding. Filter out invalid files and drop them, for example: 1. File has no inode node or inode nlink is zero 2. Nonconsistent file type between inode node and dentry nodes 3. File has no dentry nodes(excepts '/') 4. Encrypted file has no xattr information 5. Non regular file has data nodes 6. Directory/xattr file has more than one dentries 7. Xattr file has no host inode, or the host inode is a xattr ... Valid xattr file will be inserted into corresponding host file's subtree. Signed-off-by: Zhihao Cheng Signed-off-by: David Oberhollenzer --- ubifs-utils/libubifs/journal.c | 4 ++-- ubifs-utils/libubifs/ubifs.h | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'ubifs-utils/libubifs') diff --git a/ubifs-utils/libubifs/journal.c b/ubifs-utils/libubifs/journal.c index 37dc3f0..d3fdb76 100644 --- a/ubifs-utils/libubifs/journal.c +++ b/ubifs-utils/libubifs/journal.c @@ -404,10 +404,10 @@ static void finish_reservation(struct ubifs_info *c) } /** - * get_dent_type - translate VFS inode mode to UBIFS directory entry type. + * ubifs_get_dent_type - translate VFS inode mode to UBIFS directory entry type. * @mode: inode mode */ -static int get_dent_type(int mode) +int ubifs_get_dent_type(int mode) { switch (mode & S_IFMT) { case S_IFREG: diff --git a/ubifs-utils/libubifs/ubifs.h b/ubifs-utils/libubifs/ubifs.h index 21b0ce0..e6de7ce 100644 --- a/ubifs-utils/libubifs/ubifs.h +++ b/ubifs-utils/libubifs/ubifs.h @@ -1611,6 +1611,9 @@ int ubifs_log_end_commit(struct ubifs_info *c, int new_ltail_lnum); int ubifs_log_post_commit(struct ubifs_info *c, int old_ltail_lnum); int ubifs_consolidate_log(struct ubifs_info *c); +/* journal.c */ +int ubifs_get_dent_type(int mode); + /* budget.c */ int ubifs_budget_space(struct ubifs_info *c, struct ubifs_budget_req *req); void ubifs_release_budget(struct ubifs_info *c, struct ubifs_budget_req *req); -- cgit v1.2.3