git: 856af5ff745f - releng/13.0 - mkimg: Add support for offset if the source is an image
Emmanuel Vadot
manu at FreeBSD.org
Tue Mar 2 14:21:30 UTC 2021
The branch releng/13.0 has been updated by manu:
URL: https://cgit.FreeBSD.org/src/commit/?id=856af5ff745f2687015a5564f8daf0cf6cde368d
commit 856af5ff745f2687015a5564f8daf0cf6cde368d
Author: Emmanuel Vadot <manu at FreeBSD.org>
AuthorDate: 2021-02-25 17:10:19 +0000
Commit: Emmanuel Vadot <manu at FreeBSD.org>
CommitDate: 2021-03-02 14:21:08 +0000
mkimg: Add support for offset if the source is an image
This allow us to create image with the following format:
mkimg -v -o sdcard -s gpt -p efi:=esp_aarch64.img:1M -p freebsd-ufs::1G
Which will add a efi partition at a 1M offset on the image with its content
coming from the esp_aarch64.img file.
MFC after: 3 days
Approved by: re (gjb)
(cherry picked from commit 8f3c71c85e5f6a4d2bddbfead225d33b96dbd7d7)
(cherry picked from commit 6f6c6480047ba1ebbc398c1052446e35f8a4ecab)
---
usr.bin/mkimg/mkimg.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/usr.bin/mkimg/mkimg.c b/usr.bin/mkimg/mkimg.c
index c4f0acbe3927..e5e6c036575b 100644
--- a/usr.bin/mkimg/mkimg.c
+++ b/usr.bin/mkimg/mkimg.c
@@ -174,8 +174,10 @@ usage(const char *why)
fprintf(stderr, "\t<t>[/<l>]::<size>[:[+]<offset>]\t- "
"empty partition of given size and\n\t\t\t\t\t"
" optional relative or absolute offset\n");
- fprintf(stderr, "\t<t>[/<l>]:=<file>\t\t- partition content and size "
- "are\n\t\t\t\t\t determined by the named file\n");
+ fprintf(stderr, "\t<t>[/<l>]:=<file>[:[+]offset]\t- partition "
+ "content and size are\n\t\t\t\t\t"
+ " determined by the named file and\n"
+ "\t\t\t\t\t optional relative or absolute offset\n");
fprintf(stderr, "\t<t>[/<l>]:-<cmd>\t\t- partition content and size "
"are taken\n\t\t\t\t\t from the output of the command to run\n");
fprintf(stderr, "\t-\t\t\t\t- unused partition entry\n");
@@ -459,9 +461,11 @@ mkimg(void)
/* Look for an offset. Set size too if we can. */
switch (part->kind) {
case PART_KIND_SIZE:
+ case PART_KIND_FILE:
offset = part->contents;
size = strsep(&offset, ":");
- if (expand_number(size, &bytesize) == -1)
+ if (part->kind == PART_KIND_SIZE &&
+ expand_number(size, &bytesize) == -1)
error = errno;
if (offset != NULL) {
if (*offset != '+')
@@ -476,14 +480,13 @@ mkimg(void)
/* Work out exactly where the partition starts. */
blkoffset = (byteoffset + secsz - 1) / secsz;
- if (abs_offset) {
- part->block = scheme_metadata(SCHEME_META_PART_ABSOLUTE,
+ if (abs_offset)
+ block = scheme_metadata(SCHEME_META_PART_ABSOLUTE,
blkoffset);
- } else {
+ else
block = scheme_metadata(SCHEME_META_PART_BEFORE,
block + blkoffset);
- part->block = block;
- }
+ part->block = block;
if (verbose)
fprintf(stderr, "partition %d: starting block %llu "
More information about the dev-commits-src-all
mailing list