From: Charles-Antoine Couret <charles-antoine.couret@mind.be>
To: openembedded-core@lists.openembedded.org
Cc: Charles-Antoine Couret <charles-antoine.couret@mind.be>
Subject: [PATCH 1/3] image_types: use IMAGE_FILE_MAXSIZE variable for ext2/3/4 image types
Date: Sun, 4 Jun 2023 14:37:53 +0200 [thread overview]
Message-ID: <20230604123755.2541295-2-charles-antoine.couret@mind.be> (raw)
In-Reply-To: <20230604123755.2541295-1-charles-antoine.couret@mind.be>
If defined, this variable value overrides the size of ext* partition file created by mkfs.
Otherwise previous logic based on ROOTFS_SIZE variable is used.
It should be set when the final file size would not be above a specific value due to fixed
partitionning for example.
Signed-off-by: Charles-Antoine Couret <charles-antoine.couret@mind.be>
---
meta/classes-recipe/image_types.bbclass | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/meta/classes-recipe/image_types.bbclass b/meta/classes-recipe/image_types.bbclass
index e4939af459..cebbb61545 100644
--- a/meta/classes-recipe/image_types.bbclass
+++ b/meta/classes-recipe/image_types.bbclass
@@ -68,24 +68,33 @@ IMAGE_CMD:cramfs = "mkfs.cramfs ${IMAGE_ROOTFS} ${IMGDEPLOYDIR}/${IMAGE_NAME}${I
oe_mkext234fs () {
fstype=$1
+ image_file_maxsize=$2
extra_imagecmd=""
+ rootfs_file_size=$ROOTFS_SIZE
- if [ $# -gt 1 ]; then
- shift
+ if [ $# -gt 2 ]; then
+ shift 2
extra_imagecmd=$@
fi
+
+ if [[ "${image_file_maxsize}" != "\"\"" ]]; then
+ # Remove quotes to get numbers only
+ rootfs_file_size=$(echo "${image_file_maxsize}" | tr -d '"')
+ fi
+
# If generating an empty image the size of the sparse block should be large
# enough to allocate an ext4 filesystem using 4096 bytes per inode, this is
# about 60K, so dd needs a minimum count of 60, with bs=1024 (bytes per IO)
eval local COUNT=\"0\"
eval local MIN_COUNT=\"60\"
- if [ $ROOTFS_SIZE -lt $MIN_COUNT ]; then
+ if [ $rootfs_file_size -lt $MIN_COUNT ]; then
eval COUNT=\"$MIN_COUNT\"
fi
+
# Create a sparse image block
- bbdebug 1 Executing "dd if=/dev/zero of=${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.$fstype seek=$ROOTFS_SIZE count=$COUNT bs=1024"
- dd if=/dev/zero of=${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.$fstype seek=$ROOTFS_SIZE count=$COUNT bs=1024
+ bbdebug 1 Executing "dd if=/dev/zero of=${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.$fstype seek=$rootfs_file_size count=$COUNT bs=1024"
+ dd if=/dev/zero of=${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.$fstype seek=$rootfs_file_size count=$COUNT bs=1024
bbdebug 1 "Actual Rootfs size: `du -s ${IMAGE_ROOTFS}`"
bbdebug 1 "Actual Partition size: `stat -c '%s' ${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.$fstype`"
bbdebug 1 Executing "mkfs.$fstype -F $extra_imagecmd ${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.$fstype -d ${IMAGE_ROOTFS}"
@@ -94,9 +103,9 @@ oe_mkext234fs () {
fsck.$fstype -pvfD ${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.$fstype || [ $? -le 3 ]
}
-IMAGE_CMD:ext2 = "oe_mkext234fs ext2 ${EXTRA_IMAGECMD}"
-IMAGE_CMD:ext3 = "oe_mkext234fs ext3 ${EXTRA_IMAGECMD}"
-IMAGE_CMD:ext4 = "oe_mkext234fs ext4 ${EXTRA_IMAGECMD}"
+IMAGE_CMD:ext2 = "oe_mkext234fs ext2 \"${IMAGE_FILE_MAXSIZE:ext2}\" ${EXTRA_IMAGECMD}"
+IMAGE_CMD:ext3 = "oe_mkext234fs ext3 \"${IMAGE_FILE_MAXSIZE:ext3}\" ${EXTRA_IMAGECMD}"
+IMAGE_CMD:ext4 = "oe_mkext234fs ext4 \"${IMAGE_FILE_MAXSIZE:ext4}\" ${EXTRA_IMAGECMD}"
MIN_BTRFS_SIZE ?= "16384"
IMAGE_CMD:btrfs () {
--
2.40.1
next prev parent reply other threads:[~2023-06-04 12:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-04 12:37 [PATCH 0/3] image_types: use IMAGE_FILE_MAXSIZE variable to create fixed partition size Charles-Antoine Couret
2023-06-04 12:37 ` Charles-Antoine Couret [this message]
2023-06-07 12:30 ` [OE-core] [PATCH 1/3] image_types: use IMAGE_FILE_MAXSIZE variable for ext2/3/4 image types Alexandre Belloni
2023-06-04 12:37 ` [PATCH 2/3] image_types: use IMAGE_FILE_MAXSIZE variable for btrfs " Charles-Antoine Couret
2023-06-04 12:37 ` [PATCH 3/3] image_types: use IMAGE_FILE_MAXSIZE variable for f2fs " Charles-Antoine Couret
2023-06-07 9:52 ` [OE-core] [PATCH 0/3] image_types: use IMAGE_FILE_MAXSIZE variable to create fixed partition size Alexandre Belloni
2023-07-06 11:57 ` Ross Burton
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=20230604123755.2541295-2-charles-antoine.couret@mind.be \
--to=charles-antoine.couret@mind.be \
--cc=openembedded-core@lists.openembedded.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).