Commit 952f95e9 authored by Michael Büsch's avatar Michael Büsch

pilc: Fix image writing safety check

Signed-off-by: Michael Büsch's avatarMichael Buesch <m@bues.ch>
parent dd9a61b9
......@@ -122,6 +122,9 @@ write_image()
local image="$1"
local dev="$2"
[ -b "$dev" ] || die "$dev is not a block device"
mount | grep -q "$dev" && die "$dev is mounted. Refusing to write to it!"
if have_program blkdiscard; then
info "Discarding $dev ..."
blkdiscard "$dev" ||\
......@@ -132,9 +135,6 @@ write_image()
info "Writing $image to $dev ..."
[ -b "$dev" ] || die "$dev is not a block device"
mount | grep -q "$dev" && die "$dev is mounted. Refusing to write to it!"
dd if="$image" of="$dev" bs=32M status=progress ||\
die "Failed to write image."
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment