summaryrefslogtreecommitdiff
path: root/ubifs-utils/libubifs/dir.c
AgeCommit message (Collapse)Author
3 daysfsck.ubifs: fix platform dependant ino_t and loff_t formattingYuta Hayama
On architectures such as armv7-a, ino_t and loff_t are unsigned long long rather than unsigned long. In such cases, the printf format specifier "%lu" is not appropriate and causes an incorrect address offset. mtd-utils/ubifs-utils/fsck.ubifs/problem.c:224 log_out(c, "problem: %s, ino %lu, unreachable dentry %s, type %s%s", problem->desc, ifp->file->inum, c->encrypted && !ifp->file->ino.is_xattr ? "<encrypted>" : dent_node->name, ubifs_get_type_name(dent_node->type), key_type(c, &dent_node->key) == UBIFS_XENT_KEY ? "(xattr)" : ""); fsck.ubifs[484] (/dev/ubi0_0,danger mode): problem: Dentry is unreachable, ino 917, unreachable dentry (null), type checksum_typefile Furthermore, running fsck.ubifs with the --debug=4 option will almost certainly cause a SEGV at the following point. mtd-utils/ubifs-utils/fsck.ubifs/check_files.c:103 dbg_fsck("construct file(%lu) for %s node, TNC location %d:%d, in %s", inum, ubifs_get_key_name(key_type(c, key)), sn->lnum, sn->offs, c->dev_name); To ensure functionality regardless of environment, cast ino_t to unsigned long, since it will never be more than 4 bytes. For loff_t, use %lld and cast accordingly. Signed-off-by: Yuta Hayama <hayama@lineo.co.jp> Signed-off-by: Tomas Alvarez Vanoli <tomas.alvarez-vanoli@hitachienergy.com> Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-11-11ubifs-utils: libubifs: Support some file operationsZhihao Cheng
Add some file operations, such as ubifs_lookup, ubifs_mkdir, etc., this is a preparation for recovering disconnected files or root dir in fsck. File writing operations are based on the journal subsystem, generated dirty data depends on a new commit in subsequent steps to update disk content. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-11-11ubifs-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>
2024-11-11ubifs-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>