New upstream version 0.79.5
This commit is contained in:
793
rs01-verify.c
793
rs01-verify.c
@@ -1,22 +1,23 @@
|
||||
/* dvdisaster: Additional error correction for optical media.
|
||||
* Copyright (C) 2004-2012 Carsten Gnoerlich.
|
||||
* Project home page: http://www.dvdisaster.com
|
||||
* Email: carsten@dvdisaster.com -or- cgnoerlich@fsfe.org
|
||||
* Copyright (C) 2004-2015 Carsten Gnoerlich.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* Email: carsten@dvdisaster.org -or- cgnoerlich@fsfe.org
|
||||
* Project homepage: http://www.dvdisaster.org
|
||||
*
|
||||
* This file is part of dvdisaster.
|
||||
*
|
||||
* dvdisaster is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* dvdisaster is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA,
|
||||
* or direct your browser at http://www.gnu.org.
|
||||
* along with dvdisaster. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "dvdisaster.h"
|
||||
@@ -149,10 +150,10 @@ static gboolean expose_cb(GtkWidget *widget, GdkEventExpose *event, gpointer dat
|
||||
|
||||
wl->cmpSpiral->mx = a->width / 2;
|
||||
wl->cmpSpiral->my = (wl->cmpSpiral->diameter + a->height - size)/2;
|
||||
// wl->cmpSpiral->my = wl->cmpSpiral->diameter/2 + 20;
|
||||
|
||||
if(event->count) /* Exposure compression */
|
||||
return TRUE;
|
||||
{ return TRUE;
|
||||
}
|
||||
|
||||
/* Redraw the spiral */
|
||||
|
||||
@@ -344,44 +345,46 @@ void CreateRS01VerifyWindow(Method *self, GtkWidget *parent)
|
||||
***/
|
||||
|
||||
typedef struct
|
||||
{ ImageInfo *ii;
|
||||
EccInfo *ei;
|
||||
{ Image *image;
|
||||
} verify_closure;
|
||||
|
||||
static void cleanup(gpointer data)
|
||||
{ verify_closure *cc = (verify_closure*)data;
|
||||
{ verify_closure *vc = (verify_closure*)data;
|
||||
|
||||
Closure->cleanupProc = NULL;
|
||||
UnregisterCleanup();
|
||||
|
||||
if(Closure->guiMode)
|
||||
AllowActions(TRUE);
|
||||
|
||||
if(cc->ii) FreeImageInfo(cc->ii);
|
||||
if(cc->ei) FreeEccInfo(cc->ei);
|
||||
|
||||
g_free(cc);
|
||||
if(vc->image) CloseImage(vc->image);
|
||||
g_free(vc);
|
||||
|
||||
if(Closure->guiMode)
|
||||
g_thread_exit(0);
|
||||
}
|
||||
|
||||
void RS01Verify(Method *self)
|
||||
{ RS01Widgets *wl = (RS01Widgets*)self->widgetList;
|
||||
verify_closure *cc = g_malloc0(sizeof(verify_closure));
|
||||
ImageInfo *ii;
|
||||
EccInfo *ei;
|
||||
void RS01Verify(Image *image)
|
||||
{ verify_closure *vc = g_malloc0(sizeof(verify_closure));
|
||||
Method *self = FindMethod("RS01");
|
||||
RS01Widgets *wl = (RS01Widgets*)self->widgetList;
|
||||
char idigest[33],edigest[33];
|
||||
gint64 excess_sectors = 0;
|
||||
gint64 eh_sectors = 0;
|
||||
int n;
|
||||
char *ecc_advice = NULL;
|
||||
int in_last = 0;
|
||||
|
||||
EccHeader *eh;
|
||||
gint8 method[5];
|
||||
int ecc_in_last = 0;
|
||||
gint64 ecc_blocks,ecc_expected,count;
|
||||
struct MD5Context md5ctxt;
|
||||
int percent,last_percent;
|
||||
unsigned char digest[16];
|
||||
unsigned char buf[1024];
|
||||
|
||||
idigest[0] = 0;
|
||||
|
||||
/*** Prepare for early termination */
|
||||
|
||||
RegisterCleanup(_("Comparison aborted"), cleanup, cc);
|
||||
RegisterCleanup(_("Comparison aborted"), cleanup, vc);
|
||||
|
||||
/*** Examine the .iso file */
|
||||
|
||||
@@ -390,127 +393,132 @@ void RS01Verify(Method *self)
|
||||
_("Comparing image and error correction files."),
|
||||
_("- Checking image file -"));
|
||||
|
||||
PrintLog("\n%s: ", Closure->imageName);
|
||||
ei = cc->ei = OpenEccFile(READABLE_ECC | PRINT_MODE);
|
||||
ii = cc->ii = OpenImageFile(ei ? ei->eh : NULL, PRINT_MODE);
|
||||
|
||||
if(ei)
|
||||
{ eh_sectors = uchar_to_gint64(ei->eh->sectors);
|
||||
if(Closure->guiMode)
|
||||
vc->image = image;
|
||||
if(image && image->eccFile)
|
||||
{ if(Closure->guiMode)
|
||||
SetLabelText(GTK_LABEL(wl->cmpChkSumErrors), "0");
|
||||
}
|
||||
else
|
||||
if(Closure->guiMode)
|
||||
SetLabelText(GTK_LABEL(wl->cmpChkSumErrors), _("n/a"));
|
||||
|
||||
if(!ii)
|
||||
/* Report basic image properties */
|
||||
|
||||
PrintLog("\n%s: ", Closure->imageName);
|
||||
if(!image || !image->file)
|
||||
{ PrintLog(_("not present\n"));
|
||||
|
||||
if(Closure->guiMode)
|
||||
SwitchAndSetFootline(wl->cmpImageNotebook, 0, NULL, NULL);
|
||||
goto process_ecc;
|
||||
}
|
||||
|
||||
if(image->inLast == 2048)
|
||||
{ PrintLog(_("present, contains %lld medium sectors.\n"), image->sectorSize);
|
||||
if(Closure->guiMode)
|
||||
SetLabelText(GTK_LABEL(wl->cmpImageSectors), "%lld", image->sectorSize);
|
||||
}
|
||||
else
|
||||
{ if(ii->inLast == 2048)
|
||||
{ PrintLog(_("present, contains %lld medium sectors.\n"), ii->sectors);
|
||||
if(Closure->guiMode)
|
||||
SetLabelText(GTK_LABEL(wl->cmpImageSectors), "%lld", ii->sectors);
|
||||
}
|
||||
else
|
||||
{ PrintLog(_("present, contains %lld medium sectors and %d bytes.\n"),
|
||||
ii->sectors-1, ii->inLast);
|
||||
if(Closure->guiMode)
|
||||
SetLabelText(GTK_LABEL(wl->cmpImageSectors), _("%lld sectors + %d bytes"),
|
||||
ii->sectors-1, ii->inLast);
|
||||
}
|
||||
{ PrintLog(_("present, contains %lld medium sectors and %d bytes.\n"),
|
||||
image->sectorSize-1, image->inLast);
|
||||
if(Closure->guiMode)
|
||||
SetLabelText(GTK_LABEL(wl->cmpImageSectors), _("%lld sectors + %d bytes"),
|
||||
image->sectorSize-1, image->inLast);
|
||||
}
|
||||
|
||||
RS01ScanImage(self, ii, ei, PRINT_MODE);
|
||||
if(!Closure->quickVerify)
|
||||
RS01ScanImage(self, image, NULL, PRINT_MODE);
|
||||
|
||||
if(Closure->stopActions)
|
||||
{ SetLabelText(GTK_LABEL(wl->cmpImageResult),
|
||||
if(Closure->stopActions)
|
||||
{ if(Closure->stopActions == STOP_CURRENT_ACTION) /* suppress memleak warning when closing window */
|
||||
SetLabelText(GTK_LABEL(wl->cmpImageResult),
|
||||
_("<span %s>Aborted by user request!</span>"),
|
||||
Closure->redMarkup);
|
||||
goto terminate;
|
||||
goto terminate;
|
||||
}
|
||||
|
||||
/*** Peek into the ecc file to get expected sector count */
|
||||
|
||||
if(image->eccFile)
|
||||
{ guint64 diff = 0;
|
||||
|
||||
if(image->sectorSize < image->expectedSectors)
|
||||
{ diff = image->expectedSectors - image->sectorSize;
|
||||
|
||||
PrintLog(_("* truncated image : %lld sectors too short\n"), diff);
|
||||
if(Closure->guiMode)
|
||||
SetLabelText(GTK_LABEL(wl->cmpImageSectors),
|
||||
_("<span %s>%lld (%lld sectors too short)</span>"),
|
||||
Closure->redMarkup, image->sectorSize, diff);
|
||||
image->sectorsMissing += diff;
|
||||
}
|
||||
|
||||
/*** Peek into the ecc file to get expected sector count */
|
||||
|
||||
if(ei)
|
||||
{ gint64 diff = 0;
|
||||
|
||||
if(ii->sectors < eh_sectors)
|
||||
{ diff = eh_sectors - ii->sectors;
|
||||
|
||||
PrintLog(_("* truncated image : %lld sectors too short\n"), diff);
|
||||
if(Closure->guiMode)
|
||||
SetLabelText(GTK_LABEL(wl->cmpImageSectors),
|
||||
_("<span %s>%lld (%lld sectors too short)</span>"),
|
||||
Closure->redMarkup, ii->sectors, diff);
|
||||
ii->sectorsMissing += diff;
|
||||
}
|
||||
if(ii->sectors > eh_sectors)
|
||||
{ excess_sectors = ii->sectors - eh_sectors;
|
||||
}
|
||||
if(image->sectorSize > image->expectedSectors)
|
||||
{ excess_sectors = image->sectorSize - image->expectedSectors;
|
||||
}
|
||||
}
|
||||
|
||||
/*** Show summary of image read */
|
||||
/*** Show summary of image read */
|
||||
|
||||
if(Closure->guiMode)
|
||||
{ if(image->crcErrors)
|
||||
SetLabelText(GTK_LABEL(wl->cmpChkSumErrors),
|
||||
"<span %s>%lld</span>", Closure->redMarkup, image->crcErrors);
|
||||
if(image->sectorsMissing)
|
||||
SetLabelText(GTK_LABEL(wl->cmpMissingSectors),
|
||||
"<span %s>%lld</span>", Closure->redMarkup, image->sectorsMissing);
|
||||
}
|
||||
|
||||
if(excess_sectors)
|
||||
{ PrintLog(_("* image too long : %lld excess sectors\n"), excess_sectors);
|
||||
if(Closure->guiMode)
|
||||
{ if(ii->crcErrors)
|
||||
SetLabelText(GTK_LABEL(wl->cmpChkSumErrors),
|
||||
"<span %s>%lld</span>", Closure->redMarkup, ii->crcErrors);
|
||||
if(ii->sectorsMissing)
|
||||
SetLabelText(GTK_LABEL(wl->cmpMissingSectors),
|
||||
"<span %s>%lld</span>", Closure->redMarkup, ii->sectorsMissing);
|
||||
{ SetLabelText(GTK_LABEL(wl->cmpImageSectors),
|
||||
_("<span %s>%lld (%lld excess sectors)</span>"),
|
||||
Closure->redMarkup, image->sectorSize, excess_sectors);
|
||||
SetLabelText(GTK_LABEL(wl->cmpImageResult),
|
||||
_("<span %s>Bad image.</span>"),
|
||||
Closure->redMarkup);
|
||||
}
|
||||
|
||||
if(excess_sectors)
|
||||
{ PrintLog(_("* image too long : %lld excess sectors\n"), excess_sectors);
|
||||
if(Closure->guiMode)
|
||||
{ SetLabelText(GTK_LABEL(wl->cmpImageSectors),
|
||||
_("<span %s>%lld (%lld excess sectors)</span>"),
|
||||
Closure->redMarkup, ii->sectors, excess_sectors);
|
||||
SetLabelText(GTK_LABEL(wl->cmpImageResult),
|
||||
_("<span %s>Bad image.</span>"),
|
||||
Closure->redMarkup);
|
||||
}
|
||||
}
|
||||
else
|
||||
{ if(!ii->sectorsMissing)
|
||||
{
|
||||
AsciiDigest(idigest, ii->mediumSum);
|
||||
}
|
||||
else if(Closure->quickVerify)
|
||||
{ PrintLog(_("* quick mode : image NOT scanned\n"));
|
||||
}
|
||||
else
|
||||
{ if(!image->sectorsMissing)
|
||||
{
|
||||
AsciiDigest(idigest, image->mediumSum);
|
||||
|
||||
if(!ii->crcErrors)
|
||||
{ PrintLog(_("- good image : all sectors present\n"
|
||||
"- image md5sum : %s\n"),idigest);
|
||||
if(Closure->guiMode)
|
||||
{ SetLabelText(GTK_LABEL(wl->cmpImageResult),_("<span %s>Good image.</span>"), Closure->greenMarkup);
|
||||
SetLabelText(GTK_LABEL(wl->cmpImageMd5Sum), "%s", idigest);
|
||||
}
|
||||
}
|
||||
else
|
||||
{ PrintLog(_("* suspicious image : all sectors present, but %lld CRC errors\n"
|
||||
"- image md5sum : %s\n"),ii->crcErrors,idigest);
|
||||
|
||||
if(Closure->guiMode)
|
||||
{ SetLabelText(GTK_LABEL(wl->cmpImageResult), _("<span %s>Image complete, but contains checksum errors!</span>"), Closure->redMarkup);
|
||||
SetLabelText(GTK_LABEL(wl->cmpImageMd5Sum), "%s", idigest);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{ if(!ii->crcErrors)
|
||||
PrintLog(_("* BAD image : %lld sectors missing\n"), ii->sectorsMissing);
|
||||
else PrintLog(_("* BAD image : %lld sectors missing, %lld CRC errors\n"),
|
||||
ii->sectorsMissing, ii->crcErrors);
|
||||
if(!image->crcErrors)
|
||||
{ PrintLog(_("- good image : all sectors present\n"
|
||||
"- image md5sum : %s\n"),idigest);
|
||||
if(Closure->guiMode)
|
||||
SetLabelText(GTK_LABEL(wl->cmpImageResult),
|
||||
_("<span %s>Bad image.</span>"), Closure->redMarkup);
|
||||
}
|
||||
{ SetLabelText(GTK_LABEL(wl->cmpImageResult),_("<span %s>Good image.</span>"), Closure->greenMarkup);
|
||||
SetLabelText(GTK_LABEL(wl->cmpImageMd5Sum), "%s", idigest);
|
||||
}
|
||||
}
|
||||
else
|
||||
{ PrintLog(_("* suspicious image : all sectors present, but %lld CRC errors\n"
|
||||
"- image md5sum : %s\n"),image->crcErrors,idigest);
|
||||
|
||||
if(Closure->guiMode)
|
||||
{ SetLabelText(GTK_LABEL(wl->cmpImageResult), _("<span %s>Image complete, but contains checksum errors!</span>"), Closure->redMarkup);
|
||||
SetLabelText(GTK_LABEL(wl->cmpImageMd5Sum), "%s", idigest);
|
||||
}
|
||||
}
|
||||
}
|
||||
else /* sectors are missing */
|
||||
{ if(!image->crcErrors)
|
||||
PrintLog(_("* BAD image : %lld sectors missing\n"), image->sectorsMissing);
|
||||
else PrintLog(_("* BAD image : %lld sectors missing, %lld CRC errors\n"),
|
||||
image->sectorsMissing, image->crcErrors);
|
||||
if(Closure->guiMode)
|
||||
SetLabelText(GTK_LABEL(wl->cmpImageResult),
|
||||
_("<span %s>Bad image.</span>"), Closure->redMarkup);
|
||||
}
|
||||
}
|
||||
|
||||
/*** The .ecc file */
|
||||
|
||||
process_ecc:
|
||||
if(Closure->guiMode)
|
||||
SetLabelText(GTK_LABEL(wl->cmpHeadline), "<big>%s</big>\n<i>%s</i>",
|
||||
_("Comparing image and error correction files."),
|
||||
@@ -518,194 +526,225 @@ void RS01Verify(Method *self)
|
||||
|
||||
PrintLog("\n%s: ", Closure->eccName);
|
||||
|
||||
if(!ei)
|
||||
if(!image)
|
||||
{ PrintLog(_("not present\n"));
|
||||
if(Closure->guiMode)
|
||||
SwitchAndSetFootline(wl->cmpEccNotebook, 0,
|
||||
wl->cmpEccEmptyMsg,_("No error correction file present."));
|
||||
goto skip_ecc;
|
||||
}
|
||||
|
||||
if(image && !image->eccFile)
|
||||
{
|
||||
switch(image->eccFileState)
|
||||
{ case ECCFILE_MISSING:
|
||||
PrintLog(_("not present\n"));
|
||||
break;
|
||||
case ECCFILE_INVALID:
|
||||
PrintLog(_("invalid\n"));
|
||||
break;
|
||||
case ECCFILE_DEFECTIVE_HEADER:
|
||||
PrintLog(_("defective header (unusable)\n"));
|
||||
break;
|
||||
case ECCFILE_WRONG_CODEC:
|
||||
PrintLog(_("unknown codec (unusable)\n"));
|
||||
break;
|
||||
default:
|
||||
PrintLog(_("unusable\n"));
|
||||
break;
|
||||
}
|
||||
if(Closure->guiMode)
|
||||
SwitchAndSetFootline(wl->cmpEccNotebook, 0,
|
||||
wl->cmpEccEmptyMsg,_("No error correction file present."));
|
||||
goto skip_ecc;
|
||||
}
|
||||
|
||||
eh = image->eccFileHeader; /* simply an alias */
|
||||
|
||||
/* Version number of dvdisaster used for creating the ecc file */
|
||||
|
||||
if(!eh->neededVersion) /* The V0.41.* series did not fill in this field. */
|
||||
eh->neededVersion = 4100;
|
||||
|
||||
if(eh->creatorVersion)
|
||||
{ int major = eh->creatorVersion/10000;
|
||||
int minor = (eh->creatorVersion%10000)/100;
|
||||
int pl = eh->creatorVersion%100;
|
||||
|
||||
if(eh->creatorVersion%100)
|
||||
{ char *format, *color_format = NULL;
|
||||
|
||||
if(eh->creatorVersion < 6000) format = "%s-%d.%d.%d";
|
||||
else if(eh->creatorVersion <= 6500) format = "%s-%d.%d (pl%d)";
|
||||
else
|
||||
{ if(eh->methodFlags[3] & MFLAG_DEVEL)
|
||||
{ format = "%s-%d.%d (devel-%d)";
|
||||
color_format = "%s-%d.%d <span %s>(devel-%d)</span>";
|
||||
}
|
||||
else if(eh->methodFlags[3] & MFLAG_RC)
|
||||
{ format = "%s-%d.%d (rc-%d)";
|
||||
color_format = "%s-%d.%d <span %s>(rc-%d)</span>";
|
||||
}
|
||||
else format = "%s-%d.%d (pl%d)";
|
||||
}
|
||||
PrintLog(format, _("created by dvdisaster"), major, minor, pl);
|
||||
PrintLog("\n");
|
||||
|
||||
if(Closure->guiMode)
|
||||
{ if(color_format)
|
||||
SwitchAndSetFootline(wl->cmpEccNotebook, 1,
|
||||
wl->cmpEccCreatedBy,
|
||||
color_format, "dvdisaster",
|
||||
major, minor, Closure->redMarkup, pl);
|
||||
else
|
||||
SwitchAndSetFootline(wl->cmpEccNotebook, 1,
|
||||
wl->cmpEccCreatedBy,
|
||||
format, "dvdisaster",
|
||||
major, minor, pl);
|
||||
}
|
||||
}
|
||||
else
|
||||
{ PrintLog(_("created by dvdisaster-%d.%d\n"),
|
||||
major, minor);
|
||||
if(Closure->guiMode)
|
||||
SwitchAndSetFootline(wl->cmpEccNotebook, 1,
|
||||
wl->cmpEccCreatedBy, "dvdisaster-%d.%d",
|
||||
major, minor);
|
||||
}
|
||||
}
|
||||
else
|
||||
{ EccHeader *eh = ei->eh;
|
||||
gint8 method[5];
|
||||
gint64 ecc_blocks,ecc_expected,count;
|
||||
struct MD5Context md5ctxt;
|
||||
unsigned char buf[1024];
|
||||
unsigned char digest[16];
|
||||
int percent,last_percent;
|
||||
gint64 ecc_file_size;
|
||||
|
||||
if(!LargeStat(Closure->eccName, &ecc_file_size))
|
||||
Stop(_("Could not open %s: %s"), Closure->eccName, strerror(errno));
|
||||
|
||||
// strncpy(method, eh->method, 4); method[4] = 0;
|
||||
memcpy(method, eh->method, 4); method[4] = 0;
|
||||
|
||||
if(!eh->neededVersion) /* The V0.41.* series did not fill in this field. */
|
||||
eh->neededVersion = 4100;
|
||||
|
||||
if(eh->creatorVersion)
|
||||
{ int major = eh->creatorVersion/10000;
|
||||
int minor = (eh->creatorVersion%10000)/100;
|
||||
int pl = eh->creatorVersion%100;
|
||||
|
||||
if(eh->creatorVersion%100)
|
||||
{ char *format, *color_format = NULL;
|
||||
|
||||
if(eh->creatorVersion < 6000) format = "%s-%d.%d.%d";
|
||||
else if(eh->creatorVersion <= 6500) format = "%s-%d.%d (pl%d)";
|
||||
else
|
||||
{ if(eh->methodFlags[3] & MFLAG_DEVEL)
|
||||
{ format = "%s-%d.%d (devel-%d)";
|
||||
color_format = "%s-%d.%d <span %s>(devel-%d)</span>";
|
||||
}
|
||||
else if(eh->methodFlags[3] & MFLAG_RC)
|
||||
{ format = "%s-%d.%d (rc-%d)";
|
||||
color_format = "%s-%d.%d <span %s>(rc-%d)</span>";
|
||||
}
|
||||
else format = "%s-%d.%d (pl%d)";
|
||||
}
|
||||
PrintLog(format, _("created by dvdisaster"), major, minor, pl);
|
||||
PrintLog("\n");
|
||||
|
||||
if(Closure->guiMode)
|
||||
{ if(color_format)
|
||||
SwitchAndSetFootline(wl->cmpEccNotebook, 1,
|
||||
wl->cmpEccCreatedBy,
|
||||
color_format, "dvdisaster",
|
||||
major, minor, Closure->redMarkup, pl);
|
||||
else
|
||||
SwitchAndSetFootline(wl->cmpEccNotebook, 1,
|
||||
wl->cmpEccCreatedBy,
|
||||
format, "dvdisaster",
|
||||
major, minor, pl);
|
||||
}
|
||||
}
|
||||
else
|
||||
{ PrintLog(_("created by dvdisaster-%d.%d\n"),
|
||||
major, minor);
|
||||
if(Closure->guiMode)
|
||||
SwitchAndSetFootline(wl->cmpEccNotebook, 1,
|
||||
wl->cmpEccCreatedBy, "dvdisaster-%d.%d",
|
||||
major, minor);
|
||||
}
|
||||
}
|
||||
else
|
||||
{ PrintLog(_("created by dvdisaster-0.41.x.\n"));
|
||||
if(Closure->guiMode)
|
||||
SwitchAndSetFootline(wl->cmpEccNotebook, 1,
|
||||
wl->cmpEccCreatedBy, "dvdisaster-0.41.x");
|
||||
}
|
||||
|
||||
PrintLog(_("- method : %4s, %d roots, %4.1f%% redundancy.\n"),
|
||||
method, eh->eccBytes,
|
||||
((double)eh->eccBytes*100.0)/(double)eh->dataBytes);
|
||||
{ PrintLog(_("created by dvdisaster-0.41.x.\n"));
|
||||
if(Closure->guiMode)
|
||||
SetLabelText(GTK_LABEL(wl->cmpEccMethod), _("%4s, %d roots, %4.1f%% redundancy"),
|
||||
method, eh->eccBytes,
|
||||
((double)eh->eccBytes*100.0)/(double)eh->dataBytes);
|
||||
SwitchAndSetFootline(wl->cmpEccNotebook, 1,
|
||||
wl->cmpEccCreatedBy, "dvdisaster-0.41.x");
|
||||
}
|
||||
|
||||
/* Information on RS01 properties */
|
||||
|
||||
if(!VerifyVersion(eh, 0))
|
||||
{ PrintLog(_("- requires : dvdisaster-%d.%d (good)\n"),
|
||||
eh->neededVersion/10000,
|
||||
(eh->neededVersion%10000)/100);
|
||||
if(Closure->guiMode)
|
||||
SetLabelText(GTK_LABEL(wl->cmpEccRequires), "dvdisaster-%d.%d",
|
||||
eh->neededVersion/10000,
|
||||
(eh->neededVersion%10000)/100);
|
||||
}
|
||||
else
|
||||
{ PrintLog(_("* requires : dvdisaster-%d.%d (BAD)\n"
|
||||
"* Warning : The following output might be incorrect.\n"
|
||||
"* : Please visit http://www.dvdisaster.com for an upgrade.\n"),
|
||||
eh->neededVersion/10000,
|
||||
(eh->neededVersion%10000)/100);
|
||||
memcpy(method, eh->method, 4); method[4] = 0;
|
||||
|
||||
if(Closure->guiMode)
|
||||
{ SetLabelText(GTK_LABEL(wl->cmpEccRequires),
|
||||
"<span %s>dvdisaster-%d.%d</span>",
|
||||
Closure->redMarkup,
|
||||
eh->neededVersion/10000,
|
||||
(eh->neededVersion%10000)/100);
|
||||
PrintLog(_("- method : %4s, %d roots, %4.1f%% redundancy.\n"),
|
||||
method, eh->eccBytes,
|
||||
((double)eh->eccBytes*100.0)/(double)eh->dataBytes);
|
||||
if(Closure->guiMode)
|
||||
SetLabelText(GTK_LABEL(wl->cmpEccMethod), _("%4s, %d roots, %4.1f%% redundancy"),
|
||||
method, eh->eccBytes,
|
||||
((double)eh->eccBytes*100.0)/(double)eh->dataBytes);
|
||||
|
||||
/* Show and verify needed version */
|
||||
|
||||
if(Closure->version >= eh->neededVersion)
|
||||
{ PrintLog(_("- requires : dvdisaster-%d.%d (good)\n"),
|
||||
eh->neededVersion/10000,
|
||||
(eh->neededVersion%10000)/100);
|
||||
if(Closure->guiMode)
|
||||
SetLabelText(GTK_LABEL(wl->cmpEccRequires), "dvdisaster-%d.%d",
|
||||
eh->neededVersion/10000,
|
||||
(eh->neededVersion%10000)/100);
|
||||
}
|
||||
else
|
||||
{ PrintLog(_("* requires : dvdisaster-%d.%d (BAD)\n"
|
||||
"* Warning : The following output might be incorrect.\n"
|
||||
"* : Please visit http://www.dvdisaster.org for an upgrade.\n"),
|
||||
eh->neededVersion/10000,
|
||||
(eh->neededVersion%10000)/100);
|
||||
|
||||
if(Closure->guiMode)
|
||||
{ SetLabelText(GTK_LABEL(wl->cmpEccRequires),
|
||||
"<span %s>dvdisaster-%d.%d</span>",
|
||||
Closure->redMarkup,
|
||||
eh->neededVersion/10000,
|
||||
(eh->neededVersion%10000)/100);
|
||||
if(!ecc_advice)
|
||||
ecc_advice = g_strdup_printf(_("<span %s>Please upgrade your version of dvdisaster!</span>"), Closure->redMarkup);
|
||||
}
|
||||
ecc_advice = g_strdup_printf(_("<span %s>Please upgrade your version of dvdisaster!</span>"), Closure->redMarkup);
|
||||
}
|
||||
}
|
||||
|
||||
eh_sectors = uchar_to_gint64(eh->sectors);
|
||||
|
||||
if(eh->creatorVersion >= 6600 && eh->inLast != 2048) /* image file whose length is */
|
||||
in_last = eh->inLast; /* not a multiple of 2048 */
|
||||
/* image size comparison */
|
||||
|
||||
if(ii)
|
||||
{ if(ii->sectors == eh_sectors && (!in_last || ii->inLast == eh->inLast))
|
||||
{ if(!in_last)
|
||||
{ PrintLog(_("- medium sectors : %lld (good)\n"),eh_sectors);
|
||||
if(Closure->guiMode)
|
||||
SetLabelText(GTK_LABEL(wl->cmpEccMediumSectors), "%lld", eh_sectors);
|
||||
}
|
||||
else
|
||||
{ PrintLog(_("- medium sectors : %lld sectors + %d bytes (good)\n"),
|
||||
eh_sectors-1, in_last);
|
||||
if(Closure->guiMode)
|
||||
SetLabelText(GTK_LABEL(wl->cmpEccMediumSectors),
|
||||
_("%lld sectors + %d bytes"),
|
||||
eh_sectors-1, in_last);
|
||||
}
|
||||
}
|
||||
else
|
||||
{ if(ii->sectors > eh_sectors && ii->sectors - eh_sectors <= 2)
|
||||
{ PrintLog(_("* medium sectors : %lld (BAD, perhaps TAO/DAO mismatch)\n"),eh_sectors);
|
||||
if(Closure->guiMode)
|
||||
{ if(!in_last)
|
||||
SetLabelText(GTK_LABEL(wl->cmpEccMediumSectors), "<span %s>%lld</span>", Closure->redMarkup, eh_sectors);
|
||||
else SetLabelText(GTK_LABEL(wl->cmpEccMediumSectors), "<span %s>%lld sectors + %d bytes</span>", Closure->redMarkup, eh_sectors-1, in_last);
|
||||
}
|
||||
}
|
||||
else
|
||||
{ if(!in_last)
|
||||
{ PrintLog(_("* medium sectors : %lld (BAD)\n"),eh_sectors);
|
||||
if(Closure->guiMode)
|
||||
{ SetLabelText(GTK_LABEL(wl->cmpEccMediumSectors), "<span %s>%lld</span>", Closure->redMarkup, eh_sectors);
|
||||
if(!ecc_advice)
|
||||
ecc_advice = g_strdup_printf(_("<span %s>Image size does not match error correction file.</span>"), Closure->redMarkup);
|
||||
}
|
||||
}
|
||||
else
|
||||
{ PrintLog(_("* medium sectors : %lld sectors + %d bytes (BAD)\n"),
|
||||
eh_sectors-1, in_last);
|
||||
if(Closure->guiMode)
|
||||
{ SetLabelText(GTK_LABEL(wl->cmpEccMediumSectors),
|
||||
_("<span %s>%lld sectors + %d bytes</span>"),
|
||||
Closure->redMarkup, eh_sectors-1, in_last);
|
||||
if(!ecc_advice)
|
||||
ecc_advice = g_strdup_printf(_("<span %s>Image size does not match error correction file.</span>"), Closure->redMarkup);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(eh->creatorVersion >= 6600 && eh->inLast != 2048) /* image file whose length is */
|
||||
ecc_in_last = eh->inLast; /* not a multiple of 2048 */
|
||||
|
||||
if(!image->file)
|
||||
{ if(!ecc_in_last)
|
||||
{ PrintLog(_("- medium sectors : %lld\n"), image->expectedSectors);
|
||||
if(Closure->guiMode)
|
||||
SetLabelText(GTK_LABEL(wl->cmpEccMediumSectors), "%lld", image->expectedSectors);
|
||||
}
|
||||
else
|
||||
{ if(!in_last)
|
||||
{ PrintLog(_("- medium sectors : %lld\n"),eh_sectors);
|
||||
if(Closure->guiMode)
|
||||
SetLabelText(GTK_LABEL(wl->cmpEccMediumSectors), "%lld", eh_sectors);
|
||||
{ PrintLog(_("- medium sectors : %lld sectors + %d bytes\n"),
|
||||
image->expectedSectors-1, ecc_in_last);
|
||||
if(Closure->guiMode)
|
||||
SetLabelText(GTK_LABEL(wl->cmpEccMediumSectors),
|
||||
_("%lld sectors + %d bytes"),
|
||||
image->expectedSectors-1, ecc_in_last);
|
||||
}
|
||||
}
|
||||
|
||||
if(image->file)
|
||||
{
|
||||
if(image->sectorSize == image->expectedSectors
|
||||
&& (!ecc_in_last || image->inLast == eh->inLast))
|
||||
{ if(!ecc_in_last)
|
||||
{ PrintLog(_("- medium sectors : %lld (good)\n"), image->expectedSectors);
|
||||
if(Closure->guiMode)
|
||||
SetLabelText(GTK_LABEL(wl->cmpEccMediumSectors), "%lld", image->expectedSectors);
|
||||
}
|
||||
else
|
||||
{ PrintLog(_("- medium sectors : %lld sectors + %d bytes\n"),
|
||||
eh_sectors-1, in_last);
|
||||
if(Closure->guiMode)
|
||||
{ PrintLog(_("- medium sectors : %lld sectors + %d bytes (good)\n"),
|
||||
image->expectedSectors-1, ecc_in_last);
|
||||
if(Closure->guiMode)
|
||||
SetLabelText(GTK_LABEL(wl->cmpEccMediumSectors),
|
||||
_("%lld sectors + %d bytes"),
|
||||
eh_sectors-1, in_last);
|
||||
image->expectedSectors-1, ecc_in_last);
|
||||
}
|
||||
}
|
||||
|
||||
/*** Verify md5sums against image and map (if present) */
|
||||
else /* sector sizes differ */
|
||||
{ /* TAO case (1 or 2 sectors more than expected) */
|
||||
if(image->sectorSize > image->expectedSectors && image->sectorSize - image->expectedSectors <= 2)
|
||||
{ PrintLog(_("* medium sectors : %lld (BAD, perhaps TAO/DAO mismatch)\n"), image->expectedSectors);
|
||||
if(Closure->guiMode)
|
||||
{ if(!ecc_in_last)
|
||||
SetLabelText(GTK_LABEL(wl->cmpEccMediumSectors), "<span %s>%lld</span>",
|
||||
Closure->redMarkup, image->expectedSectors);
|
||||
else SetLabelText(GTK_LABEL(wl->cmpEccMediumSectors), "<span %s>%lld sectors + %d bytes</span>",
|
||||
Closure->redMarkup, image->expectedSectors-1, ecc_in_last);
|
||||
}
|
||||
}
|
||||
else /* more than 2 Sectors difference */
|
||||
{ if(!ecc_in_last)
|
||||
{ PrintLog(_("* medium sectors : %lld (BAD)\n"), image->expectedSectors);
|
||||
if(Closure->guiMode)
|
||||
{ SetLabelText(GTK_LABEL(wl->cmpEccMediumSectors), "<span %s>%lld</span>",
|
||||
Closure->redMarkup, image->expectedSectors);
|
||||
if(!ecc_advice)
|
||||
ecc_advice = g_strdup_printf(_("<span %s>Image size does not match error correction file.</span>"), Closure->redMarkup);
|
||||
}
|
||||
}
|
||||
else /* byte size difference */
|
||||
{ PrintLog(_("* medium sectors : %lld sectors + %d bytes (BAD)\n"),
|
||||
image->expectedSectors-1, ecc_in_last);
|
||||
if(Closure->guiMode)
|
||||
{ SetLabelText(GTK_LABEL(wl->cmpEccMediumSectors),
|
||||
_("<span %s>%lld sectors + %d bytes</span>"),
|
||||
Closure->redMarkup, image->expectedSectors-1, ecc_in_last);
|
||||
if(!ecc_advice)
|
||||
ecc_advice = g_strdup_printf(_("<span %s>Image size does not match error correction file.</span>"), Closure->redMarkup);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*** Show and verify image md5sum */
|
||||
|
||||
AsciiDigest(edigest, eh->mediumSum);
|
||||
if(ii && !ii->sectorsMissing && !excess_sectors)
|
||||
{ n = !memcmp(eh->mediumSum, ii->mediumSum, 16);
|
||||
if(n) PrintLog(_("- image md5sum : %s (good)\n"),edigest);
|
||||
if(!Closure->quickVerify)
|
||||
{ AsciiDigest(edigest, eh->mediumSum);
|
||||
if(image && image->file && !image->sectorsMissing && !excess_sectors)
|
||||
{ int n = !memcmp(eh->mediumSum, image->mediumSum, 16);
|
||||
if(n) PrintLog(_("- image md5sum : %s (good)\n"),edigest);
|
||||
else PrintLog(_("* image md5sum : %s (BAD)\n"),edigest);
|
||||
if(Closure->guiMode)
|
||||
{ if(n) SetLabelText(GTK_LABEL(wl->cmpEccImgMd5Sum), "%s", edigest);
|
||||
@@ -717,95 +756,109 @@ void RS01Verify(Method *self)
|
||||
}
|
||||
else
|
||||
{ PrintLog(_("- image md5sum : %s\n"),edigest);
|
||||
if(Closure->guiMode)
|
||||
if(Closure->guiMode)
|
||||
SetLabelText(GTK_LABEL(wl->cmpEccImgMd5Sum), "%s", edigest);
|
||||
}
|
||||
|
||||
if(ii)
|
||||
{ if(!memcmp(ii->mediumFP, "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 16))
|
||||
{ PrintLog(_("* fingerprint match: NOT POSSIBLE - related sector is missing in image!\n"));
|
||||
if(Closure->guiMode)
|
||||
SetLabelText(GTK_LABEL(wl->cmpEccFingerprint), _("<span %s>missing sector prevents calculation</span>"), Closure->redMarkup);
|
||||
}
|
||||
else
|
||||
if(memcmp(ii->mediumFP, eh->mediumFP, 16))
|
||||
{ PrintLog(_("* fingerprint match: MISMATCH - .iso and .ecc don't belong together!\n"));
|
||||
if(Closure->guiMode)
|
||||
{ SetLabelText(GTK_LABEL(wl->cmpEccFingerprint),
|
||||
_("<span %s>mismatch</span>"), Closure->redMarkup);
|
||||
|
||||
if(!ecc_advice)
|
||||
ecc_advice = g_strdup_printf(_("<span %s>Image and error correction files do not belong together!</span>"), Closure->redMarkup);
|
||||
}
|
||||
}
|
||||
else
|
||||
{ PrintLog(_("- fingerprint match: good\n"));
|
||||
if(Closure->guiMode)
|
||||
SetLabelText(GTK_LABEL(wl->cmpEccFingerprint), _("good"));
|
||||
}
|
||||
}
|
||||
|
||||
ecc_expected = 2048*((eh_sectors+eh->dataBytes-1)/eh->dataBytes);
|
||||
ecc_blocks = (ecc_file_size-eh_sectors*sizeof(guint32)-sizeof(EccHeader))/eh->eccBytes;
|
||||
|
||||
if(ecc_expected == ecc_blocks)
|
||||
{ PrintLog(_("- ecc blocks : %lld (good)\n"),ecc_blocks);
|
||||
if(Closure->guiMode)
|
||||
SetLabelText(GTK_LABEL(wl->cmpEccBlocks), "%lld", ecc_blocks);
|
||||
}
|
||||
else
|
||||
{ PrintLog(_("* ecc blocks : %lld (BAD, expected %lld)\n"),ecc_blocks,ecc_expected);
|
||||
if(Closure->guiMode)
|
||||
SetLabelText(GTK_LABEL(wl->cmpEccBlocks), _("<span %s>%lld (bad, expected %lld)</span>"),Closure->redMarkup,ecc_blocks,ecc_expected);
|
||||
}
|
||||
|
||||
/*** Test ecc file against its own md5sum */
|
||||
|
||||
MD5Init(&md5ctxt);
|
||||
|
||||
last_percent = -1;
|
||||
count = sizeof(EccHeader);
|
||||
|
||||
if(!LargeSeek(ei->file, (gint64)sizeof(EccHeader)))
|
||||
Stop(_("Failed skipping the ecc header: %s"),strerror(errno));
|
||||
|
||||
while(!LargeEOF(ei->file))
|
||||
{ n = LargeRead(ei->file, buf, 1024);
|
||||
MD5Update(&md5ctxt, buf, n);
|
||||
|
||||
count += n;
|
||||
percent = (100*count)/ecc_file_size;
|
||||
if(last_percent != percent)
|
||||
{ if(!Closure->guiMode)
|
||||
PrintProgress(_("- ecc md5sum : %3d%%"),percent);
|
||||
else SetLabelText(GTK_LABEL(wl->cmpEccMd5Sum), "%3d%%", percent);
|
||||
last_percent = percent;
|
||||
}
|
||||
|
||||
if(Closure->stopActions)
|
||||
{ SetLabelText(GTK_LABEL(wl->cmpEccResult),
|
||||
_("<span %s>Aborted by user request!</span>"), Closure->redMarkup);
|
||||
goto terminate;
|
||||
}
|
||||
}
|
||||
MD5Final(digest, &md5ctxt);
|
||||
AsciiDigest(edigest, digest);
|
||||
|
||||
if(memcmp(eh->eccSum, digest, 16))
|
||||
{ PrintLog(_("* ecc md5sum : BAD, ecc file may be damaged!\n"));
|
||||
if(Closure->guiMode)
|
||||
{ SetLabelText(GTK_LABEL(wl->cmpEccMd5Sum), _("<span %s>bad</span>"), Closure->redMarkup);
|
||||
if(!ecc_advice)
|
||||
ecc_advice = g_strdup_printf(_("<span %s>Error correction file may be damaged!</span>"), Closure->redMarkup);
|
||||
}
|
||||
}
|
||||
else
|
||||
{ PrintLog(_("- ecc md5sum : %s (good)\n"),edigest);
|
||||
if(Closure->guiMode)
|
||||
SetLabelText(GTK_LABEL(wl->cmpEccMd5Sum), "%s", edigest);
|
||||
}
|
||||
}
|
||||
|
||||
if(image && image->file)
|
||||
{ if(image->fpState != FP_PRESENT)
|
||||
{ PrintLog(_("* fingerprint match: NOT POSSIBLE - related sector is missing in image!\n"));
|
||||
if(Closure->guiMode)
|
||||
SetLabelText(GTK_LABEL(wl->cmpEccFingerprint), _("<span %s>missing sector prevents calculation</span>"), Closure->redMarkup);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(memcmp(image->imageFP, eh->mediumFP, 16))
|
||||
{ PrintLog(_("* fingerprint match: MISMATCH - .iso and .ecc don't belong together!\n"));
|
||||
|
||||
if(Closure->guiMode)
|
||||
{ SetLabelText(GTK_LABEL(wl->cmpEccFingerprint),
|
||||
_("<span %s>mismatch</span>"), Closure->redMarkup);
|
||||
|
||||
if(!ecc_advice)
|
||||
ecc_advice = g_strdup_printf(_("<span %s>Image and error correction files do not belong together!</span>"), Closure->redMarkup);
|
||||
}
|
||||
}
|
||||
else
|
||||
{ PrintLog(_("- fingerprint match: good\n"));
|
||||
if(Closure->guiMode)
|
||||
SetLabelText(GTK_LABEL(wl->cmpEccFingerprint), _("good"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Show and verify the number of ecc blocks */
|
||||
|
||||
if(Closure->quickVerify) /* terminate early */
|
||||
{ PrintLog(_("* quick mode : ecc file NOT scanned\n"));
|
||||
goto terminate;
|
||||
}
|
||||
|
||||
ecc_expected = 2048*((image->expectedSectors+eh->dataBytes-1)/eh->dataBytes);
|
||||
ecc_blocks = (image->eccFile->size-image->expectedSectors*sizeof(guint32)-sizeof(EccHeader))/eh->eccBytes;
|
||||
|
||||
if(ecc_expected == ecc_blocks)
|
||||
{ PrintLog(_("- ecc blocks : %lld (good)\n"),ecc_blocks);
|
||||
if(Closure->guiMode)
|
||||
SetLabelText(GTK_LABEL(wl->cmpEccBlocks), "%lld", ecc_blocks);
|
||||
}
|
||||
else
|
||||
{ PrintLog(_("* ecc blocks : %lld (BAD, expected %lld)\n"),ecc_blocks,ecc_expected);
|
||||
if(Closure->guiMode)
|
||||
SetLabelText(GTK_LABEL(wl->cmpEccBlocks), _("<span %s>%lld (bad, expected %lld)</span>"),Closure->redMarkup,ecc_blocks,ecc_expected);
|
||||
}
|
||||
|
||||
/*** Test ecc file against its own md5sum */
|
||||
|
||||
MD5Init(&md5ctxt);
|
||||
|
||||
last_percent = -1;
|
||||
count = sizeof(EccHeader);
|
||||
|
||||
if(!LargeSeek(image->eccFile, (gint64)sizeof(EccHeader)))
|
||||
Stop(_("Failed skipping the ecc header: %s"),strerror(errno));
|
||||
|
||||
while(!LargeEOF(image->eccFile))
|
||||
{ int n = LargeRead(image->eccFile, buf, 1024);
|
||||
|
||||
MD5Update(&md5ctxt, buf, n);
|
||||
|
||||
count += n;
|
||||
percent = (100*count)/image->eccFile->size;
|
||||
if(last_percent != percent)
|
||||
{ if(!Closure->guiMode)
|
||||
PrintProgress(_("- ecc md5sum : %3d%%"),percent);
|
||||
else SetLabelText(GTK_LABEL(wl->cmpEccMd5Sum), "%3d%%", percent);
|
||||
last_percent = percent;
|
||||
}
|
||||
|
||||
if(Closure->stopActions)
|
||||
{ if(Closure->stopActions == STOP_CURRENT_ACTION) /* suppress memlead warning when closing window */
|
||||
SetLabelText(GTK_LABEL(wl->cmpEccResult),
|
||||
_("<span %s>Aborted by user request!</span>"), Closure->redMarkup);
|
||||
goto terminate;
|
||||
}
|
||||
}
|
||||
|
||||
MD5Final(digest, &md5ctxt);
|
||||
AsciiDigest(edigest, digest);
|
||||
|
||||
if(memcmp(eh->eccSum, digest, 16))
|
||||
{ PrintLog(_("* ecc md5sum : BAD, ecc file may be damaged!\n"));
|
||||
if(Closure->guiMode)
|
||||
{ SetLabelText(GTK_LABEL(wl->cmpEccMd5Sum), _("<span %s>bad</span>"), Closure->redMarkup);
|
||||
if(!ecc_advice)
|
||||
ecc_advice = g_strdup_printf(_("<span %s>Error correction file may be damaged!</span>"), Closure->redMarkup);
|
||||
}
|
||||
}
|
||||
else
|
||||
{ PrintLog(_("- ecc md5sum : %s (good)\n"),edigest);
|
||||
if(Closure->guiMode)
|
||||
SetLabelText(GTK_LABEL(wl->cmpEccMd5Sum), "%s", edigest);
|
||||
}
|
||||
|
||||
skip_ecc:
|
||||
PrintLog("\n");
|
||||
|
||||
if(Closure->guiMode)
|
||||
@@ -821,5 +874,5 @@ void RS01Verify(Method *self)
|
||||
/*** Close and clean up */
|
||||
|
||||
terminate:
|
||||
cleanup((gpointer)cc);
|
||||
cleanup(vc);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user