From: AshishKumar Mishra <emailaddress.ashish@gmail.com>
To: openembedded-devel@lists.openembedded.org
Cc: skandigraun@gmail.com, Sean Anderson <sean.anderson@seco.com>,
Khem Raj <raj.khem@gmail.com>,
AshishKumar Mishra <emailaddress.ashish@gmail.com>
Subject: [kirkstone][PATCH] image_types_sparse: backport fix pad source image to block size
Date: Sat, 20 Sep 2025 23:07:42 +0530 [thread overview]
Message-ID: <20250920173742.3449291-1-emailaddress.ashish@gmail.com> (raw)
From: Sean Anderson <sean.anderson@seco.com>
If the source image's size is not aligned to the sparse image's block
size, then conversion will fail with
img2simg: libsparse/sparse.cpp:133: int write_all_blocks(sparse_file*, output_file*): Assertion `pad >= 0' failed.
This is a bug in img2simg, but an easy way to work around it is to pad
the source image ourselves. The default block size of 4096 matches
img2simg's default block size.
This change corresponds to upstream fb331cb62eafd1e534dee292525084ccee0ef3e1
Signed-off-by: Sean Anderson <sean.anderson@seco.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: AshishKumar Mishra <emailaddress.ashish@gmail.com>
---
meta-oe/classes/image_types_sparse.bbclass | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/meta-oe/classes/image_types_sparse.bbclass b/meta-oe/classes/image_types_sparse.bbclass
index 4263593a8d..b092f68406 100644
--- a/meta-oe/classes/image_types_sparse.bbclass
+++ b/meta-oe/classes/image_types_sparse.bbclass
@@ -1,8 +1,16 @@
inherit image_types
+# This sets the granularity of the sparse image conversion. Chunk sizes will be
+# specified in units of this value. Setting this value smaller than the
+# underlying image's block size will not result in any further space saving.
+# However, there is no loss in correctness if this value is larger or smaller
+# than optimal. This value should be a power of two.
+SPARSE_BLOCK_SIZE ??= "4096"
+
CONVERSIONTYPES += "sparse"
CONVERSION_CMD:sparse = " \
- img2simg "${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}" \
- "${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}.sparse" \
+ INPUT="${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}" && \
+ truncate --no-create --size=%${SPARSE_BLOCK_SIZE} "$INPUT" && \
+ img2simg "$INPUT" "$INPUT.sparse" ${SPARSE_BLOCK_SIZE} \
"
CONVERSION_DEPENDS_sparse = "android-tools-native"
--
2.43.0
next reply other threads:[~2025-09-20 17:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-20 17:37 AshishKumar Mishra [this message]
2025-09-23 6:32 ` [kirkstone][PATCH] image_types_sparse: backport fix pad source image to block size Ashish Mishra
2025-09-23 6:34 ` [oe] " Gyorgy Sarvari
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250920173742.3449291-1-emailaddress.ashish@gmail.com \
--to=emailaddress.ashish@gmail.com \
--cc=openembedded-devel@lists.openembedded.org \
--cc=raj.khem@gmail.com \
--cc=sean.anderson@seco.com \
--cc=skandigraun@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.