diff mbox series

[isar-cip-core,RFC,04/10] initramfs-overlay-hook: Optimize variable initialization

Message ID 8492ee6dbf5634817cfe0bd80a18f0c21fad5bf5.1738229957.git.jan.kiszka@siemens.com (mailing list archive)
State New
Headers show
Series Provide A/B snapshot support for persistent /var | expand

Commit Message

Jan Kiszka Jan. 30, 2025, 9:39 a.m. UTC
From: Jan Kiszka <jan.kiszka@siemens.com>

Move some variables that are only relevant if the storage filesystem
was not mounted yet into the respective branch. This specifically avoids
to uselessly retrieve the filesystem type of the storage.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 .../initramfs-overlay-hook/files/local-bottom.tmpl     | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/recipes-initramfs/initramfs-overlay-hook/files/local-bottom.tmpl b/recipes-initramfs/initramfs-overlay-hook/files/local-bottom.tmpl
index f829a9bb..1087c3f7 100644
--- a/recipes-initramfs/initramfs-overlay-hook/files/local-bottom.tmpl
+++ b/recipes-initramfs/initramfs-overlay-hook/files/local-bottom.tmpl
@@ -8,17 +8,19 @@ 
 #  Quirin Gylstorff <quirin.gylstorff@siemens.com>
 #
 
-ovl_partition_device="${INITRAMFS_OVERLAY_STORAGE_DEVICE}"
 ovl_storage_path="${INITRAMFS_OVERLAY_STORAGE_PATH}"
 ovl_lower_dirs="${INITRAMFS_OVERLAY_PATHS}"
-ovl_mount_option="${INITRAMFS_OVERLAY_MOUNT_OPTION}"
-ovl_recovery_script="/scripts/${INITRAMFS_OVERLAY_RECOVERY_SCRIPT}"
 
 root_mount_storage=${rootmnt}${ovl_storage_path}
 storage_mount_point="$(echo "${ovl_storage_path}" | awk -F/ '{print FS$2}' )"
-partition_fstype=$(get_fstype "${ovl_partition_device}")
 
 if ! mountpoint -q "${rootmnt}${storage_mount_point}"; then
+	ovl_partition_device="${INITRAMFS_OVERLAY_STORAGE_DEVICE}"
+	ovl_mount_option="${INITRAMFS_OVERLAY_MOUNT_OPTION}"
+	ovl_recovery_script="/scripts/${INITRAMFS_OVERLAY_RECOVERY_SCRIPT}"
+
+	partition_fstype=$(get_fstype "${ovl_partition_device}")
+
 	case $partition_fstype in
 	ext*)
 		e2fsck -p -f "$ovl_partition_device"