From 72ef04a9e1ec2e9c2727c3cc765b1ca49c35b258 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Tue, 28 Feb 2023 16:08:41 +0100 Subject: [PATCH] Enabled -check_media with pseudo-blank overwritable media --- xorriso/drive_mgt.c | 53 +++++++++++++++++++++++++++---------- xorriso/xorriso_timestamp.h | 2 +- 2 files changed, 40 insertions(+), 15 deletions(-) diff --git a/xorriso/drive_mgt.c b/xorriso/drive_mgt.c index dc908cb9..14c607f4 100644 --- a/xorriso/drive_mgt.c +++ b/xorriso/drive_mgt.c @@ -2591,9 +2591,10 @@ int Xorriso__add_spot(struct xorriso_md5_state *state, int Xorriso_chunk_md5(struct XorrisO *xorriso, char *data, int to_read, uint32_t from_lba, struct xorriso_md5_state *state, int flag) { - int j, ret= 0, valid, tag_type, decode_ret= 0; + int j, k, ret= 0, valid, tag_type, decode_ret= 0; uint32_t lba, pos, range_start, range_size; char md5[16], tag_md5[16], *tag_type_name= "", *comparison, *sev_text; + char md5_text[33]; void *cloned_ctx= NULL; for(j= 0; j < to_read; j++) { @@ -2633,12 +2634,10 @@ int Xorriso_chunk_md5(struct XorrisO *xorriso, char *data, int to_read, } } else if(valid && tag_type == 4 && lba < 32) { tag_type_name= "relocated 64kB superblock"; - }else if(valid && tag_type == 3 && state->was_sb_tag) { + } else if(valid && tag_type == 3 && state->was_sb_tag) { tag_type_name= "tree"; - }else if(valid && tag_type == 1) { - - /* >>> ??? allow this without superblock and tree tag ? */ - + } else if(valid && tag_type == 1) { + /* Allow this without superblock and tree tag */ tag_type_name= "session"; } else { tag_type_name= ""; @@ -2648,9 +2647,14 @@ int Xorriso_chunk_md5(struct XorrisO *xorriso, char *data, int to_read, sprintf(xorriso->info_text, "Found MD5 %s tag which covers different data range", tag_type_name); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE",0); - sprintf(xorriso->info_text, " Expected: %u Found: %u", + sprintf(xorriso->info_text, " Expected start: %u Found: %u", (unsigned int) state->md5_start, range_start); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE",0); + for(k= 0; k < 16; k++) + sprintf(md5_text + 2 * k, "%2.2x", ((unsigned char *) tag_md5)[k]); + sprintf(xorriso->info_text, " Size: %u MD5: %s", + range_size, md5_text); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE",0); state->chain_broken= 1; valid= 0; } else { @@ -2691,7 +2695,7 @@ int Xorriso_chunk_md5(struct XorrisO *xorriso, char *data, int to_read, goto ex; } state->md5_spot_value= Xorriso_read_quality_untesteD; - state->md5_start = lba + 1; + state->md5_start= lba + 1; if(state->md5_start % 32) state->md5_start= state->md5_start + (32 - (state->md5_start % 32)); state->next_tag= 0; @@ -3316,24 +3320,43 @@ int Xorriso_check_media(struct XorrisO *xorriso, struct SpotlisT **spotlist, s= isoburn_disc_get_status(drive); if(s != BURN_DISC_APPENDABLE && s != BURN_DISC_FULL) { - Xorriso_msgs_submit(xorriso, 0, "-check_media: No readable medium found", - 0, "SORRY", 0); - ret= 0; goto ex; + ret= 0; + if(s == BURN_DISC_BLANK) { + /* check whether medium is overwritable */ + ret= burn_disc_get_multi_caps(drive, BURN_WRITE_NONE, &caps, 0); + if(ret > 0) + if(caps->start_adr == 0) + ret= 0; + } + if(ret <= 0) { +no_readable_medium:; + Xorriso_msgs_submit(xorriso, 0, "-check_media: No readable medium found", + 0, "SORRY", 0); + ret= 0; goto ex; + } } ret= burn_get_read_capacity(drive, &read_capacity, 0); if(ret <= 0) read_capacity= -1; + if(s == BURN_DISC_BLANK && read_capacity <= 0) + goto no_readable_medium; if(job->max_lba >= 0) { blocks= job->max_lba + 1 - start_lba; xorriso->pacifier_total= blocks; ret= Xorriso_check_interval(xorriso, *spotlist, job, start_lba, blocks, - read_chunk, 0, 0); + read_chunk, start_lba, 0); if(ret <= 0) goto ex; } else if(mode == 0) { /* track by track */ + if(s == BURN_DISC_BLANK) { +no_tracks_found:; + Xorriso_msgs_submit(xorriso, 0, "-check_media: No tracks found on medium", + 0, "SORRY", 0); + ret= 0; goto ex; + } isoburn_disc= isoburn_toc_drive_get_disc(drive); if(isoburn_disc == NULL) goto libburn_whole_disc; @@ -3444,6 +3467,8 @@ int Xorriso_check_media(struct XorrisO *xorriso, struct SpotlisT **spotlist, } else if(mode == 1) { /* Image range */ /* Default is the emulated disc capacity. */ + if(s == BURN_DISC_BLANK) + goto no_tracks_found; isoburn_disc= isoburn_toc_drive_get_disc(drive); if(isoburn_disc == NULL) goto libburn_whole_disc; @@ -3465,7 +3490,7 @@ int Xorriso_check_media(struct XorrisO *xorriso, struct SpotlisT **spotlist, goto libburn_whole_disc; xorriso->pacifier_total= blocks; ret= Xorriso_check_interval(xorriso, *spotlist, job, start_lba, blocks, - read_chunk, 0, (4 * (xorriso->do_md5 & 1))); + read_chunk, start_lba, (4 * (xorriso->do_md5 & 1))); if(ret <= 0) goto ex; } else if(mode == 2) { @@ -3481,7 +3506,7 @@ libburn_whole_disc:; blocks-= start_lba; xorriso->pacifier_total= blocks; ret= Xorriso_check_interval(xorriso, *spotlist, job, start_lba, blocks, - read_chunk, 0, (4 * (xorriso->do_md5 & 1))); + read_chunk, start_lba, (4 * (xorriso->do_md5 & 1))); if(ret <= 0) goto ex; } diff --git a/xorriso/xorriso_timestamp.h b/xorriso/xorriso_timestamp.h index 51bf7891..4d6658a1 100644 --- a/xorriso/xorriso_timestamp.h +++ b/xorriso/xorriso_timestamp.h @@ -1 +1 @@ -#define Xorriso_timestamP "2023.02.28.135556" +#define Xorriso_timestamP "2023.02.28.150706"