git: 00a6cf0cf44a - stable/15 - mkimg: Ignore redundant %align values
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 28 Oct 2026 05:52:42 UTC
The branch stable/15 has been updated by cperciva:
URL: https://cgit.FreeBSD.org/src/commit/?id=00a6cf0cf44a879dce048e462cdf8195ecc9aee8
commit 00a6cf0cf44a879dce048e462cdf8195ecc9aee8
Author: Colin Percival <cperciva@FreeBSD.org>
AuthorDate: 2026-10-17 19:14:16 +0000
Commit: Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2026-10-28 05:45:05 +0000
mkimg: Ignore redundant %align values
Partitions are trivially aligned to sector boundaries, so asking e.g.
for a partition to be aligned to a 64-byte boundary is pointless but
harmless. Treat it as such, with a warning (in case the request was
a mistake, e.g. requesting 1-byte instead of 1M-byte alignment) rather
than as an error.
Reviewed by: markj
Suggested by: markj
MFC after: 1 week
Sponsored by: Amazon
Differential Revision: https://reviews.freebsd.org/D60819
(cherry picked from commit da04cf02c96b97c587580b336fa527392467f689)
---
usr.bin/mkimg/mkimg.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/usr.bin/mkimg/mkimg.c b/usr.bin/mkimg/mkimg.c
index d8f872b72261..ce0bc98a9f3f 100644
--- a/usr.bin/mkimg/mkimg.c
+++ b/usr.bin/mkimg/mkimg.c
@@ -516,7 +516,15 @@ mkimg(void)
if (expand_number(align, &bytealign) == -1)
err(EX_DATAERR, "partition %d",
part->index + 1);
- if ((bytealign == 0) || (bytealign % secsz != 0))
+ if (bytealign == 0)
+ errx(EX_DATAERR, "partition %d: "
+ "invalid alignment", part->index + 1);
+ if (secsz % bytealign == 0) {
+ warnx("partition %d: ignoring "
+ "redundant alignment", part->index + 1);
+ bytealign = secsz;
+ }
+ if (bytealign % secsz != 0)
errx(EX_DATAERR, "partition %d: "
"invalid alignment", part->index + 1);
blkalign = bytealign / secsz;