Skip to content
Snippets Groups Projects
Commit f8e149f5 authored by ke hu's avatar ke hu Committed by Reidar Cederqvist
Browse files

sysupgrade: on usb-upgrade do not modify image refs #17396

When upgrading from usb storage, do not modify the image
on the storage device
parent 975363a0
No related branches found
No related tags found
2 merge requests!5sysupgrade: on usb-upgrade do not modify image refs #17396,!4sysupgrade: on usb-upgrade do not modify image refs #17396
Pipeline #105 failed
...@@ -296,7 +296,41 @@ check_sig() { ...@@ -296,7 +296,41 @@ check_sig() {
return 1 return 1
} }
#if user upg by command line sysupgrade, so need to check image in usb disk
image_in_usb()
{
local from=$1
local file_name=$(basename $from)
local file_path
file_path="$(mount -t vfat | awk '{print $3}')"
if [ -z "$file_path" ];then
echo 0
else
find /mnt/ -name "$file_name" | grep -q mnt && echo 1 || echo 0
fi
}
do_usb_image_op(){
case "$1" in
save)
#check if the file exist in the usb disk
[ "$(image_in_usb $2)" == "1" ] && cp -f $2 $2.bak
;;
restore)
if [ -f $2.bak ] ;then
mv $2.bak $2
fi
;;
clean)
if [ -f $2.bak ] ;then
rm -f $2.bak
fi
;;
esac
}
#-------------------------------------------------------------- #--------------------------------------------------------------
# Verify an Iopsys image is good for writing # Verify an Iopsys image is good for writing
...@@ -326,6 +360,8 @@ iopsys_check_image() { ...@@ -326,6 +360,8 @@ iopsys_check_image() {
;; ;;
esac esac
do_usb_image_op "save" $from
[ "$(check_crc $from)" == "CRC_OK" ] || { [ "$(check_crc $from)" == "CRC_OK" ] || {
echo "CRC check failed" echo "CRC check failed"
return 1 return 1
...@@ -444,7 +480,8 @@ iopsys_upgrade() { ...@@ -444,7 +480,8 @@ iopsys_upgrade() {
fi fi
# Product specific low level write to flash # Product specific low level write to flash
target_upgrade $from || return target_upgrade $from || ( do_usb_image_op "clean" $from ; return )
do_usb_image_op "restore" $from
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment