[Bug 539] dd gets stuck on bad sectors

bugzilla at busybox.net bugzilla at busybox.net
Wed Aug 5 21:04:53 UTC 2009


https://bugs.busybox.net/show_bug.cgi?id=539





--- Comment #1 from Denys Vlasenko <vda.linux at googlemail.com>  2009-08-05 21:04:52 UTC ---
What GNU dd does with conv=noerror (without sync, that is)?

sync seems to be a dangerous option for image creation, it will result in extra
NUL bytes if there are any short reads.

Typically there are no short reads, but I imagine if you use bs=1M and you hit
a bad sector, there will be a short read and then a failed read. You do not
want to pad short read result, you want it to be copied as-is, and then next
read fails and dd seeks over 1M, writing 1M NULs to output. This at least
preserves file size.

With conv=sync,noerror, there will be extra bytes: 1st 1M block is <data up to
bad sector><NUL padding to 1M>, 2nd 1M block is 1M of NULs.

I plan to fix the bug in dd.c as follows:

                n = safe_read(ifd, ibuf, ibs);
                if (n == 0)
                        break;
                if (n < 0) {
                        if (!(flags & FLAG_NOERROR))
                                goto die_infile;
                        n = ibs;
                        bb_simple_perror_msg(infile);
==>                     /* GNU dd with conv=noerror skips over "bad blocks" */
==>                     xlseek(ifd, ibs, SEEK_CUR);
                }

Please try it.


-- 
Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


More information about the busybox-cvs mailing list