mirror of
https://github.com/flatcar/scripts.git
synced 2025-12-06 18:02:02 +01:00
image_to_usb.sh: allow writing to character devices
This is useful for debugging, e.g. --to /dev/null. The user will have to use --force_non_usb to allow this, in which case all bets are off and we should let her do this. Also note that, before this fix, using --to /dev/null would have given a strange error message (target device does not exist); with it, we're handling all devices in a more comprehensive way, spitting the right error message when appropriate. BUG=None TEST=--to /dev/null dies as expected; works with --force_non_usb Change-Id: I514e14e1f7cc49b3d6172a2a53aa6da33ef5ecfd Reviewed-on: https://gerrit.chromium.org/gerrit/41133 Commit-Queue: Gilad Arnold <garnold@chromium.org> Reviewed-by: Gilad Arnold <garnold@chromium.org> Tested-by: Gilad Arnold <garnold@chromium.org>
This commit is contained in:
parent
8f861c05b6
commit
11e0f66cc9
@ -226,7 +226,7 @@ FLAGS_to=`eval readlink -f ${FLAGS_to}`
|
|||||||
|
|
||||||
# Check whether target device is USB/MMC, and obtain a string descriptor for it.
|
# Check whether target device is USB/MMC, and obtain a string descriptor for it.
|
||||||
unset disk_string
|
unset disk_string
|
||||||
if [ -b "${FLAGS_to}" ]; then
|
if [ -b "${FLAGS_to}" -o -c "${FLAGS_to}" ]; then
|
||||||
if list_usb_disks | grep -q '^'${FLAGS_to##*/}'$' ||
|
if list_usb_disks | grep -q '^'${FLAGS_to##*/}'$' ||
|
||||||
list_mmc_disks | grep -q '^'${FLAGS_to##*/}'$'; then
|
list_mmc_disks | grep -q '^'${FLAGS_to##*/}'$'; then
|
||||||
disk_string=$(get_disk_string ${FLAGS_to})
|
disk_string=$(get_disk_string ${FLAGS_to})
|
||||||
@ -310,7 +310,7 @@ if [ ! -f "${SRC_IMAGE}" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Let's do it.
|
# Let's do it.
|
||||||
if [ -b "${FLAGS_to}" ]; then
|
if [ -b "${FLAGS_to}" -o -c "${FLAGS_to}" ]; then
|
||||||
# Output to a block device (i.e., a real USB key / SD card), so need sudo dd
|
# Output to a block device (i.e., a real USB key / SD card), so need sudo dd
|
||||||
if [ ${FLAGS_install} -ne ${FLAGS_TRUE} ]; then
|
if [ ${FLAGS_install} -ne ${FLAGS_TRUE} ]; then
|
||||||
echo "Copying image ${SRC_IMAGE} to device ${FLAGS_to}..."
|
echo "Copying image ${SRC_IMAGE} to device ${FLAGS_to}..."
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user