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

Jan Kiszka
2025-01-30T09:39:28Z

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 --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"
--
2.43.0