check_ab_partition_scheme() {
CURRENT_AB="$(/bin/sed -E 's|.*(partition_ab=)([a-b]).*|\2|' /proc/cmdline)"
if [ "$CURRENT_AB" != "a" ] && [ "$CURRENT_AB" != "b" ]; then
- flog "[Info] There is no A/B partition scheme"
+ flog "[Error] There is no A/B partition scheme"
exit_error
fi
NEXT_AB="b"
fi
}
+unmap_dp () {
+ local part=$1
+
+ for i in 1 .. 5; do
+ if dmsetup remove --retry "${part}"; then
+ return 0
+ fi
+ done
+
+ flog "[Error] It was not possible to remove /dev/mapper/$part"
+ exit_error
+}
+
unmap_next_dynamic_partitions () {
if [ -n "$SUPERFS" ]; then
local MAPPED_DEVICES=""
MAPPED_DEVICES=$(dmsetup ls)
if [[ $MAPPED_DEVICES = *"rootfs_${NEXT_AB}"* ]]; then
- dmsetup remove rootfs_"${NEXT_AB}"
+ unmap_dp "rootfs_${NEXT_AB}"
fi
if [[ $MAPPED_DEVICES = *"hal_${NEXT_AB}"* ]]; then
- dmsetup remove hal_"${NEXT_AB}"
+ unmap_dp "hal_${NEXT_AB}"
fi
fi
}