aboutsummaryrefslogtreecommitdiff
path: root/ubifs-utils/fsck.ubifs/check_files.c
AgeCommit message (Collapse)Author
2024-11-11fsck.ubifs: Check and create the root dirZhihao Cheng
This is the 15/18 step of fsck. Check whether the root dir is existed, create a new one if it is not found. This step makes sure that filesystem can be mounted successful. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-11-11fsck.ubifs: Check whether the TNC is emptyZhihao Cheng
This is the 11/18 step of fsck. Check whether the TNC is empty, turn to rebuild_fs if it is not found. Can we recreate a new root dir to avoid empty TNC? The answer is no, lpt fixing should be done before creating new entry, but lpt fixing needs a committing before new dirty data generated to ensure that bud data won't be overwritten(bud LEB could become freeable after replaying journal, corrected lpt may treat it as a free one to hold new data, see details in space checking & correcting step). Then we have to create the new root dir after fixing lpt and a committing, znode without children(empty TNC) maybe written on disk at the moment of committing, which corrupts the UBIFS image. So we choose to rebuild the filesystem if the TNC is empty, this case is equivalent to corrupted TNC. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-11-11fsck.ubifs: Check and handle unreachable filesZhihao Cheng
This is the 9/18 step of fsck. Check and handle unreachable files, the checking rule is same as rebuild mode which has been implemented in file_is_reachable, but the methods of handling are different: 1. Move unreachable regular file into disconnected list, let subsequent steps to handle them with lost+found. 2. Delete unreachable non-regular file. 3. Delete unreachable directory entries. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-11-11fsck.ubifs: Check and handle invalid filesZhihao Cheng
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>
2024-11-11fsck.ubifs: Update files' size for check modeZhihao Cheng
This is the 7/18 step of fsck. Update files' size according to size tree for check mode, now all files are updated after replaying journal. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-11-11fsck.ubifs: Ensure that TNC LEB can be scanned successfulZhihao Cheng
This is the second part of 6/18 step in fsck. Add an extra checking for non-check mode while traversing TNC, make sure that all LEBs(contains TNC) can be scanned successful. There could be following steps and possible errors: Step 2. Scan all LEBs(contain TNC), remove TNC branch which points to corrupted LEB. a. corrupted node is found by scanning: If current node is index node, danger mode with rebuild_fs and normal mode with 'yes' answer will turn to rebuild filesystem, other modes will exit; If current node is non-index node, danger mode and normal mode with 'yes' answer will remove all TNC branches which point to the corrupted LEB, other modes will exit. b. LEB contains both index and non-index nodes: danger mode with rebuild_fs and normal mode with 'yes' answer will turn to rebuild filesystem, other modes will exit. This is a preparation for space checking, which means that ubifs_scan will always succeed when check properties for any TNC LEBs. We do this before checking files(step 7) & extracting dentry tree(step 8), nodes cannot be dropped(which may corrupted file and make file inconsistent again) when scanning corrupted as long as the dentry tree is extracted. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-11-11fsck.ubifs: Traverse TNC and construct filesZhihao Cheng
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 <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>