Using dd option status=progress if available

This commit is contained in:
2020-01-06 21:44:11 +01:00
parent 56238c3c6a
commit 557e69ada1
4 changed files with 65 additions and 30 deletions

View File

@ -1,6 +1,6 @@
#!/bin/sh
# Copyright (c) 2019
# Copyright (c) 2019 - 2020
# Nio Wiklund alias sudodus <nio dot wiklund at gmail dot com>
# Thomas Schmitt <scdbackup@gmx.net>
# Provided under GPL version 2 or later.
@ -127,6 +127,8 @@ xdt_print_usage() {
echo " is found, then they get listed but no writing"
echo " happens. In this case, re-run with one of the"
echo " advised device names to get a real write run."
echo " -no_pacifier Do not use dd options to print progress messages"
echo " and to perform synchronized output."
echo " -dummy Report the -DO_WRITE actions but do not perform"
echo " them."
echo " -dummy_force If a single device name is given, do a run of"
@ -211,6 +213,7 @@ xdt_reset_job() {
xdt_do_write=
xdt_dummy_run=
xdt_dummy_force=
xdt_no_pacifier=
xdt_do_plug_test=
# Status
@ -313,6 +316,9 @@ xdt_arg_interpreter() {
elif test "X$xdt_i" = "X-DO_WRITE"
then
xdt_do_write=y
elif test "X$xdt_i" = "X-no_pacifier"
then
xdt_no_pacifier=y
elif test "X$xdt_i" = "X-help"
then
xdt_print_usage
@ -331,6 +337,17 @@ xdt_arg_interpreter() {
fi
done
xdt_predict_su_power || return "$?"
# Prepare for using dd pacifier if desired and available
xdt_dd_bs="bs=1M"
if test -n "$xdt_dd_cmd"
then
if test -z "$xdt_no_pacifier" && \
"$xdt_dd_cmd" if=/dev/zero of=/dev/null count=1 \
bs=1M status=progress oflag=dsync 2>/dev/null
then
xdt_dd_bs="bs=1M status=progress oflag=dsync"
fi
fi
return 0
}
@ -725,11 +742,11 @@ xdt_write_image() {
fi
if test -n "$xdt_dummy_run"
then
echo " $xdt_sudo_cmd $xdt_dd_cmd if='${1}' bs=1M of=/dev/'${2}' ; sync"
echo " $xdt_sudo_cmd $xdt_dd_cmd if='${1}' of=/dev/'${2}' $xdt_dd_bs ; sync"
else
echo "Performing:"
echo " $xdt_sudo_cmd $xdt_dd_cmd if='${1}' bs=1M of=/dev/'${2}' ; sync"
$xdt_sudo_cmd "$xdt_dd_cmd" if="${1}" bs=1M of=/dev/"${2}"
echo " $xdt_sudo_cmd $xdt_dd_cmd if='${1}' of=/dev/'${2}' $xdt_dd_bs ; sync"
$xdt_sudo_cmd "$xdt_dd_cmd" if="${1}" of=/dev/"${2}" $xdt_dd_bs
xdt_ret="$?"
sync
if test "$xdt_ret" -ne 0