bug-ddrescue
[Top][All Lists]
Advanced

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

Feature request: Check read sectors for known 'bad data'


From: Eliyahu Saks
Subject: Feature request: Check read sectors for known 'bad data'
Date: Thu, 21 Jul 2022 23:08:53 +0300

Sometimes when a disk head is failing, a read will be successful but the
actual returned data is garbage - but consistent 'known' garbage. It would
be helpful if the read buffer would be checked for matches to the known
pattern and be marked as bad sectors.

Files containing the search pattern could be passed as arguments on the
command line (like this: --bad-pattern file1.dat --bad-pattern file2.dat)

>>>> Example code:

struct bad_data {
      uint8_t * payload;
      size_t size;
};

std::vector<struct bad_data> bd_list;

>>> and in rescuebook.cc:

for (auto &bd : bd_list)
{
   off_t off = 0; size_t badlen = 0;
   for (; (off + bd.size) <= b.size(); off += bd.size, badlen = 0, off = 0)
{
      if (!memcmp(bd.payload, iobuf() + off, bd.size)) {
        badlen += bd.size;
      } else if (badlen) {
        change_chunk_status( Block( b.pos() + off - bad_size, bad_size ),
Sblock::bad_sector );
        badlen = 0;
      }
   }
   if (badlen)
     change_chunk_status( Block( b.pos() + off - badlen, bad_size ),
Sblock::bad_sector);
}


reply via email to

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