Made structs SpotlistiteM and SpotlisT ready for long block adresses

This commit is contained in:
Thomas Schmitt 2024-03-17 22:07:23 +01:00
parent 86261b7972
commit ba12014d46
6 changed files with 76 additions and 73 deletions

View File

@ -39,14 +39,14 @@
struct SpotlistiteM {
int start_lba;
int blocks;
off_t start_lba;
off_t blocks;
int quality;
struct SpotlistiteM *next;
};
int Spotlistitem_new(struct SpotlistiteM **o, int start_lba, int blocks,
int Spotlistitem_new(struct SpotlistiteM **o, off_t start_lba, off_t blocks,
int quality, int flag)
{
struct SpotlistiteM *m;
@ -76,9 +76,9 @@ int Spotlistitem_destroy(struct SpotlistiteM **o, int flag)
struct SpotlisT {
struct SpotlistiteM *list_start;
struct SpotlistiteM *list_end;
int list_count;
off_t list_count;
struct SpotlistiteM *current_item;
int current_idx;
off_t current_idx;
};
@ -117,7 +117,7 @@ int Spotlist_destroy(struct SpotlisT **o, int flag)
}
int Spotlist_add_item(struct SpotlisT *o, int start_lba, int blocks,
int Spotlist_add_item(struct SpotlisT *o, off_t start_lba, off_t blocks,
int quality, int flag)
{
int ret;
@ -135,8 +135,9 @@ int Spotlist_add_item(struct SpotlisT *o, int start_lba, int blocks,
(o->list_count)++;
if(debug_verbous) {char quality_name[80];
fprintf(stderr, "debug: lba %10d , size %10d , quality '%s'\n",
start_lba, blocks, Spotlist__quality_name(quality, quality_name,
fprintf(stderr, "debug: lba %10.f , size %10.f , quality '%s'\n",
(double) start_lba, (double) blocks,
Spotlist__quality_name(quality, quality_name,
Xorriso_read_quality_invaliD, 0) + 2);
}
@ -144,15 +145,15 @@ int Spotlist_add_item(struct SpotlisT *o, int start_lba, int blocks,
}
int Spotlist_count(struct SpotlisT *o, int flag)
off_t Spotlist_count(struct SpotlisT *o, int flag)
{
return o->list_count;
}
int Spotlist_block_count(struct SpotlisT *o, int flag)
off_t Spotlist_block_count(struct SpotlisT *o, int flag)
{
int list_blocks= 0;
off_t list_blocks= 0;
struct SpotlistiteM *li;
for(li= o->list_start; li != NULL; li= li->next) {
@ -163,9 +164,9 @@ int Spotlist_block_count(struct SpotlisT *o, int flag)
}
int Spotlist_sector_size(struct SpotlisT *o, int read_chunk, int flag)
off_t Spotlist_sector_size(struct SpotlisT *o, off_t read_chunk, int flag)
{
int sector_size;
off_t sector_size;
struct SpotlistiteM *li;
sector_size= read_chunk * 2048;
@ -179,10 +180,10 @@ int Spotlist_sector_size(struct SpotlisT *o, int read_chunk, int flag)
}
int Spotlist_get_item(struct SpotlisT *o, int idx,
int *start_lba, int *blocks, int *quality, int flag)
int Spotlist_get_item(struct SpotlisT *o, off_t idx,
off_t *start_lba, off_t *blocks, int *quality, int flag)
{
int i;
off_t i;
struct SpotlistiteM *li;
if(idx < 0 || idx > o->list_count)
@ -996,7 +997,7 @@ int Xorriso_sectormap_to_spotlist(struct XorrisO *xorriso,
if(value == old_value)
continue;
if(old_value >= 0) {
ret= Spotlist_add_item(*spotlist, (int) old_start, (int) (i * sector_size - old_start),
ret= Spotlist_add_item(*spotlist, old_start, i * sector_size - old_start,
(old_value ? Xorriso_read_quality_valiD :
Xorriso_read_quality_invaliD), 0);
if(ret <= 0)
@ -1007,8 +1008,8 @@ int Xorriso_sectormap_to_spotlist(struct XorrisO *xorriso,
job->item_limit);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
if(sectors - i > 1) {
ret= Spotlist_add_item(*spotlist, (int) (i * sector_size),
(int) ((sectors - i - 1) * sector_size),
ret= Spotlist_add_item(*spotlist, i * sector_size,
(sectors - i - 1) * sector_size,
Xorriso_read_quality_untesteD, 0);
if(ret <= 0)
goto ex;
@ -1020,7 +1021,7 @@ int Xorriso_sectormap_to_spotlist(struct XorrisO *xorriso,
old_start= i * sector_size;
}
if(old_value >= 0) {
ret= Spotlist_add_item(*spotlist, (int) old_start, (int) (i * sector_size - old_start),
ret= Spotlist_add_item(*spotlist, old_start, i * sector_size - old_start,
(old_value ? Xorriso_read_quality_valiD :
Xorriso_read_quality_invaliD), 0);
if(ret <= 0)
@ -1039,15 +1040,16 @@ ex:;
*/
int Xorriso_spotlist_to_sectormap(struct XorrisO *xorriso,
struct SpotlisT *spotlist,
int read_chunk,
off_t read_chunk,
struct SectorbitmaP **map,
int flag)
{
struct SectorbitmaP *m;
int valid;
off_t map_sectors= -1, map_sector_size= -1;
int list_sectors, list_blocks, sector_size, sector_blocks;
int replace_map= 0, count, i, lba, blocks, quality, ret, pass;
int replace_map= 0, quality, ret, pass;
off_t list_sectors, list_blocks, sector_size, sector_blocks;
off_t count, i, lba, blocks;
sector_size= Spotlist_sector_size(spotlist, read_chunk, 0);
sector_blocks= sector_size / 2048;
@ -1067,12 +1069,10 @@ int Xorriso_spotlist_to_sectormap(struct XorrisO *xorriso,
m= *map;
else {
if(*map != NULL) {
if((*map)->sectors * (*map)->sector_size >
((off_t) list_sectors) * ((off_t) sector_size))
list_sectors= (*map)->sectors * (*map)->sector_size /
((off_t) sector_size) + 1;
if((*map)->sectors * (*map)->sector_size > list_sectors * sector_size)
list_sectors= (*map)->sectors * (*map)->sector_size / sector_size + 1;
}
ret= Sectorbitmap_new(&m, (off_t) list_sectors, (off_t) sector_size, 0);
ret= Sectorbitmap_new(&m, list_sectors, sector_size, 0);
if(ret <= 0)
return(-1);
replace_map= 1;
@ -1103,8 +1103,6 @@ int Xorriso_spotlist_to_sectormap(struct XorrisO *xorriso,
continue;
Sectorbitmap_set_range(m, lba / sector_blocks, blocks / sector_blocks,
valid);
Sectorbitmap_set_range(m, (off_t) (lba / sector_blocks),
(off_t) ( blocks / sector_blocks), valid);
}
}
if(replace_map) {
@ -1138,10 +1136,11 @@ int Xorriso_open_job_data_to(struct XorrisO *xorriso,
int Xorriso_update_in_sector_map(struct XorrisO *xorriso,
struct SpotlisT *spotlist, int read_chunk,
struct SpotlisT *spotlist, off_t read_chunk,
struct CheckmediajoB *job, int flag)
{
int sectors, sector_size, sector_blocks, ret;
int ret;
off_t sectors, sector_size, sector_blocks;
struct SectorbitmaP *map;
Sectorbitmap_destroy(&(xorriso->in_sector_map), 0);
@ -1155,8 +1154,7 @@ int Xorriso_update_in_sector_map(struct XorrisO *xorriso,
sector_blocks= sector_size / 2048;
if(sector_blocks > 1)
sectors= sectors / sector_blocks + !!(sectors % sector_blocks);
ret= Sectorbitmap_new(&(xorriso->in_sector_map), (off_t) sectors,
(off_t) sector_size, 0);
ret= Sectorbitmap_new(&(xorriso->in_sector_map), sectors, sector_size, 0);
if(ret <= 0)
return(ret);
if(map != NULL)

View File

@ -32,7 +32,7 @@ int Xorriso_sectormap_to_spotlist(struct XorrisO *xorriso,
*/
int Xorriso_spotlist_to_sectormap(struct XorrisO *xorriso,
struct SpotlisT *spotlist,
int read_chunk,
off_t read_chunk,
struct SectorbitmaP **map,
int flag);
@ -50,7 +50,7 @@ int Xorriso_check_media_list_job(struct XorrisO *xorriso,
char *report, int flag);
int Xorriso_update_in_sector_map(struct XorrisO *xorriso,
struct SpotlisT *spotlist, int read_chunk,
struct SpotlisT *spotlist, off_t read_chunk,
struct CheckmediajoB *job, int flag);
@ -66,17 +66,17 @@ int Spotlist_new(struct SpotlisT **o, int flag);
int Spotlist_destroy(struct SpotlisT **o, int flag);
int Spotlist_add_item(struct SpotlisT *o, int start_lba, int blocks,
int Spotlist_add_item(struct SpotlisT *o, off_t start_lba, off_t blocks,
int quality, int flag);
int Spotlist_count(struct SpotlisT *o, int flag);
off_t Spotlist_count(struct SpotlisT *o, int flag);
int Spotlist_block_count(struct SpotlisT *o, int flag);
off_t Spotlist_block_count(struct SpotlisT *o, int flag);
int Spotlist_sector_size(struct SpotlisT *o, int read_chunk, int flag);
off_t Spotlist_sector_size(struct SpotlisT *o, off_t read_chunk, int flag);
int Spotlist_get_item(struct SpotlisT *o, int idx,
int *start_lba, int *blocks, int *quality, int flag);
int Spotlist_get_item(struct SpotlisT *o, off_t idx,
off_t *start_lba, off_t *blocks, int *quality, int flag);
char *Spotlist__quality_name(int quality, char name[80], int bad_limit,
int flag);

View File

@ -2578,7 +2578,7 @@ int Xorriso__add_spot(struct xorriso_md5_state *state,
if(ret != 0)
return(0);
}
ret= Spotlist_add_item(state->spotlist, start_lba, blocks, quality, 0);
ret= Spotlist_add_item(state->spotlist, (off_t) start_lba, (off_t) blocks, quality, 0);
if(state->chunk != NULL) {
uret= pthread_mutex_unlock(&(state->spot_mutex));
if(uret != 0 && ret > 0)
@ -3255,10 +3255,11 @@ ex:;
int Xorriso_check_media(struct XorrisO *xorriso, struct SpotlisT **spotlist,
struct CheckmediajoB *job, int flag)
{
int media_blocks= 0, read_chunk= 32, ret, mode, start_lba= 0;
int blocks, os_errno, i, j, last_track_end= -1, track_blocks, track_lba;
int media_blocks= 0, read_chunk= 32, ret, mode;
int num_sessions, num_tracks, declare_untested= 0, md5_start;
int read_capacity= -1, end_lba, hret, count, quality, profile_no;
int os_errno, j, track_blocks;
int read_capacity= -1, end_lba, hret, quality, profile_no;
off_t i, blocks, last_track_end= -1, count, track_lba, start_lba= 0;
int track_bad_claim= 0;
char *toc_info= NULL, profile_name[80], msg[160];
struct burn_drive *drive;
@ -3313,7 +3314,7 @@ int Xorriso_check_media(struct XorrisO *xorriso, struct SpotlisT **spotlist,
mode= job->mode;
if(job->min_lba > 0) {
start_lba= job->min_lba;
ret= Spotlist_add_item(*spotlist, 0, job->min_lba,
ret= Spotlist_add_item(*spotlist, (off_t) 0, (off_t) job->min_lba,
Xorriso_read_quality_untesteD, 0);
if(ret <= 0)
goto ex;
@ -3346,8 +3347,8 @@ 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, start_lba, 0);
ret= Xorriso_check_interval(xorriso, *spotlist, job, (int) start_lba, (int) blocks,
read_chunk, (int) start_lba, 0);
if(ret <= 0)
goto ex;
@ -3386,7 +3387,7 @@ no_tracks_found:;
track_bad_claim= track_lba + track_blocks;
if(track_lba >= read_capacity) {
sprintf(msg, "-check_media: Track %d of session %d begins after end of readable medium area.",
j + 1, i + 1);
j + 1, (int) (i + 1));
Xorriso_msgs_submit(xorriso, 0, msg, 0, "WARNING", 0);
continue;
} else {
@ -3398,7 +3399,7 @@ no_tracks_found:;
Xorriso_msgs_submit(xorriso, 0, msg, 0, "DEBUG", 0);
} else {
sprintf(msg, "-check_media: Track %d of session %d extends over the end of readable medium area.",
j + 1, i + 1);
j + 1, (int) (i + 1));
Xorriso_msgs_submit(xorriso, 0, msg, 0, "WARNING", 0);
}
track_blocks= read_capacity - track_lba;
@ -3434,12 +3435,12 @@ no_tracks_found:;
if(track_blocks <= 0)
continue;
if(declare_untested) {
ret= Spotlist_add_item(*spotlist, track_lba, track_blocks,
ret= Spotlist_add_item(*spotlist, track_lba, (off_t) track_blocks,
Xorriso_read_quality_untesteD, 0);
if(ret <= 0)
goto ex;
} else {
ret= Xorriso_check_interval(xorriso, *spotlist, job, track_lba,
ret= Xorriso_check_interval(xorriso, *spotlist, job, (int) track_lba,
track_blocks, read_chunk, md5_start,
(i > 0) | (4 * (xorriso->do_md5 & 1)));
if(ret <= 0)
@ -3459,8 +3460,8 @@ no_tracks_found:;
quality= Xorriso_read_quality_tao_enD;
else
quality= Xorriso_read_quality_unreadablE;
ret= Spotlist_add_item(*spotlist, read_capacity,
track_bad_claim - read_capacity, quality, 0);
ret= Spotlist_add_item(*spotlist, (off_t) read_capacity,
(off_t) (track_bad_claim - read_capacity), quality, 0);
if(ret <= 0)
goto ex;
}
@ -3479,7 +3480,7 @@ no_tracks_found:;
*/
track_lba= isoburn_get_attached_start_lba(drive);
if(track_lba >= 0) {
ret= isoburn_read_iso_head(drive, track_lba, &track_blocks, NULL, 0);
ret= isoburn_read_iso_head(drive, (int) track_lba, &track_blocks, NULL, 0);
if(ret > 0) {
blocks= media_blocks= track_lba + track_blocks;
}
@ -3490,14 +3491,14 @@ no_tracks_found:;
if(media_blocks <= 0)
goto libburn_whole_disc;
xorriso->pacifier_total= blocks;
ret= Xorriso_check_interval(xorriso, *spotlist, job, start_lba, blocks,
read_chunk, start_lba, (4 * (xorriso->do_md5 & 1)));
ret= Xorriso_check_interval(xorriso, *spotlist, job, (int) start_lba, (int) blocks,
read_chunk, (int) start_lba, (4 * (xorriso->do_md5 & 1)));
if(ret <= 0)
goto ex;
} else if(mode == 2) {
libburn_whole_disc:;
/* single sweep over libburn medium capacity */
ret= burn_get_read_capacity(drive, &blocks, 0);
ret= burn_get_read_capacity_v2(drive, &blocks, 0);
if(ret <= 0) {
Xorriso_process_msg_queues(xorriso,0);
sprintf(xorriso->info_text, "No content detected on media");
@ -3506,8 +3507,8 @@ libburn_whole_disc:;
}
blocks-= start_lba;
xorriso->pacifier_total= blocks;
ret= Xorriso_check_interval(xorriso, *spotlist, job, start_lba, blocks,
read_chunk, start_lba, (4 * (xorriso->do_md5 & 1)));
ret= Xorriso_check_interval(xorriso, *spotlist, job, (int) start_lba, (int) blocks,
read_chunk, (int) start_lba, (4 * (xorriso->do_md5 & 1)));
if(ret <= 0)
goto ex;
}
@ -3531,7 +3532,7 @@ ex:;
end_lba= start_lba + blocks;
}
if(read_capacity > end_lba) {
hret= Spotlist_add_item(*spotlist, end_lba, read_capacity - end_lba,
hret= Spotlist_add_item(*spotlist, (off_t) end_lba, (off_t) (read_capacity - end_lba),
Xorriso_read_quality_untesteD, 0);
if(hret < ret)
ret= hret;
@ -3539,10 +3540,11 @@ ex:;
}
if(ret > 0)
ret= Xorriso_update_in_sector_map(xorriso, *spotlist, read_chunk, job, 0);
ret= Xorriso_update_in_sector_map(xorriso, *spotlist, (off_t) read_chunk,
job, 0);
if(ret > 0) {
ret= Xorriso_spotlist_to_sectormap(xorriso, *spotlist, read_chunk,
ret= Xorriso_spotlist_to_sectormap(xorriso, *spotlist, (off_t) read_chunk,
&(job->sector_map), 2);
if(ret > 0 && job->sector_map_path[0]) {
ret= Sectorbitmap_to_file(job->sector_map, job->sector_map_path, toc_info,

View File

@ -1919,7 +1919,8 @@ ex:;
int Xorriso_option_check_media(struct XorrisO *xorriso,
int argc, char **argv, int *idx, int flag)
{
int ret, i, count, lba, blocks, quality, pass, was_md5= 0, was_event= 0;
int ret, quality, pass, was_md5= 0, was_event= 0;
off_t i, count, lba, blocks;
int end_idx, old_idx, os_errno, to_info= 0;
char quality_name[80], *head_buffer= NULL;
struct SpotlisT *spotlist= NULL;
@ -2038,9 +2039,10 @@ int Xorriso_option_check_media(struct XorrisO *xorriso,
else if(pass == 1 && !(quality == Xorriso_read_quality_md5_matcH ||
quality == Xorriso_read_quality_md5_mismatcH))
continue;
sprintf(xorriso->result_line, "%s: %10d , %10d , %s\n",
sprintf(xorriso->result_line, "%s: %10.f , %10.f , %s\n",
pass == 0 ? "Media region " : "MD5 tag range",
lba, blocks, Spotlist__quality_name(quality, quality_name,
(double) lba, (double) blocks,
Spotlist__quality_name(quality, quality_name,
xorriso->check_media_bad_limit, 0));
if(to_info) {
strcpy(xorriso->info_text, xorriso->result_line);

View File

@ -2418,7 +2418,8 @@ int Xorriso_read_file_data(struct XorrisO *xorriso, IsoNode *node,
off_t bytes, int flag)
{
int ret, i, lba_count= 0, *start_lbas= NULL, *end_lbas= NULL, read_chunk= 16;
int lba, count, blocks, quality, spot, bad_extract= 0;
int quality, bad_extract= 0;
off_t lba, count, blocks, spot;
int data_to_skip= 0;
uint32_t indev_blocks;
off_t size= 0, file_base_bytes= 0, file_processed_bytes= 0, img_adr;
@ -2481,7 +2482,7 @@ int Xorriso_read_file_data(struct XorrisO *xorriso, IsoNode *node,
for(i= 0; i < lba_count && file_base_bytes < upto_file_bytes; i++) {
lba= start_lbas[i];
count= end_lbas[i] + 1 - start_lbas[i];
new_file_base_bytes= file_base_bytes + ((off_t) count) * (off_t) 2048;
new_file_base_bytes= file_base_bytes + count * (off_t) 2048;
/* skip intervals before img_offset */
if(new_file_base_bytes <= img_offset) {
@ -2489,7 +2490,7 @@ int Xorriso_read_file_data(struct XorrisO *xorriso, IsoNode *node,
continue;
}
/* Eventually adjust first interval start */
img_adr= ((off_t) lba) * (off_t) 2048;
img_adr= lba * (off_t) 2048;
if(file_base_bytes < img_offset) {
img_adr+= img_offset - file_base_bytes;
lba= img_adr / (off_t) 2048;
@ -2505,8 +2506,8 @@ int Xorriso_read_file_data(struct XorrisO *xorriso, IsoNode *node,
job->data_to_limit= size - file_base_bytes;
job->data_to_skip= data_to_skip;
data_to_skip= 0;
file_processed_bytes+= ((off_t) count) * (off_t) 2048;
ret= Xorriso_check_interval(xorriso, spotlist, job, lba, count, read_chunk,
file_processed_bytes+= count * (off_t) 2048;
ret= Xorriso_check_interval(xorriso, spotlist, job, (int) lba, (int) count, read_chunk,
0, (flag & 2));
if(ret <= 0)
goto ex;

View File

@ -1 +1 @@
#define Xorriso_timestamP "2024.03.17.160830"
#define Xorriso_timestamP "2024.03.17.205516"