git: 34d6f05e22f4 - stable/12 - mkimg: We always want the last block of the last inserted partition

From: Li-Wen Hsu <lwhsu_at_FreeBSD.org>
Date: Wed, 02 Feb 2022 14:24:11 UTC
The branch stable/12 has been updated by lwhsu:

URL: https://cgit.FreeBSD.org/src/commit/?id=34d6f05e22f4f86c06175a562e12698a04abda96

commit 34d6f05e22f4f86c06175a562e12698a04abda96
Author:     Emmanuel Vadot <manu@FreeBSD.org>
AuthorDate: 2021-02-25 15:34:28 +0000
Commit:     Li-Wen Hsu <lwhsu@FreeBSD.org>
CommitDate: 2022-02-02 14:18:56 +0000

    mkimg: We always want the last block of the last inserted partition
    
    Even with an absolute offset we want to know the last block the partition
    otherwise we endup with an image the size of the metadata.
    This allow to create image with the ESP placed at a specific position which
    is useful on arm/arm64 where u-boot have always a hard time to read the ESP
    if it's not aligned on 512k.
    mkimg -v -o sdcard -s gpt -p efi::54M:1M -p freebsd-ufs::1G
    now works.
    
    MFC after:      3 days
    
    (cherry picked from commit 3b6268bb9e4aea939c4ce7f37353174aa90e6751)
---
 usr.bin/mkimg/mkimg.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/usr.bin/mkimg/mkimg.c b/usr.bin/mkimg/mkimg.c
index 8967e538df42..8bfbeb753170 100644
--- a/usr.bin/mkimg/mkimg.c
+++ b/usr.bin/mkimg/mkimg.c
@@ -528,10 +528,8 @@ mkimg(void)
 				    (long long)blkoffset);
 			}
 		}
-		if (!abs_offset) {
-			block = scheme_metadata(SCHEME_META_PART_AFTER,
-			    part->block + part->size);
-		}
+		block = scheme_metadata(SCHEME_META_PART_AFTER,
+		    part->block + part->size);
 	}
 
 	mkimg_validate();