[PATCH 03/10] base-files: upgrade: add get_image_dd()

Yousong Zhou yszhou4tech at gmail.com
Tue Nov 3 07:21:00 EST 2020


This is mainly to handle error message "Broken pipe" by common pattern
"xcat | dd .."

Ref: https://bugs.openwrt.org/index.php?do=details&task_id=3140
Reported-by: Philip Prindeville <philipp at redfish-solutions.com>
Signed-off-by: Yousong Zhou <yszhou4tech at gmail.com>
---
 package/base-files/files/lib/upgrade/common.sh | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/package/base-files/files/lib/upgrade/common.sh b/package/base-files/files/lib/upgrade/common.sh
index 808fad178b..654f24d0a7 100644
--- a/package/base-files/files/lib/upgrade/common.sh
+++ b/package/base-files/files/lib/upgrade/common.sh
@@ -94,6 +94,12 @@ get_image() { # <source> [ <command> ]
 	$cmd <"$from"
 }
 
+get_image_dd() {
+	local from="$1"; shift
+
+	( get_image "$from" | dd "$@" ) 2>&1 | grep -v -F ': Broken pipe'
+}
+
 get_magic_word() {
 	(get_image "$@" | dd bs=2 count=1 | hexdump -v -n 2 -e '1/1 "%02x"') 2>/dev/null
 }



More information about the openwrt-devel mailing list