diff --git a/xorriso/xorriso.1 b/xorriso/xorriso.1 index 938ca30b..00b4745c 100644 --- a/xorriso/xorriso.1 +++ b/xorriso/xorriso.1 @@ -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 diff --git a/xorriso/xorriso.c b/xorriso/xorriso.c index 1d834383..5bdfa86d 100644 --- a/xorriso/xorriso.c +++ b/xorriso/xorriso.c @@ -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; i0 || 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) diff --git a/xorriso/xorriso_timestamp.h b/xorriso/xorriso_timestamp.h index 6e3298ff..d2f4fd91 100644 --- a/xorriso/xorriso_timestamp.h +++ b/xorriso/xorriso_timestamp.h @@ -1 +1 @@ -#define Xorriso_timestamP "2009.08.19.180842" +#define Xorriso_timestamP "2009.08.20.204309" diff --git a/xorriso/xorrisoburn.c b/xorriso/xorrisoburn.c index 31ba848f..5a2f1619 100644 --- a/xorriso/xorrisoburn.c +++ b/xorriso/xorrisoburn.c @@ -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); +} + diff --git a/xorriso/xorrisoburn.h b/xorriso/xorrisoburn.h index 0189a011..8d52a456 100644 --- a/xorriso/xorrisoburn.h +++ b/xorriso/xorrisoburn.h @@ -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. */