bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

coreutils-5.2.1 shred minor error


From: Jon Peatfield
Subject: coreutils-5.2.1 shred minor error
Date: Thu, 03 Jun 2004 05:59:05 +0100
User-agent: SEMI/1.14.5 (Awara-Onsen) FLIM/1.14.5 (Demachiyanagi) APEL/10.4 Emacs/21.2 (i686-pc-linux-gnu) MULE/5.0 (SAKAKI)

While testing shred on a device where the size reported is slightly
larger than the real device (I'm not sure how this state was
achieved), I spotted that the code to skip the "bad" sectors seems to
be incorrect.

In the loop to retry partial writes, if the write() returns an error
but the error reported was EIO and iff soff is block aligned it tries
to seek to the next block and increment soff by 512.

However at the end of the loop it still does soff += ssize (the return
from the write()), which moves us to no longer being block aligned so
at the 2nd "error", it fails to skip the block and instead errors out.

You probably never notice unless there are 2 "bad" blocks in the same
region which results in the rewrite code (which is I assume why it
hadn't been fixed before).

Here is a trivial patch which seems to fix it for me:

--cut-here--
--- src/shred.c.orig    Wed Jan 21 22:27:02 2004
+++ src/shred.c Thu Jun  3 04:26:07 2004
@@ -880,6 +880,11 @@
                          != -1)
                        {
                          soff += 512;
+                         /* if we don't "fix" ssize from being <0 (-1
+                             usually) it will be added to soff at the
+                             end of the loop messing up the addition
+                             we just did!  */
+                         ssize=0;
                          continue;
                        }
                      error (0, errno, "%s: lseek", qname);
--cut-here--

Of course I now need to find out why my device is being reported 2
blocks bigger than it really is...

 -- Jon

Jon Peatfield,  Computer Officer,  DAMTP,  University of Cambridge
Mail:  address@hidden     Web:  http://www.damtp.cam.ac.uk/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]