From a505a2cc56acf493607fdf24cbf129393a0873fa Mon Sep 17 00:00:00 2001 From: Yuta Hayama Date: Fri, 13 Feb 2026 14:55:22 +0100 Subject: fsck.ubifs: fix platform dependant ino_t and loff_t formatting 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 ? "" : 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 Signed-off-by: Tomas Alvarez Vanoli Reviewed-by: Zhihao Cheng Signed-off-by: David Oberhollenzer --- ubifs-utils/fsck.ubifs/rebuild_fs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ubifs-utils/fsck.ubifs/rebuild_fs.c') diff --git a/ubifs-utils/fsck.ubifs/rebuild_fs.c b/ubifs-utils/fsck.ubifs/rebuild_fs.c index b82d728..b399b3e 100644 --- a/ubifs-utils/fsck.ubifs/rebuild_fs.c +++ b/ubifs-utils/fsck.ubifs/rebuild_fs.c @@ -697,7 +697,7 @@ static void extract_dentry_tree(struct ubifs_info *c) file = list_entry(unreachable.next, struct scanned_file, list); dbg_fsck("remove unreachable file %lu, in %s", - file->inum, c->dev_name); + (unsigned long)file->inum, c->dev_name); list_del(&file->list); destroy_file_content(c, file); rb_erase(&file->rb, tree); @@ -1097,7 +1097,7 @@ static int record_file_used_lebs(struct ubifs_info *c, struct scanned_data_node *data_node; dbg_fsck("recovered file(inum:%lu name:%s type:%s), in %s", - file->inum, get_file_name(c, file), + (unsigned long)file->inum, get_file_name(c, file), file->ino.is_xattr ? "xattr" : ubifs_get_type_name(ubifs_get_dent_type(file->ino.mode)), c->dev_name); -- cgit v1.2.3