From 383e46e26d469c5f1a92c208b0f9590508c55019 Mon Sep 17 00:00:00 2001 From: Mateusz Moscicki Date: Tue, 1 Feb 2022 13:10:59 +0100 Subject: [PATCH] Add support for the case that rootfs is a device mapped by DM Change-Id: I074e72c9fad9289d059e81bd0801f7f26460aa64 --- scripts/upgrade-fota.sh | 9 ++++++++- scripts/upgrade-partial.sh | 9 ++++++++- scripts/upgrade-prepare-partitions.sh | 9 ++++++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/scripts/upgrade-fota.sh b/scripts/upgrade-fota.sh index fdb5c06..f75f042 100644 --- a/scripts/upgrade-fota.sh +++ b/scripts/upgrade-fota.sh @@ -50,7 +50,14 @@ check_ab_partition_scheme() { } check_used_block_device() { - if ! EMMC_DEVICE="/dev/$(/bin/lsblk -ndo pkname "$(/bin/findmnt / -no SOURCE)")" ||\ + ROOTFS_DEVICE="$(findmnt / -no SOURCE)" + if MAPPER_DEVICE="$(echo ${ROOTFS_DEVICE} | grep /dev/mapper)"; then + DM_NAME=$(basename "${MAPPER_DEVICE}") + DM_N=$(dmsetup ls -o blkdevname | grep "${DM_NAME}" | sed -e 's/^.*(\([^)]\+\))/\1/') + ROOTFS_DEVICE="/dev/$(ls /sys/class/block/${DM_N}/slaves/)" + fi + + if ! EMMC_DEVICE="/dev/$(/bin/lsblk -ndo pkname "${ROOTFS_DEVICE}")" ||\ [ "$EMMC_DEVICE" == "/dev/" ]; then flog "[Error] Unable to find used block device: $EMMC_DEVICE, for /" exit 1 diff --git a/scripts/upgrade-partial.sh b/scripts/upgrade-partial.sh index 0e4c296..d1cc2b3 100644 --- a/scripts/upgrade-partial.sh +++ b/scripts/upgrade-partial.sh @@ -48,7 +48,14 @@ check_ab_partition_scheme() { } check_used_block_device() { - if ! EMMC_DEVICE="/dev/$(/bin/lsblk -ndo pkname "$(/bin/findmnt / -no SOURCE)")" ||\ + ROOTFS_DEVICE="$(findmnt / -no SOURCE)" + if MAPPER_DEVICE="$(echo ${ROOTFS_DEVICE} | grep /dev/mapper)"; then + DM_NAME=$(basename "${MAPPER_DEVICE}") + DM_N=$(dmsetup ls -o blkdevname | grep "${DM_NAME}" | sed -e 's/^.*(\([^)]\+\))/\1/') + ROOTFS_DEVICE="/dev/$(ls /sys/class/block/${DM_N}/slaves/)" + fi + + if ! EMMC_DEVICE="/dev/$(/bin/lsblk -ndo pkname "${ROOTFS_DEVICE}")" ||\ [ "$EMMC_DEVICE" == "/dev/" ]; then flog "[Error] Unable to find used block device: $EMMC_DEVICE, for /" exit 1 diff --git a/scripts/upgrade-prepare-partitions.sh b/scripts/upgrade-prepare-partitions.sh index a014913..75f70d3 100644 --- a/scripts/upgrade-prepare-partitions.sh +++ b/scripts/upgrade-prepare-partitions.sh @@ -40,7 +40,14 @@ check_ab_partition_scheme() { } check_used_block_device() { - if ! EMMC_DEVICE="/dev/$(/bin/lsblk -ndo pkname "$(/bin/findmnt / -no SOURCE)")" ||\ + ROOTFS_DEVICE="$(findmnt / -no SOURCE)" + if MAPPER_DEVICE="$(echo ${ROOTFS_DEVICE} | grep /dev/mapper)"; then + DM_NAME=$(basename "${MAPPER_DEVICE}") + DM_N=$(dmsetup ls -o blkdevname | grep "${DM_NAME}" | sed -e 's/^.*(\([^)]\+\))/\1/') + ROOTFS_DEVICE="/dev/$(ls /sys/class/block/${DM_N}/slaves/)" + fi + + if ! EMMC_DEVICE="/dev/$(/bin/lsblk -ndo pkname "${ROOTFS_DEVICE}")" ||\ [ "$EMMC_DEVICE" == "/dev/" ]; then flog "[Error] Unable to find used block device: $EMMC_DEVICE, for /" exit 1 -- 2.7.4