Made Xorriso_toc() ready for long block adresses

This commit is contained in:
Thomas Schmitt 2024-03-19 19:59:06 +01:00
parent 82deb547c0
commit 662b305d12
2 changed files with 59 additions and 48 deletions

View File

@ -1057,13 +1057,11 @@ int Xorriso_media_product(struct XorrisO *xorriso, int flag)
*/
int Xorriso_toc(struct XorrisO *xorriso, int flag)
{
int num_sessions= 0, num_tracks= 0, lba= 0, nwa= -1, ret;
int track_count= 0, session_no, track_no, profile_no= -1, track_size;
int session_size, first_track_start= 0;
int num_session_data, num_session_other;
int num_data= 0, other_data= 0, is_data= 0;
int is_inout_drive= 0, drive_role, status, num_formats, emul_lba;
int not_recognizable= 0, start_lba, end_lba;
int num_sessions= 0, num_tracks= 0, ret;
int track_count= 0, session_no, track_no, profile_no= -1;
int is_data= 0;
int is_inout_drive= 0, drive_role, status, num_formats;
int not_recognizable= 0;
int sessions_seen, open_sessions= 0, have_real_open_session= 0;
char profile_name[80],*respt,*devadr, *typetext= "";
struct burn_toc_entry toc_entry;
@ -1077,14 +1075,16 @@ int Xorriso_toc(struct XorrisO *xorriso, int flag)
struct isoburn_toc_disc *disc= NULL;
struct isoburn_toc_session **sessions;
struct isoburn_toc_track **tracks;
int image_blocks= 0;
char volume_id[33];
struct burn_toc_entry next_toc_entry;
int disk_category, part_version, num_layers, num_blocks;
char *book_name;
int num_data_from_format= 0;
char *sno = NULL;
int sno_len, i, is_bdr_pow= 0, overburn_blocks= 0;
int sno_len, i, is_bdr_pow= 0, int_start_lba= -1, int_end_lba= -1;
off_t lba= 0, nwa= -1, track_size, session_size, first_track_start= 0;
off_t num_session_data, num_session_other, num_data, other_data= 0;
off_t emul_lba, end_lba, image_blocks, overburn_blocks= 0;
ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
"on attempt to print Table Of Content",
@ -1233,17 +1233,17 @@ int Xorriso_toc(struct XorrisO *xorriso, int flag)
sno= NULL;
respt= xorriso->result_line;
ret= burn_get_read_capacity(drive, &num_data, 0);
ret= burn_get_read_capacity_v2(drive, &num_data, 0);
if(ret != 1 || s == BURN_DISC_BLANK)
num_data= 0;
num_free= isoburn_disc_available_space(drive, NULL) / 2048;
nwa= -1;
if (s == BURN_DISC_APPENDABLE) {
ret= isoburn_disc_track_lba_nwa(drive, NULL, 0, &lba, &nwa);
ret= isoburn_disc_track_lba_nwa_v2(drive, NULL, 0, &lba, &nwa);
if(ret <= 0)
nwa= -1;
} else if(s == BURN_DISC_BLANK) {
ret= isoburn_disc_track_lba_nwa(drive, NULL, 0, &lba, &nwa);
ret= isoburn_disc_track_lba_nwa_v2(drive, NULL, 0, &lba, &nwa);
if(ret == 1) {
num_free+= nwa;
nwa= 0;
@ -1261,7 +1261,8 @@ int Xorriso_toc(struct XorrisO *xorriso, int flag)
ret= burn_disc_read_atip(drive);
if(ret < 0)
goto ex;
ret= burn_drive_get_start_end_lba(drive, &start_lba, &end_lba, 0);
ret= burn_drive_get_start_end_lba(drive, &int_start_lba, &int_end_lba, 0);
end_lba= int_end_lba;
if(s == BURN_DISC_FULL && ret == 1) {
if(lba > end_lba - 2) {
overburn_blocks= lba - end_lba + 2;
@ -1271,7 +1272,7 @@ int Xorriso_toc(struct XorrisO *xorriso, int flag)
} else {
if(ret == 1 && end_lba - 2 > lba) {
sprintf(xorriso->info_text,
"ATIP end_lba %d > overall %d", end_lba, lba);
"ATIP end_lba %.f > overall %.f", (double) end_lba, (double) lba);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
}
}
@ -1291,11 +1292,12 @@ int Xorriso_toc(struct XorrisO *xorriso, int flag)
num_free_text = "unused";
else
num_free_text = "writable";
sprintf(respt, "Media blocks : %d %s , %d %s , %d overall\n",
num_data, num_data_text, (int) num_free, num_free_text, lba);
sprintf(respt, "Media blocks : %.f %s , %.f %s , %.f overall\n",
(double) num_data, num_data_text,
(double) num_free, num_free_text, (double) lba);
Xorriso_toc_line(xorriso, flag & 8);
if(overburn_blocks > 0) {
sprintf(respt, "Overburnt by : %d blocks\n", overburn_blocks);
sprintf(respt, "Overburnt by : %.f blocks\n", (double) overburn_blocks);
Xorriso_toc_line(xorriso, flag & 8);
}
}
@ -1349,7 +1351,7 @@ int Xorriso_toc(struct XorrisO *xorriso, int flag)
Xorriso_process_msg_queues(xorriso,0);
nwa= 0;
if(drive_role == 5 && s == BURN_DISC_APPENDABLE) {
ret= burn_disc_track_lba_nwa(drive, NULL, 0, &lba, &nwa);
ret= burn_disc_track_lba_nwa_v2(drive, NULL, 0, &lba, &nwa);
if(ret != 1)
nwa= 0;
} else {
@ -1371,10 +1373,10 @@ int Xorriso_toc(struct XorrisO *xorriso, int flag)
ret= 0;
typetext= "Session ";
} else
ret= isoburn_read_iso_head(drive, 0, &image_blocks, volume_id, 1);
ret= isoburn_read_iso_head_v2(drive, 0, &image_blocks, volume_id, 1);
if(ret>0) {
sprintf(respt, "ISO session : %3d , %9d , %9ds , %s\n",
1, 0, image_blocks, volume_id);
sprintf(respt, "ISO session : %3d , %9d , %9.fs , %s\n",
1, 0, (double) image_blocks, volume_id);
nwa= image_blocks;
} else {
ret= burn_disc_get_formats(drive, &status, &size, &dummy,
@ -1382,17 +1384,17 @@ int Xorriso_toc(struct XorrisO *xorriso, int flag)
if(ret <= 0 || status != BURN_FORMAT_IS_FORMATTED)
size= 0;
if(size <= 0) {
ret= burn_get_read_capacity(drive, &num_data, 0);
ret= burn_get_read_capacity_v2(drive, &num_data, 0);
if(ret == 1)
size= ((off_t) num_data) * (off_t) 2048;
size= num_data * (off_t) 2048;
} else {
num_data_from_format= 1;
}
num_data= size / 2048;
if(num_data == 0 && drive_role == 5 && s == BURN_DISC_APPENDABLE)
num_data= nwa;
sprintf(respt, "%13s: %3d , %9d , %9ds , \n",
typetext, 1, 0, num_data);
sprintf(respt, "%13s: %3d , %9d , %9.fs , \n",
typetext, 1, 0, (double) num_data);
}
if(!(flag&1))
Xorriso_toc_line(xorriso, flag & 8);
@ -1418,7 +1420,10 @@ int Xorriso_toc(struct XorrisO *xorriso, int flag)
isoburn_toc_track_get_entry(tracks[track_no], &toc_entry);
if((toc_entry.control & 7) >= 4) /* data track */
is_data= 1;
if (toc_entry.extensions_valid & 1) {
if(toc_entry.extensions_valid & 8) {
lba= toc_entry.long_start_lba;
track_size= toc_entry.long_track_blocks;
} else if(toc_entry.extensions_valid & 1) {
/* DVD extension valid */
lba= toc_entry.start_lba;
track_size= toc_entry.track_blocks;
@ -1437,14 +1442,15 @@ int Xorriso_toc(struct XorrisO *xorriso, int flag)
if((flag & (1 | 4)) || !is_data) {
ret= 0;
} else {
ret= isoburn_toc_track_get_emul(tracks[track_no], &emul_lba,
&image_blocks, volume_id, 0);
ret= isoburn_toc_track_get_emul_v2(tracks[track_no], &emul_lba,
&image_blocks, volume_id, 0);
if(ret <= 0)
ret= isoburn_read_iso_head(drive, lba, &image_blocks, volume_id, 1);
ret= isoburn_read_iso_head_v2(drive, lba, &image_blocks, volume_id,
1);
if(image_blocks > track_size) {
sprintf(xorriso->info_text,
"Session %d bears ISO image size %ds larger than track size %ds",
session_no + 1, image_blocks, track_size);
"Session %d bears ISO image size %.fs larger than track size %.fs",
session_no + 1, (double) image_blocks, (double) track_size);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING",
0);
image_blocks= track_size;
@ -1453,26 +1459,28 @@ int Xorriso_toc(struct XorrisO *xorriso, int flag)
if(session_no >= num_sessions && track_no == 0) {
if(ret <= 0)
volume_id[0]= 0;
sprintf(respt, "Incmp session: %3d , %9d , %9ds , %s\n",
session_no+1, lba, image_blocks, volume_id);
sprintf(respt, "Incmp session: %3d , %9.f , %9.fs , %s\n",
session_no + 1, (double) lba, (double) image_blocks,
volume_id);
} else if(ret>0 && track_no==0) {
sprintf(respt, "ISO session : %3d , %9d , %9ds , %s\n",
session_no+1, lba, image_blocks , volume_id);
sprintf(respt, "ISO session : %3d , %9.f , %9.fs , %s\n",
session_no + 1, (double) lba, (double) image_blocks ,
volume_id);
} else if(ret>0) {
sprintf(respt, "ISO track : %3d , %9d , %9ds , %s\n",
track_count, lba, image_blocks , volume_id);
sprintf(respt, "ISO track : %3d , %9.f , %9.fs , %s\n",
track_count, (double) lba, (double) image_blocks , volume_id);
} else if(track_no==0) {
typetext= "Other session";
if(flag & 4)
typetext= "Session ";
sprintf(respt, "%13s: %3d , %9d , %9ds , \n",
typetext, session_no+1, lba, track_size);
sprintf(respt, "%13s: %3d , %9.f , %9.fs , \n",
typetext, session_no+1, (double) lba, (double) track_size);
} else {
typetext= "Other track ";
if(flag & 4)
typetext= "Track ";
sprintf(respt, "%13s: %3d , %9d , %9ds , \n",
typetext, track_count, lba, track_size);
sprintf(respt, "%13s: %3d , %9.f , %9.fs , \n",
typetext, track_count, (double) lba, (double) track_size);
}
if(!(flag&1))
Xorriso_toc_line(xorriso, flag & 8);
@ -1484,7 +1492,9 @@ int Xorriso_toc(struct XorrisO *xorriso, int flag)
first_track_start= lba;
}
isoburn_toc_session_get_leadout_entry(sessions[session_no], &toc_entry);
if (toc_entry.extensions_valid & 1) {
if (toc_entry.extensions_valid & 8) {
lba= toc_entry.long_start_lba;
} else if(toc_entry.extensions_valid & 1) {
lba= toc_entry.start_lba;
} else {
lba= burn_msf_to_lba(toc_entry.pmin, toc_entry.psec, toc_entry.pframe);
@ -1507,8 +1517,9 @@ int Xorriso_toc(struct XorrisO *xorriso, int flag)
sessions_seen= num_sessions + open_sessions;
if(open_sessions > 0 && !have_real_open_session)
sessions_seen--;
sprintf(respt, "Media summary: %d session%s, %d data blocks, %s data",
sessions_seen, (sessions_seen == 1 ? "" : "s"), num_data, mem_text);
sprintf(respt, "Media summary: %d session%s, %.f data blocks, %s data",
sessions_seen, (sessions_seen == 1 ? "" : "s"), (double) num_data,
mem_text);
if(num_data_from_format)
num_free= 0;
else
@ -1520,14 +1531,14 @@ int Xorriso_toc(struct XorrisO *xorriso, int flag)
Xorriso_toc_line(xorriso, flag & 8);
if(other_data > 0) {
sprintf(respt, "Non-data blks: %d\n", other_data);
sprintf(respt, "Non-data blks: %.f\n", (double) other_data);
Xorriso_toc_line(xorriso, flag & 8);
}
if (s==BURN_DISC_APPENDABLE && nwa!=0) {
ret= isoburn_disc_track_lba_nwa(drive, NULL, 0, &lba, &nwa);
ret= isoburn_disc_track_lba_nwa_v2(drive, NULL, 0, &lba, &nwa);
if(ret>0) {
sprintf(respt, "Media nwa : %ds\n", nwa);
sprintf(respt, "Media nwa : %.fs\n", (double) nwa);
if(!(flag&1))
Xorriso_toc_line(xorriso, flag & 8);
}

View File

@ -1 +1 @@
#define Xorriso_timestamP "2024.03.19.112303"
#define Xorriso_timestamP "2024.03.19.185848"