All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: cip-dev@lists.cip-project.org
Cc: Quirin Gylstorff <quirin.gylstorff@siemens.com>,
	Christian Storm <christian.storm@siemens.com>
Subject: [isar-cip-core][PATCH v2 5/6] initramfs-verify-hook: Optimize probing of partitions
Date: Fri, 22 Apr 2022 09:47:37 +0200	[thread overview]
Message-ID: <8980b6e18b02a48e469f2033b0d53d1e7c1761d6.1650613658.git.jan.kiszka@siemens.com> (raw)
In-Reply-To: <cover.1650613658.git.jan.kiszka@siemens.com>

From: Jan Kiszka <jan.kiszka@siemens.com>

Rather than verifying the complete device, match on the UUID embedded
into the dm-verity superblock. That is much faster and, thus, saves boot
time with large partitions and/or slow devices.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 .../files/verity.script.tmpl                   | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/recipes-initramfs/initramfs-verity-hook/files/verity.script.tmpl b/recipes-initramfs/initramfs-verity-hook/files/verity.script.tmpl
index 7c75b5b..da37711 100644
--- a/recipes-initramfs/initramfs-verity-hook/files/verity.script.tmpl
+++ b/recipes-initramfs/initramfs-verity-hook/files/verity.script.tmpl
@@ -37,12 +37,20 @@ case "$ROOT" in
     "")
         # No Root device was given. Use veritysetup verify to search matching roots
         partitions=$(blkid -o device)
-        for part in $partitions; do
+        for part in ${partitions}; do
             if [ "$(blkid -p ${part} --match-types novfat -s USAGE -o value)" = "filesystem" ]; then
-                if veritysetup verify \
-                   "$part" "$part" "${ROOT_HASH}" \
-                   --hash-offset "${HASH_OFFSET}";then
-                    ROOT="$part"
+                verity_uuid=$(
+                    veritysetup dump "${part}" --hash-offset "${HASH_OFFSET}" | \
+                        while IFS=":" read key value; do
+                            if [ "${key}" = "UUID" ]; then
+                                # this pattern must use a real tab
+                                echo "${value##*	}"
+                                break
+                            fi
+                        done
+                    )
+                if [ "${UUID}" = "${verity_uuid}" ]; then
+                    ROOT="${part}"
                     break
                 fi
             fi
-- 
2.34.1



  parent reply	other threads:[~2022-04-22 16:52 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-22  7:47 [isar-cip-core][PATCH v2 0/6] Fix read-only rootfs setup /wrt etc overlay - and more Jan Kiszka
2022-04-22  7:47 ` [isar-cip-core][PATCH v2 1/6] wic: Align kernel command line of qemu-amd64-efibootguard* Jan Kiszka
2022-04-22  7:47 ` [isar-cip-core][PATCH v2 2/6] initramfs-abrootfs-hook: Convert to an initramfs-class recipe Jan Kiszka
2022-04-22 16:59   ` Jan Kiszka
2022-04-22  7:47 ` [isar-cip-core][PATCH v2 3/6] Convert /etc overlay from systemd mount unit to initramfs hook Jan Kiszka
2022-04-22  7:47 ` [isar-cip-core][PATCH v2 4/6] customizations: Relocate /root under /home Jan Kiszka
2022-04-22 12:22   ` Gylstorff Quirin
2022-04-22 12:53     ` Jan Kiszka
2022-04-22  7:47 ` Jan Kiszka [this message]
2022-04-22  7:47 ` [isar-cip-core][PATCH v2 6/6] secureboot: Prevent getting shell on panic Jan Kiszka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8980b6e18b02a48e469f2033b0d53d1e7c1761d6.1650613658.git.jan.kiszka@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=christian.storm@siemens.com \
    --cc=cip-dev@lists.cip-project.org \
    --cc=quirin.gylstorff@siemens.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.