Skip to contentSkip to conversation

crypt-hook: Check if WATCHDOG_DEV is set and available

PATCH New Jan Kiszka 1 participant 1 message Apr 28

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

PATCH v3 1/1 crypt-hook: Check if WATCHDOG_DEV is set and available

From: Quirin Gylstorff <[email protected]>

This allows the user to disable the watchdog by emptying the variable INITRAMFS_WATCHDOG_DEVICE.

Also add a panic if the watchdog device is configured and not available.

[Jan: fix up device test, link INITRAMFS_WATCHDOG_DEVICE to WDOG_TIMEOUT]

---

Posting as the second change, conditional INITRAMFS_WATCHDOG_DEVICE default, deserves review.

 .../files/local-top-complete                    | 17 ++++++++++++-----
 ...ook_0.10.bb => initramfs-crypt-hook_0.11.bb} |  4 ++--
 2 files changed, 14 insertions(+), 7 deletions(-)
 rename recipes-initramfs/initramfs-crypt-hook/{initramfs-crypt-hook_0.10.bb => initramfs-crypt-hook_0.11.bb} (97%)
recipes-initramfs/initramfs-crypt-hook/files/local-top-complete +12 -5
index 4f3eafc6..b0335975 100644
@@ -2,7 +2,7 @@
 #
 # CIP Core, generic profile
 #
-# Copyright (c) Siemens AG, 2023-2025
+# Copyright (c) Siemens AG, 2023-2026
 #
 # Authors:
 #  Quirin Gylstorff <[email protected]>
@@ -64,10 +64,17 @@ if [ -z "${create_file_system_cmd}" ]; then
 fi
 
 service_watchdog() {
-	for n in $(seq $(($SETUP_TIMEOUT / 10)) ); do
-		printf '\0'
-		sleep 10
-	done > "$WATCHDOG_DEV"
+	if [ -n "$WATCHDOG_DEV" ]; then
+		if [ ! -e "$WATCHDOG_DEV" ]; then
+			panic "Could not find '$WATCHDOG_DEV' - Please check your kernel configuration."
+		fi
+		for n in $(seq $(($SETUP_TIMEOUT / 10)) ); do
+			printf '\0'
+			sleep 10
+		done > "$WATCHDOG_DEV"
+	else
+		echo "Watchdog is disabled."
+	fi
 }
 
 check_partitions()
recipes-initramfs/initramfs-crypt-hook/initramfs-crypt-hook_0.11.bb renamed from recipes-initramfs/initramfs-crypt-hook/initramfs-crypt-hook_0.10.bb +2 -2
similarity index 97%
rename from recipes-initramfs/initramfs-crypt-hook/initramfs-crypt-hook_0.10.bb
rename to recipes-initramfs/initramfs-crypt-hook/initramfs-crypt-hook_0.11.bb
index c0572f2f..3cb05201 100644
@@ -1,7 +1,7 @@
 #
 # CIP Core, generic profile
 #
-# Copyright (c) Siemens AG, 2020-2025
+# Copyright (c) Siemens AG, 2020-2026
 #
 # Authors:
 #  Quirin Gylstorff <[email protected]>
@@ -88,7 +88,7 @@ CRYPT_CREATE_FILE_SYSTEM_CMD ??= "/usr/sbin/mke2fs -t ext4"
 # Timeout for creating / re-encrypting partitions on first boot
 CRYPT_SETUP_TIMEOUT ??= "600"
 # Watchdog to service during the initial setup of the crypto partitions
-INITRAMFS_WATCHDOG_DEVICE ??= "/dev/watchdog"
+INITRAMFS_WATCHDOG_DEVICE ??= "${@'/dev/watchdog' if int(d.getVar('WDOG_TIMEOUT') or 0) > 0 else ''}"
 # clevis needs tpm hash algorithm type
 CRYPT_HASH_TYPE ??= "sha256"
 CRYPT_KEY_ALGORITHM ??= "ecc"
Signature · 1 line
2.47.3