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
This commit is contained in:
parent
655fa04406
commit
8f3c71c85e
@ -174,8 +174,10 @@ usage(const char *why)
|
|||||||
fprintf(stderr, "\t<t>[/<l>]::<size>[:[+]<offset>]\t- "
|
fprintf(stderr, "\t<t>[/<l>]::<size>[:[+]<offset>]\t- "
|
||||||
"empty partition of given size and\n\t\t\t\t\t"
|
"empty partition of given size and\n\t\t\t\t\t"
|
||||||
" optional relative or absolute offset\n");
|
" optional relative or absolute offset\n");
|
||||||
fprintf(stderr, "\t<t>[/<l>]:=<file>\t\t- partition content and size "
|
fprintf(stderr, "\t<t>[/<l>]:=<file>[:[+]offset]\t- partition "
|
||||||
"are\n\t\t\t\t\t determined by the named file\n");
|
"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 "
|
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");
|
"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");
|
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. */
|
/* Look for an offset. Set size too if we can. */
|
||||||
switch (part->kind) {
|
switch (part->kind) {
|
||||||
case PART_KIND_SIZE:
|
case PART_KIND_SIZE:
|
||||||
|
case PART_KIND_FILE:
|
||||||
offset = part->contents;
|
offset = part->contents;
|
||||||
size = strsep(&offset, ":");
|
size = strsep(&offset, ":");
|
||||||
if (expand_number(size, &bytesize) == -1)
|
if (part->kind == PART_KIND_SIZE &&
|
||||||
|
expand_number(size, &bytesize) == -1)
|
||||||
error = errno;
|
error = errno;
|
||||||
if (offset != NULL) {
|
if (offset != NULL) {
|
||||||
if (*offset != '+')
|
if (*offset != '+')
|
||||||
@ -476,14 +480,13 @@ mkimg(void)
|
|||||||
|
|
||||||
/* Work out exactly where the partition starts. */
|
/* Work out exactly where the partition starts. */
|
||||||
blkoffset = (byteoffset + secsz - 1) / secsz;
|
blkoffset = (byteoffset + secsz - 1) / secsz;
|
||||||
if (abs_offset) {
|
if (abs_offset)
|
||||||
part->block = scheme_metadata(SCHEME_META_PART_ABSOLUTE,
|
block = scheme_metadata(SCHEME_META_PART_ABSOLUTE,
|
||||||
blkoffset);
|
blkoffset);
|
||||||
} else {
|
else
|
||||||
block = scheme_metadata(SCHEME_META_PART_BEFORE,
|
block = scheme_metadata(SCHEME_META_PART_BEFORE,
|
||||||
block + blkoffset);
|
block + blkoffset);
|
||||||
part->block = block;
|
part->block = block;
|
||||||
}
|
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
fprintf(stderr, "partition %d: starting block %llu "
|
fprintf(stderr, "partition %d: starting block %llu "
|
||||||
|
Loading…
Reference in New Issue
Block a user