scripts: sd_fusing_rpi3: check file type before writing an image
authorŁukasz Stelmach <stlman@poczta.fm>
Mon, 13 Sep 2021 16:46:39 +0000 (18:46 +0200)
committerJaehoon Chung <jh80.chung@samsung.com>
Wed, 12 Oct 2022 05:48:58 +0000 (14:48 +0900)
Sometimes, when sfdisk failure is not handeled properly, sd_fusing_rpi3
may leave a regular file named like a device in the /dev directory. Such
file will exist and prevent images from beeing properly flashed until
the machine is rebooted. The message indicates there is somehting wrong
with the device file so users may check and fix any problems.

Change-Id: Ie7021129b858f0f4f2923ce88ee96f349e869029
Signed-off-by: Łukasz Stelmach <stlman@poczta.fm>
scripts/tizen/sd_fusing_rpi3.sh

index e7a7383bef606a5d2e7394a1be44f6ca93f23693..62efa1352eb1369de0fdc5561fb5438052a63b6e 100755 (executable)
@@ -88,6 +88,11 @@ function fusing_image () {
                return
        fi
 
+       if ! [ -b "$device" ]; then
+               print_message 1 "$device is not a block device."
+               exit 1
+       fi
+
        local -r input_size=`du -b $fusing_img | awk '{print $1}'`
        local -r input_size_mb=`expr $input_size / 1024 / 1024`