Eventually truncate stdio: track size to file size and issue warning

This commit is contained in:
Thomas Schmitt 2009-09-13 09:50:36 +00:00
parent 6068c14634
commit 81d0d30cb8
3 changed files with 19 additions and 3 deletions

View File

@ -1118,7 +1118,7 @@ int isoburn_emulate_toc(struct burn_drive *d, int flag)
{
int ret, image_size= 0, lba, track_blocks, session_count= 0, read_flag= 0;
int scan_start= 0, scan_count= 0, probe_minus_16= 0, growisofs_nwa;
int with_enclosure= 0;
int with_enclosure= 0, readable_blocks= -1;
struct isoburn *o;
char msg[160], size_text[80], *sev, volid[33], *volid_pt= NULL;
time_t start_time, last_pacifier, now;
@ -1132,6 +1132,10 @@ int isoburn_emulate_toc(struct burn_drive *d, int flag)
if(o->emulation_mode<=0 && !(flag&1))
return(0);
ret= burn_get_read_capacity(d, &readable_blocks, 0);
if(ret <= 0)
readable_blocks= -1;
start_time= last_pacifier= time(NULL);
lba= 0;
if(!(flag&2)) {
@ -1209,6 +1213,12 @@ int isoburn_emulate_toc(struct burn_drive *d, int flag)
if(ret==2) /* ISO header was found in first half block */
lba-= 16;
if(readable_blocks >= 0 && lba + track_blocks > readable_blocks) {
sprintf(msg, "ISO image size %ds larger than readable size %ds",
lba + track_blocks, readable_blocks);
isoburn_msgs_submit(o, 0x00060000, msg, 0, "WARNING", 0);
track_blocks= readable_blocks - lba;
}
ret= isoburn_make_toc_entry(o, &session_count, lba, track_blocks, volid_pt,
0);
if(ret<=0)
@ -1242,6 +1252,12 @@ int isoburn_emulate_toc(struct burn_drive *d, int flag)
failure:;
isoburn_toc_entry_destroy(&(o->toc), 1);
if(with_enclosure && o->emulation_mode == 1) {
if(readable_blocks >= 0 && image_size > readable_blocks) {
sprintf(msg, "ISO image size %ds larger than readable size %ds",
image_size, readable_blocks);
isoburn_msgs_submit(o, 0x00060000, msg, 0, "WARNING", 0);
image_size= readable_blocks;
}
session_count= 0;
ret= isoburn_make_toc_entry(o, &session_count, 0, image_size, NULL, 0);
}

View File

@ -1 +1 @@
#define Xorriso_timestamP "2009.09.07.161247"
#define Xorriso_timestamP "2009.09.13.095136"

View File

@ -5234,7 +5234,7 @@ 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;
int image_blocks= 0;
char volume_id[33];
struct burn_toc_entry next_toc_entry;