The rootfs module uses echo, cut, and grep to resolve root= identifiers. This starts several short-lived processes before checking the root device.
Use POSIX shell case matching and parameter expansion for UUID, PARTUUID, PARTLABEL, and LABEL identifiers. Validate ubiN: identifiers with shell pattern matching while preserving the existing behavior. Measured on rb3gen2-core-kit with root=LABEL=otaroot using rootfs-resolve-start and rootfs-resolve-end kernel markers: before: 18.195 ms after: 0.089 ms improvement: 18.106 ms (99.5%) The overall rootfs time is also affected by storage mount variability, so the resolution interval is the direct measurement. Tested with dash and BusyBox sh syntax checks. Signed-off-by: Wenwen Fu <[email protected]> --- .../initrdscripts/initramfs-framework/rootfs | 37 +++++++++++-------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/rootfs b/meta/recipes-core/initrdscripts/initramfs-framework/rootfs index df0cbfb091..05557be211 100644 --- a/meta/recipes-core/initrdscripts/initramfs-framework/rootfs +++ b/meta/recipes-core/initrdscripts/initramfs-framework/rootfs @@ -21,21 +21,28 @@ rootfs_run() { if [ -n "$bootparam_root" ]; then debug "No e2fs compatible filesystem has been mounted, mounting $bootparam_root..." - if [ "`echo ${bootparam_root} | cut -c1-5`" = "UUID=" ]; then - root_uuid=`echo $bootparam_root | cut -c6-` - bootparam_root="/dev/disk/by-uuid/$root_uuid" - elif [ "`echo ${bootparam_root} | cut -c1-9`" = "PARTUUID=" ]; then - root_partuuid=`echo $bootparam_root | cut -c10-` - bootparam_root="/dev/disk/by-partuuid/$root_partuuid" - elif [ "`echo ${bootparam_root} | cut -c1-10`" = "PARTLABEL=" ]; then - root_partlabel=`echo $bootparam_root | cut -c11-` - bootparam_root="/dev/disk/by-partlabel/$root_partlabel" - elif [ "`echo ${bootparam_root} | cut -c1-6`" = "LABEL=" ]; then - root_label=`echo $bootparam_root | cut -c7-` - bootparam_root="/dev/disk/by-label/$root_label" - elif echo "${bootparam_root}" | grep -q '^ubi[0-9]\+:'; then - bootparam_rootfstype="ubifs" - fi + case "$bootparam_root" in + UUID=*) + bootparam_root="/dev/disk/by-uuid/${bootparam_root#UUID=}" + ;; + PARTUUID=*) + bootparam_root="/dev/disk/by-partuuid/${bootparam_root#PARTUUID=}" + ;; + PARTLABEL=*) + bootparam_root="/dev/disk/by-partlabel/${bootparam_root#PARTLABEL=}" + ;; + LABEL=*) + bootparam_root="/dev/disk/by-label/${bootparam_root#LABEL=}" + ;; + ubi[0-9]*:*) + ubi_prefix=${bootparam_root%%:*} + ubi_digits=${ubi_prefix#ubi} + case "$ubi_digits" in + ''|*[!0-9]*) ;; + *) bootparam_rootfstype="ubifs" ;; + esac + ;; + esac if [ -e "$bootparam_root" ] || [ -n "$bootparam_rootfstype" ]; then flags="" -- 2.43.0
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#245758): https://lists.openembedded.org/g/openembedded-core/message/245758 Mute This Topic: https://lists.openembedded.org/mt/121239116/21656 Group Owner: [email protected] Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
