aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
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>
8 daysubifs-utils: Add linux hexdump implementations libZhihao Cheng
Add linux hexdump implementations lib, because function print_hex_dump() 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>
8 daysubifs-utils: Add implementations for linux kernel printing functionsZhihao Cheng
Add implementations for linux kernel printing functions, because these functions(eg. pr_debug, pr_err, etc.) are widely used in UBIFS linux kernel libs. No need to define multiple levels in dbg_msg for debuging, just replace dbg_msg with pr_debug. Now, there are five levels of printing messages: 0 - none 1 - error message 2 - warning message [default] 3 - notice message 4 - debug message 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 daysubifs-utils: Add sorting implementationsZhihao Cheng
Add sorting implementations, because the sorting function 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>
8 daysubifs-utils: Add rwsem implementationsZhihao Cheng
Add rwsem implementations, because there are some rwsems (eg. c->commit_sem) used in UBIFS linux kernel libs. The rwsem is implemented based on pthread mutex. 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 daysubifs-utils: Add mutexlock implementationsZhihao Cheng
Add mutexlock implementations, because there are some mutexlocks (eg. c->tnc_mutex, c->log_mutex) used in UBIFS linux kernel libs. The mutexlock is implemented based on pthread mutex. 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 daysubifs-utils: Add spinlock implementationsZhihao Cheng
Add spinlock implementations, because there are some spinlocks (eg. c->cnt_lock, c->buds_lock) used in UBIFS linux kernel libs. The spinlock is implemented based on pthread mutex. 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 daysubifs-utils: Add bit operations implementationsZhihao Cheng
Add bit operations implementations, because there are some bit operations (eg. __set_bit, test_bit) 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 daysubifs-utils: Add atomic implementationsZhihao Cheng
Add atomic implementations, because there are some atomic operations (eg. atomic_long_xxx) 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 daysubifs-utils: Add linux kernel memory allocation implementationsZhihao Cheng
Add linux kernel memory allocation implementations, because there are many memory allocations(eg. kmalloc, kzalloc) 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 daysubifs-utils: Add linux kernel error conversion definitionsZhihao Cheng
Add linux kernel error conversion definitions, because there are many error type conversions(eg. PTR_ERR, ERR_PTR) 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 daysubifs-utils: Add linux type definitionsZhihao Cheng
Add linux type definitions, because there are many types (eg. u8/u16/u64) used in UBIFS linux kernel libs. Besides move type conversions (eg. cpu_to_le16, cpu_to_le32, etc.) into type definitions header file. 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 daysubifs-utils: Add compiler attributes implementationsZhihao Cheng
Add compiler attributes implementations, such as __packed, __unused, __const, etc., which could be used in linux kernel libs. Besides, change some existing attributes into linux kernel style. 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 daysubifs-utils: Import UBIFS libs from linux kernelZhihao Cheng
Import UBIFS libs from linux kernel. Next patches will replace ubifs related source code with implementation of linux kernel, which makes userspace implementation be same with linux kernel, then fsck.ubifs can resuse the code. Notice: lpt.c is modified with [1] applied. ubifs.h and orphan.c are modified with [2] applied, journal.c is modified with [3] reverted( because fsck runs in a single thread, so waitqueue is not needed to be implemented in userspace.). [1] https://lore.kernel.org/linux-mtd/20231228014112.2836317-13-chengzhihao1@huawei.com/ [2] https://lore.kernel.org/linux-mtd/20240410073751.2522830-1-chengzhihao1@huawei.com/ [3] https://lore.kernel.org/linux-mtd/20240122063103.359501-1-chengzhihao1@huawei.com/ Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysubifs-utils: Extract UBI opening/closing/volume_check_empty functions into a ↵Zhihao Cheng
new source file Move UBI opening/closing/volume_check_empty functions into common/super.c. These functions will be used in fsck. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysubifs-utils: Add 'dev_fd' and 'libubi' into 'ubifs_info' structureZhihao Cheng
Embed new members 'dev_fd' and 'libubi' into ubifs_info structure, so that global variable 'ubi', 'out_fd' and 'out_ubi' could be removed from mkfs.ubifs.c. Besides, add parameter in check_volume_empty(). Next patch will extract UBI opening/closing/check_volume_empty functions into a new source file, these functions will be used in fsck. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysubifs-utils: Add 'dev_name' into 'ubifs_info' structureZhihao Cheng
Embed new member 'dev_name' into 'ubifs_info' structure, then global variable 'output' can be removed from mkfs.ubifs.c. Next patches will import UBIFS libs from linux kernel, which could print messages that contain device information, so this patch can distinguish different devices according to messages. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysubifs-utils: Move 'debug_level' into ubifs_info structureZhihao Cheng
Embed new member 'debug_level' into 'ubifs_info' structure, then global variable 'debug_level' can be removed from mkfs.ubifs.c. Next patches will import UBIFS libs from linux kernel, which could print messages with different levels, then 'debug_level' can be used to control which level messages should be printed. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysubifs-utils: Clean up error message printing functionsZhihao Cheng
Functions 'err_msg' and 'sys_err_msg' are almost same with 'errmsg' and 'sys_errmsg', since 'errmsg' and 'sys_errmsg' can print programe name, so replace error message printing functions (ubifs-utils) with common lib functions(include/common.h). Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysubifs-utils: Define PROGRAM_NAME as variableZhihao Cheng
PROGRAM_NAME is defined as a const string "mkfs.ubifs", which won't be suitable for fsck.ubifs. Add 'program_name' member in ubifs_info structure, define PROGRAM_NAME as ubifs_info.program_name. Then, error messages will display right program name if fsck.ubifs is supported. Besides, add 'program_type' member in ubifs_info structure to identify which current program type is, without comparing program name. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysubifs-utils: Decouple mkfs.ubifs.h out of other modulesZhihao Cheng
Header file mkfs.ubifs.h is included in other modules(eg. compr.c, lpt.c, fscrypt.h, sign.c), decouple it out of other modules. There are two parts in mkfs.ubifs.h: 1. common functions, for example dbg_msg, err_msg and write_leb, move these functions into common/defs.h and common/ubifs.h. 2. devtable related definations, move them into a new header file common/devtable.h. Splitting common functions from mkfs.ubifs.h is also a preparation for importing libubifs(from linux kernel) to replace current UBIFS libs. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
8 daysubifs-utils: Split common source files from mkfs.ubifsZhihao Cheng
Split common source files into common dir from mkfs.ubifs, this is a preparation for importing libubifs(from linux kernel) to replace current UBIFS libs. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-10-08mkfs.jffs2: fix segfault when parsing dev tableRosen Penev
Make sure that the first item is parsed correctly. One issue otherwise is a null pointer dereference when the first item is not found. Signed-off-by: Rosen Penev <rosenp@gmail.com> Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-10-08mtd-tests: flash_speed: Benchmark continuous readsMiquel Raynal
Currently the read throuput test tries: - 1 page - 2 pages - 1 block (64 or more pages, usually) But it might be interesting to see how the speed gradually increases, eg. testing all number of pages from 1 to maybe 16, and then arbitrarilly 32 and 64. Let's add a -C parameter to enable this additional test. The 2-page read/write tests are also moved under this new option. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-10-08mtd-tests: flash_speed: Drop read_eraseblock_by_page()Miquel Raynal
The read_eraseblock_by_2pages() has been generalized so it became read_eraseblock_by_npages(), but there is no limitation (besides 0) regarding the number of pages. Hence, drop the _by_page() helper and replace it with the _by_npages(), using 'npages = 1'. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-10-08mtd-tests: flash_speed: Generalize read_eraseblock_by_2pages()Miquel Raynal
Right now there are only 2 pages that may be read continuously, but why not trying more? At least when the continuous feature is out, this type of benchmarking will be interesting. In order to facilitate later additions, lets make this helper more generic and accept a global 'npages' variable as parameter (because this function is called in a macro, it is simpler like that). Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-10-08mtd-tests: flash_speed: Clarify the number of pages in each set while measuringMiquel Raynal
So far speed calculations have only be done 1 page at a time or 2 pages at a time in a block; so basically all the block was always read because all blocks are multiple of 2. But in the future, if we want to extend the number of pages in a single read, the final number of pages actually read might be less than an erase block size, hence failing the throuput calculations. Make the number of pages in a set explicit. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-10-08mtd-tests: flash_speed: Drop an apparently useless blockMiquel Raynal
I know no device without a multiple of 2 number of pages in each block. Even though it might be the case, it is clearly not a big deal and we don't really care about reading the last page, we are doing a speed benchmark; so as long as the throughput calculation knows how much data has been read it's fine. Eitherway, I don't think we ever have fallen in this block because we would read the content of two pages (so one past the block) and put it in a page-wide buffer, which would probably lead to an out-of-bound abort. Just drop the block. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-10-08mtd-tests: nandbiterrs: Add support for testing continuous readsMiquel Raynal
In order to trigger a continuous read, the user needs to request at least two pages at the same time. So far the tool would only read single pages, so let's extend its capabilities to test continuous read output when the -c option is passed. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-10-08mtd-tests: nandbiterrs: Store the chunks size in an intermediate variableMiquel Raynal
'pagesize' is used for two purposes: - accessing the size of a page - getting the size of the test buffer, which happen to be the size of a page for now. Use an intermediate variable when getting the size of the test buffer, as we will later increase its size. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-10-08nand-utils: nanddump: Add support for testing continuous readsMiquel Raynal
In order to trigger a continuous read, the user needs to request more than one data page. So far the tool would split the length into page chunks. This is no longer the case when the -C option is passed (-c is already used for the canonical output style). Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-10-08nand-utils: nanddump: Explicitely use the page size when relevantMiquel Raynal
Using bs when skipping the bad sector is abusive as what we want is using the size of a block and the size of a page. The fact that bs currently is the size of a page is misleading here, has I intend to make this amount grow. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-10-08nand-utils: nanddump: Use a specific variable for the buffer sizeMiquel Raynal
The read buffer size happen to be as big as the bs variable, but this is going to change. When accessing the buffer size, use a specific variable instead. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-09-25Release mtd-utils-2.2.1v2.2.1David Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-09-25Update CHANGELOGDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-09-25mtd-utils: Extract rbtree implementation to common libZhihao Cheng
Current rbtree implementation code is put under jffs utils, extract it into common lib, and add more rbtree operations(eg. rb_first_postorder, rb_next_postorder, etc.). 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>
2024-09-25mtd-utils: Extract list implementation to common lib and add list_sort supportZhihao Cheng
Current list implementation code is put under jffs utils, extract it into common lib, and add more list operations(eg. list_move, list_splice, etc.). Besides, add list sorting support in new source file lib/list_sort.c. 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>
2024-09-25mkfs.ubifs: Fix memleak for 'output' in error pathsZhihao Cheng
The 'output' is allocated in get_options(), don't forget to free it in error paths, move 'output' freeing out of close_target(), which simplifies the logic of close_target(). Fixes: 36ec51948e0ec ("Add mkfs.ubifs") Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-09-25mkfs.ubifs: Fix missed closing out_fdZhihao Cheng
Closing 'out_fd' is missed in handling paths in open_target(), fix it by adding closing operations before returning. Fixes: a48340c335dab ("mkfs.ubifs: use libubi to format UBI volume") Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-09-25mkfs.ubifs: Close libubi in error handling pathsZhihao Cheng
The libubi could be opened in get_options(), don't forget to close it in error handling paths in main(). Also close libubi in error handling paths in open_ubi(). To implement that, extract libubi_close() into a new helper function close_ubi(). Besides, invoke crypto_cleanup() in error handling paths in main(). Fixes: a48340c335dab ("mkfs.ubifs: use libubi to format UBI volume") Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>