Compare commits

...

2 Commits

4 changed files with 96 additions and 30 deletions

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# Copyright (c) 2019 # Copyright (c) 2019 - 2020
# Nio Wiklund alias sudodus <nio dot wiklund at gmail dot com> # Nio Wiklund alias sudodus <nio dot wiklund at gmail dot com>
# Thomas Schmitt <scdbackup@gmx.net> # Thomas Schmitt <scdbackup@gmx.net>
# Provided under GPL version 2 or later. # Provided under GPL version 2 or later.
@ -14,6 +14,10 @@
# if $no_xorriso_dd_target_run is empty. It implements what xdt_print_usage # if $no_xorriso_dd_target_run is empty. It implements what xdt_print_usage
# announces. # announces.
xdt_print_version() {
echo "xorriso-dd-target , version 1.5.3 , 2020.01.06.204949"
}
## This obtrusive setting shall make the script safe against exotic locales. ## This obtrusive setting shall make the script safe against exotic locales.
## Supposed to stabilize grep expression interpretation and error messages. ## Supposed to stabilize grep expression interpretation and error messages.
@ -127,12 +131,15 @@ xdt_print_usage() {
echo " is found, then they get listed but no writing" echo " is found, then they get listed but no writing"
echo " happens. In this case, re-run with one of the" echo " happens. In this case, re-run with one of the"
echo " advised device names to get a real write run." 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 " -dummy Report the -DO_WRITE actions but do not perform"
echo " them." echo " them."
echo " -dummy_force If a single device name is given, do a run of" echo " -dummy_force If a single device name is given, do a run of"
echo " -dummy -DO_WRITE even against the advice of" echo " -dummy -DO_WRITE even against the advice of"
echo " this program. This probably shows you ways to" echo " this program. This probably shows you ways to"
echo " shoot your own foot." echo " shoot your own foot."
echo " -version Print version text and then end the program."
echo " -help Print this text to stdout and then end the program." echo " -help Print this text to stdout and then end the program."
echo "Examples:" echo "Examples:"
echo " $0 -with_sudo -list_all" echo " $0 -with_sudo -list_all"
@ -211,11 +218,13 @@ xdt_reset_job() {
xdt_do_write= xdt_do_write=
xdt_dummy_run= xdt_dummy_run=
xdt_dummy_force= xdt_dummy_force=
xdt_no_pacifier=
xdt_do_plug_test= xdt_do_plug_test=
# Status # Status
xdt_sudo_cmd= xdt_sudo_cmd=
xdt_have_su_power= xdt_have_su_power=
xdt_end_after_setup=
return 0 return 0
} }
@ -313,9 +322,18 @@ xdt_arg_interpreter() {
elif test "X$xdt_i" = "X-DO_WRITE" elif test "X$xdt_i" = "X-DO_WRITE"
then then
xdt_do_write=y xdt_do_write=y
elif test "X$xdt_i" = "X-no_pacifier"
then
xdt_no_pacifier=y
elif test "X$xdt_i" = "X-version"
then
xdt_print_version
xdt_end_after_setup=y
return 0
elif test "X$xdt_i" = "X-help" elif test "X$xdt_i" = "X-help"
then then
xdt_print_usage xdt_print_usage
xdt_end_after_setup=y
return 0 return 0
elif echo "X$xdt_i" | grep -v '^X-' >/dev/null elif echo "X$xdt_i" | grep -v '^X-' >/dev/null
then then
@ -331,6 +349,17 @@ xdt_arg_interpreter() {
fi fi
done done
xdt_predict_su_power || return "$?" 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 return 0
} }
@ -725,11 +754,11 @@ xdt_write_image() {
fi fi
if test -n "$xdt_dummy_run" if test -n "$xdt_dummy_run"
then 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 else
echo "Performing:" echo "Performing:"
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"
$xdt_sudo_cmd "$xdt_dd_cmd" if="${1}" bs=1M of=/dev/"${2}" $xdt_sudo_cmd "$xdt_dd_cmd" if="${1}" of=/dev/"${2}" $xdt_dd_bs
xdt_ret="$?" xdt_ret="$?"
sync sync
if test "$xdt_ret" -ne 0 if test "$xdt_ret" -ne 0
@ -848,6 +877,10 @@ xdt_main()
xdt_reset_job xdt_reset_job
xdt_arg_interpreter "$@" || return "$?" xdt_arg_interpreter "$@" || return "$?"
if test -n "$xdt_end_after_setup"
then
return 0
fi
if test -n "$xdt_do_plug_test" if test -n "$xdt_do_plug_test"
then then

View File

@ -9,7 +9,7 @@
.\" First parameter, NAME, should be all caps .\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1) .\" other parameters are allowed: see man(7), man(1)
.TH XORRISO-DD-TARGET 1 "Version 1.5.3, Dec 7, 2019" .TH XORRISO-DD-TARGET 1 "Version 1.5.3, Jan 6, 2020"
.\" Please adjust this date whenever revising the manpage. .\" Please adjust this date whenever revising the manpage.
.\" .\"
.\" Some roff macros, for reference: .\" Some roff macros, for reference:
@ -270,7 +270,7 @@ Unmounted: /dev/sde2
.br .br
Performing: Performing:
.br .br
sudo /bin/dd if='debian\-live\-10.0.0\-amd64\-xfce.iso' bs=1M of=/dev/sde ; sync sudo /bin/dd if='debian\-live\-10.0.0\-amd64\-xfce.iso' of=/dev/sde bs=1M status=progress oflag=dsync ; sync
.br .br
... dd messages ... ... dd messages ...
.SS .SS
@ -326,7 +326,7 @@ AGAINST THE ADVICE BY THIS PROGRAM, a daring user could do:
.br .br
sudo /bin/umount /dev/sdd3 sudo /bin/umount /dev/sdd3
.br .br
sudo /bin/dd if='debian\-live\-10.0.0\-amd64\-xfce.iso' bs=1M of=/dev/sdd ; sync sudo /bin/dd if='debian\-live\-10.0.0\-amd64\-xfce.iso' of=/dev/sdd bs=1M status=progress oflag=dsync ; sync
.br .br
BE SMART. BE CAUTIOUS. BEWARE. BE SMART. BE CAUTIOUS. BEWARE.
.SS .SS
@ -494,6 +494,11 @@ In this case, to get a real write run, consider unplugging unneeded devices,
or using option \-plug_test, or a re\-run with one of the advised device names or using option \-plug_test, or a re\-run with one of the advised device names
as additional argument. as additional argument.
.TP .TP
\fB\-no_pacifier\fR
Do not use dd options to print progress messages and to perform synchronized
output. These options are used by default if program dd offers progress
messages.
.TP
\fB\-dummy\fR \fB\-dummy\fR
Report the \-DO_WRITE actions but do not perform them. Report the \-DO_WRITE actions but do not perform them.
.TP .TP
@ -502,6 +507,10 @@ If a single device name is given, do a run of \-dummy \-DO_WRITE even against
the advice of this program. This probably shows you ways to shoot your own the advice of this program. This probably shows you ways to shoot your own
foot. foot.
.TP .TP
\fB\-version\fR
Print the program name, version text, and timestamp to stdout and then end
the program.
.TP
\fB\-help\fR \fB\-help\fR
Print the help text to stdout and then end the program. Print the help text to stdout and then end the program.
.SH EXAMPLES .SH EXAMPLES

View File

@ -224,8 +224,8 @@ Looking for mount points of sde:
Unmounted: /dev/sde1 Unmounted: /dev/sde1
Unmounted: /dev/sde2 Unmounted: /dev/sde2
Performing: Performing:
sudo /bin/dd if='debian-live-10.0.0-amd64-xfce.iso' bs=1M of=/dev/sde ; sudo /bin/dd if='debian-live-10.0.0-amd64-xfce.iso' of=/dev/sde bs=1M
sync status=progress oflag=dsync ; sync
... dd messages ... ... dd messages ...
 
@ -263,8 +263,8 @@ AGAINST THE ADVICE BY THIS PROGRAM, a daring user could do:
sudo /bin/umount /dev/sdd1 sudo /bin/umount /dev/sdd1
sudo /bin/umount /dev/sdd2 sudo /bin/umount /dev/sdd2
sudo /bin/umount /dev/sdd3 sudo /bin/umount /dev/sdd3
sudo /bin/dd if='debian-live-10.0.0-amd64-xfce.iso' bs=1M of=/dev/sdd ; sudo /bin/dd if='debian-live-10.0.0-amd64-xfce.iso' of=/dev/sdd bs=1M
sync status=progress oflag=dsync ; sync
BE SMART. BE CAUTIOUS. BEWARE. BE SMART. BE CAUTIOUS. BEWARE.
 
@ -390,12 +390,19 @@ File: xorriso-dd-target.info, Node: Options, Next: Examples, Prev: Overview,
In this case, to get a real write run, consider unplugging unneeded In this case, to get a real write run, consider unplugging unneeded
devices, or using option -plug_test, or a re-run with one of the devices, or using option -plug_test, or a re-run with one of the
advised device names as additional argument. advised device names as additional argument.
-no_pacifier
Do not use dd options to print progress messages and to perform
synchronized output. These options are used by default if program
dd offers progress messages.
-dummy -dummy
Report the -DO_WRITE actions but do not perform them. Report the -DO_WRITE actions but do not perform them.
-dummy_force -dummy_force
If a single device name is given, do a run of -dummy -DO_WRITE even If a single device name is given, do a run of -dummy -DO_WRITE even
against the advice of this program. This probably shows you ways against the advice of this program. This probably shows you ways
to shoot your own foot. to shoot your own foot.
-version
Print the program name, version text, and timestamp to stdout and
then end the program.
-help -help
Print the help text to stdout and then end the program. Print the help text to stdout and then end the program.
@ -478,16 +485,18 @@ File: xorriso-dd-target.info, Node: CommandIdx, Next: ConceptIdx, Prev: Legal
* Menu: * Menu:
* -DO_WRITE write image file to device: Options. (line 48) * -DO_WRITE write image file to device: Options. (line 48)
* -dummy report but do not perform: Options. (line 55) * -dummy report but do not perform: Options. (line 59)
* -dummy_force show raw copy commands: Options. (line 57) * -dummy_force show raw copy commands: Options. (line 61)
* -help print help text to stdout: Options. (line 61) * -help print help text to stdout: Options. (line 68)
* -image_file set path of disk image file: Options. (line 45) * -image_file set path of disk image file: Options. (line 45)
* -list_all print list of disk devices: Options. (line 15) * -list_all print list of disk devices: Options. (line 15)
* -list_long print extra device info: Options. (line 18) * -list_long print extra device info: Options. (line 18)
* -look_for_iso demand presence of ISO 9660: Options. (line 33) * -look_for_iso demand presence of ISO 9660: Options. (line 33)
* -max_size set size limit for device: Options. (line 24) * -max_size set size limit for device: Options. (line 24)
* -min_size set size limit for device: Options. (line 29) * -min_size set size limit for device: Options. (line 29)
* -no_pacifier do not show dd progress: Options. (line 55)
* -plug_test detect target device plugging: Options. (line 7) * -plug_test detect target device plugging: Options. (line 7)
* -version print version text to stdout: Options. (line 65)
* -with_sudo run lsblk, umount, dd by sudo: Options. (line 38) * -with_sudo run lsblk, umount, dd by sudo: Options. (line 38)
* -with_vendor_model add drive info to advice: Options. (line 22) * -with_vendor_model add drive info to advice: Options. (line 22)
@ -501,6 +510,7 @@ File: xorriso-dd-target.info, Node: ConceptIdx, Next: Top, Prev: CommandIdx,
* Menu: * Menu:
* Bugs, reporting: Bugreport. (line 6) * Bugs, reporting: Bugreport. (line 6)
* dd progress, do not show, -no_pacifier: Options. (line 55)
* Device info, print extra, -list_long: Options. (line 18) * Device info, print extra, -list_long: Options. (line 18)
* Device size, set limit, -max_size: Options. (line 24) * Device size, set limit, -max_size: Options. (line 24)
* Device size, set limit, -min_size: Options. (line 29) * Device size, set limit, -min_size: Options. (line 29)
@ -508,12 +518,12 @@ File: xorriso-dd-target.info, Node: ConceptIdx, Next: Top, Prev: CommandIdx,
* disk image file, set path, -image_file: Options. (line 45) * disk image file, set path, -image_file: Options. (line 45)
* disk image file, write to device, -DO_WRITE: Options. (line 48) * disk image file, write to device, -DO_WRITE: Options. (line 48)
* Drive info, add to advice, -with_vendor_model: Options. (line 22) * Drive info, add to advice, -with_vendor_model: Options. (line 22)
* help text, print to stdout, -help: Options. (line 61) * help text, print to stdout, -help: Options. (line 68)
* ISO 9660, demand presence on target, -look_for_iso: Options. (line 33) * ISO 9660, demand presence on target, -look_for_iso: Options. (line 33)
* lsblk, umount, dd, run by sudo, -with_sudo: Options. (line 38) * lsblk, umount, dd, run by sudo, -with_sudo: Options. (line 38)
* only report, do not perform, -dummy: Options. (line 55) * only report, do not perform, -dummy: Options. (line 59)
* Problems, reporting: Bugreport. (line 6) * Problems, reporting: Bugreport. (line 6)
* raw copy commands, show, -dummy_force: Options. (line 57) * raw copy commands, show, -dummy_force: Options. (line 61)
* Reasons, list of: Reasons. (line 6) * Reasons, list of: Reasons. (line 6)
* Target device, detect by plugging, -plug_test: Options. (line 7) * Target device, detect by plugging, -plug_test: Options. (line 7)
* Use case, detect intended device by plugging: Plugtest. (line 6) * Use case, detect intended device by plugging: Plugtest. (line 6)
@ -523,6 +533,7 @@ File: xorriso-dd-target.info, Node: ConceptIdx, Next: Top, Prev: CommandIdx,
* Use case, show commands for writing to a not advised device: Unwise. * Use case, show commands for writing to a not advised device: Unwise.
(line 6) (line 6)
* Use case, write image to an advised device: Dowrite. (line 6) * Use case, write image to an advised device: Dowrite. (line 6)
* version text, print to stdout, -version: Options. (line 65)
* xorriso-dd-target, options: Options. (line 6) * xorriso-dd-target, options: Options. (line 6)
@ -535,15 +546,15 @@ Node: Listall3516
Node: Givendevices5089 Node: Givendevices5089
Node: Plugtest6053 Node: Plugtest6053
Node: Dowrite7954 Node: Dowrite7954
Node: Unwise9069 Node: Unwise9097
Node: Reasons10581 Node: Reasons10637
Node: Options13162 Node: Options13218
Node: Examples15964 Node: Examples16315
Node: Files16137 Node: Files16488
Node: Seealso16295 Node: Seealso16646
Node: Bugreport16461 Node: Bugreport16812
Node: Legal17048 Node: Legal17399
Node: CommandIdx17752 Node: CommandIdx18103
Node: ConceptIdx18872 Node: ConceptIdx19369
 
End Tag Table End Tag Table

View File

@ -50,7 +50,7 @@
@c man .\" First parameter, NAME, should be all caps @c man .\" First parameter, NAME, should be all caps
@c man .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection @c man .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
@c man .\" other parameters are allowed: see man(7), man(1) @c man .\" other parameters are allowed: see man(7), man(1)
@c man .TH XORRISO-DD-TARGET 1 "Version 1.5.3, Dec 7, 2019" @c man .TH XORRISO-DD-TARGET 1 "Version 1.5.3, Jan 6, 2020"
@c man .\" Please adjust this date whenever revising the manpage. @c man .\" Please adjust this date whenever revising the manpage.
@c man .\" @c man .\"
@c man .\" Some roff macros, for reference: @c man .\" Some roff macros, for reference:
@ -375,7 +375,7 @@ Unmounted: /dev/sde2
@* @*
Performing: Performing:
@* @*
sudo /bin/dd if='debian-live-10.0.0-amd64-xfce.iso' bs=1M of=/dev/sde ; sync sudo /bin/dd if='debian-live-10.0.0-amd64-xfce.iso' of=/dev/sde bs=1M status=progress oflag=dsync ; sync
@* @*
... dd messages ... ... dd messages ...
@c man .SS @c man .SS
@ -434,7 +434,7 @@ AGAINST THE ADVICE BY THIS PROGRAM, a daring user could do:
@* @*
sudo /bin/umount /dev/sdd3 sudo /bin/umount /dev/sdd3
@* @*
sudo /bin/dd if='debian-live-10.0.0-amd64-xfce.iso' bs=1M of=/dev/sdd ; sync sudo /bin/dd if='debian-live-10.0.0-amd64-xfce.iso' of=/dev/sdd bs=1M status=progress oflag=dsync ; sync
@* @*
BE SMART. BE CAUTIOUS. BEWARE. BE SMART. BE CAUTIOUS. BEWARE.
@c man .SS @c man .SS
@ -630,6 +630,13 @@ In this case, to get a real write run, consider unplugging unneeded devices,
or using option -plug_test, or a re-run with one of the advised device names or using option -plug_test, or a re-run with one of the advised device names
as additional argument. as additional argument.
@c man .TP @c man .TP
@item -no_pacifier
@kindex -no_pacifier do not show dd progress
@cindex dd progress, do not show, -no_pacifier
Do not use dd options to print progress messages and to perform synchronized
output. These options are used by default if program dd offers progress
messages.
@c man .TP
@item -dummy @item -dummy
@kindex -dummy report but do not perform @kindex -dummy report but do not perform
@cindex only report, do not perform, -dummy @cindex only report, do not perform, -dummy
@ -642,6 +649,12 @@ If a single device name is given, do a run of -dummy -DO_WRITE even against
the advice of this program. This probably shows you ways to shoot your own the advice of this program. This probably shows you ways to shoot your own
foot. foot.
@c man .TP @c man .TP
@item -version
@kindex -version print version text to stdout
@cindex version text, print to stdout, -version
Print the program name, version text, and timestamp to stdout and then end
the program.
@c man .TP
@item -help @item -help
@kindex -help print help text to stdout @kindex -help print help text to stdout
@cindex help text, print to stdout, -help @cindex help text, print to stdout, -help