From owner-dev-commits-src-branches@freebsd.org Tue Mar 2 13:03:04 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 099FF568FB0; Tue, 2 Mar 2021 13:03:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DqckH6T6Pz3sHw; Tue, 2 Mar 2021 13:03:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8A4FA17581; Tue, 2 Mar 2021 13:03:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 122D33vf066083; Tue, 2 Mar 2021 13:03:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 122D33nb066082; Tue, 2 Mar 2021 13:03:03 GMT (envelope-from git) Date: Tue, 2 Mar 2021 13:03:03 GMT Message-Id: <202103021303.122D33nb066082@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Emmanuel Vadot Subject: git: 6f6c6480047b - stable/13 - mkimg: Add support for offset if the source is an image MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: manu X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 6f6c6480047ba1ebbc398c1052446e35f8a4ecab Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Mar 2021 13:03:04 -0000 The branch stable/13 has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=6f6c6480047ba1ebbc398c1052446e35f8a4ecab commit 6f6c6480047ba1ebbc398c1052446e35f8a4ecab Author: Emmanuel Vadot AuthorDate: 2021-02-25 17:10:19 +0000 Commit: Emmanuel Vadot CommitDate: 2021-03-02 13:02:51 +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 (cherry picked from commit 8f3c71c85e5f6a4d2bddbfead225d33b96dbd7d7) --- 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- " "empty partition of given size and\n\t\t\t\t\t" " optional relative or absolute offset\n"); - fprintf(stderr, "\t[/]:=\t\t- partition content and size " - "are\n\t\t\t\t\t determined by the named file\n"); + fprintf(stderr, "\t[/]:=[:[+]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\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 "