diff --git a/libisoburn/trunk/xorriso/xorriso.1 b/libisoburn/trunk/xorriso/xorriso.1 index e9d05073..21079486 100644 --- a/libisoburn/trunk/xorriso/xorriso.1 +++ b/libisoburn/trunk/xorriso/xorriso.1 @@ -2532,6 +2532,10 @@ correction will fail and the drive is supposed to indicate error. xorriso can scan the media for readable data blocks, classify them according to their read speed, save them to a file, and keep track of successfuly saved blocks for further tries on the same media. +.br +By option -md5 checksums may get recorded with data files and whole +sessions. These checksums are reachable only via indev and a loaded image. +They work independently of the media type and can detect transmission errors. .TP \fB\-check_media\fR [option [option ...]] -- Try to read data blocks from the indev drive, eventually copy them to a @@ -2642,6 +2646,10 @@ of the program run. Severity ALL suppresses that event. This option reports match and mismatch of data files to the result channel. Non-data files cause NOTE events. There will also be UPDATE events from data reading. +.br +If no iso_rr_path is given then the whole loaded session is compared with its +MD5 sum. Be aware that this covers only one session and not the whole image +if there are older sessions. .TP \fB\-check_md5_r\fR severity iso_rr_path [***] Like -check_md5 but checking all data files underneath the given paths. diff --git a/libisoburn/trunk/xorriso/xorriso.c b/libisoburn/trunk/xorriso/xorriso.c index 391fe396..391b900b 100644 --- a/libisoburn/trunk/xorriso/xorriso.c +++ b/libisoburn/trunk/xorriso/xorriso.c @@ -8357,8 +8357,9 @@ int Xorriso_opt_args(struct XorrisO *xorriso, char *cmd, *optc= 0; *optv= NULL; sprintf(xorriso->info_text, "%s : Not enough arguments given", cmd); - if(!(flag & 128)) - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + if((flag & 128)) + return(1); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); return(0); } *end_idx= Xorriso_end_idx(xorriso, argc, argv, idx, @@ -12470,8 +12471,8 @@ ex:; } -int Xorriso_report_m5_outcome(struct XorrisO *xorriso, char *severity, - int flag) +int Xorriso_report_md5_outcome(struct XorrisO *xorriso, char *severity, + int flag) { if((xorriso->find_check_md5_result & 3) == 0) { sprintf(xorriso->result_line, @@ -13367,21 +13368,20 @@ int Xorriso_option_check_md5(struct XorrisO *xorriso, Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); return(ret); } + (*idx)++; - ret= Xorriso_opt_args(xorriso, "-check_md5", argc, argv, (*idx) + 1, + ret= Xorriso_opt_args(xorriso, "-check_md5", argc, argv, *idx, &end_idx, &optc, &optv, 128); if(ret<=0) goto ex; + xorriso->find_check_md5_result= 0; + if(optc == 0) { - - /* >>> check whole session */; - ret= 1; - - return(ret); + ret= Xorriso_check_session_md5(xorriso, severity, 0); + goto ex; } - xorriso->find_check_md5_result= 0; for(i= 0; i < optc; i++) { if(flag & 8) { ret= Findjob_new(&job, optv[i], 0); @@ -13422,7 +13422,7 @@ int Xorriso_option_check_md5(struct XorrisO *xorriso, Xorriso_pacifier_callback(xorriso, "content bytes read", xorriso->pacifier_count, 0, "", 1); report_outcome:; - Xorriso_report_m5_outcome(xorriso, severity, 0); + Xorriso_report_md5_outcome(xorriso, severity, 0); ex:; (*idx)= end_idx; diff --git a/libisoburn/trunk/xorriso/xorriso_private.h b/libisoburn/trunk/xorriso/xorriso_private.h index 513c4230..ac258219 100644 --- a/libisoburn/trunk/xorriso/xorriso_private.h +++ b/libisoburn/trunk/xorriso/xorriso_private.h @@ -675,8 +675,8 @@ int Xorriso_compare_2_files(struct XorrisO *xorriso, char *disk_adr, char *iso_adr, char *adr_common_tail, int *result, int flag); -int Xorriso_report_m5_outcome(struct XorrisO *xorriso, char *severity, - int flag); +int Xorriso_report_md5_outcome(struct XorrisO *xorriso, char *severity, + int flag); int Sfile_str(char target[SfileadrL], char *source, int flag); diff --git a/libisoburn/trunk/xorriso/xorriso_timestamp.h b/libisoburn/trunk/xorriso/xorriso_timestamp.h index c42f3c99..ed36cd0b 100644 --- a/libisoburn/trunk/xorriso/xorriso_timestamp.h +++ b/libisoburn/trunk/xorriso/xorriso_timestamp.h @@ -1 +1 @@ -#define Xorriso_timestamP "2009.08.12.130401" +#define Xorriso_timestamP "2009.08.12.202423" diff --git a/libisoburn/trunk/xorriso/xorrisoburn.c b/libisoburn/trunk/xorriso/xorrisoburn.c index 20acd387..8be7cf23 100644 --- a/libisoburn/trunk/xorriso/xorrisoburn.c +++ b/libisoburn/trunk/xorriso/xorrisoburn.c @@ -8283,7 +8283,7 @@ int Xorriso_findi_sorted(struct XorrisO *xorriso, struct FindjoB *job, ret= 1; ex:; if((flag & 8) && job->action == 35) - Xorriso_report_m5_outcome(xorriso, job->target, 0); + Xorriso_report_md5_outcome(xorriso, job->target, 0); if(!(flag & (2 | 4))) Xorriso_destroy_node_array(xorriso, 0); if(hmboss != NULL) @@ -12208,3 +12208,97 @@ ex:; iso_md5_end(&ctx, data_md5); return(ret); } + + +int Xorriso_check_md5_range(struct XorrisO *xorriso, off_t start_lba, + off_t end_lba, char md5[16], int flag) +{ + int ret, i; + struct burn_drive_info *dinfo= NULL; + struct burn_drive *drive= NULL; + off_t pos, data_count, to_read; + char data[64 * 1024], data_md5[16]; + void *ctx = NULL; + + ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive, + "on attempt to check session MD5 checksum", 0); + if(ret <= 0) + goto ex; + ret= iso_md5_start(&ctx); + if(ret <= 0) { + Xorriso_no_malloc_memory(xorriso, NULL, 0); + goto ex; + } + for(pos= start_lba; pos < end_lba; pos+= 32) { + to_read= 32; + if(pos + to_read > end_lba) + to_read= end_lba - pos; + ret= burn_read_data(drive, pos * (off_t) 2048, data, + to_read * (off_t) 2048, &data_count, 0); + if(ret <= 0) + goto ex; + iso_md5_compute(ctx, data, (int) data_count); + xorriso->pacifier_count+= data_count; + xorriso->pacifier_byte_count+= data_count; + Xorriso_pacifier_callback(xorriso, "content bytes read", + xorriso->pacifier_count, 0, "", 0); + } + iso_md5_end(&ctx, data_md5); + for(i= 0; i < 16; i++) + if(md5[i] != data_md5[i]) + break; + ret= 1; + if(i < 16 ) + ret= 0; +ex:; + Xorriso_process_msg_queues(xorriso,0); + if(ctx != NULL) + iso_md5_end(&ctx, data_md5); + return(ret); +} + + +int Xorriso_check_session_md5(struct XorrisO *xorriso, char *severity, + int flag) +{ + int ret, i; + IsoImage *image; + uint32_t start_lba, end_lba; + char md5[16], md5_text[33]; + + ret= Xorriso_get_volume(xorriso, &image, 0); + if(ret<=0) + return(ret); + ret= iso_image_get_session_md5(image, &start_lba, &end_lba, md5, 0); + Xorriso_process_msg_queues(xorriso,0); + if(ret < 0) + return(ret); + if(ret == 0) { + sprintf(xorriso->info_text, + "No session MD5 is recorded with the loaded session"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); + return(0); + } + for(i= 0; i < 16; i++) + sprintf(md5_text + 2 * i, "%2.2x", ((unsigned char *) md5)[i]); + sprintf(xorriso->info_text, + "Session MD5 %s , LBA %.f , %.f blocks\n", + md5_text, (double) start_lba, (double) end_lba - start_lba); + Xorriso_info(xorriso, 0); + ret= Xorriso_check_md5_range(xorriso, (off_t) start_lba, (off_t) end_lba, + md5, 0); + if(ret <= 0) { + sprintf(xorriso->result_line, "MD5 MISMATCH WITH DATA OF LOADED SESSION\n"); + Xorriso_result(xorriso,0); + if(strcmp(severity, "ALL") != 0) { + sprintf(xorriso->info_text, "Event triggered by MD5 comparison mismatch"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, severity, 0); + } + } else { + sprintf(xorriso->result_line, "md5 of session data matches recorded md5\n"); + Xorriso_result(xorriso,0); + } + return(ret); +} + + diff --git a/libisoburn/trunk/xorriso/xorrisoburn.h b/libisoburn/trunk/xorriso/xorrisoburn.h index 558fa232..0e1bb10b 100644 --- a/libisoburn/trunk/xorriso/xorrisoburn.h +++ b/libisoburn/trunk/xorriso/xorrisoburn.h @@ -324,6 +324,9 @@ int Xorriso_restore_node_array(struct XorrisO *xorriso, int flag); int Xorriso_check_md5(struct XorrisO *xorriso, void *in_node, char *path, int flag); +int Xorriso_check_session_md5(struct XorrisO *xorriso, char *severity, + int flag); + struct CheckmediajoB { int use_dev; /* 0= use indev , 1= use outdev , 2= use sector map*/