Enabled multi-session with partition offset

This commit is contained in:
2010-09-10 17:10:03 +00:00
parent 5af8ad46f4
commit d54efd4bc2
6 changed files with 215 additions and 64 deletions

View File

@ -115,7 +115,7 @@ struct isoburn *isoburn_list_start= NULL;
int isoburn_new(struct isoburn **objpt, int flag)
{
struct isoburn *o;
int i, ret;
int ret;
*objpt= o= (struct isoburn *) malloc(sizeof(struct isoburn));
if(o==NULL) {
@ -137,8 +137,9 @@ 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<Libisoburn_target_head_sizE;i++)
o->target_iso_head[i]= 0;
o->loaded_partition_offset= 0;
o->target_iso_head_size= Libisoburn_target_head_sizE;
o->target_iso_head= NULL;
o->image= NULL;
o->iso_data_source= NULL;
o->read_pacifier= NULL;
@ -148,9 +149,15 @@ int isoburn_new(struct isoburn **objpt, int flag)
o->msgs_submit_flag= 0;
o->prev= NULL;
o->next= NULL;
o->target_iso_head= calloc(1, o->target_iso_head_size);
if(o->target_iso_head == NULL) {
isoburn_report_iso_error(ISO_OUT_OF_MEM, "Cannot allocate overwrite buffer",
0, "FATAL", 0);
goto failed;
}
ret= iso_image_new("ISOIMAGE", &o->image);
if(ret<0) {
isoburn_report_iso_error(ret, "Cannot create image", 0, "FATAL", 0);
isoburn_report_iso_error(ret, "Cannot create image object", 0, "FATAL", 0);
goto failed;
}
isoburn_link(o, isoburn_list_start, 1);
@ -188,6 +195,8 @@ int isoburn_destroy(struct isoburn **objpt, int flag)
burn_source_free(o->iso_source);
if(o->iso_data_source!=NULL)
iso_data_source_unref(o->iso_data_source);
if(o->target_iso_head != NULL)
free(o->target_iso_head);
free((char *) o);
*objpt= NULL;
return(1);
@ -346,6 +355,37 @@ int isoburn_msgs_submit(struct isoburn *o, int error_code, char msg_text[],
}
/* TWINTREE:
Check whether size of target_iso_head matches partition offset.
Eventually adjust size.
*/
int isoburn_adjust_target_iso_head(struct isoburn *o,
uint32_t offst, int flag)
{
uint8_t *new_buf;
uint32_t new_size;
if(o->target_iso_head_size == Libisoburn_target_head_sizE + 2048 * offst)
return(1);
new_size= Libisoburn_target_head_sizE + 2048 * offst;
new_buf= calloc(1, new_size);
if(new_buf == NULL) {
isoburn_msgs_submit(o, 0x00060000,
"Cannot re-allocate overwrite buffer", 0, "FATAL", 0);
return(-1);
}
memcpy(new_buf, o->target_iso_head,
o->target_iso_head_size < new_size ? o->target_iso_head_size : new_size);
free(o->target_iso_head);
o->target_iso_head= new_buf;
o->target_iso_head_size= new_size;
if(o->nwa == o->zero_nwa)
o->nwa= Libisoburn_overwriteable_starT + offst;
o->zero_nwa= Libisoburn_overwriteable_starT + offst;
return(1);
}
/* @param flag bit0= modifying rather than growing
bit1= prepare for early release of input drive:
wait until input and then disable image data source
@ -458,10 +498,17 @@ int isoburn_prepare_disc_aux(struct burn_drive *in_d, struct burn_drive *out_d,
opts->vol_expiration_time, opts->vol_effective_time,
opts->vol_uuid);
ret= isoburn_adjust_target_iso_head(out_o, opts->partition_offset, 0);
if(ret <= 0)
{ret= -1; goto ex;}
iso_write_opts_set_overwrite_buf(wopts,
nwa>0 ? out_o->target_iso_head : NULL);
if(opts->no_emul_toc) {
if(out_o->nwa == out_o->zero_nwa &&
out_o->zero_nwa == Libisoburn_overwriteable_starT &&
out_o->emulation_mode == 1) {
out_o->zero_nwa == Libisoburn_overwriteable_starT
+ opts->partition_offset
&& out_o->emulation_mode == 1) {
out_o->nwa= 0;
out_o->zero_nwa= 0;
out_o->min_start_byte= 0;
@ -477,41 +524,9 @@ int isoburn_prepare_disc_aux(struct burn_drive *in_d, struct burn_drive *out_d,
}
iso_write_opts_set_ms_block(wopts, nwa);
iso_write_opts_set_appendable(wopts, !new_img);
iso_write_opts_set_overwrite_buf(wopts,
nwa>0 ? out_o->target_iso_head : NULL);
if (opts->partition_offset > 0) {
if (nwa > 0) {
/* >>> refuse because for now this works only for single session with
no_emul_toc
<<< to be removed when multi session stuff is fully ready
*/
isoburn_msgs_submit(in_o, 0x00060000,
"Programming error: non-zero NWA combined with partition offset",
0, "FATAL", 0);
{ret= -4; goto ex;}
}
iso_write_opts_set_part_offset(wopts, opts->partition_offset,
opts->partition_secs_per_head,
opts->partition_heads_per_cyl);
}
#ifdef Libisoburn_partition_offseT
#if Libisoburn_partition_offseT >= 16
else {
/* <<< For preliminary testing of emulated TOC and partition offset.
Problem is that only this macro can prepare the overwrite buffer
for partition offset yet. Emulated TOC does not work yet.
*/
iso_write_opts_set_part_offset(wopts,
(uint32_t) Libisoburn_partition_offseT,
0, 0);
}
#endif
#endif
iso_write_opts_set_part_offset(wopts, opts->partition_offset,
opts->partition_secs_per_head,
opts->partition_heads_per_cyl);
ret = iso_image_create_burn_source(in_o->image, wopts, &wsrc);
if (ret < 0) {