diff --git a/package/base-files/files/lib/upgrade/common.sh b/package/base-files/files/lib/upgrade/common.sh index af1182cb16..ba2e364775 100644 --- a/package/base-files/files/lib/upgrade/common.sh +++ b/package/base-files/files/lib/upgrade/common.sh @@ -167,7 +167,7 @@ part_magic_fat() { export_bootdevice() { local cmdline uuid blockdev uevent line class - local MAJOR MINOR DEVNAME DEVTYPE + local MAJOR MINOR DEVNAME DEVTYPE DISKSEQ PARTN local rootpart="$(cmdline_get_var root)" case "$rootpart" in @@ -216,8 +216,7 @@ export_bootdevice() { while read line; do export -n "$line" done < "$uevent" - export BOOTDEV_MAJOR=$MAJOR - export BOOTDEV_MINOR=$MINOR + export BOOTDEV_DISKSEQ=$DISKSEQ return 0 fi @@ -225,16 +224,18 @@ export_bootdevice() { } export_partdevice() { - local var="$1" offset="$2" - local uevent line MAJOR MINOR DEVNAME DEVTYPE + local var="$1" partn="$2" + local uevent line MAJOR MINOR DEVNAME DEVTYPE DISKSEQ PARTN for uevent in /sys/class/block/*/uevent; do while read line; do export -n "$line" done < "$uevent" - if [ "$BOOTDEV_MAJOR" = "$MAJOR" -a $(($BOOTDEV_MINOR + $offset)) = "$MINOR" -a -b "/dev/$DEVNAME" ]; then - export "$var=$DEVNAME" - return 0 + if [ "$BOOTDEV_DISKSEQ" = "$DISKSEQ" -a -b "/dev/$DEVNAME" ]; then + if [ "$PARTN" = "$partn" -a "$DEVTYPE" = "partition" ] || [ "$partn" = "0" -a "$DEVTYPE" = "disk" ]; then + export "$var=$DEVNAME" + return 0 + fi fi done diff --git a/target/linux/stm32/base-files/lib/upgrade/platform.sh b/target/linux/stm32/base-files/lib/upgrade/platform.sh index 4cd88ab6bd..92e5bb5d2b 100644 --- a/target/linux/stm32/base-files/lib/upgrade/platform.sh +++ b/target/linux/stm32/base-files/lib/upgrade/platform.sh @@ -31,8 +31,7 @@ export_bootdevice() { while read line; do export -n "$line" done < "$uevent" - export BOOTDEV_MAJOR=$MAJOR - export BOOTDEV_MINOR=$MINOR + export BOOTDEV_DISKSEQ=$DISKSEQ return 0 fi