From 1866c05be96a2532e363576f34ca67947e5505ab Mon Sep 17 00:00:00 2001
From: Caleb Connolly <caleb@postmarketos.org>
Date: Wed, 17 Apr 2024 18:45:34 +0100
Subject: [PATCH] postmarketos-initramfs: check for root subpartition

In mount_subpartition we currently try to look for the boot partition,
to see if we're done (either we aren't using subpartitions or we found
the right one). However it is possible that a device might have
originally used the subpartition scheme, but was later converted to have
a real boot partition (for EFI for example).

In this scenario, the boot partition would be found immediately, but the
root subpartition would not be.

Address this by making mount_subpartition check for success by calling
find_root_partition instead of find_boot_partition. For most
installations this has no impact.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
---
 main/postmarketos-initramfs/init_functions.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/main/postmarketos-initramfs/init_functions.sh b/main/postmarketos-initramfs/init_functions.sh
index b98d893d40d..100bc988f5a 100644
--- a/main/postmarketos-initramfs/init_functions.sh
+++ b/main/postmarketos-initramfs/init_functions.sh
@@ -129,7 +129,7 @@ mount_subpartitions() {
 	attempt_start=$(get_uptime_seconds)
 	wait_seconds=10
 	echo "Trying to mount subpartitions for $wait_seconds seconds..."
-	while [ -z "$(find_boot_partition)" ]; do
+	while [ -z "$(find_root_partition)" ]; do
 		partitions="$android_parts $(grep -v "loop\|ram" < /proc/diskstats |\
 			sed 's/\(\s\+[0-9]\+\)\+\s\+//;s/ .*//;s/^/\/dev\//')"
 		for partition in $partitions; do
@@ -140,7 +140,7 @@ mount_subpartitions() {
 					# Ensure that this was the *correct* subpartition
 					# Some devices have mmc partitions that appear to have
 					# subpartitions, but aren't our subpartition.
-					if [ -n "$(find_boot_partition)" ]; then
+					if [ -n "$(find_root_partition)" ]; then
 						break
 					fi
 					kpartx -d "$partition"
-- 
GitLab