[PATCH mtd-utils 2/2] fsck.ubifs: use the appropriate format specifiers for ino_t and loff_t
Zhihao Cheng
chengzhihao1 at huawei.com
Fri Nov 14 00:54:28 PST 2025
在 2025/11/13 16:32, Yuta Hayama 写道:
> On architectures such as armv7-a, ino_t is 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
The ubifs inode number won't exceed 4 bytes, and the bytewidth of
'ino_t' varies on different machines. How about changing debug message
like '%lu, (unsigned long)inum'?
>
> 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 long and output using "%lld". Apply the same fix for loff_t.
>
More information about the linux-mtd
mailing list