cip-dev.lists.cip-project.org archive mirror
 help / color / mirror / Atom feed
* [cip-dev][isar-cip-core][PATCH] initramfs-abrootfs: check if /etc/os-release exists
@ 2022-11-30 11:18 Quirin Gylstorff
  2022-12-08  9:30 ` Jan Kiszka
  0 siblings, 1 reply; 2+ messages in thread
From: Quirin Gylstorff @ 2022-11-30 11:18 UTC (permalink / raw)
  To: cip-dev, jan.kiszka

From: Quirin Gylstorff <quirin.gylstorff@siemens.com>

If a valid root file system does not contain /etc/os-release the
script aborts before checking other root file systems. This occurs
for example if the boot occurs from a USB stick and a ext4 root
file system exists on internal memory.

Also ensure that IMAGE_UUID and TARGET_IMAGE_UUID are not empty
before comparing to each other.

Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com>
---
 .../initramfs-abrootfs-hook/files/abrootfs.script          | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/recipes-initramfs/initramfs-abrootfs-hook/files/abrootfs.script b/recipes-initramfs/initramfs-abrootfs-hook/files/abrootfs.script
index 23bbfe7..848e829 100644
--- a/recipes-initramfs/initramfs-abrootfs-hook/files/abrootfs.script
+++ b/recipes-initramfs/initramfs-abrootfs-hook/files/abrootfs.script
@@ -35,9 +35,12 @@ find_root_via_image_uuid()
     for part in $partitions; do
         if [ "$(blkid -p "${part}" --match-types novfat -s USAGE -o value)" = "filesystem" ]; then
             mount -o ro -t "$(get_fstype "${part}")" "${part}" "${rootmnt}"
-            . "${rootmnt}/etc/os-release"
+            if [ -e "${rootmnt}/etc/os-release" ]; then
+                . "${rootmnt}/etc/os-release"
+            fi
             umount "${rootmnt}"
-            if [ "${IMAGE_UUID}" = "${TARGET_IMAGE_UUID}" ]; then
+            if [ -n "${IMAGE_UUID}" ] && [ -n "${TARGET_IMAGE_UUID}" ] &&
+                   [ "${IMAGE_UUID}" = "${TARGET_IMAGE_UUID}" ]; then
                 found_root="${part}"
                 break
             fi
-- 
2.35.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [cip-dev][isar-cip-core][PATCH] initramfs-abrootfs: check if /etc/os-release exists
  2022-11-30 11:18 [cip-dev][isar-cip-core][PATCH] initramfs-abrootfs: check if /etc/os-release exists Quirin Gylstorff
@ 2022-12-08  9:30 ` Jan Kiszka
  0 siblings, 0 replies; 2+ messages in thread
From: Jan Kiszka @ 2022-12-08  9:30 UTC (permalink / raw)
  To: Quirin Gylstorff, cip-dev

On 30.11.22 12:18, Quirin Gylstorff wrote:
> From: Quirin Gylstorff <quirin.gylstorff@siemens.com>
> 
> If a valid root file system does not contain /etc/os-release the
> script aborts before checking other root file systems. This occurs
> for example if the boot occurs from a USB stick and a ext4 root
> file system exists on internal memory.
> 
> Also ensure that IMAGE_UUID and TARGET_IMAGE_UUID are not empty
> before comparing to each other.
> 
> Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com>
> ---
>  .../initramfs-abrootfs-hook/files/abrootfs.script          | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/recipes-initramfs/initramfs-abrootfs-hook/files/abrootfs.script b/recipes-initramfs/initramfs-abrootfs-hook/files/abrootfs.script
> index 23bbfe7..848e829 100644
> --- a/recipes-initramfs/initramfs-abrootfs-hook/files/abrootfs.script
> +++ b/recipes-initramfs/initramfs-abrootfs-hook/files/abrootfs.script
> @@ -35,9 +35,12 @@ find_root_via_image_uuid()
>      for part in $partitions; do
>          if [ "$(blkid -p "${part}" --match-types novfat -s USAGE -o value)" = "filesystem" ]; then
>              mount -o ro -t "$(get_fstype "${part}")" "${part}" "${rootmnt}"
> -            . "${rootmnt}/etc/os-release"
> +            if [ -e "${rootmnt}/etc/os-release" ]; then
> +                . "${rootmnt}/etc/os-release"
> +            fi
>              umount "${rootmnt}"
> -            if [ "${IMAGE_UUID}" = "${TARGET_IMAGE_UUID}" ]; then
> +            if [ -n "${IMAGE_UUID}" ] && [ -n "${TARGET_IMAGE_UUID}" ] &&
> +                   [ "${IMAGE_UUID}" = "${TARGET_IMAGE_UUID}" ]; then
>                  found_root="${part}"
>                  break
>              fi

Thanks, applied.

Jan

-- 
Siemens AG, Technology
Competence Center Embedded Linux



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-12-08  9:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-30 11:18 [cip-dev][isar-cip-core][PATCH] initramfs-abrootfs: check if /etc/os-release exists Quirin Gylstorff
2022-12-08  9:30 ` Jan Kiszka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).