Corrected strange behavior with non-ISO images on overwriteable media

This commit is contained in:
2008-05-13 13:52:33 +00:00
parent ab7591f04b
commit b450b1d249
7 changed files with 38 additions and 18 deletions

View File

@ -485,6 +485,8 @@ void isoburn_disc_erase(struct burn_drive *drive, int fast)
{
int ret;
struct isoburn *o;
enum burn_disc_status s;
char zero_buffer[Libisoburn_target_head_sizE];
ret= isoburn_find_emulator(&o, drive, 0);
if(ret>0) {
@ -494,9 +496,16 @@ void isoburn_disc_erase(struct burn_drive *drive, int fast)
return;
}
if(o->emulation_mode>0) {
ret= isoburn_invalidate_iso(o, 0);
s= isoburn_disc_get_status(drive);
if(s==BURN_DISC_FULL) { /* unknown data format in first 64 kB */
memset(zero_buffer, 0, Libisoburn_target_head_sizE);
ret= burn_random_access_write(drive, (off_t) 0, zero_buffer,
(off_t) Libisoburn_target_head_sizE, 1);
} else {
ret= isoburn_invalidate_iso(o, 0);
}
if(ret<=0)
burn_drive_cancel(drive);
burn_drive_cancel(drive); /* mark run as failure */
return;
}
}
@ -510,12 +519,16 @@ off_t isoburn_disc_available_space(struct burn_drive *d,
int ret;
struct isoburn *o;
struct burn_write_opts *eff_opts= NULL, *local_opts= NULL;
enum burn_disc_status s;
off_t avail;
eff_opts= opts;
ret= isoburn_find_emulator(&o, d, 0);
if(ret>0 && o!=NULL)
if(o->emulation_mode!=0) {
s= isoburn_disc_get_status(d);
if(s==BURN_DISC_FULL) /* unknown data format in first 64 kB */
return((off_t) 0);
local_opts= burn_write_opts_new(d);
eff_opts= local_opts;
burn_write_opts_set_start_byte(eff_opts, ((off_t) o->nwa) * (off_t) 2048);

View File

@ -121,7 +121,7 @@ int isoburn_new(struct isoburn **objpt, int flag)
o->fabricated_disc_status= BURN_DISC_UNREADY;
o->toc= NULL;
o->wrote_well= -1;
for(i=0;i<65536;i++)
for(i=0;i<Libisoburn_target_head_sizE;i++)
o->target_iso_head[i]= 0;
o->image= NULL;
o->read_pacifier= NULL;

View File

@ -33,6 +33,11 @@ int isoburn_toc_entry_new(struct isoburn_toc_entry **objpt,
int isoburn_toc_entry_destroy(struct isoburn_toc_entry **o, int flag);
/* Size of target_iso_head which is to be written during
isoburn_activate_session()
*/
#define Libisoburn_target_head_sizE (32*2048)
struct isoburn {
@ -89,7 +94,7 @@ struct isoburn {
/* Buffered ISO head from media (should that become part of
ecma119_read_opts ?) */
uint8_t target_iso_head[65536];
uint8_t target_iso_head[Libisoburn_target_head_sizE];
/* Libisofs image context */
IsoImage *image;
@ -368,12 +373,7 @@ struct isoburn_imgen_opts {
#define Libisoburn_toc_scan_max_gaP 8192
/* Size of target_iso_head which is to be written during
isoburn_activate_session()
*/
#define Libisoburn_target_head_sizE (32*2048)
/* >>> Experiment to create a chain of image headers which form a TOC:
/* Creating a chain of image headers which form a TOC:
The header of the first session is written after the LBA 0 header.
So it persists and can give the end of its session. By help of

View File

@ -283,7 +283,7 @@ int isoburn_activate_session(struct burn_drive *drive)
o->zero_nwa > 0)))
return 1;
ret = burn_random_access_write(drive, 0, (char*)o->target_iso_head,
ret = burn_random_access_write(drive, (off_t) 0, (char*)o->target_iso_head,
Libisoburn_target_head_sizE, 1);
return ret;
@ -315,7 +315,7 @@ int isoburn_start_emulation(struct isoburn *o, int flag)
/* we can assume 0 as start block for image */
/* TODO what about ms? where we validate valid iso image in ms disc? */
ret = burn_read_data(drive, (off_t) 0, (char*)o->target_iso_head,
sizeof(o->target_iso_head), &data_count, 2);
(off_t) Libisoburn_target_head_sizE, &data_count, 2);
/* an error means an empty disc */
if (ret <= 0) {
@ -325,7 +325,7 @@ int isoburn_start_emulation(struct isoburn *o, int flag)
/* check first 64K. If 0's, the disc is treated as a blank disc, and thus
overwritten without extra check. */
i = sizeof(o->target_iso_head);
i = Libisoburn_target_head_sizE;
while (i && !o->target_iso_head[i-1])
--i;