recovery init: detach 'update' MTD device from UBI if volume is not found

If the volume is not found, the partition cannot be wiped since it is attached.

Remove 'update' UBI device in:
 * mdev automount script if volume is not found
 * recovery init script before formatting 'update' partition

https://jira.digi.com/browse/DEL-3962

Signed-off-by: Tatiana Leon <tatiana.leon@digi.com>
This commit is contained in:
Tatiana Leon 2017-03-21 18:05:34 +01:00
parent 4850d0ffa9
commit f9194019b6
2 changed files with 2 additions and 1 deletions

View File

@ -43,6 +43,7 @@ if is_update_device; then
fi fi
else else
echo "ERROR: Could not mount '${PARTITION_NAME}' partition, volume not found" echo "ERROR: Could not mount '${PARTITION_NAME}' partition, volume not found"
ubidetach -p "/dev/${MDEV}" >/dev/null 2>&1
rmdir --ignore-fail-on-non-empty ${UPDATE_MOUNTPOINT} rmdir --ignore-fail-on-non-empty ${UPDATE_MOUNTPOINT}
fi fi
fi fi

View File

@ -194,8 +194,8 @@ format_ubi_volume() {
if grep -qs "${1}" /proc/mounts; then if grep -qs "${1}" /proc/mounts; then
local path="$(sed -ne "s/.*:${1} \(.*\) ubifs.*/\1/g;T;p" /proc/mounts 2>/dev/null)" local path="$(sed -ne "s/.*:${1} \(.*\) ubifs.*/\1/g;T;p" /proc/mounts 2>/dev/null)"
umount "${path}" >/dev/null 2>&1 umount "${path}" >/dev/null 2>&1
ubidetach -p "/dev/mtd${mtd_num}" >/dev/null 2>&1
fi fi
ubidetach -p "/dev/mtd${mtd_num}" >/dev/null 2>&1
# Format MTD partition. # Format MTD partition.
if ! ubiformat "/dev/mtd${mtd_num}" -q -y; then if ! ubiformat "/dev/mtd${mtd_num}" -q -y; then
quit_with_error "Error erasing '/dev/mtd${mtd_num}' block" quit_with_error "Error erasing '/dev/mtd${mtd_num}' block"