Made -compare and -update work with recorded MD5 sums

This commit is contained in:
Thomas Schmitt 2009-08-20 20:42:14 +00:00
parent 3a88ef260c
commit 5f06ee19c5
5 changed files with 125 additions and 26 deletions

View File

@ -2,7 +2,7 @@
.\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1)
.TH XORRISO 1 "Aug 19, 2009"
.TH XORRISO 1 "Aug 20, 2009"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
@ -697,6 +697,7 @@ automatic last minute changes before the session gets written. Command
e.g. if you need to apply filters to all updated files.
.br
Mode "without_update" avoids hardlink processing during update commands.
Use this if your filesystem situation does not allow -disk_dev_ino "on".
.br
xorriso commands which extract files from an ISO image try to hardlink files
with identical inode number. The normal scope of this operation is from
@ -734,6 +735,11 @@ checksums tags of superblock and directory tree match properly. The MD5
checksums of data files and whole session get loaded from the image if there
are any.
.br
With options -compare and -update the eventually recorded MD5 of a file
will be used to avoid content reading from the image. Only the disk file
content will be read and compared with that MD5. This can save much time
if -disk_dev_ino "on" is not suitable.
.br
At image generation time they are computed for each file which gets its data
written into the new session. The checksums of files which have their data
in older sessions get copied into the new session. Superblock, tree and whole
@ -770,6 +776,9 @@ same filesystems. Use this if mode "on" always sees all files changed.
.br
The speed advantage appears only if the loaded session was produced with
-disk_dev_ino "on" too.
.br
Note that -disk_dev_ino "off" is totally in effect only if -hardlinks is "off",
too.
.TP
\fB\-rom_toc_scan\fR "on"|"off"[:"emul_on"|"emul_off"]
Read-only drives do not tell the actual media type but show any media as

View File

