aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
8 daysfsck.ubifs: Recover isizeZhihao Cheng
This is the 5/18 step of fsck. Recover isize. There could be following steps and possible errors: Step 1. Traverse size tree, lookup corresponding inode from TNC a. corrupted node searched from TNC: skip node 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. Step 2. update isize for inode. Keep <inum, isize> in size tree for check mode, update inode node in place for other modes. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysfsck.ubifs: Consolidate logZhihao Cheng
This is the 4/18 step of fsck. Consolidate log to ensure enough space in log area. There could be following possible errors: 1. corrupted scanning data in log area: 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>
8 daysfsck.ubifs: Handle orphan nodesZhihao Cheng
This is the 3/18 step of fsck. Handle orphan nodes, update TNC & LPT. There could be following steps and possible errors: Step 1. scan orphan LEB, get all orphan nodes a. corrupted scanning data in orphan area: danger mode and normal mode with 'yes' answer will drop orphan LEB, other modes will exit. Step 2. parse orphan node, find the original inode for each inum a. corrupted node searched from TNC: skip node 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. Step 4. remove inode for each inum, update TNC & LPT a. 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. b. corrupted lpt: Set %FR_LPT_CORRUPTED for lpt status. Ignore the error. c. incorrect lpt: Set %FR_LPT_INCORRECT for lpt status. Ignore the error. d. If lpt status is not empty, skip updating lpt. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysfsck.ubifs: Replay journalZhihao Cheng
This is the 2/18 step of fsck. Replay journal, update TNC & LPT. There could be following steps and possible errors: Step 1. scan log LEB, get all bud LEBs a. corrupted scanning data in log area: danger mode with rebuild_fs and normal mode with 'yes' answer will turn to rebuild filesystem, other modes will exit. Step 2. scan bud LEBs, get all nodes a. corrupted scanning data in bud LEB: danger mode and normal mode with 'yes' answer will drop bud LEB and set %FR_LPT_INCORRECT for lpt status, other modes will exit. Step 3. apply nodes, record latest isize into size_tree Step 4. apply nodes, update TNC & LPT a. corrupted data searched from TNC: skip node and set %FR_LPT_INCORRECT lpt status 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. c. corrupted lpt: Set %FR_LPT_CORRUPTED for lpt status. Ignore the error. d. incorrect lpt: Set %FR_LPT_INCORRECT for lpt status. Ignore the error. e. If lpt status is not empty, skip updating lpt. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysfsck.ubifs: Read master node & init lptZhihao Cheng
This is the 1/18 step of fsck. Read and check master node, init lpt. There could be following errors: 1. corrupted scanning data in master area or invalid master node: danger mode with rebuild_fs and normal mode with 'yes' answer will turn to rebuild filesystem, other modes will exit. 2. incorrect space statistics in master node: Set %FR_LPT_INCORRECT for for lpt status. Ignore the error. 3. corrupted lpt: Set %FR_LPT_CORRUPTED for lpt status. Ignore the error. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysfsck.ubifs: rebuild_fs: Write master nodeZhihao Cheng
This is the 12/12 step of rebuilding. Since all meta areas are ready, master node can be updated. After this step, a consistent UBIFS image can be mounted, and it should pass all tests from chk_fs, chk_general, chk_index, chk_lprops and chk_orphans. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysfsck.ubifs: rebuild_fs: Clean up log and orphan areaZhihao Cheng
This is the 11/12 step of rebuilding. Clean up log and orphan area, all nodes have been recovered, these two areas should be cleared, otherwise old content in journal/orphan could be replayed in next mounting. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysfsck.ubifs: rebuild_fs: Build LPTZhihao Cheng
This is the 10/12 step of rebuilding. All LEBs' properties can be calculated in previous steps according to all nodes' position, then construct LPT just like mkfs does, and write LPT on flash. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysfsck.ubifs: rebuild_fs: Build TNCZhihao Cheng
This is the 9/12 step of repairing. Construct TNC according to scanned files, and write TNC on flash, just like mkfs does. Building TNC can effectively solve many failed mounting problems caused by bad TNC (eg. bad node pointed by TNC, bad key order in znode, etc.). Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysfsck.ubifs: rebuild_fs: Create new root dir if there are no scanned filesZhihao Cheng
This is a preparation for building TNC, there must at least one file in filesystem, if not, just create new root dir. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysfsck.ubifs: rebuild_fs: Re-write dataZhihao Cheng
This is the 8/12 step of rebuilding. Re-write data. Read data from LEB and write back data, make sure that all LEB is ended with empty data(0xFF). It will prevent failed gc scanning in next mounting. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysfsck.ubifs: rebuild_fs: Record used LEBsZhihao Cheng
This is the 7/12 step of rebuilding. Record used LEBs which may hold useful nodes, then left unused LEBs could be taken for storing new index tree. Notice, LEB that contains effective nodes on deleted trees in step 1 is regarded as used. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysfsck.ubifs: rebuild_fs: Check and correct files' informationZhihao Cheng
This is the 6/12 step of rebuilding. Correct the file information. Traverse all files and calculate information (nlink, size, xattr_cnt, etc.) for each file just like check_leaf() does, correct inode node based on the calculated information. Now, all files are consistent, and UBIFS will pass chk_fs after mounting. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysfsck.ubifs: rebuild_fs: Extract reachable directory entries treeZhihao Cheng
This is the 5/12 step of rebuilding. Extract reachable directory entries tree. Make sure that all files can be searched from '/', unreachable file is deleted. So, all files can be accessible in userspace after reparing. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysfsck.ubifs: rebuild_fs: Filter invalid filesZhihao Cheng
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 <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysfsck.ubifs: rebuild_fs: Add valid nodes into fileZhihao Cheng
This is the 3/12 step of rebuilding. Generate file according to left valid inode nodes and dentry nodes. Based on the results from step 2, it is easy to understand: Step 2 has done: valid_inos - del_inos = left_inos valid_dents - del_dents = left_dents Step 3 should do: Traverse left_inos and left_dents, insert inode/dentry nodes into corresponding file. After that, all files are generated by scanning, the next thing to do is dropping invalid files(eg. nonconsistent file type between inode node and dentry nodes, file has no dentry nodes(excepts '/'), encrypted file has no xattr information, etc.), which will be done in next step. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysfsck.ubifs: rebuild_fs: Remove deleted nodes from valid node treeZhihao Cheng
This is the 2/12 step of rebuilding. Traverse nodes from del_inos and del_dents trees, remove inode nodes and dentry nodes with smaller sqnum from valid trees. This step handles deleting case, for example, file A is deleted, deleted inode node and deleted dentry node are written, if we ignore the deleted nodes, file A can be recovered after rebuilding because undeleted inode node and undeleted dentry node can be scanned. There's an exception, if deleted inode node and deleted dentry node are reclaimed(by gc) after deletion, file A is recovered. UBIFS rebuild_fs cannot solve it, because the real existence information of nodes depends on TNC, but TNC should not be depended for UBIFS rebuild_fs. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysfsck.ubifs: Add rebuilding filesystem supportZhihao Cheng
Add rebuilding filesystem support. This is the 1/12 step of rebuilding. Collect files, valid inode nodes, deleted inode nodes, valid dentry nodes and deleted dentry nodes in kinds of trees by scanning nodes from flash. Corrupted nodes(eg. incorrect crc, bad inode size, bad dentry name length, etc.) are dropped during scanning. Larger sqnum node is picked when more than 1 nodes with same index. In this step, trun node and data nodes are put into corresponding file, inode/dentry nodes are put into four trees: valid_inos(nlink != 0), del_inos(nlink is 0), valid_dents(inum != 0), del_dents(inum is 0). Next step will process above four trees to deal deletion situations. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysfsck.ubifs: Add file organization realizationZhihao Cheng
In order to check the consistency of each file and the reachability of the whole dentry tree, fsck orginizes all nodes into files. And the final recovered file(xattr is treated as a file) is organized as: (rbtree, inum indexed) / \ file1 file2 / \ file3 file4 file { inode node // each file has 1 inode node dentry (sub rb_tree, sqnum indexed) // '/' has no dentries, // otherwise at least 1 // dentry is required. trun node // the newest one truncation node data (sub rb_tree, block number indexed) // Each file may have 0 // or many data nodes xattrs (sub rb_tree, inum indexed) // Each file may have 0 or // many xattr files } Each file from file rb_tree is constructed by scanning nodes(eg. inode, dentry, etc.) from the TNC or the UBI volume. File's xattrs will be initialized in subsequent steps. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysfsck.ubifs: Add node parsing functionsZhihao Cheng
Add parsing functions for each type of nodes, which will be used for checking the validity of raw node data while reading from TNC or scanning from UBIFS logical erase block. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysfsck.ubifs: Load filesystem information from UBI volumeZhihao Cheng
Load filesystem information from UBI volume (Similar to UBIFS mounting process), initialize kinds of buffers and read superblock. This is the base step for both fsck and rebuild_fs. Subsequent pacthes will complete this step by adding more steps(eg. read master, replay journal, etc.) which are only used in fsck. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysfsck.ubifs: Distinguish reasons when certain failures happenZhihao Cheng
Read failure caused by scanning corrupted data or invalid data members should be identified, because fsck can handle it. Updating lp failure caused by bad space statistics should be identified too, because fsck can handle it. Add eight callback functions to implement it for fsck: 1. set_failure_reason_callback: Record failure reasons when reading or parsing node failed, there are four reasons: a. FR_DATA_CORRUPTED: scanning corrupted data or invalid nodes found b. FR_TNC_CORRUPTED: invalid index nodes c. FR_LPT_CORRUPTED: invalid pnode/nnode d. FR_LPT_INCORRECT: invalid space statistics or invalid LEB properties 2. get_failure_reason_callback: get failure reasons 3. clear_failure_reason_callback: Clear the error which is caused by above reasons. 4. test_and_clear_failure_reason_callback: Check and clear the error which is caused by above reasons, if so, fsck will handle it according to specific situation. For example, fsck will drop data node rather than fails to return when reading failure is caused by DATA_CORRUPTED. For another example, journal replaying will continue rather than fails to return if updating lpt failure is caused by LPT_CORRUPTED. 5. set_lpt_invalid_callback: Set the invalid lpt status 6. test_lpt_valid_callback: Check whether the lpt is corrupted/incorrect, it should be invoked before updating lp, if lpt status is invalid, returns false (which means that caller should skip updating lp, because updating lp could trigger assertion failed in ubifs_change_lp). 7. can_ignore_failure_callback: Check whether the failure can be ignored, some inconsistent errors won't affect the fsck process, for example wrong space statistics can be fixed after traversing TNC, so failures caused by incorrect space statistics can be ignored. 8. handle_failure_callback: Check whether the failure can be handled, some inconsistent errors could be fixed by fsck, we have fix_problem to do that, but UBIFS needs a callback function to invoke it in common libs. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysfsck.ubifs: Add inconsistent problem handling asking functionZhihao Cheng
There are four dimensions to define the type of inconsistent problems: 1. fixable: Some inconsistent problems can't be fixed, for example corrupted superblock. Un-fixable problem will abort program. 2. must fix: Some inconsistent problems can be ignored(eg. incorrect isize), but some are not(eg. corrupted TNC), which will affect the subsequent fsck steps. 3. drop data: Some fixing methods will drop user data, which is unacceptable for safe mode. If it happens, fsck will be aborted. 4. need rebuild: Some inconsistent problems depends on rebuilding filesystem to be fixed(eg. corrupted master node, corrupted TNC). Define an asking function to handle above kinds of inconsistent problems. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysfsck.ubifs: Add fsck supportZhihao Cheng
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 <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysubifs-utils: open_ubi: Set errno if the target is not char deviceZhihao Cheng
Set errno if the target is not char device. It will be useful for fsck to print error message if open_ubi failed. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysubifs-utils: Replace ubifs related source code with linux kernel implementationZhihao Cheng
Replace ubifs related source code with the implementation of linux kernel. It makes userspace implementation be same with linux kernel, then fsck.ubifs can resuse the code. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysubifs-utils: Add descriptions for new lib files in libubifs/READMEZhihao Cheng
There are many linux kernel source files have been adapted into ubifs-utils, add descriptions for these source files in README. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysubifs-utils: Move ubifs-media.h in libubifsZhihao Cheng
Since ubifs-media.h is only used for ubifs-utils, move it under ubifs-utils/libubifs. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysubifs-utils: Adapt gc subsystem in libubifsZhihao Cheng
Adapt gc subsystem(find.c, gc.c, scan.c) in libubifs, compared with linux kernel implementations: 1. Adapt print_hex_dump based on implementations in hexdump.c. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysubifs-utils: Adapt orphan.c in libubifsZhihao Cheng
Adapt orphan.c in libubifs, compared with linux kernel implementations: 1. Keep the commit related implementations, because do_commit depends on these functions which will be invoked in fsck. 2. Keep the orphan replaying implementations, because fsck needs them. 3. Other implementations are removed which won't be used in mkfs/fsck. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysubifs-utils: Adapt misc.h in libubifsZhihao Cheng
Adapt misc.h in libubifs, compared with linux kernel implementations: 1. Remove some functions(eg. ubifs_compr_name, ubifs_wake_up_bgt) which won't be used in fsck/mkfs. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysubifs-utils: Adapt master.c in libubifsZhihao Cheng
Adapt master.c in libubifs, compared with linux kernel implementations: 1. Remove authentication related implementations (eg. mst_node_check_hash), authentication is not supported in fsck for now. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysubifs-utils: Adapt key.h in libubifsZhihao Cheng
Adapt key.h in libubifs, compared with linux kernel implementations: 1. Add '__unused' modifier for unused parameters to avoid compiling warnings. 2. Remove some functions(eg. lowest_dent_key, dent_key_init_flash) which won't be used in fsck/mkfs. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysubifs-utils: Adapt debug subsystem in libubifsZhihao Cheng
Adapt debug subsystem(debug.c, debug.h) in libubifs, compared with linux kernel implementations: 1. Only keep the disk data and space statistics dumping implementations, dbg_walk_index and add_size which are used by fsck, other debuging related implementations and sysfs interfaces are removed, because fsck will check fs in another way. 2. Change the behavior of ubifs_assert_failed(), make filesystem readonly when assertion is failed. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysubifs-utils: Adapt commit.c in libubifsZhihao Cheng
Adapt commit.c in libubifs, compared with linux kernel implementations: 1. Remove debug related implementations(eg. dbg_check_old_index), debug functions are not needed by fsck, because fsck will check fs in another way. 2. Remove ubifs background committing related implementations, there will be no background ubifs threads in fsck. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysubifs-utils: Adapt budget.c in libubifsZhihao Cheng
Adapt budget.c in libubifs, compared with linux kernel implementations: 1. Remove writeback related functions, there are no dirty pages/inodes for UBIFS in userspace process. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysubifs-utils: Adapt journal.c in libubifsZhihao Cheng
Adapt journal.c in libubifs, compared with linux kernel implementations: 1. Remove all ubifs_jnl_XXX functions. Only keep the basic space reservation code, fsck will add new functions for journaling operations without using linux in-memory inode/dentry. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysubifs-utils: Adapt dir.c in libubifsZhihao Cheng
Adapt dir.c in libubifs, compared with linux kernel implementations: 1. Remove all functions. Only keep an empty source file, fsck will add new functions for mkdir/link operations without using linux in-memory inode/dentry. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysubifs-utils: Adapt auth.c in libubifsZhihao Cheng
Adapt auth.c in libubifs, compared with linux kernel implementations: 1. Only keep implementations used by mkfs, other implementations are removed. 2. Adapt functions based on implementations in common/sign.c. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysubifs-utils: Adapt sb.c in libubifsZhihao Cheng
Adapt sb.c in libubifs, compared with linux kernel implementations: 1. Remove authentication related implementations (eg. authenticate_sb_node), authentication is not supported in fsck for now. 2. Remove some functions(eg. create_default_filesystem) which won't be used in fsck/mkfs. 3. Modify ubifs_read_superblock(), remove some assignments which won't be used in mkfs/fsck. 4. Apapt fixup_leb to ignore %-EBADMSG, subsequent steps will check all areas carefully. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysubifs-utils: Adapt recovery subsystem in libubifsZhihao Cheng
Adapt recovery subsystem(replay.c, recovery.c) in libubifs, compared with linux kernel implementations: 1. Remove authentication related implementations (eg. authenticate_sleb_hash), authentication is not supported in fsck for now. 2. Add explicit type conversions(const char *) to avoid compiling warnings. 3. Replace implementations of inode_fix_size() with ubifs_assert(0), authentication is not supported in fsck, so this function won't be invoked. 4. Remove unused ubifs_clean_lebs() and ubifs_write_rcvrd_mst_node(). 5. Adapt fix_unclean_leb/recover_head/fix_size_in_place to ignore %-EBADMSG, subsequent steps will check nodes in lpt/main area carefully. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysubifs-utils: Adapt log.c in libubifsZhihao Cheng
Adapt log.c in libubifs, compared with linux kernel implementations: 1. Remove debug related implementations(eg. dbg_check_bud_bytes), debug functions are not needed by fsck, because fsck will check fs in another way. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysubifs-utils: Adapt tnc subsystem in libubifsZhihao Cheng
Adapt tnc subsystem(tnc.c,tnc_misc.c,tnc_commit.c) in libubifs, compared with linux kernel implementations: 1. Remove debug related functions(eg. dbg_check_inode_size), debug functions are not needed by fsck, because fsck will check fs in another way. 2. Remove some functions(eg. ubifs_tnc_bulk_read) which won't be used in fsck/mkfs. 3. Adapt tnc_delete and ubifs_search_zbranch to handle empty TNC case, which could happen in fsck. 4. Don't skip checking the length of non-leaf index node's branch in read_znode. 5. Adapt try_read_node to ignore %-EBADMSG, subsequent steps will check nodes carefully. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysubifs-utils: Adapt lpt subsystem in libubifsZhihao Cheng
Adapt lpt subsystem(lpt.c,lprops.c,lpt_commit.c) in libubifs, compared with linux kernel implementations: 1. Remove debug related functions(eg. dbg_chk_lpt_sz, dbg_chk_pnode), some of debug functions are not needed by fsck, because fsck will check fs in another way. 2. Remove some functions(eg. ubifs_create_dflt_lpt) which won't be used in fsck/mkfs. 3. Adapt do_calc_lpt_geom() to mkfs/fsck situations. 4. Adapt calc_dflt_lpt_geom to support the mkfs tool, and export it. 5. Adapt ubifs_create_lpt() according to create_lpt(mkfs), make sure that the height of created lpt is right. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysubifs-utils: Adapt io.c in libubifsZhihao Cheng
Adapt io.c in libubifs, compared with linux kernel implementations: 1. Modify io related functions(eg. ubifs_leb_read/ubifs_leb_write, etc.), adapt them with userspace io functions lseek/read/write. 2. Remove some functions(eg. record_magic_error, ubifs_bg_wbufs_sync) which won't be used in fsck/mkfs. 3. Replce ubifs_errc with ubifs_err, because there will be no SB_SILENT options in mkfs/fsck. 4. Initiate wbuf->size as c->max_write_size. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysubifs-utils: Adapt super.c in libubifsZhihao Cheng
Adapt super.c in libubifs, compared with linux kernel implementations: 1. It contains all definitions in common/super.c(Message printing functions are replaced with linux kernel styles). 2. Remove some functions(eg. ubifs_iget, ubifs_dirty_inode) which won't be used in fsck/mkfs. 3. Remove unused variables initialization in some functions(eg. init_constants_early, init_constants_sb). Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysubifs-utils: Adapt ubifs header file in libubifsZhihao Cheng
Adapt ubifs header file in libubifs, compared with linux kernel implementations: 1. New header file contains all definitions in common/ubifs.h 2. Remove some structures(eg. ubifs_mount_opts, bu_info) and functions(eg. ubifs_sync_wbufs_by_inode, ubifs_jnl_XXX) which won't be used in fsck/mkfs. 3. Modify some authentication related functions, keep functions that mkfs may need, other functions are defined as empty. 4. Move ubifs message printing functions(ubifs_err/warn/msg) which are originally defined in misc.c into ubifs.h. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysubifs-utils: Add descriptions for new lib files in common/READMEZhihao Cheng
There are several new libs(eg. atomic, kmem, bitops. etc.) have been imported into ubifs-utils, add descriptions for these libs in README. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysubifs-utils: Add common definitions in linux kernelZhihao Cheng
Add common definitions in linux kernel, which are used in UBIFS linux kernel libs. This is a preparation for replacing implementation of UBIFS utils with linux kernel libs. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 dayslibubi: Add new interface ubi_leb_map()Zhihao Cheng
Add ubi_leb_map() implementation, it is used in UBIFS linux kernel libs. This is a preparation for replacing implementation of UBIFS utils with linux kernel libs. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>