Dynamic Partitions: map partitions in recovery 47/306047/1 accepted/tizen/unified/20240308.173940 accepted/tizen/unified/x/20240311.095819
authorJacek Kryszyn <j.kryszyn@samsung.com>
Thu, 15 Feb 2024 15:15:19 +0000 (16:15 +0100)
committerJacek Kryszyn <j.kryszyn@samsung.com>
Thu, 15 Feb 2024 15:15:19 +0000 (16:15 +0100)
Allow mapping of dynamic partitions stored on super partition
when in recovery mode.

Change-Id: I62fb1eecc3acc0225d216beb29a215c249a6afbc

src/bootmode-fota/fota-init.sh
src/bootmode-recovery/recovery-init.in
src/initrd-recovery/init

index 509ed8f35e2b7a5a9a533c60868f2573d7f21551..5fa06a8dcc2c399f556026bb7f9a6f7df074138a 100755 (executable)
@@ -31,21 +31,6 @@ do_reboot() {
        done
 }
 
-function map_from_super() {
-    local part_name="$1"
-    local part_table="$2"
-    echo -e "$part_table" | /usr/sbin/dmsetup create "$part_name" &>/dev/null
-    if [ $? = 0 ]
-    then
-        /usr/sbin/dmsetup mknodes "$part_name"
-        echo "/dev/mapper/$part_name"
-        return 0
-    else
-        echo "WARNING : SUPER FOUND BUT $part_name NOT FOUND" >&2
-        return 1
-    fi
-}
-
 #------------------------------------------------
 #       get partition id
 #------------------------------------------------
@@ -58,29 +43,6 @@ get_partition_id() {
         echo "Using A/B slot: ${P_SLOT}"
     fi
 
-    SUPERFS=`/sbin/blkid -t PARTLABEL=super -o device -l`
-    if [ x$SUPERFS = "x" ]
-    then
-        SUPERFS=`/sbin/blkid -t LABEL=super -o device -l`
-    fi
-
-    if [ x$SUPERFS != "x" ]
-    then
-        PARSE_DYNPARTS=`/usr/sbin/parse-dynparts "$SUPERFS" --list-tables`
-
-        while read -r part_name part_table; do
-            if [ "$part_name" = "rootfs${P_SUFFIX}" ]
-            then
-                PART_ROOTFS=`map_from_super "$part_name" "$part_table"`
-            fi
-
-            if [ "$part_name" = "hal${P_SUFFIX}" ]
-            then
-                PART_HAL=`map_from_super "$part_name" "$part_table"`
-            fi
-        done <<< "$PARSE_DYNPARTS"
-    fi
-
     if [ x$PART_ROOTFS = "x" ]
     then
         PART_ROOTFS=`/sbin/blkid -t PARTLABEL=rootfs${P_SUFFIX} -o device -l`
index 281d2d6eaa2242bccb77e81f7b427b894292e845..e79d776cfc14ef323227357b3c60c3986bea44f7 100755 (executable)
@@ -98,7 +98,10 @@ get_partition_id() {
         echo "Using A/B slot: ${P_SLOT}"
     fi
 
-    PART_ROOTFS=`/sbin/blkid -t PARTLABEL=rootfs${P_SUFFIX} -o device -l`
+    if [ x$PART_ROOTFS = "x" ]
+    then
+        PART_ROOTFS=`/sbin/blkid -t PARTLABEL=rootfs${P_SUFFIX} -o device -l`
+    fi
     if [ x$PART_ROOTFS = "x" ]
     then
         PART_ROOTFS=`/sbin/blkid -L rootfs`
@@ -116,7 +119,10 @@ get_partition_id() {
         PART_RAMDISK=`/sbin/blkid -L ramdisk`
     fi
 
-    PART_HAL=`/sbin/blkid -t PARTLABEL=hal${P_SUFFIX} -o device -l`
+    if [ x$HALFS = "x" ]
+    then
+        PART_HAL=`/sbin/blkid -t PARTLABEL=hal${P_SUFFIX} -o device -l`
+    fi
     if [ x$PART_HAL = "x" ]
     then
         PART_HAL=`/sbin/blkid -L hal`
index a099b538a53281f69f5ea7ac2f862a4bc4254e58..65002f7ebc04f34524362e202ff161861e6da8ca 100755 (executable)
@@ -14,6 +14,9 @@ REBOOT="/sbin/reboot"
 BLKID="/usr/sbin/blkid"
 CP="/bin/cp"
 BOW_RESTORE="/sbin/bow-restore"
+export SUPERFS=""
+export PART_ROOTFS=""
+export PART_HAL=""
 
 #------------------------------------------------
 #       mount_partitions
@@ -50,6 +53,24 @@ mkdir_p_parent() {
     fi
 }
 
+#------------------------------------------------
+#       map_from_super
+#------------------------------------------------
+function map_from_super() {
+    local part_name="$1"
+    local part_table="$2"
+    echo -e "$part_table" | /usr/sbin/dmsetup create "$part_name" &>/dev/null
+    if [ $? = 0 ]
+    then
+        /usr/sbin/dmsetup mknodes "$part_name"
+        echo "/dev/mapper/$part_name"
+        return 0
+    else
+        echo "WARNING : SUPER FOUND BUT $part_name NOT FOUND" >&2
+        return 1
+    fi
+}
+
 #------------------------------------------------
 #       get partition id
 #------------------------------------------------
@@ -62,7 +83,33 @@ get_partition_id() {
         echo "Using A/B slot: ${P_SLOT}"
     fi
 
-    PART_ROOTFS=`/sbin/blkid -t PARTLABEL=rootfs${P_SUFFIX} -o device -l`
+    SUPERFS=`/sbin/blkid -t PARTLABEL=super -o device -l`
+    if [ x$SUPERFS = "x" ]
+    then
+        SUPERFS=`/sbin/blkid -t LABEL=super -o device -l`
+    fi
+
+    if [ x$SUPERFS != "x" ]
+    then
+        PARSE_DYNPARTS=`/usr/sbin/parse-dynparts "$SUPERFS" --list-tables`
+
+        while read -r part_name part_table; do
+            if [ "$part_name" = "rootfs${P_SUFFIX}" ]
+            then
+                PART_ROOTFS=`map_from_super "$part_name" "$part_table"`
+            fi
+
+            if [ "$part_name" = "hal${P_SUFFIX}" ]
+            then
+                PART_HAL=`map_from_super "$part_name" "$part_table"`
+            fi
+        done <<< "$PARSE_DYNPARTS"
+    fi
+
+    if [ x$PART_ROOTFS = "x" ]
+    then
+        PART_ROOTFS=`/sbin/blkid -t PARTLABEL=rootfs${P_SUFFIX} -o device -l`
+    fi
     if [ x$PART_ROOTFS = "x" ]
     then
         PART_ROOTFS=`/sbin/blkid -L rootfs`
@@ -80,7 +127,10 @@ get_partition_id() {
         PART_RAMDISK=`/sbin/blkid -L ramdisk`
     fi
 
-    PART_HAL=`/sbin/blkid -t PARTLABEL=hal${P_SUFFIX} -o device -l`
+    if [ x$PART_HAL = "x" ]
+    then
+        PART_HAL=`/sbin/blkid -t PARTLABEL=hal${P_SUFFIX} -o device -l`
+    fi
     if [ x$PART_HAL = "x" ]
     then
         PART_HAL=`/sbin/blkid -L hal`