| Message ID | 20260912143745.3722559-1-wenwfu@qti.qualcomm.com |
|---|---|
| State | New |
| Headers | show |
| Series | [v2,1/2] initramfs-framework: avoid processes when parsing cmdline | expand |
diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/init b/meta/recipes-core/initrdscripts/initramfs-framework/init index e560d25d53..e2da3511b8 100755 --- a/meta/recipes-core/initrdscripts/initramfs-framework/init +++ b/meta/recipes-core/initrdscripts/initramfs-framework/init @@ -152,11 +152,15 @@ mkdir $ROOTFS_DIR # Load and run modules for m in $MODULES_DIR/*; do # Skip backup files - if [ "`echo $m | sed -e 's/\~$//'`" != "$m" ]; then - continue - fi + case "$m" in + *~) + continue + ;; + esac - module=`basename $m | cut -d'-' -f 2` + module=${m##*/} + module=${module#*-} + module=${module%%-*} debug "Loading module $module" # pre hooks
Use shell pattern matching and parameter expansion to skip backup modules and derive module names without invoking sed, basename, or cut during initramfs module loading. On QEMU, backup filtering decreased from 104.529 ms to 3.731 ms, and module name parsing decreased from 115.657 ms to 4.071 ms. Together, these stages decreased from 220.186 ms to 7.802 ms. Tested with dash and BusyBox sh syntax checks and QEMU. AI-Generated: OpenAI Codex Signed-off-by: Wenwen Fu <wenwfu@qti.qualcomm.com> --- .../initrdscripts/initramfs-framework/init | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)