diff options
author | Zhihao Cheng <chengzhihao1@huawei.com> | 2024-11-11 17:08:04 +0800 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2024-11-11 10:32:46 +0100 |
commit | c5ca3893ea854e8d8b5916bc492db8523db70122 (patch) | |
tree | 5817c717593cfb28fc54eb8991f541ea88429bcc /ubifs-utils/fsck.ubifs/fsck.ubifs.c | |
parent | e708c6f33e51d9cd5565e16c76af2c4180341499 (diff) |
fsck.ubifs: Check and handle invalid files
This is the 8/18 step of fsck. Check and handle invalid files, the
checking rule is same as rebuild mode which has been implemented in
file_is_valid, but the methods of handling are different:
1. Move unattached(file has no dentries) regular file into disconnected
list, let subsequent steps to handle them with lost+found.
2. Make file type be consistent between inode, detries and data nodes by
deleting dentries or data blocks.
3. Delete file for other invalid cases(eg. file has no inode).
Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'ubifs-utils/fsck.ubifs/fsck.ubifs.c')
-rw-r--r-- | ubifs-utils/fsck.ubifs/fsck.ubifs.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/ubifs-utils/fsck.ubifs/fsck.ubifs.c b/ubifs-utils/fsck.ubifs/fsck.ubifs.c index ec42fa7..ac94ba4 100644 --- a/ubifs-utils/fsck.ubifs/fsck.ubifs.c +++ b/ubifs-utils/fsck.ubifs/fsck.ubifs.c @@ -369,6 +369,7 @@ static int init_fsck_info(struct ubifs_info *c, int argc, char *argv[]) c->private = fsck; FSCK(c)->mode = mode; + INIT_LIST_HEAD(&FSCK(c)->disconnected_files); c->assert_failed_cb = fsck_assert_failed; c->set_failure_reason_cb = fsck_set_failure_reason; c->get_failure_reason_cb = fsck_get_failure_reason; @@ -445,6 +446,15 @@ static int do_fsck(void) update_files_size(c); + log_out(c, "Check and handle invalid files"); + err = handle_invalid_files(c); + if (err) { + exit_code |= FSCK_ERROR; + goto free_used_lebs; + } + + destroy_file_list(c, &FSCK(c)->disconnected_files); +free_used_lebs: kfree(FSCK(c)->used_lebs); destroy_file_tree(c, &FSCK(c)->scanned_files); return err; @@ -484,6 +494,7 @@ int main(int argc, char *argv[]) /* * Step 6: Traverse tnc and construct files * Step 7: Update files' size + * Step 8: Check and handle invalid files */ err = do_fsck(); if (err && FSCK(c)->try_rebuild) { |