@ -7288,10 +7288,12 @@ int Xorriso_compare_2_contents(struct XorrisO *xorriso, char *common_adr,
char *iso_adr, off_t iso_size,
int *result, int flag)
{
int fd1= -1, ret, r1, r2, done, wanted, i, was_error= 0;
int fd1= -1, ret, r1, r2, done, wanted, i, was_error= 0, use_md5= 0;
void *stream2= NULL;
off_t r1count= 0, r2count= 0, diffcount= 0, first_diff= -1;
char *respt, buf1[32*1024], buf2[32*1024], offset_text[80];
char disk_md5[16], iso_md5[16];
void *ctx= NULL;
respt= xorriso->result_line;
@ -7303,7 +7305,7 @@ cannot_address:;
if(!(flag&(1<<31)))
Xorriso_result(xorriso,0);
(*result)|= 2048;
return(0);
{ret= 0; goto ex;}
}
if(offset>0)
if(lseek(fd1, offset, SEEK_SET)==-1) {
@ -7313,14 +7315,27 @@ cannot_address:;
goto cannot_address;
}
ret= Xorriso_iso_file_open(xorriso, iso_adr, NULL, &stream2, 0);
if(ret<=0) {
sprintf(respt, "- %s (ISO) : cannot open() file in ISO image\n", iso_adr);
if(!(flag&(1<<31)))
Xorriso_result(xorriso,0);
close(fd1);
(*result)|= 4096;
return(0);
if(xorriso->do_md5 & 16) {
use_md5= 1;
ret= Xorriso_get_md5(xorriso, NULL, iso_adr, iso_md5, 1);
if(ret <= 0)
use_md5= 0;
else {
ret= Xorriso_md5_start(xorriso, &ctx, 0);
if(ret <= 0)
use_md5= 0;
}
}
if (! use_md5) {
ret= Xorriso_iso_file_open(xorriso, iso_adr, NULL, &stream2, 0);
if(ret<=0) {
sprintf(respt, "- %s (ISO) : cannot open() file in ISO image\n",iso_adr);
if(!(flag&(1<<31)))
Xorriso_result(xorriso,0);
close(fd1);
(*result)|= 4096;
{ret= 0; goto ex;}
}
}
done= 0;
@ -7347,7 +7362,9 @@ cannot_address:;
if(r2count+wanted>bytes)
wanted= bytes-r2count;
*/
if(wanted>0)
if(use_md5)
r2= r1;
else if(wanted>0)
r2= Xorriso_iso_file_read(xorriso, stream2, buf2, wanted, 0);
else
r2= 0;
@ -7397,11 +7414,16 @@ cannot_address:;
r2count+= r2;
if(r1>r2)
r1= r2;
for(i= 0; i<r1; i++) {
if(buf1[i]!=buf2[i]) {
if(first_diff<0)
first_diff= i;
diffcount++;
if(use_md5) {
Xorriso_md5_compute(xorriso, ctx, buf1, r1, 0);
} else {
for(i= 0; i<r1; i++) {
if(buf1[i]!=buf2[i]) {
if(first_diff<0)
first_diff= i;
diffcount++;
}
}
}
if(!(flag&(1<<29))) {
@ -7415,7 +7437,27 @@ cannot_address:;
"", 1<<6);
}
}
if(diffcount>0 || r1count!=r2count) {
if(use_md5) {
ret= Xorriso_md5_end(xorriso, &ctx, disk_md5, 0);
if(ret <= 0) {
*result |= (1 << 15);
ret= -1; goto ex;
}
for(i= 0; i < 16; i++)
if(iso_md5[i] != disk_md5[i])
break;
if(i < 16 ) {
offset_text[0]= 0;
if(offset>0)
sprintf(offset_text, "%.f+", (double) offset);
sprintf(respt, "%s %s : differs by MD5 sums.\n",
common_adr, (flag&1 ? "CONTENT": "content"));
if(!(flag&(1<<31)))
Xorriso_result(xorriso,0);
(*result)|= (1<<15);
}
} else if(diffcount>0 || r1count!=r2count) {
if(first_diff<0)
first_diff= (r1count>r2count ? r2count : r1count);
offset_text[0]= 0;
@ -7431,10 +7473,15 @@ cannot_address:;
}
if(fd1!=-1)
close(fd1);
Xorriso_iso_file_close(xorriso, &stream2, 0);
if(! use_md5)
Xorriso_iso_file_close(xorriso, &stream2, 0);
if(was_error)
return(-1);
return(1);
{ret= -1; goto ex;}
ret= 1;
ex:;
if(ctx != NULL)
Xorriso_md5_end(xorriso, &ctx, disk_md5, 0);
return(ret);
}
@ -16546,11 +16593,11 @@ int Xorriso_option_md5(struct XorrisO *xorriso, char *mode, int flag)
if(l == 0)
continue;
if(l == 3 && strncmp(cpt, "off", l) == 0)
xorriso->do_md5&= ~15;
xorriso->do_md5&= ~31;
else if(l == 2 && strncmp(cpt, "on", l) == 0)
xorriso->do_md5|= 7;
xorriso->do_md5|= 7 | 16;
else if(l == 3 && strncmp(cpt, "all", l) == 0)
xorriso->do_md5|= 15;
xorriso->do_md5|= 31;
else if(l == 18 && strncmp(cpt, "stability_check_on", l) == 0)
xorriso->do_md5|= 8;
else if(l == 19 && strncmp(cpt, "stability_check_off", l) == 0)

View File

@ -1 +1 @@
#define Xorriso_timestamP "2009.08.19.180842"
#define Xorriso_timestamP "2009.08.20.204309"

View File

@ -12484,6 +12484,40 @@ int Xorriso_image_has_md5(struct XorrisO *xorriso, int flag)
ret= iso_image_get_session_md5(image, &start_lba, &end_lba, md5, 0);
Xorriso_process_msg_queues(xorriso,0);
if(ret <= 0)
return(ret);
return(0);
return(1);
}
int Xorriso_md5_start(struct XorrisO *xorriso, void **ctx, int flag)
{
int ret;
ret= iso_md5_start(ctx);
if(ret == 1)
return(1);
Xorriso_no_malloc_memory(xorriso, NULL, 0);
return(-1);
}
int Xorriso_md5_compute(struct XorrisO *xorriso, void *ctx,
char *data, int datalen, int flag)
{
iso_md5_compute(ctx, data, datalen);
return(1);
}
int Xorriso_md5_end(struct XorrisO *xorriso, void **ctx, char md5[16],
int flag)
{
int ret;
ret= iso_md5_end(ctx, md5);
Xorriso_process_msg_queues(xorriso,0);
if(ret <= 0)
return(0);
return(1);
}

View File

@ -460,6 +460,15 @@ int Xorriso_get_md5(struct XorrisO *xorriso, void *in_node, char *path,
char md5[16], int flag);
int Xorriso_md5_start(struct XorrisO *xorriso, void **ctx, int flag);
int Xorriso_md5_compute(struct XorrisO *xorriso, void *ctx,
char *data, int datalen, int flag);
int Xorriso_md5_end(struct XorrisO *xorriso, void **ctx, char md5[16],
int flag);
/* A pseudo file type for El-Torito bootsectors as in man 2 stat :
For now take the highest possible value.
*/