Made Xorriso_update_iso_lba0() ready for long block adresses

This commit is contained in:
Thomas Schmitt 2024-03-22 22:32:58 +01:00
parent 9377f667b5
commit 8c61d88404
4 changed files with 41 additions and 32 deletions

View File

@ -1994,7 +1994,7 @@ int Xorriso_option_check_media(struct XorrisO *xorriso,
if(ret <= 0)
goto ex;
if(ret == 1) {
ret= Xorriso_update_iso_lba0(xorriso, (int) job->patch_lba0_msc1, 0,
ret= Xorriso_update_iso_lba0(xorriso, job->patch_lba0_msc1, (off_t) 0,
head_buffer, job,
(8 * (job->patch_lba0 == 1)) |
4 | (job->patch_lba0_msc1 < 0));

View File

@ -2542,7 +2542,7 @@ int Xorriso_burn_track(struct XorrisO *xorriso, off_t write_start_address,
}
if(flag & 1) {
ret= Xorriso_update_iso_lba0(xorriso, (int) nwa, (int) isosize, head_buffer, NULL,
ret= Xorriso_update_iso_lba0(xorriso, nwa, isosize, head_buffer, NULL,
flag & 2);
if(ret <= 0)
goto ex;
@ -3171,11 +3171,13 @@ md5_comp_failed:;
bit5= bit1 for Xorriso_find_sb_checksum:
accept tag with ISO_MD5_AREA_CORRUPTED
*/
int Xorriso_update_iso_lba0(struct XorrisO *xorriso, int iso_lba, int isosize,
int Xorriso_update_iso_lba0(struct XorrisO *xorriso,
off_t iso_lba, off_t isosize,
char *head_buffer, struct CheckmediajoB *job,
int flag)
{
int ret, full_size, i, checksum_block= -1, vd_end;
int ret, i, checksum_block= -1, vd_end;
uint32_t full_size;
char *headpt;
struct burn_drive_info *dinfo;
struct burn_drive *drive = NULL;
@ -3189,7 +3191,7 @@ int Xorriso_update_iso_lba0(struct XorrisO *xorriso, int iso_lba, int isosize,
"on attempt to learn current session lba", 0);
if(ret<=0)
return(0);
ret= isoburn_disc_get_msc1(drive, &iso_lba);
ret= isoburn_disc_get_msc1_v2(drive, &iso_lba);
if(ret<=0)
return(0);
drive= NULL; /* indev will not be used furtherly */
@ -3211,19 +3213,18 @@ int Xorriso_update_iso_lba0(struct XorrisO *xorriso, int iso_lba, int isosize,
if(job != NULL && job->data_to_fd >= 0) {
if((flag & 8) && job->sector_map != NULL) {
ret= Sectorbitmap_bytes_are_set(job->sector_map,
((off_t) iso_lba) * (off_t) 2048,
((off_t) (iso_lba + 32)) * ((off_t) 2048) - (off_t) 1, 0);
iso_lba * (off_t) 2048,
(iso_lba + 32) * ((off_t) 2048) - (off_t) 1, 0);
if(ret <= 0) {
sprintf(xorriso->info_text,
"ISO image head at lba %d is marked as invalid blocks in file copy",
iso_lba);
"ISO image head at lba %.f is marked as invalid blocks in file copy",
(double) iso_lba);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE",
0);
return(0);
}
}
seek_ret= lseek(job->data_to_fd, ((off_t) 2048) * (off_t) iso_lba,
SEEK_SET);
seek_ret= lseek(job->data_to_fd, ((off_t) 2048) * iso_lba, SEEK_SET);
if(seek_ret == -1)
ret= 0;
else
@ -3235,7 +3236,8 @@ int Xorriso_update_iso_lba0(struct XorrisO *xorriso, int iso_lba, int isosize,
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE",0);
return(0);
}
ret= isoburn_read_iso_head(NULL, 0, &isosize, head_buffer, 1 << 13);
ret= isoburn_read_iso_head_v2(NULL, (off_t) 0, &isosize,
head_buffer, 1 << 13);
if(ret<=0) {
Xorriso_process_msg_queues(xorriso,0);
sprintf(xorriso->info_text,
@ -3246,7 +3248,7 @@ int Xorriso_update_iso_lba0(struct XorrisO *xorriso, int iso_lba, int isosize,
} else {
ret= 0;
if(drive != NULL)
ret= isoburn_read_iso_head(drive, iso_lba, &isosize, head_buffer, 2);
ret= isoburn_read_iso_head_v2(drive, iso_lba, &isosize, head_buffer, 2);
if(ret<=0) {
Xorriso_process_msg_queues(xorriso,0);
sprintf(xorriso->info_text,
@ -3258,6 +3260,12 @@ int Xorriso_update_iso_lba0(struct XorrisO *xorriso, int iso_lba, int isosize,
}
/* patch ISO header */
if(iso_lba + isosize > (off_t) 0xffffffff) {
sprintf(xorriso->info_text,
"The total ISO filesystem size would exceed 8 TiB");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
}
full_size= iso_lba + isosize;
headpt= head_buffer + 32*1024;
for(i=0;i<4;i++)
@ -3312,7 +3320,7 @@ int Xorriso_update_iso_lba0(struct XorrisO *xorriso, int iso_lba, int isosize,
}
if(flag & 4) {
sprintf(xorriso->info_text,
"Overwrote LBA 0 to 31 by 64 KiB from LBA %d", iso_lba);
"Overwrote LBA 0 to 31 by 64 KiB from LBA %.f", (double) iso_lba);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
}
return(1);
@ -3636,9 +3644,9 @@ ex:
int Xorriso_truncate_overwritable(struct XorrisO *xorriso, char *adr_mode,
char *adr_value, char *adjust, int flag)
{
int ret, iso_lba= 0, iso_session, iso_track, iso_size= 0, image_start_mode= 0;
int old_size, new_size, blocks, was_indev= 0, checksum_block= 0, vd_end;
int readable_blocks, headless_mode= 0, i;
int ret, iso_session, iso_track, image_start_mode= 0;
int was_indev= 0, checksum_block= 0, vd_end, headless_mode= 0, i;
off_t iso_lba= 0, iso_size= 0, old_size, new_size, blocks, readable_blocks;
char image_start_value[81], *head_buffer= NULL, iso_volid[33];
char *sb_buffer= NULL, *checksum_pt;
struct burn_drive_info *dinfo;
@ -3680,14 +3688,14 @@ int Xorriso_truncate_overwritable(struct XorrisO *xorriso, char *adr_mode,
{ret= 2; goto ex;}
/* Learn old size */
ret= isoburn_read_iso_head(drive, 0, &old_size, iso_volid, 0);
ret= isoburn_read_iso_head_v2(drive, 0, &old_size, iso_volid, 0);
if(ret <= 0) {
sprintf(xorriso->info_text,
"-truncate_overwritable: Cannot read ISO 9660 Volume Descriptor from LBA 0");
if((strcmp(adr_mode, "lba") == 0 || strcmp(adr_mode, "sbsector") == 0)
&& strcmp(adjust, "new") == 0) {
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
ret= burn_get_read_capacity(drive, &old_size, 0);
ret= burn_get_read_capacity_v2(drive, &old_size, 0);
if(ret <= 0)
goto ex;
headless_mode= 1;
@ -3699,8 +3707,8 @@ int Xorriso_truncate_overwritable(struct XorrisO *xorriso, char *adr_mode,
if(headless_mode) {
iso_lba= Scanf_io_size(adr_value, 0);
ret= isoburn_read_iso_head(drive, iso_lba, &new_size, head_buffer,
2 | (1 << 12));
ret= isoburn_read_iso_head_v2(drive, iso_lba, &new_size, head_buffer,
2 | (1 << 12));
if(ret <= 0)
goto not_iso_9660;
} else {
@ -3710,9 +3718,9 @@ int Xorriso_truncate_overwritable(struct XorrisO *xorriso, char *adr_mode,
image_start_value, 0);
if(ret <= 0)
goto ex;
ret= isoburn_get_mount_params(drive, image_start_mode, image_start_value,
&iso_lba, &iso_track, &iso_session, iso_volid,
0);
ret= isoburn_get_mount_params_v2(drive, image_start_mode, image_start_value,
&iso_lba, &iso_track, &iso_session,
iso_volid, 0);
if(ret <= 0)
goto ex;
if(ret != 1) {
@ -3728,7 +3736,7 @@ not_iso_9660:;
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
ret= 0; goto ex;
}
ret= isoburn_read_iso_head(drive, iso_lba, &new_size, head_buffer, 2);
ret= isoburn_read_iso_head_v2(drive, iso_lba, &new_size, head_buffer, 2);
if(ret <= 0)
goto ex;
}
@ -3761,7 +3769,7 @@ wrong_adjust:;
iso_size= blocks - iso_lba;
}
ret= burn_get_read_capacity(drive, &readable_blocks, 0);
ret= burn_get_read_capacity_v2(drive, &readable_blocks, 0);
Xorriso_process_msg_queues(xorriso, 0);
if(ret > 0) {
if(iso_lba + iso_size > readable_blocks) {
@ -3784,8 +3792,8 @@ wrong_adjust:;
if(iso_size != new_size) {
ret=Xorriso_adjust_session_size(xorriso, drive, head_buffer,
iso_lba, iso_size, checksum_block,
new_size, 0);
(int) iso_lba, (int) iso_size,
checksum_block, (int) new_size, 0);
if(ret <= 0)
goto ex;
}
@ -3805,8 +3813,8 @@ wrong_adjust:;
"libisofs_rlsb32_checksum_tag_v1 pos=%d range_start=0 range_size=%d",
i, i);
sprintf(checksum_pt + strlen(checksum_pt),
" session_start=%d md5=0123456789abcdef0123456789abcdef self=0123456789abcdef0123456789abcdef\n",
iso_lba);
" session_start=%.f md5=0123456789abcdef0123456789abcdef self=0123456789abcdef0123456789abcdef\n",
(double) iso_lba);
}
} else {
ret= Xorriso_adjust_relocated_sb(xorriso, drive, head_buffer, &sb_buffer,

View File

@ -1 +1 @@
#define Xorriso_timestamP "2024.03.22.165841"
#define Xorriso_timestamP "2024.03.22.204740"

View File

@ -337,7 +337,8 @@ int Xorriso_msinfo(struct XorrisO *xorriso, off_t *msc1, off_t *msc2,
bit2= issue message about success
bit3= check whether source blocks are banned by in_sector_map
*/
int Xorriso_update_iso_lba0(struct XorrisO *xorriso, int iso_lba, int isosize,
int Xorriso_update_iso_lba0(struct XorrisO *xorriso,
off_t iso_lba, off_t isosize,
char *head_buffer, struct CheckmediajoB *job,
int flag);