Prepared libisoburn for drive role 5

This commit is contained in:
Thomas Schmitt 2011-03-21 09:31:51 +00:00
parent ced69fa340
commit 37789c3f71
3 changed files with 59 additions and 15 deletions

View File

@ -345,6 +345,7 @@ static int isoburn_welcome_media(struct isoburn **o, struct burn_drive *d,
int flag)
{
int ret, lba, nwa, profile, readonly= 0, role, random_access;
int emulation_started= 0;
struct burn_multi_caps *caps= NULL;
struct isoburn_toc_entry *t;
char profile_name[80];
@ -394,7 +395,7 @@ static int isoburn_welcome_media(struct isoburn **o, struct burn_drive *d,
(*o)->nwa= 0;
(*o)->zero_nwa= 0;
}
if(flag&1) {
if((flag & 1) && role != 4 && role != 5) {
(*o)->nwa= (*o)->zero_nwa;
(*o)->fabricated_disc_status= BURN_DISC_BLANK;
} else {
@ -403,6 +404,7 @@ static int isoburn_welcome_media(struct isoburn **o, struct burn_drive *d,
(*o)->emulation_mode= -1;
goto ex;
}
emulation_started= 1;
/* try to read emulated toc */
ret= isoburn_emulate_toc(d, flag & 16);
if(ret<0) {
@ -443,6 +445,12 @@ static int isoburn_welcome_media(struct isoburn **o, struct burn_drive *d,
if((flag & 16) || track_count >= 2) {
ret= 0; /* toc emulation off, or not overwriteable */
} else {
ret= isoburn_start_emulation(*o, 1);
if(ret<=0) {
(*o)->emulation_mode= -1;
goto ex;
}
emulation_started= 1;
ret= isoburn_emulate_toc(d, 1);
if(ret<0)
goto ex;
@ -455,6 +463,13 @@ static int isoburn_welcome_media(struct isoburn **o, struct burn_drive *d,
CD-R TOC (profile 0x08) can be trusted. Others not.
Do a scan search of ISO headers.
*/
if(!emulation_started) {
ret= isoburn_start_emulation(*o, 1);
if(ret<=0) {
(*o)->emulation_mode= -1;
goto ex;
}
}
ret= isoburn_emulate_toc(d, 1|2);
if(ret<0)
goto ex;
@ -638,12 +653,22 @@ int isoburn_disc_erasable(struct burn_drive *d)
void isoburn_disc_erase(struct burn_drive *drive, int fast)
{
int ret, do_pseudo_blank= 0;
int ret, do_pseudo_blank= 0, role;
struct isoburn *o;
enum burn_disc_status s;
char zero_buffer[Libisoburn_target_head_sizE];
struct burn_multi_caps *caps= NULL;
role = burn_drive_get_drive_role(drive);
if (role == 5) {
/* libburn will truncate the random-access write-only file
to zero size and change its state */
burn_disc_erase(drive, fast);
o->fabricated_disc_status= burn_disc_get_status(drive);
o->nwa= 0;
return;
}
ret= isoburn_find_emulator(&o, drive, 0);
if(ret>0) {
if(o->emulation_mode==-1) {
@ -831,7 +856,6 @@ void isoburn_disc_write(struct burn_write_opts *opts, struct burn_disc *disc)
return;
}
/* end of DVD-RW oriented check */
burn_write_opts_set_start_byte(opts, nwa * (off_t) 2048);
}
}
@ -863,7 +887,7 @@ void isoburn_disc_write(struct burn_write_opts *opts, struct burn_disc *disc)
if(o->truncate) {
ret= burn_drive_get_drive_role(drive);
if(ret==2) {
if(ret == 2 || ret == 5) {
ret= burn_drive_d_get_adr(drive, adr);
if(ret>0) {
ret= lstat(adr, &stbuf);
@ -1145,13 +1169,21 @@ int isoburn_read_iso_head(struct burn_drive *d, int lba,
unsigned char buffer[64*1024];
int ret, info_mode, capacity, role;
off_t data_count, to_read;
enum burn_disc_status s;
info_mode= flag&255;
*image_blocks= 0;
if(flag&(1<<13)) {
memcpy(buffer, info, 64*1024);
} else {
memset(buffer, 0, 64 * 1024);
s= isoburn_disc_get_status(d);
role = burn_drive_get_drive_role(d);
if (role == 3 || role == 5)
/* >>> ??? return always 0 ? */
return(-1*!!(flag&(1<<15)));
ret = burn_get_read_capacity(d, &capacity, 0);
if (ret <= 0 && (role == 2 || role == 4)) {
/* Might be a block device on a system where libburn cannot determine its
@ -1159,7 +1191,6 @@ int isoburn_read_iso_head(struct burn_drive *d, int lba,
capacity = 0x7ffffff0;
ret = 1;
}
memset(buffer, 0, 64 * 1024);
to_read= (off_t) capacity * ((off_t) 2048);
if(ret > 0 && to_read >= (off_t) (36 * 1024)) {
if(to_read >= (off_t) (64 * 1024))
@ -1245,7 +1276,6 @@ int isoburn_emulate_toc(struct burn_drive *d, int flag)
ret= burn_get_read_capacity(d, &readable_blocks, 0);
if(ret <= 0) {
role = burn_drive_get_drive_role(d);
if (role == 2 || role == 4)
/* Might be a block device on a system where libburn cannot determine its

View File

@ -439,14 +439,16 @@ static int isoburn_inspect_partition(struct isoburn *o, uint32_t img_size,
The need for emulation is confirmed already.
@param o A freshly created isoburn object. isoburn_create_data_source() was
already called, nevertheless.
@param flag bit0= read-only
@return <=0 error , 1 = success
*/
int isoburn_start_emulation(struct isoburn *o, int flag)
{
int ret, i, capacity = -1, role;
int ret, i, capacity = -1, role, dummy;
off_t data_count, to_read;
struct burn_drive *drive;
struct ecma119_pri_vol_desc *pvm;
enum burn_disc_status s;
if(o==NULL) {
isoburn_msgs_submit(NULL, 0x00060000,
@ -457,6 +459,9 @@ int isoburn_start_emulation(struct isoburn *o, int flag)
drive= o->drive;
if(flag & 1)
o->fabricated_disc_status= BURN_DISC_FULL;
/* We can assume 0 as start block for image.
The data there point to the most recent session.
*/
@ -464,7 +469,12 @@ int isoburn_start_emulation(struct isoburn *o, int flag)
ret = burn_get_read_capacity(drive, &capacity, 0);
if (ret <= 0)
capacity = -1;
if (capacity > 0 || role == 2 || role == 4) {
if (role == 5) { /* random access write-only media */
s = burn_disc_get_status(drive);
o->fabricated_disc_status= s;
burn_disc_track_lba_nwa(drive, NULL, 0, &dummy, &(o->nwa));
return 1;
} else if (capacity > 0 || role == 2 || role == 4) {
/* Might be a block device on a system where libburn cannot determine its
size. Try to read anyway. */
to_read = o->target_iso_head_size;
@ -477,13 +487,14 @@ int isoburn_start_emulation(struct isoburn *o, int flag)
/* an error means a disc with no ISO image */
if (capacity > 0)
o->fabricated_disc_status= BURN_DISC_FULL;
else
o->fabricated_disc_status= BURN_DISC_BLANK;
else if(!(flag & 1))
o->fabricated_disc_status= BURN_DISC_BLANK;
return 1;
}
} else {
/* No read capacity means blank media */
o->fabricated_disc_status= BURN_DISC_BLANK;
if(!(flag & 1))
o->fabricated_disc_status= BURN_DISC_BLANK;
return 1;
}
@ -494,7 +505,8 @@ int isoburn_start_emulation(struct isoburn *o, int flag)
--i;
if (!i) {
o->fabricated_disc_status= BURN_DISC_BLANK;
if(!(flag & 1))
o->fabricated_disc_status= BURN_DISC_BLANK;
return 1;
}
@ -518,12 +530,14 @@ int isoburn_start_emulation(struct isoburn *o, int flag)
return ret;
size *= (off_t) 2048; /* block size in bytes */
isoburn_set_start_byte(o, size, 0);
o->fabricated_disc_status= BURN_DISC_APPENDABLE;
if(!(flag & 1))
o->fabricated_disc_status= BURN_DISC_APPENDABLE;
} else if (!strncmp((char*)pvm->std_identifier, "CDXX1", 5)) {
/* empty image */
isoburn_set_start_byte(o, o->zero_nwa * 2048, 0);
o->fabricated_disc_status= BURN_DISC_BLANK;
if(!(flag & 1))
o->fabricated_disc_status= BURN_DISC_BLANK;
} else {
/* treat any disc in an unknown format as full */
o->fabricated_disc_status= BURN_DISC_FULL;

View File

@ -1 +1 @@
#define Xorriso_timestamP "2011.03.13.131557"
#define Xorriso_timestamP "2011.03.21.093208"