diff options
| author | Yuta Hayama <hayama@lineo.co.jp> | 2026-02-13 14:55:22 +0100 |
|---|---|---|
| committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2026-04-13 07:32:41 +0200 |
| commit | a505a2cc56acf493607fdf24cbf129393a0873fa (patch) | |
| tree | fc5c9bce375e974413051bafee835f7767102255 /ubifs-utils/fsck.ubifs/problem.c | |
| parent | a75782ee97eb5940c865fd560d846b9a93ed9122 (diff) | |
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 ? "<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>
Diffstat (limited to 'ubifs-utils/fsck.ubifs/problem.c')
| -rw-r--r-- | ubifs-utils/fsck.ubifs/problem.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/ubifs-utils/fsck.ubifs/problem.c b/ubifs-utils/fsck.ubifs/problem.c index 916c976..edb5f57 100644 --- a/ubifs-utils/fsck.ubifs/problem.c +++ b/ubifs-utils/fsck.ubifs/problem.c @@ -147,7 +147,7 @@ static void print_problem(const struct ubifs_info *c, { const struct invalid_file_problem *ifp = (const struct invalid_file_problem *)priv; - log_out(c, "problem: %s, ino %lu", problem->desc, ifp->file->inum); + log_out(c, "problem: %s, ino %lu", problem->desc, (unsigned long)ifp->file->inum); break; } case FILE_HAS_INCONSIST_TYPE: @@ -156,7 +156,7 @@ static void print_problem(const struct ubifs_info *c, const struct scanned_dent_node *dent_node = (const struct scanned_dent_node *)ifp->priv; log_out(c, "problem: %s, ino %lu, inode type %s%s, dentry %s has type %s%s", - problem->desc, ifp->file->inum, + problem->desc, (unsigned long)ifp->file->inum, ubifs_get_type_name(ubifs_get_dent_type(ifp->file->ino.mode)), ifp->file->ino.is_xattr ? "(xattr)" : "", c->encrypted && !ifp->file->ino.is_xattr ? "<encrypted>" : dent_node->name, @@ -171,7 +171,7 @@ static void print_problem(const struct ubifs_info *c, const struct scanned_dent_node *dent_node = (const struct scanned_dent_node *)ifp->priv; log_out(c, "problem: %s, ino %lu, type %s%s, dentry %s", - problem->desc, ifp->file->inum, + problem->desc, (unsigned long)ifp->file->inum, ubifs_get_type_name(ubifs_get_dent_type(ifp->file->ino.mode)), ifp->file->ino.is_xattr ? "(xattr)" : "", c->encrypted && !ifp->file->ino.is_xattr ? "<encrypted>" : dent_node->name); @@ -183,7 +183,7 @@ static void print_problem(const struct ubifs_info *c, const struct scanned_data_node *data_node = (const struct scanned_data_node *)ifp->priv; log_out(c, "problem: %s, ino %lu, type %s%s, data block %u", - problem->desc, ifp->file->inum, + problem->desc, (unsigned long)ifp->file->inum, ubifs_get_type_name(ubifs_get_dent_type(ifp->file->ino.mode)), ifp->file->ino.is_xattr ? "(xattr)" : "", key_block(c, &data_node->key)); @@ -198,7 +198,7 @@ static void print_problem(const struct ubifs_info *c, const struct invalid_file_problem *ifp = (const struct invalid_file_problem *)priv; log_out(c, "problem: %s, ino %lu type %s%s", problem->desc, - ifp->file->inum, + (unsigned long)ifp->file->inum, ubifs_get_type_name(ubifs_get_dent_type(ifp->file->ino.mode)), ifp->file->ino.is_xattr ? "(xattr)" : ""); break; @@ -209,9 +209,9 @@ static void print_problem(const struct ubifs_info *c, const struct scanned_file *host = (const struct scanned_file *)ifp->priv; log_out(c, "problem: %s, ino %lu type %s%s, host ino %lu type %s%s", - problem->desc, ifp->file->inum, + problem->desc, (unsigned long)ifp->file->inum, ubifs_get_type_name(ubifs_get_dent_type(ifp->file->ino.mode)), - ifp->file->ino.is_xattr ? "(xattr)" : "", host->inum, + ifp->file->ino.is_xattr ? "(xattr)" : "", (unsigned long)host->inum, ubifs_get_type_name(ubifs_get_dent_type(host->ino.mode)), host->ino.is_xattr ? "(xattr)" : ""); break; @@ -222,7 +222,7 @@ static void print_problem(const struct ubifs_info *c, const struct scanned_dent_node *dent_node = (const struct scanned_dent_node *)ifp->priv; log_out(c, "problem: %s, ino %lu, unreachable dentry %s, type %s%s", - problem->desc, ifp->file->inum, + problem->desc, (unsigned long)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)" : ""); @@ -235,7 +235,7 @@ static void print_problem(const struct ubifs_info *c, log_out(c, "problem: %s, ino %lu type %s, nlink %u xcnt %u xsz %u xnms %u size %llu, " "should be nlink %u xcnt %u xsz %u xnms %u size %llu", - problem->desc, file->inum, + problem->desc, (unsigned long)file->inum, file->ino.is_xattr ? "xattr" : ubifs_get_type_name(ubifs_get_dent_type(file->ino.mode)), file->ino.nlink, file->ino.xcnt, file->ino.xsz, file->ino.xnms, file->ino.size, @@ -299,7 +299,7 @@ static void print_problem(const struct ubifs_info *c, const struct scanned_file *file = (const struct scanned_file *)priv; log_out(c, "problem: %s, ino %lu, size %llu", problem->desc, - file->inum, file->ino.size); + (unsigned long)file->inum, file->ino.size); break; } default: |
