Hello community, here is the log from the commit of package dd_rescue for openSUSE:Factory checked in at 2013-06-05 11:48:14 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/dd_rescue (Old) and /work/SRC/openSUSE:Factory/.dd_rescue.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "dd_rescue" Changes: -------- --- /work/SRC/openSUSE:Factory/dd_rescue/dd_rescue.changes 2013-02-11 10:59:07.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.dd_rescue.new/dd_rescue.changes 2013-06-05 11:48:16.000000000 +0200 @@ -1,0 +2,8 @@ +Sun May 26 17:22:08 UTC 2013 - asterios.dra...@gmail.com + +- Update to version 1.33: + * Long options + * New double overwrite mode (-2) + * Man page added + +------------------------------------------------------------------- Old: ---- dd_rescue-1.32.tar.gz New: ---- dd_rescue-1.33.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ dd_rescue.spec ++++++ --- /var/tmp/diff_new_pack.GuO106/_old 2013-06-05 11:48:16.000000000 +0200 +++ /var/tmp/diff_new_pack.GuO106/_new 2013-06-05 11:48:16.000000000 +0200 @@ -17,7 +17,7 @@ Name: dd_rescue -Version: 1.32 +Version: 1.33 Release: 0 Summary: Data Copying in the Presence of I/O Errors License: GPL-2.0 or GPL-3.0 @@ -70,5 +70,6 @@ #UsrMerge /bin/dd_rescue #EndUsrMerge +%doc %{_mandir}/man1/dd_rescue.1%{ext_man} %changelog ++++++ dd_rescue-1.32.tar.gz -> dd_rescue-1.33.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dd_rescue/Makefile new/dd_rescue/Makefile --- old/dd_rescue/Makefile 2013-02-10 09:12:28.000000000 +0100 +++ new/dd_rescue/Makefile 2013-03-30 20:33:15.000000000 +0100 @@ -1,8 +1,8 @@ # Makefile for dd_rescue # (c) garl...@suse.de, 99/10/09, GNU GPL -# $Id: Makefile,v 1.48 2013/02/10 08:12:28 garloff Exp $ +# $Id: Makefile,v 1.50 2013/03/30 19:33:15 garloff Exp $ -VERSION = 1.32 +VERSION = 1.33 DESTDIR = @@ -15,6 +15,7 @@ prefix = $(DESTDIR)/usr #INSTALLDIR = $(prefix)/bin INSTALLDIR = $(DESTDIR)/bin +MANDIR = $(prefix)/share/man/ #MYDIR = dd_rescue-$(VERSION) MYDIR = dd_rescue TARGETS = dd_rescue @@ -66,3 +67,7 @@ $(INSTALL) $(INSTALLFLAGS) $(INSTASROOT) -m 755 $(TARGETS) $(INSTALLDIR) #$(INSTALL) $(INSTASROOT) -m 755 -d $(DOCDIR)/dd_rescue #$(INSTALL) $(INSTASROOT) -g root -m 644 README.dd_rescue $(DOCDIR)/dd_rescue/ + mkdir -p $(MANDIR)/man1 + $(INSTALL) $(INSTASROOT) -m 644 dd_rescue.1 $(MANDIR)/man1/ + gzip -9 $(MANDIR)/man1/dd_rescue.1 + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dd_rescue/README.dd_rescue new/dd_rescue/README.dd_rescue --- old/dd_rescue/README.dd_rescue 2013-02-08 00:59:53.000000000 +0100 +++ new/dd_rescue/README.dd_rescue 2013-02-17 22:47:46.000000000 +0100 @@ -157,6 +157,7 @@ (option -4); this option has been designed to meet the BSI GSDS M7.15 criteria for safe deletion of data. https://www.bsi.bund.de/ContentBSI/grundschutz/baustein-datenschutz/html/m07015.html + Alternatively you can shorten it to just one frandom pass with -2 (since 1.33,). * Starting with 1.32, you can write the data to multiple output files at once (option -Y); it can be used more than once. Also, if you want to concatenate data from multiple input files, @@ -203,4 +204,4 @@ Kurt Garloff <k...@garloff.de>, 2000-08-30 -$Id: README.dd_rescue,v 1.24 2013/02/07 23:59:53 garloff Exp $ +$Id: README.dd_rescue,v 1.25 2013/02/17 21:47:46 garloff Exp $ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dd_rescue/dd_rescue.1 new/dd_rescue/dd_rescue.1 --- old/dd_rescue/dd_rescue.1 1970-01-01 01:00:00.000000000 +0100 +++ new/dd_rescue/dd_rescue.1 2013-03-31 10:23:56.000000000 +0200 @@ -0,0 +1,603 @@ +.\" $Id: dd_rescue.1,v 1.10 2013/03/31 08:23:56 garloff Exp $ +. +.TH dd_rescue 1 "2013-02-24" "Kurt Garloff" "Rescue copy tool" +. +.SH NAME +dd_rescue \- Rescue copy tool +. +.SH SYNOPSIS +.na +.nh +.B dd_rescue +[options] infile outfile +. +.br +.B dd_rescue +[options] [-2/-3/-4/-z/-Z seed/seedfile] outfile +. +.br +.B dd_rescue +[options] [--shred2/--shred3/--shred4/--random/--frandom seed/seedfile] outfile +. +.SH DESCRIPTION +.B dd_rescue +is a tool that copies data from a source (file, block device, pipe, ...) +to one (or several) output file(s). +.PP +If input and output files are seekable (block devices or regular files), +.B dd_rescue +does copy with large blocks (softbs) to increase performance. When +a read error is encountered, +.B dd_rescue +falls back to reading smaller blocks (hardbs), to allow to recover the maximum +amount of data. If blocks can still not be read, +.B dd_rescue +by default skips over them also in the output file, avoiding to overwrite +data that might have been copied there successfully in a previous run. +(Option -A / --alwayswrite changes this.). +. +.PP +.B dd_rescue +can copy in reverse direction as well, allowing to approach a bad spot +from both directions. As trying to read over a bad spot of significant size +can take very long (and potentially cause further damage), this is an important +optimization when recovering data. The +.B dd_rhelp +tool takes advantage of this and automates data recovery. +.B dd_rescue +does not (by default) truncate the output file. +.PP +.B dd_rescue +by default reports on progress, and optionally also writes into a logfile. +It has a progress bar and gives an estimate for the remaining time. +.B dd_rescue +has a wealth of options that influence its behaviour, such as the possibility +to use direct IO for input/output, to use fallocate() to preallocate space +for the output file, using splice copy (in kernel zerocopy) for efficiency, +looking for empty blocks to create sparse files, or using a pseudo random +number generator (PRNG) to quickly overwrite data with random numbers. +.PP +You can use "-" as infile or outfile, meaning stdin or stdout. Note that +this means that either file is not seekable, limiting the usefulness of +some of dd_rescues features. +. +.SH OPTIONS +When parsing numbers, +.B dd_rescue +assumes bytes. It accepts the following suffixes: +.br +b -- 512 size units (blocks) +.br +k -- 1024 size units (binary kilobytes, kiB) +.br +M -- 1024^2 size units (binary megabytes, MiB) +.br +G -- 1024^3 size units (binary gigabytes, GiB) +.PP +The following options may be used to modify the behaviour of +.B dd_rescue +.SS General options +.TP 8 +.BR \-h ", " \-\-help +This option tells +.B dd_rescue +to output a list of options and exit. +.TP 8 +.BR \-V ", " \-\-version +Display version number and exit. +.TP 8 +.BR \-q ", " \-\-quiet +tells +.B dd_rescue +to be less verbose. +.TP 8 +.BR \-v ", " \-\-verbose +makes +.B dd_rescue +more verbose. +.BR \-v ", " \-\-verbose +makes +.B dd_rescue +more verbose. +.TP 8 +.BR \-f ", " \-\-force +makes +.B dd_rescue +skip some sanity checks (e.g. automatically setting reverse direction when +input and output file are the same and ipos < opos). +.TP 8 +.BR \-i ", " \-\-interactive +tells +.B dd_rescue +to ask before overwriting existing files. +. +.SS Block sizes +.TP 8 +.BI \-b\ softbs \fR,\ \fB\-\-softbs= softbs \fR,\ \fB\-\-bs= softbs +sets the (larger) blocksize to +.IR softbs +bytes. +.B dd_rescue +will transfer chunks of that size unless a read error is encountered (or the +end of the input file or the maximum transfer size has been reached). +The default value for this is 64k for buffered I/O and 1M for direct I/O. +.TP 8 +.BI \-B\ hardbs \fR,\ \fB\-\-hardbs= hardbs \fR,\ \fB\-\-block\-size= hardbs +sets the (smaller) fallback blocksize to +.IR hardbs +bytes. When +.B dd_rescue +encounters read errors, it will fall back to copying data in chunks of +this size. This value defaults to 4k for buffered I/O and 512 bytes for +direct I/O. +.br +.IR hardbs +should be equal to or smaller than +.IR softbs . +If both block sizes are identical, no fallback mechanism (and thus no +retry) will take place on read errors. +.TP 8 +.BI \-y\ syncfreq \fR,\ \fB\-\-syncfreq= syncfreq +tells +.B dd_rescue +to call fsync() on the output file every +.IR syncfreq +blocks (in terms of +.IR softbs +sized blocks). It will also update the progress indicator at least as +often. By default, +.IR syyncfreq +is set to 0, meaning that fsync() is only issued at the end of the +copy operation. +. +.SS Positions and length +.TP 8 +.BI \-s\ ipos \fR,\ \fB\-\-ipos= ipos \fR,\ \fB\-\-input\-position= ipos +sets the starting position of the +.IR infile +to +.IR ipos . +Note that ipos is specified in bytes (but suffixes can be used, see above), +not in terms of +.IR softbs +or +.IR hardbs +sized blocks. +The default value for this is 0. When reverse direction copy is used, an +.IR ipos +of 0 is treated specially, meaning the end of file. +.br +Negative positions result in an error message. +.TP 8 +.BI \-S\ opos \fR,\ \fB\-\-opos= opos \fR,\ \fB\-\-output\-position= opos +sets the starting position of the +.IR outfile +to +.IR opos . +If not specified, +.IR opos +is set to +.IR ipos , +so the file offsets in input and output file are the same. +For reverse direction copy, an explicit +.IR opos +of 0 will position at the end of the output file. +.TP 8 +.BR \-x ", " \-\-extend ", " \-\-append +changes the interpretation of the output position to start at the +end of the existing output file, making appending to a file convenient. +If the output file does not exist, an error will be reported and +.B dd_rescue +aborted. +.TP 8 +.BI \-m\ maxxfer \fR,\ \fB\-\-maxxfer= maxxfer \fR,\ \fB\-\-max\-size= maxxfer +specifies the maximum number of bytes (suffixes apply, but it's NOT +counted in blocks) that +.B dd_rescue +copies. If EOF is encountered before +.IR maxxfer +bytes have been transferred, this option will be silently ignored. +.TP 8 +.BR \-M ", " \-\-noextend +tells +.B dd_rescue +to not extend the output file. This option is particularly helpful +when overwriting a file with random data or zeroes for safe data +destruction. If the output file does not exist, an error message +will be generated and the program be aborted. +.SS Error handling +.TP 8 +.BI \-e\ maxerr \fR,\ \fB\-\-maxerr= maxerr +tells +.B dd_rescue +to exit, after +.IR maxerr +read errors have been encountered. By default, this is set to 0, +resulting in +.B dd_rescue +trying to move on until it hits EOF (or +.IR maxxfer +bytes have been transferred). +.TP 8 +.BR \-w ", " \-\-abort_we +makes +.B dd_rescue +abort on any write errors. By default, write errors are ignored. +This is because for buffered writes, errors can't be detected and +located reliably anyway. Also, write errors are not often reported +to userspace, as hard drives e.g. reallocate bad blocks on writes +and the OS block layer typically also does some retries on write +operations. Note that +.B dd_rescue +does exit if writes to the output file result in the Operating +System reporting that no space is left. +.SS Sparse files and write avoidance +.TP 8 +.BR \-A ", " \-\-alwayswrite +changes the behaviour of +.B dd_rescue +to write zeroes to the output file when the input file could not +be read. By default, it just skips over, leaving whatever content +was in the output file at the file position before. The default +behaviour may be desired, if e.g. previous copy operations may have +resulted in good data being in place; it may be undesired if the +output file may contain garbage (or sensitive information) that should +rather be overwritten with zeroes. +.TP 8 +.BR \-a ", " \-\-sparse +will make +.B dd_rescue +look for empty blocks (of +.IR softbs +size), i.e. blocks filled with zeroes. Rather than writing those +zeroes to the output file, it will then skip forward in the output +file, resulting in a sparse file, saving space in the output filesystem +(if it supports sparse files). Note that if the output file does already +exist and already has data stored at the location where zeroes are skipped +over, this will result in an incomplete copy in that the output file is +different from the input file, where blocks of zeroes are skipped over. +.B dd_rescue +tries to detect this and issue a warning, but it does not prevent this +from happening +.TP 8 +.BR \-W ", " \-\-avoidwrite +results in +.B dd_rescue +reading a block ( +.IR softbs +sized) from the output file prior to writing it. If it is already identical +with the data that would be written to it, the writes are actually avoided. +This option may be useful for devices, where e.g. writes should be avoided +(e.g. because they may impact the reaining lifetime or because they are very +slow compared to reads). +.SS Other optimizations +.TP 8 +.BR \-R ", " \-\-repeat +tells +.B dd_rescue +to only read one block ( +.IR softbs +sized) and then repeatedly write it to the output file. +Note that this results in never hitting EOF on the input file and should be +used with a limit for the transfer size (options -m or -M) or when filling +up an output device completely. +.br +This option is automatically set, if the input file name equals "/dev/zero". +.TP 8 +.BR \-k ", " \-\-splice +tells +.B dd_rescue +to use the Linux in-kernel zerocopy splice() copy operation rather than +reading blocks into a userspace buffer. Note that this operation mode +does prevent the support of a number of +.B dd_rescue +features that can normally be used, such as falling back to smaller block +sizes, avoiding writes, sparse mode, repeat optimization, reverse direction +copy. A warning is issued to make the user aware. +.TP 8 +.BR \-P ", " \-\-fallocate +results in +.B dd_rescue +calling fallocate() on the output file, telling the filesystem how much +space to preallocate for the output file. (The size is determined by the +expected last position, as inferred from the input file length and +.IR maxxfer +). On filesystems that support it, this results in them making better +allocation decisions, avoiding fragmentation. (Note that it does not +make sense to use sparse together with fallocate().) +.SS Misc options +.TP 8 +.BR \-r ", " \-\-reverse +tells +.B dd_rescue +to copy in reverse direction, starting at +.IR ipos +(with special case 0 meaning EOF) and working towards the beginning of +the file. This is especially helpful if the input file has a bad spot +which can be extremely slow to skip over, so approaching it from both +directions saves a lot of time (and may prevent further damage). +.br +Note that +.B dd_rescue +does automatically switch to reverse direction copy, if input and output +file are identical and the input position is smaller than the output +position, similar to the intelligence that memmove() uses to prevent +loss of data when overlapping areas are copied. The option -f / --force +does prevent this intelligence from happening. +.TP 8 +.BR \-p ", " \-\-preserve +When copying files, this option does result in file metadata (timestamps, +ownership, access rights) to be copied, similar to the option with the +same name in the cp program. +.br +Note that +.B dd_rescue +at this point does not have support for copying extended attributes +or ACLs. (But the behaviour of -p is still consistent with cp.) +.TP 8 +.BR \-t ", " \-\-truncate +tells +.B dd_rescue +to open the output file with O_TRUNC, resulting in the output file +(if it is a regular file) to be truncated to 0 bytes, removing all +previous content that the file may have contained. By default, +.B dd_rescue +does not remove previous content. +.TP 8 +.BR \-T ", " \-\-trunclast +tells +.B dd_rescue +to truncate the output file to the highest copied position, thus +ensuring there's no data beyond the end of the data that has been +copied in this run. +.TP 8 +.BR \-d ", " \-\-odir_in +instructs +.b dd_rescue +to open +.IR infie +with O_DIRECT, bypassing the kernel buffers. While this option has a negative +effect on performance (the kernel does readahead for buffered I/O), it will +result in errors to be detected more quickly (kernel won't retry) and allows +for smaller I/O units (hardware sector size, 512bytes for most hard disks). +.TP 8 +.BR \-D ", " \-\-odir_out +tells +.B dd_rescue +to open +.IR outfile +with O_DIRECT, bypassing kernel buffers. This has a significant negative +effect on performance, as the program needs to wait for writes to hit the +disks as opposed to the asynchronous nature of buffered writeback. +On the flipside, the return status from writing is reliable this +way and smaller I/O chunks (hardware sector size, 512bytes) are possible. + +.SS Logging +.TP 8 +.BI \-l\ logfile \fR,\ \fB\-\-logfile= logfile +Unless in quiet mode, +.B dd_rescue +does produce constant updates on the status of the copy operation to +stderr. With this option, these updates are also written to the specified +.IR logfile . +The control characters (to move the cursor up to overwrite the existing +status lines) are not written to the logfile. +.TP 8 +.BI \-o\ bbfile \fR,\ \fB\-\-bbfile= bbfile +instructs +.B dd_rescue +to write a list of bad blocks to +.IR bbfile . +The file will contain a list of numbers (ASCII), one per line, where +the numbers indicate the offset in terms of +.IR hardbs +sized blocks. The file format is compatible with that of badblocks. +Using dd_rescue on a block device (partition) and setting +.IR hardbs +to the block size of a filesystem that you want to create, you should +be able to feed the +.IR bbfile +to mke2fs with the option -l. + +.SS Multiple output files +.TP 8 +.BI \-Y\ ofileX \fR,\ \fB\-\-outfile= ofileX \fR,\ \fB\-\-of= ofileX +If you want to copy data to multiple filess simultaneously, you can specify +this option. It can be specified multiple times, so many copies can be made. +Note that these files are secondary output files; they share file position +with the primary output file +.IR outfile . +Errors when writing to a secondary output file are ignored. + +.SS Random data generation +.TP 8 +.BI \-z\ RANDSEED \fR,\ \fB\-\-random= RANDSEED +.PD 0 +.TP +.BI \-Z\ RANDSEED \fR,\ \fB\-\-frandom= RANDSEED +.TP +.BI \-2\ RANDSEED \fR,\ \fB\-\-shred2= RANDSEED +.TP +.BI \-3\ RANDSEED \fR,\ \fB\-\-shred3= RANDSEED +.TP +.BI \-4\ RANDSEED \fR,\ \fB\-\-shred4= RANDSEED +.PD 1 +.\".PD 0 +.\".IP "\fB\-5\fR \fIRANDSEED\fR,\ \fB\-\-shred5=\fR\fIRANDSEED\fR" 4 +When you want to overwrite a file, partition or disk with random data, +using /dev/urandom (on Linux) as input is not a very good idea; the interface +has not been designed to yield a high bandwidth. It's better to use a +userspace Pseudo Random Number Generator (PRNG). With option -z / --random, +the C library's PRNG is used. With -Z / --frandom and the -2/-3/-4 / +--shred2/3/4 options, an RC4 based PRNG is used. +.br +Note that in this mode, there is no +.IR infile +so the first non-option argument is the output file. +.br +The PRNG needs seeding; the C libraries PRNG takes a 32bit integer (4 bytes); +the RC4 based PRNG takes 256 bytes. If +.IR RANDSEED +is an integer, the integer +number will be used to seed the C library's PRNG. For the RC4 method, the C +library's PRNG then generates the 256 bytes to seed it. This creates +repeatable PRNG data. The RANDSEED value of 0 is special; it will create +a seedval that's based on the current time and the process' PID and should +be different for multiple runs of +.B dd_recue . +.br +If +.IR RANDSEED +is not an integer, it's assumed to be a filename from which the seed values +can be read. +.B dd_rescue +will read 4 or 256 bytes from the file to seed the C library's or the RC4 +PRNG. For good pseudo random numbers, using /dev/urandom to seed is a good idea. +.br +The modes -2/-3/-4 resp. --shred2/--shred3/--shred4 will overwrite the output +file multiple times; after each pass, fsync() will ensure that the data does +indeed hit the file. The last pass for these modes will overwrite the file +with zeroes. The rationale behind doing this is to make it easier to hide +that important data may have been overwritten, to make it easier for intelligent +storage systems (such as SSDs) to recycle the empty blocks and to allow for +better compression of a filesystem image containing such data. +.br +With -2 / --shred2, one pass with RC4 generated PRNG is happening and then +zeroes are written. With -3 / --shred3, there are two passes with RC4 PRNG +generated random numbers and a zero pass; the second PRNG pass writes the +inverse (bitwise reversed) numbers from the first pass. -4 / --shred4 works +like -3 / --shred3, with an additional pass with independent random numbers +as third pass. + +.SH EXIT STATUS +On successful completion, +.B dd_rescue +returns an exit code of 0. +Any other exit code indicates that the program has aborted because of an +error condition or that copying of the file has not been entirely successful. +.PP +.\"TODO: Better documentation of the error codes! + +.SH EXAMPLES +.TP +.BI dd_rescue\ \-k\ \-P\ \-p\ \-t\ infile\ outfile +copies +.IR infile +to +.IR outfile +and does truncate the output file on opening (so deleting any previous data +in it), copies mode, times, ownerships at the end, uses fallocate to +reserve the space for the output file and uses efficient in kernel splice +copy method. +.TP +.BI dd_rescue\ \-A\ \-d\ \-D\ \-b\ 512\ /dev/sda\ /dev/sda +reads the contents of every sector of disk sda and writes it back to the +same location. Typical hard disks reallocate flaky and faulty sectors on +writes, so this operation may result in the complete disk being usable +again when there were errors before. Unreadable blocks however will contain +zeroes after this. +.TP +.BI dd_rescue\ \-2\ /dev/urandom\ \-M\ outfile +overwrites the file +.IR outfile +twice; once with good pseudo random numbers and then with zeroes. +.TP +.BI dd_rescue\ \-t\ \-a\ image1.raw\ image2.raw +copies a filesystem image and looks for empty blocks to create a +sparse output file to save disk space. (If the source filesystem +has been used a bit, on that filesystem creating a large file with +zeroes and removing it again prior to this operation will result +in more sectors with zeroes. dd_rescue /dev/zero DUMMY; rm DUMMY +will achieve this ...) +.PP +See README.dd_rescue to learn about some more possibilities. +.SH BUGS/LIMITATIONS +The source code does use the 64bit functions provided by glibc for file +positioning. However, your kernel might not support it, so you might be +unable to copy partitions larger then 2GB into a file. +.br +This program has been written using Linux and only tested on a couple of +Linux systems. It should be possible to port it easily to other Un*x +platforms, and I occasionally get hints from users of other *nix like +systems that I take into account. Still, my own testing is limited to Linux. +.br +Currently, the escape sequence for moving the cursor up is hard coded in the +sources. It's fine for most terminal emulations (including vt100 and linux), +but it should use the terminal description database instead. +.br +Since dd_rescue-1.10, non-seekable input or output files are supported, +but there's of course limitations to recover errors in such cases. +.PP +The modes for overwriting data with pseudo random numbers to securely +delete sensitive data on purpose only implement a limited number of +overwrites. While Peter Gutmann's classic analysis concludes that the +then current harddisk technology requires more overwrites to be really +secure, the author believes that modern hard disk technology does not +allow data restoration in sectors that have been overwritten with the +--shred4 mode. This is in compliance with the recommendations from +BSI GSDS M7.15. +.br +However, users should be aware that depending on your filesystem, overwriting +files with this technology may not render file content safely overwritten +on hard disk. This is due to journals keeping data or filesystems writing +data to different locations every time. So here, only overwriting a whole +partition or disk will be effective. The fact that the hard disk firmware +has spare sectors to be allocated when regular sectors become flaky or +faulty may leave traces of files on the medium. The Flash Translation Layer +on SSDs may have similar effects. +.PP +dd_rescue does not automate the recovery of faulty files or partitions +by automatically keeping a list of copied sectors and approaching bad spots +from both sides. There is a helper script dd_rhelp from LAB Valentin that +does this. Integration of such a mode into +.B dd_rescue +is non-trivial and due to the complexity of the source code probably +will never happen. +.br +There also is a tool, GNU ddrescue, that is a reimplementation of this +tool and which contains the capabilities to automate recovery of bad +files in the way dd_rhelp does. +.PP +Please report bugs to me via email. +.SH SEE ALSO +.BR README.dd_rescue +.BR README.dd_rhelp +.BR wipe (1) +.BR shred (1) +.BR ddrescue (1) +.BR dd (1) +.SH AUTHOR +Kurt Garloff <k...@garloff.de> +.SH CREDITS +Many little issues were reported by Valentin LAB, the author of +.B dd_rhelp . +.br +The RC4 PRNG (frandom) is a port from Eli Billauer's kernel mode PRNG. +.br +A number of recent ideas and suggestions came from Thomas. +.SH COPYRIGHT +This program is protected by the GNU General Public License (GPL) +v2 or v3 - at your option. +.SH HISTORY +Since version 1.10, non seekable input and output files are supported. +.br +Splice copy -k is supported since 1.15. +.br +A progress bar exists since 1.17. +.br +Support for preallocation (fallocate) -P exists since 1.19. +.br +Since 1.23, we default to -y0, enhancing performance. +.br +The Pseudo Random Number modes have been started with 1.29. +.br +Write avoidance -W has been implemented in 1.30 +.br +Multiple output files -Y have been added in 1.32. +.br +Long options and man page came with 1.33. +.PP +More detailed information can be found on +.br +http://garloff.de/kurt/linux/ddrescue/ + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dd_rescue/dd_rescue.c new/dd_rescue/dd_rescue.c --- old/dd_rescue/dd_rescue.c 2013-02-10 22:37:10.000000000 +0100 +++ new/dd_rescue/dd_rescue.c 2013-03-30 20:24:34.000000000 +0100 @@ -37,6 +37,7 @@ * - Optional colors * - Use dlopen to open libfallocate rather than linking to it ... * - Display more infos on errors by collecting info from syslog + * - A man page ... */ #ifndef VERSION @@ -46,7 +47,7 @@ # define "(unknown compiler)" #endif -#define ID "$Id: dd_rescue.c,v 1.166 2013/02/10 21:37:10 garloff Exp $" +#define ID "$Id: dd_rescue.c,v 1.173 2013/03/30 19:24:34 garloff Exp $" #ifndef BUF_SOFTBLOCKSIZE # define BUF_SOFTBLOCKSIZE 65536 @@ -86,7 +87,7 @@ #include "frandom.h" #include "list.h" -#ifdef HAVE_GETOPT_H +#ifndef LACK_GETOPT_LONG #include <getopt.h> #endif // hack around buggy splice definition(!) @@ -126,7 +127,7 @@ /* Global vars and options */ unsigned int softbs, hardbs, syncfreq; int maxerr, nrerr, dotrunc; -char reverse, abwrerr, sparse, nosparse; +char trunclast, reverse, abwrerr, sparse, nosparse; char verbose, quiet, interact, force, in_report; unsigned char *buf, *buf2; char *lname, *iname, *oname, *bbname = NULL; @@ -140,7 +141,7 @@ int i_rep_zero, prng_seed; char noextend, avoidwrite; char prng_libc, prng_frnd; -char bsim715, bsim715_4, bsim715_2ndpass; +char bsim715, bsim715_4, bsim715_2, bsim715_2ndpass; char extend; char* prng_sfile; @@ -245,12 +246,6 @@ return 0; } -static char* safe_strcat(char* base, const char* toapp) -{ - char* str = realloc(base, strlen(base) + strlen(toapp) + 1); - return strcat(str, toapp); -} - static int openfile(const char* const fname, const int flags) { int fdes; @@ -630,7 +625,7 @@ stat(onm, &st); if (!S_ISREG(st.st_mode)) return 0; - if (st.st_size < maxopos) + if (st.st_size < maxopos || trunclast) return truncate(onm, maxopos); else return 0; @@ -663,7 +658,8 @@ if (rc) fplog(stderr, "dd_rescue: (warning): seek %s (%1.fk): %s!\n", nm, (float)opos/1024, strerror(errno)); - } + } else if (trunclast && !reverse) + truncate(nm, opos); } return err; @@ -1205,30 +1201,33 @@ frandom_release(prng_state); prng_state = prng_state2; prng_state2 = 0; bsim715_2ndpass = 1; - opos = orig_opos; xfer = 0; ipos = 0; - startclock = clock(); gettimeofday(&starttime, NULL); - fprintf(stderr, "dd_rescue: (info): Triple overwrite (BSI M7.15): second pass ... (frandom_inv)\n\n\n\n\n"); - ret += copyfile_softbs(max); - fprintf(stderr, "syncing ... \n%s", up); - ret += fsync(odes); - LISTFOREACH(ofiles, of) - fsync(LISTDATA(of).fd); - /* TODO: better error handling */ - bsim715_2ndpass = 0; - if (bsim715_4) { - frandom_bytes(prng_state, buf, 16); - fprintf(stderr, "dd_rescue: (info): Triple overwrite (BSI M7.15): third pass ... (frandom) \n\n\n\n\n"); + if (!bsim715_2) { opos = orig_opos; xfer = 0; ipos = 0; startclock = clock(); gettimeofday(&starttime, NULL); + fprintf(stderr, "dd_rescue: (info): Triple overwrite (BSI M7.15): second pass ... (frandom_inv)\n\n\n\n\n"); ret += copyfile_softbs(max); fprintf(stderr, "syncing ... \n%s", up); ret += fsync(odes); LISTFOREACH(ofiles, of) fsync(LISTDATA(of).fd); - bsim715_2ndpass = 1; - iname = "FRND+invFRND+FRND2+ZERO"; + /* TODO: better error handling */ + bsim715_2ndpass = 0; + if (bsim715_4) { + frandom_bytes(prng_state, buf, 16); + fprintf(stderr, "dd_rescue: (info): Triple overwrite (BSI M7.15): third pass ... (frandom) \n\n\n\n\n"); + opos = orig_opos; xfer = 0; ipos = 0; + startclock = clock(); gettimeofday(&starttime, NULL); + ret += copyfile_softbs(max); + fprintf(stderr, "syncing ... \n%s", up); + ret += fsync(odes); + LISTFOREACH(ofiles, of) + fsync(LISTDATA(of).fd); + bsim715_2ndpass = 1; + iname = "FRND+invFRND+FRND2+ZERO"; + } else + iname = "FRND+invFRND+ZERO"; } else - iname = "FRND+invFRND+ZERO"; + iname = "FRND+ZERO"; fprintf(stderr, "dd_rescue: (info): Triple overwrite (BSI M7.15): last pass ... (zeros) \n\n\n\n\n"); frandom_release(prng_state); prng_state = 0; memset(buf, 0, softbs); @@ -1328,6 +1327,39 @@ fprintf(stderr, " (at your option).\n"); } + +#ifndef LACK_GETOPT_LONG +struct option longopts[] = { {"help", 0, NULL, 'h'}, {"verbose", 0, NULL, 'v'}, + {"quiet", 0, NULL, 'q'}, {"version", 0, NULL, 'V'}, + {"ipos", 1, NULL, 's'}, {"opos", 1, NULL, 'S'}, + {"softbs", 1, NULL, 'b'}, {"hardbs", 1, NULL, 'B'}, + {"maxerr", 1, NULL, 'e'}, {"maxxfer", 1, NULL, 'm'}, + {"noextend", 0, NULL, 'M'}, {"extend", 0, NULL, 'x'}, {"append", 0, NULL, 'x'}, + {"syncfreq", 1, NULL, 'y'}, {"logfile", 1, NULL, 'l'}, + {"bbfile", 1, NULL, 'o'}, {"reverse", 0, NULL, 'r'}, + {"repeat", 0, NULL, 'R'}, {"truncate", 0, NULL, 't'}, + {"trunclast", 0, NULL, 'T'}, + {"odir_in", 0, NULL, 'd'}, {"odir_out", 0, NULL, 'D'}, + {"splice", 0, NULL, 'k'}, {"fallocate", 0, NULL, 'P'}, + {"abort_we", 0, NULL, 'w'}, {"avoidwrite", 0, NULL, 'W'}, + {"sparse", 0, NULL, 'a'}, {"alwayswrite", 0, NULL, 'A'}, + {"interactive", 0, NULL, 'i'}, {"force", 0, NULL, 'f'}, + {"preserve", 0, NULL, 'p'}, {"outfile", 1, NULL, 'Y'}, + {"random", 1, NULL, 'z'}, {"frandom", 1, NULL, 'Z'}, + {"shred3", 1, NULL, '3'}, {"shred4", 1, NULL, '4'}, + {"shred2", 1, NULL, '2'}, + /* GNU ddrescue compat */ + {"block-size", 1, NULL, 'B'}, {"input-position", 1, NULL, 's'}, + {"output-position", 1, NULL, 'S'}, {"max-size", 1, NULL, 'm'}, + /* dd like args */ + {"bs", 1, NULL, 'b'}, /* seek and skip refer to obs/ibs, thus no direct corresp. */ + {"of", 1, NULL, 'Y'}, /* short form of outfile */ + /* END */ + {NULL, 0, NULL, 0}, +}; +#endif + + void printhelp() { printversion(); @@ -1347,6 +1379,7 @@ fprintf(stderr, " -r reverse direction copy (def=forward),\n"); fprintf(stderr, " -R repeatedly write same block (def if infile is /dev/zero),\n"); fprintf(stderr, " -t truncate output file (def=no),\n"); + fprintf(stderr, " -T truncate output file at last pos (def=no),\n"); #ifdef O_DIRECT fprintf(stderr, " -d/D use O_DIRECT for input/output (def=no),\n"); #endif @@ -1372,7 +1405,8 @@ fprintf(stderr, " from libc or frandom (RC4 based) as input. SEED = 0 means a time based seed;\n"); fprintf(stderr, " Using /dev/urandom as SEEDFILE gives good pseudo random numbers.\n"); fprintf(stderr, "Likewise, -3 SEED/SEEDFILE will overwrite ofile 3 times (r,ir,0, BSI M7.15).\n"); - fprintf(stderr, " With -4 SEED/SEEDFILE you get an additional random pass (r,ir,r2,0).\n\n"); + fprintf(stderr, " With -4 SEED/SEEDFILE you get an additional random pass (r,ir,r2,0).\n"); + fprintf(stderr, " With -2 SEED/SEEDFILE you only get one random pass (r,0).\n\n"); fprintf(stderr, "Sizes may be given in units b(=512), k(=1024), M(=1024^2) or G(1024^3) bytes\n"); fprintf(stderr, "This program is useful to rescue data in case of I/O errors, because\n"); fprintf(stderr, " it does not necessarily abort or truncate the output.\n"); @@ -1390,7 +1424,7 @@ fplog(file, "dd_rescue: (info): Logfile: %s, Maxerr: %li\n", (lname? lname: "(none)"), maxerr); fplog(file, "dd_rescue: (info): Reverse: %s, Trunc: %s, interactive: %s\n", - YESNO(reverse), YESNO(dotrunc), YESNO(interact)); + YESNO(reverse), (dotrunc? "yes": (trunclast? "last": "no")), YESNO(interact)); fplog(file, "dd_rescue: (info): abort on Write errs: %s, spArse write: %s\n", YESNO(abwrerr), (sparse? "yes": (nosparse? "never": "if err"))); fplog(file, "dd_rescue: (info): preserve: %s, splice: %s, avoidWrite: %s\n", @@ -1500,7 +1534,7 @@ /* defaults */ softbs = 0; hardbs = 0; /* marker for defaults */ maxerr = 0; ipos = (off_t)-INT_MAX; opos = (off_t)-INT_MAX; maxxfer = 0; - reverse = 0; dotrunc = 0; abwrerr = 0; sparse = 0; nosparse = 0; + reverse = 0; dotrunc = 0; trunclast = 0; abwrerr = 0; sparse = 0; nosparse = 0; verbose = 0; quiet = 0; interact = 0; force = 0; preserve = 0; lname = 0; iname = 0; oname = 0; o_dir_in = 0; o_dir_out = 0; dosplice = 0; falloc = 0; @@ -1512,7 +1546,7 @@ i_repeat = 0; i_rep_init = 0; i_rep_zero = 0; noextend = 0; avoidwrite = 0; - bsim715 = 0; bsim715_4 = 0; bsim715_2ndpass = 0; + bsim715 = 0; bsim715_4 = 0; bsim715_2 = 0; bsim715_2ndpass = 0; extend = 0; prng_libc = 0; prng_frnd = 0; prng_seed = 0; prng_sfile = 0; @@ -1523,12 +1557,17 @@ #ifdef _SC_PAGESIZE pagesize = sysconf(_SC_PAGESIZE); #endif - - while ((c = getopt(argc, argv, ":rtfihqvVwWaAdDkMRpPb:B:m:e:s:S:l:o:y:z:Z:3:4:xY:")) != -1) { +#ifdef LACK_GETOPT_LONG + while ((c = getopt(argc, argv, ":rtTfihqvVwWaAdDkMRpPb:B:m:e:s:S:l:o:y:z:Z:2:3:4:xY:")) != -1) +#else + while ((c = getopt_long(argc, argv, ":rtTfihqvVwWaAdDkMRpPb:B:m:e:s:S:l:o:y:z:Z:2:3:4:xY:", longopts, NULL)) != -1) +#endif + { switch (c) { case 'r': reverse = 1; break; case 'R': i_repeat = 1; break; case 't': dotrunc = O_TRUNC; break; + case 'T': trunclast = 1; break; case 'i': interact = 1; force = 0; break; case 'f': interact = 0; force = 1; break; #ifdef O_DIRECT @@ -1562,6 +1601,7 @@ case 'Y': do { ofile_t of; of.name = optarg; of.fd = -1; of.cdev = 0; LISTAPPEND(ofiles, of, ofile_t); } while (0); break; case 'z': prng_libc = 1; if (is_filename(optarg)) prng_sfile = optarg; else prng_seed = readint(optarg); break; case 'Z': prng_frnd = 1; if (is_filename(optarg)) prng_sfile = optarg; else prng_seed = readint(optarg); break; + case '2': prng_frnd = 1; if (is_filename(optarg)) prng_sfile = optarg; else prng_seed = readint(optarg); bsim715 = 1; bsim715_2 = 1; break; case '3': prng_frnd = 1; if (is_filename(optarg)) prng_sfile = optarg; else prng_seed = readint(optarg); bsim715 = 1; break; case '4': prng_frnd = 1; if (is_filename(optarg)) prng_sfile = optarg; else prng_seed = readint(optarg); bsim715 = 1; bsim715_4 = 1; break; case ':': fplog (stderr, "dd_rescue: (fatal): option %c requires an argument!\n", optopt); @@ -1838,6 +1878,8 @@ if (bsim715 && o_chr) { fplog(stderr, "dd_rescue: (warning): triple overwrite with non-seekable output!\n"); } + if (reverse && trunclast) + ftruncate(odes, opos); LISTTYPE(ofile_t) *of; LISTFOREACH(ofiles, of) { @@ -1855,6 +1897,8 @@ if (falloc && !oft->cdev) do_fallocate(oft->fd, oft->name); #endif + if (reverse && trunclast) + ftruncate(oft->fd, opos); } /* Install signal handler */ -- To unsubscribe, e-mail: opensuse-commit+unsubscr...@opensuse.org For additional commands, e-mail: opensuse-commit+h...@opensuse.org