Skip to content
Snippets Groups Projects
Select Git revision
  • 04818c170b2fb6d64eccdec5aa97673ad4419a9f
  • v2018.2.x default
  • experimental
  • master
  • v2021.1.2-ffs
  • v2021.1.1-ffs
  • nrb/gluon-master-cpe510
  • v2021.1-ffs
  • v2020.2.3-ffs
  • nrbffs/fastd-remove-delay
  • v2020.2.2-ffs
  • v2020.2.1-ffs
  • v2020.2-ffs
  • v2020.2.x
  • v2020.1.3-ffs
  • v2020.1.1-ffs
  • v2020.1-ffs
  • v2019.1.2-ffs
  • v2019.1.1-ffs
  • nrb/test-radv-filter
  • v2019.1-ffs
  • nrbffs/netgear-ex6120
  • v2021.1.2-ffs0.2
  • v2021.1.2-ffs0.1
  • v2021.1.1-ffs0.4
  • v2021.1.1-ffs0.3
  • v2021.1.1-ffs0.2
  • v2021.1.1-ffs0.1
  • v2021.1-ffs0.1
  • v2020.2.3-ffs0.3
  • v2020.2.3-ffs0.2
  • v2020.2.3-ffs0.1
  • v2020.2.2-ffs0.1
  • v2020.2.1-ffs0.1
  • v2020.2-ffs0.1
  • v2020.2
  • v2020.2.x-ffs0.1
  • v2020.1.3-ffs0.1
  • v2020.1.1-ffs0.1
  • v2020.1-ffs0.1
  • v2019.1.2-ffs0.1
  • v2019.1.1-ffs0.1
42 results

0086-x86-make-sysupgrade-work-without-partx.patch

Blame
  • Forked from firmware / FFS Gluon
    3501 commits behind the upstream repository.
    user avatar
    Matthias Schiffer authored
    Fixes #961
    bee999dd
    History
    0086-x86-make-sysupgrade-work-without-partx.patch 2.45 KiB
    From: Jo-Philipp Wich <jo@mein.io>
    Date: Wed, 30 Mar 2016 03:10:51 +0200
    Subject: x86: make sysupgrade work without partx
    
    Signed-off-by: Jo-Philipp Wich <jo@mein.io>
    
    Backport of LEDE 9f422eba7c1a297a96a03b1cce05fa3cb9d71a4a
    
    diff --git a/target/linux/x86/base-files/lib/upgrade/platform.sh b/target/linux/x86/base-files/lib/upgrade/platform.sh
    index c21f1a7e5feba553110f138c14977daaa472da70..f12deebf6484df6f3f69e453ad67688a76d57972 100644
    --- a/target/linux/x86/base-files/lib/upgrade/platform.sh
    +++ b/target/linux/x86/base-files/lib/upgrade/platform.sh
    @@ -61,7 +61,27 @@ get_partitions() { # <device> <filename>
     
     	if [ -b "$disk" -o -f "$disk" ]; then
     		echo "Reading partition table from $filename..."
    -		partx -r "$disk" -gbo NR,START,SECTORS > "/tmp/partx.$filename"
    +
    +		local magic="$(hexdump -v -n 2 -s 0x1FE -e '1/2 "0x%04X"' "$disk")"
    +		if [ "$magic" != 0xAA55 ]; then
    +			echo "Invalid partition table on $disk"
    +			exit
    +		fi
    +
    +		rm -f "/tmp/partmap.$filename"
    +
    +		local part
    +		for part in 1 2 3 4; do
    +			set -- $(hexdump -v -n 12 -s "$((0x1B2 + $part * 16))" -e '3/4 "0x%08X "' "$disk")
    +
    +			local type="$(($1 % 256))"
    +			local lba="$(($2))"
    +			local num="$(($3))"
    +
    +			[ $type -gt 0 ] || continue
    +
    +			printf "%2d %5d %7d\n" $part $lba $num >> "/tmp/partmap.$filename"
    +		done
     	fi
     }
     
    @@ -76,9 +96,11 @@ platform_do_upgrade() {
     
     
     			#get block size
    -			sectors="$(partx -r $disk -gbo SECTORS --nr 1:1)"
    -			size="$(partx -r $disk -gbo SIZE --nr 1:1)"
    -			ibs="$(($size / $sectors))"
    +			if [ -f "/sys/block/${disk##*/}/queue/physical_block_size" ]; then
    +				ibs="$(cat "/sys/block/${disk##*/}/queue/physical_block_size")"
    +			else
    +				ibs=512
    +			fi
     
     			#extract the boot sector from the image
     			get_image "$@" | dd of=/tmp/image.bs count=1 bs=512b
    @@ -86,7 +108,7 @@ platform_do_upgrade() {
     			get_partitions /tmp/image.bs image
     
     			#compare tables
    -			diff="$(grep -F -x -v -f /tmp/partx.bootdisk /tmp/partx.image)"
    +			diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.image)"
     			if [ -n "$diff" ]; then
     				echo "Partition layout is changed.  Full image will be written."
     				ask_bool 0 "Abort" && exit
    @@ -99,7 +121,7 @@ platform_do_upgrade() {
     			while read part start size; do
     			echo "Writing image to $disk$part..."
     				get_image "$@" | dd of="$disk$part" ibs="$ibs" obs=1M skip="$start" count="$size" conv=fsync
    -			done < /tmp/partx.image
    +			done < /tmp/partmap.image
     
     			#copy partition uuid
     			echo "Writing new UUID to $disk$part..."