diff --git a/libisoburn/trunk/xorriso/xorriso.c b/libisoburn/trunk/xorriso/xorriso.c index 391b900b..3e276744 100644 --- a/libisoburn/trunk/xorriso/xorriso.c +++ b/libisoburn/trunk/xorriso/xorriso.c @@ -12474,22 +12474,31 @@ ex:; int Xorriso_report_md5_outcome(struct XorrisO *xorriso, char *severity, int flag) { - if((xorriso->find_check_md5_result & 3) == 0) { + int has_md5; + + has_md5= Xorriso_image_has_md5(xorriso, 0); + if (has_md5 <= 0) { sprintf(xorriso->result_line, - "File contents and their MD5 checksums match.\n"); + "There is no MD5 checksum array loaded.\n"); } else if(xorriso->find_check_md5_result & 1) { sprintf(xorriso->result_line, "Mismatch detected between file contents and MD5 checksums.\n"); + } else if(xorriso->find_check_md5_result & 8) { + sprintf(xorriso->result_line, + "File contents and their MD5 checksums match.\n"); + } else { + sprintf(xorriso->result_line, + "Not a single file with MD5 checksum was found.\n"); } Xorriso_result(xorriso,0); if(xorriso->find_check_md5_result & 2) { sprintf(xorriso->result_line, - "Encountered other errors during MD5 checking.\n"); + "Encountered errors other than non-match during MD5 checking.\n"); Xorriso_result(xorriso,0); } - if(xorriso->find_check_md5_result & 4) { + if((xorriso->find_check_md5_result & 4) && has_md5) { sprintf(xorriso->result_line, - "There were data files which had no MD5 and thus could not be checked.\n"); + "There were data files which have no MD5 and thus could not be checked.\n"); Xorriso_result(xorriso,0); } if((xorriso->find_check_md5_result & 3) && strcmp(severity, "ALL") != 0) { @@ -13346,19 +13355,17 @@ int Xorriso_option_check_md5(struct XorrisO *xorriso, struct FindjoB *job= NULL; double mem_lut= 0.0; - if(!(flag&2)) { - Xorriso_pacifier_reset(xorriso, 0); - mem_lut= xorriso->last_update_time; - } - mem_pci= xorriso->pacifier_interval; - xorriso->pacifier_interval= 5.0; + ret= Xorriso_opt_args(xorriso, "-check_md5", argc, argv, *idx + 1, + &end_idx, &optc, &optv, 128); + if(ret<=0) + goto ex; /* Interpret argv[*idx] as severity */ if(argc <= *idx) { sprintf(xorriso->info_text, "-check_md5: No event severity given for case of mismatch"); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); - return(0); + ret= 0; goto ex; } severity= argv[*idx]; ret= Xorriso__text_to_sev(severity, &sev, 0); @@ -13366,14 +13373,24 @@ int Xorriso_option_check_md5(struct XorrisO *xorriso, sprintf(xorriso->info_text, "-check_md5: Not a known severity name : "); Text_shellsafe(severity, xorriso->info_text, 1); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); - return(ret); - } - (*idx)++; - - ret= Xorriso_opt_args(xorriso, "-check_md5", argc, argv, *idx, - &end_idx, &optc, &optv, 128); - if(ret<=0) goto ex; + } + ret= Xorriso_image_has_md5(xorriso, 0); + if(ret <= 0) { + sprintf(xorriso->info_text, + "-check_md5: There is no MD5 checksum array loaded."); + if (strcmp(severity, "ALL") == 0) + severity= "WARNING"; + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, severity, 0); + ret= -1; goto ex; + } + + if(!(flag&2)) { + Xorriso_pacifier_reset(xorriso, 0); + mem_lut= xorriso->last_update_time; + } + mem_pci= xorriso->pacifier_interval; + xorriso->pacifier_interval= 5.0; xorriso->find_check_md5_result= 0; @@ -13405,6 +13422,8 @@ int Xorriso_option_check_md5(struct XorrisO *xorriso, xorriso->find_check_md5_result|= 2; else if(ret == 0) xorriso->find_check_md5_result|= 1; + else if(ret == 1) + xorriso->find_check_md5_result|= 8; else if(ret == 2) xorriso->find_check_md5_result|= 4; } diff --git a/libisoburn/trunk/xorriso/xorriso_timestamp.h b/libisoburn/trunk/xorriso/xorriso_timestamp.h index ed36cd0b..1f6cd7bb 100644 --- a/libisoburn/trunk/xorriso/xorriso_timestamp.h +++ b/libisoburn/trunk/xorriso/xorriso_timestamp.h @@ -1 +1 @@ -#define Xorriso_timestamP "2009.08.12.202423" +#define Xorriso_timestamP "2009.08.13.203718" diff --git a/libisoburn/trunk/xorriso/xorrisoburn.c b/libisoburn/trunk/xorriso/xorrisoburn.c index 8be7cf23..527bb2c6 100644 --- a/libisoburn/trunk/xorriso/xorrisoburn.c +++ b/libisoburn/trunk/xorriso/xorrisoburn.c @@ -1116,7 +1116,8 @@ int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, int flag) goto ex; ext= isoburn_ropt_noiso1999; - if((xorriso->ino_behavior & (1 | 2)) && !(xorriso->do_aaip & (1 | 4 | 32))) + if((xorriso->ino_behavior & (1 | 2)) && !(xorriso->do_aaip & (1 | 4 | 32)) + && !(xorriso->do_md5 & 1)) ext|= isoburn_ropt_noaaip; if(!(xorriso->do_aaip & 1)) ext|= isoburn_ropt_noacl; @@ -7606,6 +7607,8 @@ int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job, xorriso->find_check_md5_result|= 1; else if(ret < 0) xorriso->find_check_md5_result|= 2; + else if(ret == 1) + xorriso->find_check_md5_result|= 8; else if(ret == 2) xorriso->find_check_md5_result|= 4; if(ret >= 0) @@ -8882,6 +8885,7 @@ int Xorriso_get_profile(struct XorrisO *xorriso, int *profile_number, } + int Xorriso_iso_file_open(struct XorrisO *xorriso, char *pathname, void *node_pt, void **stream, int flag) { @@ -8889,7 +8893,7 @@ int Xorriso_iso_file_open(struct XorrisO *xorriso, char *pathname, char eff_path[SfileadrL]; IsoNode *node= NULL; IsoFile *filenode= NULL; - IsoStream *iso_stream= NULL; + IsoStream *iso_stream= NULL, *input_stream; *stream= NULL; if(flag&1) { @@ -8915,6 +8919,15 @@ int Xorriso_iso_file_open(struct XorrisO *xorriso, char *pathname, Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); return(0); } + if(flag & 2) { + /* Dig out the most original stream */ + while(1) { + input_stream= iso_stream_get_input_stream(iso_stream, 0); + if(input_stream == NULL) + break; + iso_stream= input_stream; + } + } if(!iso_stream_is_repeatable(iso_stream)) { sprintf(xorriso->info_text, "The data production of the file in the image is one-time only"); @@ -12154,13 +12167,13 @@ int Xorriso_check_md5(struct XorrisO *xorriso, void *in_node, char *path, } /* Read file and compute MD5 */; - ret= Xorriso_iso_file_open(xorriso, path, (void *) node, &stream, 1); + ret= Xorriso_iso_file_open(xorriso, path, (void *) node, &stream, 1 | 2); if(ret <= 0) {ret= -1; goto ex;} ret= iso_md5_start(&ctx); if(ret < 0) goto ex; - todo= iso_file_get_size(file); + todo= iso_stream_get_size(stream); while(todo > 0) { if(todo < sizeof(buffer)) wanted= todo; @@ -12279,26 +12292,46 @@ int Xorriso_check_session_md5(struct XorrisO *xorriso, char *severity, Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); return(0); } + + sprintf(xorriso->info_text, "Checking loaded session by its recorded MD5.\n"); + Xorriso_info(xorriso, 0); for(i= 0; i < 16; i++) sprintf(md5_text + 2 * i, "%2.2x", ((unsigned char *) md5)[i]); - sprintf(xorriso->info_text, + sprintf(xorriso->result_line, "Session MD5 %s , LBA %.f , %.f blocks\n", md5_text, (double) start_lba, (double) end_lba - start_lba); - Xorriso_info(xorriso, 0); + Xorriso_result(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"); + 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"); + sprintf(xorriso->result_line, "Ok, session data match recorded md5.\n"); Xorriso_result(xorriso,0); } return(ret); } +int Xorriso_image_has_md5(struct XorrisO *xorriso, int flag) +{ + int ret; + IsoImage *image; + uint32_t start_lba, end_lba; + char md5[16]; + + 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); + return(1); +} diff --git a/libisoburn/trunk/xorriso/xorrisoburn.h b/libisoburn/trunk/xorriso/xorrisoburn.h index 0e1bb10b..3f8ad150 100644 --- a/libisoburn/trunk/xorriso/xorrisoburn.h +++ b/libisoburn/trunk/xorriso/xorrisoburn.h @@ -218,6 +218,7 @@ int Xorriso_get_profile(struct XorrisO *xorriso, int *profile_number, char profile_name[80], int flag); /* @param flag bit0= node_pt is a valid ISO object handle, ignore pathname + bit1= dig out the most original stream for reading */ int Xorriso_iso_file_open(struct XorrisO *xorriso, char *pathname, void *node_pt, void **stream, int flag); @@ -327,6 +328,8 @@ int Xorriso_check_md5(struct XorrisO *xorriso, void *in_node, char *path, int Xorriso_check_session_md5(struct XorrisO *xorriso, char *severity, int flag); +int Xorriso_image_has_md5(struct XorrisO *xorriso, int flag); + struct CheckmediajoB { int use_dev; /* 0= use indev , 1= use outdev , 2= use sector map*/