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.cou...@mind.be>
---
 meta/classes-recipe/image_types.bbclass | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/meta/classes-recipe/image_types.bbclass 
b/meta/classes-recipe/image_types.bbclass
index be8197f1f6..fb1e33cf3e 100644
--- a/meta/classes-recipe/image_types.bbclass
+++ b/meta/classes-recipe/image_types.bbclass
@@ -79,24 +79,32 @@ IMAGE_CMD:cramfs = "mkfs.cramfs ${IMAGE_ROOTFS} 
${IMGDEPLOYDIR}/${IMAGE_NAME}.cr
 
 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}" -ne 0 ]]; then
+               rootfs_file_size=${image_file_maxsize}
+       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}.$fstype seek=$ROOTFS_SIZE count=$COUNT bs=1024"
-       dd if=/dev/zero of=${IMGDEPLOYDIR}/${IMAGE_NAME}.$fstype 
seek=$ROOTFS_SIZE count=$COUNT bs=1024
+       bbdebug 1 Executing "dd if=/dev/zero 
of=${IMGDEPLOYDIR}/${IMAGE_NAME}.$fstype seek=$rootfs_file_size count=$COUNT 
bs=1024"
+       dd if=/dev/zero of=${IMGDEPLOYDIR}/${IMAGE_NAME}.$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}.$fstype`"
        bbdebug 1 Executing "mkfs.$fstype -F $extra_imagecmd 
${IMGDEPLOYDIR}/${IMAGE_NAME}.$fstype -d ${IMAGE_ROOTFS}"
@@ -105,9 +113,9 @@ oe_mkext234fs () {
        fsck.$fstype -pvfD ${IMGDEPLOYDIR}/${IMAGE_NAME}.$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 ${@get_max_image_size(d, 'ext2')} 
${EXTRA_IMAGECMD}"
+IMAGE_CMD:ext3 = "oe_mkext234fs ext3 ${@get_max_image_size(d, 'ext3')} 
${EXTRA_IMAGECMD}"
+IMAGE_CMD:ext4 = "oe_mkext234fs ext4 ${@get_max_image_size(d, 'ext4')} 
${EXTRA_IMAGECMD}"
 
 MIN_BTRFS_SIZE ?= "16384"
 IMAGE_CMD:btrfs () {
-- 
2.41.0

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#190050): 
https://lists.openembedded.org/g/openembedded-core/message/190050
Mute This Topic: https://lists.openembedded.org/mt/102331601/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to