From nobody Wed Feb 02 14:24:12 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 012EA193B89F; Wed, 2 Feb 2022 14:24:14 +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 4JpkZP2CJ6z3MPB; Wed, 2 Feb 2022 14:24:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1643811853; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=apgNcXHqxje/k329rzoT8glwxeYjEqfC15VrD4+B80g=; b=iEScki4Xpc0vyHX1ZxysTYwMLgumbFOZaSD4x46NuQNhKhWYNs1Ss7ZLXBfvjWb4DL+zKH VbaFtqqzUXf+U2//E/zD0rR73N7r8ixD+T6nccIMbcF5VLFMLFaeJgitK/67Sk8nPjrOyZ YMXjg3AQu8MSU3w4PmBDafmQz89tXCNHkSQAYq6HFDd2aWGVbm9ozJMFsgLcmWwOoDjcQU FEtFrwa11biSZtQtPkhrQ1l7gbXlYeLdp073MtYNyHtQqW8VuKVrkCDnvv3jq550xzWC1U tOQ8wJrVbLCadcV9dcTPbzKUINYwP1sLzwctiRYC6jqxPkzkc5K4ZAtG/NDYeA== 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 1EBCE25875; Wed, 2 Feb 2022 14:24:13 +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 212EOCDr097644; Wed, 2 Feb 2022 14:24:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 212EOCbK097643; Wed, 2 Feb 2022 14:24:12 GMT (envelope-from git) Date: Wed, 2 Feb 2022 14:24:12 GMT Message-Id: <202202021424.212EOCbK097643@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Li-Wen Hsu Subject: git: 51f120a81042 - stable/12 - mkimg: Add support for offset if the source is an image List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: lwhsu X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 51f120a810427b802c46686350fff0f30a145633 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1643811853; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=apgNcXHqxje/k329rzoT8glwxeYjEqfC15VrD4+B80g=; b=NZiQ5MsXtMhOWNc0HdmpTmU/0V1YghjGhuoaHlYjLer5KuKf9/qYObYrR0sGfRLppPA6Ct BvaGyvMFP006L2L5G9CkUiUQycsw/rKTQJH6OfhOCPRC10/SvD7EUUAZuQ2MIhyHNV2eIH 5RKw0eO8PP8ieYaVHqPXZ9yhLOvkQjoW+30ao6vUW12Hic72d1ouJTWlBmO5c1PHiDRYmJ +9QMZxl2CEKrI+VFyiyE82lyV69p6HsnxdK2QZ7RlwVUikFRcKlQf8N+BgibJTg235UeLy d8iZtmVB0xor5U22w5Zt+eu5FeNcMhsAGPCRF2V7H+BJFLdykJ0VEVSCLCkh6g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1643811853; a=rsa-sha256; cv=none; b=BPuByjCDFi3b5o4NOs0xDMSE2vTNOr0P/AFH/xa6zaqpASt8ts99JCWAraw2ar0h+BPghN gboV4Kk+caFM4coXeBf6yBTUAiUarbn0Lq0yUh4vxsLTBCcBm/Z3VF7D/bEHe1xQ6PHIQg GURbsQgIy8gAvL0jcJEiwCKPa+As38WZxzCreKEx9bVrcq/FfFrf7BcAaU63TPDAbW/BvF 9a2oM5VTY9tbjWeFqTPhJBmLchx+c2qDgtIAJZTwtgaLQq6rH+ggFbJK9rBMSG/9TjBkil 88l2e5/Z4hIlC0CizWsfXn8r5uwYE2nHFyQHhOxJKXWK6v8dkmkeR65gdyK71A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by lwhsu: URL: https://cgit.FreeBSD.org/src/commit/?id=51f120a810427b802c46686350fff0f30a145633 commit 51f120a810427b802c46686350fff0f30a145633 Author: Emmanuel Vadot AuthorDate: 2021-02-25 17:10:19 +0000 Commit: Li-Wen Hsu CommitDate: 2022-02-02 14:19:01 +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 8bfbeb753170..118bef5de2f2 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 "