diff mbox series

[isar-cip-core,03/10] initramfs-crypt-hook: Convert awk statement into simple variable evaluation

Message ID dd0af28b84c5baf56e9b86237768262f2ef51803.1733151072.git.jan.kiszka@siemens.com (mailing list archive)
State New
Headers show
Series Various initramfs hook improvements | expand

Commit Message

Jan Kiszka Dec. 2, 2024, 2:51 p.m. UTC
From: Jan Kiszka <jan.kiszka@siemens.com>

Use suffix removal to convert "/dev/some-device" into "some-device".
It's simpler and avoids sub-processes.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 .../initramfs-crypt-hook/files/encrypt_partition.script         | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/recipes-initramfs/initramfs-crypt-hook/files/encrypt_partition.script b/recipes-initramfs/initramfs-crypt-hook/files/encrypt_partition.script
index 2cd6798d..28548502 100644
--- a/recipes-initramfs/initramfs-crypt-hook/files/encrypt_partition.script
+++ b/recipes-initramfs/initramfs-crypt-hook/files/encrypt_partition.script
@@ -62,7 +62,7 @@  service_watchdog() {
 }
 
 reencrypt_existing_partition() {
-	part_size_blocks="$(cat /sys/class/block/"$(awk -v dev="$1" 'BEGIN{split(dev,a,"/"); print a[3]}' )"/size)"
+	part_size_blocks="$(cat /sys/class/block/"${1##*/}"/size)"
 	# reduce the filesystem and partition by 32M to fit the LUKS header
 	partition_fstype=$(get_fstype "${1}")
 	reduce_device_size=32768