diff mbox series

[v3,10/11] x86: upgrade: use get_image_dd

Message ID 20201110134558.7905-11-yszhou4tech@gmail.com
State Accepted
Delegated to: Yousong Zhou
Headers show
Series sysupgrade: reword and organize log lines | expand

Commit Message

Yousong Zhou Nov. 10, 2020, 1:45 p.m. UTC
Ref: https://bugs.openwrt.org/index.php?do=details&task_id=3140
Reported-by: Philip Prindeville <philipp@redfish-solutions.com>
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
---
 target/linux/x86/base-files/lib/upgrade/platform.sh | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Philip Prindeville Nov. 10, 2020, 5:19 p.m. UTC | #1
Reviewed-By: Philip Prindeville <philipp@redfish-solutions.com>


> On Nov 10, 2020, at 6:45 AM, Yousong Zhou <yszhou4tech@gmail.com> wrote:
> 
> Ref: https://bugs.openwrt.org/index.php?do=details&task_id=3140
> Reported-by: Philip Prindeville <philipp@redfish-solutions.com>
> Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
> ---
> target/linux/x86/base-files/lib/upgrade/platform.sh | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/target/linux/x86/base-files/lib/upgrade/platform.sh b/target/linux/x86/base-files/lib/upgrade/platform.sh
> index 617b267e68..0b54caea29 100644
> --- a/target/linux/x86/base-files/lib/upgrade/platform.sh
> +++ b/target/linux/x86/base-files/lib/upgrade/platform.sh
> @@ -20,7 +20,7 @@ platform_check_image() {
> 	get_partitions "/dev/$diskdev" bootdisk
> 
> 	#extract the boot sector from the image
> -	get_image "$@" | dd of=/tmp/image.bs count=63 bs=512b 2>/dev/null
> +	get_image_dd "$1" of=/tmp/image.bs count=63 bs=512b
> 
> 	get_partitions /tmp/image.bs image
> 
> @@ -83,7 +83,7 @@ platform_do_upgrade() {
> 		get_partitions "/dev/$diskdev" bootdisk
> 
> 		#extract the boot sector from the image
> -		get_image "$@" | dd of=/tmp/image.bs count=63 bs=512b >/dev/null
> +		get_image_dd "$1" of=/tmp/image.bs count=63 bs=512b
> 
> 		get_partitions /tmp/image.bs image
> 
> @@ -94,7 +94,7 @@ platform_do_upgrade() {
> 	fi
> 
> 	if [ -n "$diff" ]; then
> -		get_image "$@" | dd of="/dev/$diskdev" bs=4096 conv=fsync
> +		get_image_dd "$1" of="/dev/$diskdev" bs=4096 conv=fsync
> 
> 		# Separate removal and addtion is necessary; otherwise, partition 1
> 		# will be missing if it overlaps with the old partition 2
> @@ -108,7 +108,7 @@ platform_do_upgrade() {
> 	while read part start size; do
> 		if export_partdevice partdev $part; then
> 			v "Writing image to /dev/$partdev..."
> -			get_image "$@" | dd of="/dev/$partdev" ibs=512 obs=1M skip="$start" count="$size" conv=fsync
> +			get_image_dd "$1" of="/dev/$partdev" ibs=512 obs=1M skip="$start" count="$size" conv=fsync
> 		else
> 			v "Unable to find partition $part device, skipped."
> 		fi
> @@ -116,7 +116,7 @@ platform_do_upgrade() {
> 
> 	#copy partition uuid
> 	v "Writing new UUID to /dev/$diskdev..."
> -	get_image "$@" | dd of="/dev/$diskdev" bs=1 skip=440 count=4 seek=440 conv=fsync
> +	get_image_dd "$1" of="/dev/$diskdev" bs=1 skip=440 count=4 seek=440 conv=fsync
> 
> 	platform_do_bootloader_upgrade "$diskdev"
> 	local parttype=ext4
diff mbox series

Patch

diff --git a/target/linux/x86/base-files/lib/upgrade/platform.sh b/target/linux/x86/base-files/lib/upgrade/platform.sh
index 617b267e68..0b54caea29 100644
--- a/target/linux/x86/base-files/lib/upgrade/platform.sh
+++ b/target/linux/x86/base-files/lib/upgrade/platform.sh
@@ -20,7 +20,7 @@  platform_check_image() {
 	get_partitions "/dev/$diskdev" bootdisk
 
 	#extract the boot sector from the image
-	get_image "$@" | dd of=/tmp/image.bs count=63 bs=512b 2>/dev/null
+	get_image_dd "$1" of=/tmp/image.bs count=63 bs=512b
 
 	get_partitions /tmp/image.bs image
 
@@ -83,7 +83,7 @@  platform_do_upgrade() {
 		get_partitions "/dev/$diskdev" bootdisk
 
 		#extract the boot sector from the image
-		get_image "$@" | dd of=/tmp/image.bs count=63 bs=512b >/dev/null
+		get_image_dd "$1" of=/tmp/image.bs count=63 bs=512b
 
 		get_partitions /tmp/image.bs image
 
@@ -94,7 +94,7 @@  platform_do_upgrade() {
 	fi
 
 	if [ -n "$diff" ]; then
-		get_image "$@" | dd of="/dev/$diskdev" bs=4096 conv=fsync
+		get_image_dd "$1" of="/dev/$diskdev" bs=4096 conv=fsync
 
 		# Separate removal and addtion is necessary; otherwise, partition 1
 		# will be missing if it overlaps with the old partition 2
@@ -108,7 +108,7 @@  platform_do_upgrade() {
 	while read part start size; do
 		if export_partdevice partdev $part; then
 			v "Writing image to /dev/$partdev..."
-			get_image "$@" | dd of="/dev/$partdev" ibs=512 obs=1M skip="$start" count="$size" conv=fsync
+			get_image_dd "$1" of="/dev/$partdev" ibs=512 obs=1M skip="$start" count="$size" conv=fsync
 		else
 			v "Unable to find partition $part device, skipped."
 		fi
@@ -116,7 +116,7 @@  platform_do_upgrade() {
 
 	#copy partition uuid
 	v "Writing new UUID to /dev/$diskdev..."
-	get_image "$@" | dd of="/dev/$diskdev" bs=1 skip=440 count=4 seek=440 conv=fsync
+	get_image_dd "$1" of="/dev/$diskdev" bs=1 skip=440 count=4 seek=440 conv=fsync
 
 	platform_do_bootloader_upgrade "$diskdev"
 	local parttype=ext4