Little code changes to improve isoburn_start_emulation().
This commit is contained in:
parent
6d7d67baaa
commit
a904ef7abf
@ -202,7 +202,7 @@ int isoburn_free_rwopts(struct isoburn *o)
|
||||
*/
|
||||
int isoburn_start_emulation(struct isoburn *o, int flag)
|
||||
{
|
||||
int ret;
|
||||
int ret, i;
|
||||
off_t *data_count;
|
||||
struct burn_drive *drive;
|
||||
struct ecma119_pri_vol_desc *pvm;
|
||||
@ -213,11 +213,26 @@ int isoburn_start_emulation(struct isoburn *o, int flag)
|
||||
// TODO what about ms? where we validate valid iso image in ms disc?
|
||||
ret = burn_read_data(drive, (off_t) 0, o->target_iso_head,
|
||||
sizeof(o->target_iso_head), &data_count, 0);
|
||||
// TODO mmm, can a read error mean an empty disc (e.g. CD-R)?
|
||||
if (ret <= 0)
|
||||
return -1;
|
||||
|
||||
/* 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);
|
||||
while (i && !o->target_iso_head[i-1])
|
||||
--i;
|
||||
|
||||
if (!i) {
|
||||
o->fabricated_disc_status= BURN_DISC_BLANK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
pvm = (struct ecma119_pri_vol_desc *)(o->target_iso_head + 16 * 2048);
|
||||
|
||||
if (!strncmp((char*)pvm->std_identifier, "CD001", 5)) {
|
||||
off_t size;
|
||||
|
||||
/* sanity check */
|
||||
if (pvm->vol_desc_type[0] != 1 || pvm->vol_desc_version[0] != 1
|
||||
|| pvm->file_structure_version[0] != 1 ) {
|
||||
@ -226,9 +241,6 @@ int isoburn_start_emulation(struct isoburn *o, int flag)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!strncmp((char*)pvm->std_identifier, "CD001", 5)) {
|
||||
off_t size;
|
||||
|
||||
/* ok, PVM found, set size */
|
||||
size = (off_t) iso_read_lsb(pvm->vol_space_size, 4);
|
||||
size *= (off_t) 2048; /* block size in bytes */
|
||||
@ -240,19 +252,8 @@ int isoburn_start_emulation(struct isoburn *o, int flag)
|
||||
isoburn_set_start_byte(o, (off_t) 0, 0);
|
||||
o->fabricated_disc_status= BURN_DISC_BLANK;
|
||||
} else {
|
||||
int i;
|
||||
|
||||
/* check first 64K. If 0's, the disc is treated as a blank disc, and thus
|
||||
overwritten without extra check. If not, the disc is treated as full,
|
||||
and user needs to isoburn_disc_erase() it before burn it again */
|
||||
i = sizeof(o->target_iso_head);
|
||||
while (i && !o->target_iso_head[i-1])
|
||||
--i;
|
||||
|
||||
if (i)
|
||||
/* treat any disc in an unknown format as full */
|
||||
o->fabricated_disc_status= BURN_DISC_FULL;
|
||||
else
|
||||
o->fabricated_disc_status= BURN_DISC_BLANK;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user