Made struct SectorbitmaP ready for long block adresses

This commit is contained in:
Thomas Schmitt 2024-03-17 16:26:38 +01:00
parent a07addd083
commit 73b3923f72
5 changed files with 55 additions and 43 deletions

View File

@ -1,7 +1,7 @@
/* xorriso - creates, loads, manipulates and burns ISO 9660 filesystem images.
Copyright 2007-2020 Thomas Schmitt, <scdbackup@gmx.net>
Copyright 2007-2024 Thomas Schmitt, <scdbackup@gmx.net>
Provided under GPL version 2 or later.
@ -249,7 +249,7 @@ char *Spotlist__quality_name(int quality, char name[80], int bad_limit,
/* ---------------------------- SectorbitmaP ------------------------------ */
int Sectorbitmap_new(struct SectorbitmaP **o, int sectors, int sector_size,
int Sectorbitmap_new(struct SectorbitmaP **o, off_t sectors, off_t sector_size,
int flag)
{
struct SectorbitmaP *m;
@ -288,7 +288,9 @@ int Sectorbitmap_destroy(struct SectorbitmaP **o, int flag)
int Sectorbitmap_from_file(struct SectorbitmaP **o, char *path, char *msg,
int *os_errno, int flag)
{
int ret, fd= -1, sectors, sector_size, i, todo, map_size, skip, bufsize= 1024;
int ret, fd= -1, todo, skip, bufsize= 1024;
off_t sectors, sector_size;
ssize_t i, map_size;
unsigned char *map;
unsigned char *buf;
@ -346,7 +348,8 @@ wrong_filetype:;
ret= Sectorbitmap_new(o, sectors, sector_size, 0);
if(ret <= 0) {
if(msg != NULL)
sprintf(msg, "Cannot allocate bitmap memory for %d sectors", sectors);
sprintf(msg, "Cannot allocate bitmap memory for %.f sectors",
(double) sectors);
ret= -1; goto ex;
}
map= (*o)->map;
@ -435,7 +438,7 @@ ex:;
/* @param flag bit0= sector bit value
*/
int Sectorbitmap_set(struct SectorbitmaP *o, int sector, int flag)
int Sectorbitmap_set(struct SectorbitmaP *o, off_t sector, int flag)
{
if(sector < 0 || sector >= o->sectors)
return(0);
@ -450,9 +453,9 @@ int Sectorbitmap_set(struct SectorbitmaP *o, int sector, int flag)
/* @param flag bit0= sector bit value
*/
int Sectorbitmap_set_range(struct SectorbitmaP *o,
int start_sector, int sectors, int flag)
off_t start_sector, off_t sectors, int flag)
{
int start_i, end_i, i;
off_t start_i, end_i, i;
unsigned char value;
if(start_sector < 0 || start_sector + sectors > o->sectors || sectors < 1)
@ -474,7 +477,7 @@ int Sectorbitmap_set_range(struct SectorbitmaP *o,
}
int Sectorbitmap_is_set(struct SectorbitmaP *o, int sector, int flag)
int Sectorbitmap_is_set(struct SectorbitmaP *o, off_t sector, int flag)
{
if(sector < 0 || sector >= o->sectors)
return(0);
@ -485,7 +488,7 @@ int Sectorbitmap_is_set(struct SectorbitmaP *o, int sector, int flag)
int Sectorbitmap_bytes_are_set(struct SectorbitmaP *o,
off_t start_byte, off_t end_byte, int flag)
{
int end_sector, i;
off_t end_sector, i;
end_sector= end_byte / o->sector_size;
for(i= start_byte / o->sector_size; i <= end_sector; i++)
@ -496,7 +499,7 @@ int Sectorbitmap_bytes_are_set(struct SectorbitmaP *o,
int Sectorbitmap_get_layout(struct SectorbitmaP *o,
int *sectors, int *sector_size, int flag)
off_t *sectors, off_t *sector_size, int flag)
{
*sectors= o->sectors;
*sector_size= o->sector_size;
@ -507,8 +510,8 @@ int Sectorbitmap_get_layout(struct SectorbitmaP *o,
int Sectorbitmap_copy(struct SectorbitmaP *from, struct SectorbitmaP *to,
int flag)
{
int i, run_start, run_value, start_sec, limit_sec, start_aligned;
int end_complete;
int run_value, start_aligned, end_complete;
off_t i, run_start, start_sec, limit_sec;
if(((off_t) from->sectors) * ((off_t) from->sector_size) >
((off_t) to->sectors) * ((off_t) to->sector_size))
@ -519,7 +522,7 @@ int Sectorbitmap_copy(struct SectorbitmaP *from, struct SectorbitmaP *to,
return(1);
}
run_start= 0;
run_value= Sectorbitmap_is_set(from, 0, 0);
run_value= Sectorbitmap_is_set(from, (off_t) 0, 0);
for(i= 1; i <= from->sectors; i++) {
if(i < from->sectors)
if(Sectorbitmap_is_set(from, i, 0) == run_value)
@ -942,7 +945,8 @@ int Xorriso_sectormap_to_spotlist(struct XorrisO *xorriso,
int flag)
{
struct SectorbitmaP *map;
int ret, i, sectors, sector_size, value, old_value= -1, old_start= -1;
int ret, value, old_value= -1;
off_t i, sectors, sector_size, old_start= -1;
map= job->sector_map;
if(map == NULL)
@ -962,7 +966,7 @@ int Xorriso_sectormap_to_spotlist(struct XorrisO *xorriso,
if(value == old_value)
continue;
if(old_value >= 0) {
ret= Spotlist_add_item(*spotlist, old_start, i * sector_size - old_start,
ret= Spotlist_add_item(*spotlist, (int) old_start, (int) (i * sector_size - old_start),
(old_value ? Xorriso_read_quality_valiD :
Xorriso_read_quality_invaliD), 0);
if(ret <= 0)
@ -973,8 +977,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, i * sector_size,
(sectors - i - 1) * sector_size,
ret= Spotlist_add_item(*spotlist, (int) (i * sector_size),
(int) ((sectors - i - 1) * sector_size),
Xorriso_read_quality_untesteD, 0);
if(ret <= 0)
goto ex;
@ -986,7 +990,7 @@ int Xorriso_sectormap_to_spotlist(struct XorrisO *xorriso,
old_start= i * sector_size;
}
if(old_value >= 0) {
ret= Spotlist_add_item(*spotlist, old_start, i * sector_size - old_start,
ret= Spotlist_add_item(*spotlist, (int) old_start, (int) (i * sector_size - old_start),
(old_value ? Xorriso_read_quality_valiD :
Xorriso_read_quality_invaliD), 0);
if(ret <= 0)
@ -1010,7 +1014,8 @@ int Xorriso_spotlist_to_sectormap(struct XorrisO *xorriso,
int flag)
{
struct SectorbitmaP *m;
int map_sectors= -1, map_sector_size= -1, valid;
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;
@ -1032,13 +1037,12 @@ int Xorriso_spotlist_to_sectormap(struct XorrisO *xorriso,
m= *map;
else {
if(*map != NULL) {
if(((off_t) (*map)->sectors) * ((off_t) (*map)->sector_size) >
if((*map)->sectors * (*map)->sector_size >
((off_t) list_sectors) * ((off_t) sector_size))
list_sectors= (((off_t) (*map)->sectors) *
((off_t) (*map)->sector_size)) / ((off_t) sector_size)
+ 1;
list_sectors= (*map)->sectors * (*map)->sector_size /
((off_t) sector_size) + 1;
}
ret= Sectorbitmap_new(&m, list_sectors, sector_size, 0);
ret= Sectorbitmap_new(&m, (off_t) list_sectors, (off_t) sector_size, 0);
if(ret <= 0)
return(-1);
replace_map= 1;
@ -1069,6 +1073,8 @@ 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) {
@ -1119,7 +1125,8 @@ 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), sectors, sector_size, 0);
ret= Sectorbitmap_new(&(xorriso->in_sector_map), (off_t) sectors,
(off_t) sector_size, 0);
if(ret <= 0)
return(ret);
if(map != NULL)

View File

@ -1,7 +1,7 @@
/* xorriso - creates, loads, manipulates and burns ISO 9660 filesystem images.
Copyright 2007-2020 Thomas Schmitt, <scdbackup@gmx.net>
Copyright 2007-2024 Thomas Schmitt, <scdbackup@gmx.net>
Provided under GPL version 2 or later.
@ -13,6 +13,9 @@
#ifndef Xorriso_pvt_check_includeD
#define Xorriso_pvt_check_includeD yes
/* For ssize_t */
#include <unistd.h>
struct SpotlisT; /* List of intervals with different read qualities */
struct CheckmediajoB; /* Parameters for Xorriso_check_media() */
@ -53,10 +56,10 @@ int Xorriso_update_in_sector_map(struct XorrisO *xorriso,
/* Distiniction between valid and invalid sectors */
struct SectorbitmaP {
int sectors;
int sector_size;
off_t sectors;
off_t sector_size;
unsigned char *map;
int map_size;
ssize_t map_size;
};
int Spotlist_new(struct SpotlisT **o, int flag);
@ -154,22 +157,22 @@ int Checkmediajob_destroy(struct CheckmediajoB **o, int flag);
int Checkmediajob_copy(struct CheckmediajoB *from, struct CheckmediajoB *to,
int flag);
int Sectorbitmap_new(struct SectorbitmaP **o, int sectors, int sector_size,
int Sectorbitmap_new(struct SectorbitmaP **o, off_t sectors, off_t sector_size,
int flag);
int Sectorbitmap_destroy(struct SectorbitmaP **o, int flag);
int Sectorbitmap_from_file(struct SectorbitmaP **o, char *path, char *msg,
int *os_errno, int flag);
int Sectorbitmap_to_file(struct SectorbitmaP *o, char *path, char *info,
char *msg, int *os_errno, int flag);
int Sectorbitmap_set(struct SectorbitmaP *o, int sector, int flag);
int Sectorbitmap_set(struct SectorbitmaP *o, off_t sector, int flag);
int Sectorbitmap_set_range(struct SectorbitmaP *o,
int start_sector, int sectors, int flag);
int Sectorbitmap_is_set(struct SectorbitmaP *o, int sector, int flag);
off_t start_sector, off_t sectors, int flag);
int Sectorbitmap_is_set(struct SectorbitmaP *o, off_t sector, int flag);
int Sectorbitmap_bytes_are_set(struct SectorbitmaP *o,
off_t start_byte, off_t end_byte, int flag);
int Sectorbitmap_get_layout(struct SectorbitmaP *o,
int *sectors, int *sector_size, int flag);
off_t *sectors, off_t *sector_size, int flag);
int Sectorbitmap_copy(struct SectorbitmaP *from, struct SectorbitmaP *to,
int flag);

View File

@ -1,7 +1,7 @@
/* xorriso - creates, loads, manipulates and burns ISO 9660 filesystem images.
Copyright 2007-2023 Thomas Schmitt, <scdbackup@gmx.net>
Copyright 2007-2024 Thomas Schmitt, <scdbackup@gmx.net>
Provided under GPL version 2 or later.
@ -2231,7 +2231,7 @@ int Xorriso_atip(struct XorrisO *xorriso, int flag)
sprintf(respt, "Producer: %s\n", manuf);
Xorriso_result(xorriso, 1);
}
if(profile_number == 0x09 || profile_number == 0x0a) {
if(manuf != NULL && (profile_number == 0x09 || profile_number == 0x0a)) {
sprintf(respt, "Manufacturer: %s\n", manuf);
Xorriso_result(xorriso, 1);
} else if(product_id != NULL && media_code1 != NULL && media_code2 != NULL){
@ -2850,7 +2850,8 @@ int Xorriso_check_interval(struct XorrisO *xorriso, struct SpotlisT *spotlist,
int from_lba, int block_count, int read_chunk,
int md5_start, int flag)
{
int i, j, ret, total_count= 0, sectors= -1, sector_size= -1, skip_reading;
int i, j, ret, total_count= 0, skip_reading;
off_t sectors= -1, sector_size= -1;
int prev_quality= -1, quality= -1, retry= 0, profile_no, is_cd= 0;
int eccb_size= 16, us_corr = 0, data_skip;
int start_sec, end_sec, first_value, fret, suspect_tao_end= 0;
@ -3038,16 +3039,16 @@ abort_check:;
if(sector_size == read_chunk && from_lba % read_chunk == 0
&& !skip_reading) {
if(Sectorbitmap_is_set(job->sector_map, (i + from_lba) / sector_size, 0)){
if(Sectorbitmap_is_set(job->sector_map, (off_t) ((i + from_lba) / sector_size), 0)){
quality= Xorriso_read_quality_valiD;
skip_reading= 1;
}
} else if(sector_size > 0 && !skip_reading) {
start_sec= (i + from_lba) / sector_size;
end_sec= (i + to_read + from_lba) / sector_size;
first_value= Sectorbitmap_is_set(job->sector_map, start_sec, 0);
first_value= Sectorbitmap_is_set(job->sector_map, (off_t) start_sec, 0);
for(j= start_sec; j < end_sec; j++)
if(Sectorbitmap_is_set(job->sector_map, j, 0) != first_value)
if(Sectorbitmap_is_set(job->sector_map, (off_t) j, 0) != first_value)
break;
to_read= j * sector_size - i - from_lba;
skip_reading= !!first_value;

View File

@ -1,7 +1,7 @@
/* xorriso - creates, loads, manipulates and burns ISO 9660 filesystem images.
Copyright 2007-2022 Thomas Schmitt, <scdbackup@gmx.net>
Copyright 2007-2024 Thomas Schmitt, <scdbackup@gmx.net>
Provided under GPL version 2 or later.
@ -2504,7 +2504,8 @@ int Xorriso_file_eval_damage(struct XorrisO *xorriso, IsoNode *node,
int flag)
{
int *start_lbas= NULL, *end_lbas= NULL, lba_count= 0, sect;
int i, sectors, sector_size, ret;
int ret;
off_t i, sectors, sector_size;
off_t sect_base= 0, size= 0, byte, *section_sizes= NULL;
struct SectorbitmaP *map;

View File

@ -1 +1 @@
#define Xorriso_timestamP "2024.03.10.113018"
#define Xorriso_timestamP "2024.03.17.152556"