Bug fix: modifying to overwriteable target yielded unmountable results

This commit is contained in:
Thomas Schmitt 2008-05-24 09:28:35 +00:00
parent 50a0258a78
commit 1b6e8b94b3
2 changed files with 56 additions and 44 deletions

View File

@ -299,28 +299,40 @@ int isoburn_find_by_drive(struct isoburn **pt, struct burn_drive *d, int flag)
return(0);
}
static
int isoburn_prepare_disc_aux(struct burn_drive *d, struct burn_disc **disc,
int isoburn_prepare_disc_aux(struct burn_drive *in_d, struct burn_drive *out_d,
struct burn_disc **disc,
struct isoburn_imgen_opts *opts, int new_img)
{
struct burn_source *wsrc;
struct burn_session *session;
struct burn_track *track;
struct isoburn *o;
struct isoburn *in_o, *out_o;
IsoWriteOpts *wopts= NULL;
enum burn_disc_status state;
int ret, fifo_chunks;
int ret, fifo_chunks, lba, nwa;
ret= isoburn_find_emulator(&o, d, 0);
if(ret<0 || o==NULL)
ret= isoburn_find_emulator(&in_o, in_d, 0);
if(ret<0 || in_o==NULL)
{ret= -1; goto ex;}
o->wrote_well= 0; /* early end will be registered as failure */
ret= isoburn_find_emulator(&out_o, out_d, 0);
if(ret<0 || out_o==NULL)
{ret= -1; goto ex;}
/* early end will be registered as failure */
in_o->wrote_well= out_o->wrote_well= 0;
state = isoburn_disc_get_status(d);
if (state != BURN_DISC_BLANK && state != BURN_DISC_APPENDABLE
&& (state != BURN_DISC_FULL || ! new_img)) {
/* unsuitable status */
burn_msgs_submit(0x00060000, "Unsuitable media state", 0, "FAILURE", NULL);
state = isoburn_disc_get_status(in_d);
if (state != BURN_DISC_BLANK && state != BURN_DISC_APPENDABLE &&
state != BURN_DISC_FULL) {
burn_msgs_submit(0x00060000, "Unsuitable source media state",
0, "FAILURE", NULL);
{ret= -2; goto ex;}
}
state = isoburn_disc_get_status(out_d);
if (state != BURN_DISC_BLANK && state != BURN_DISC_APPENDABLE) {
burn_msgs_submit(0x00060000, "Unsuitable target media state",
0, "FAILURE", NULL);
{ret= -2; goto ex;}
}
@ -359,33 +371,26 @@ int isoburn_prepare_disc_aux(struct burn_drive *d, struct burn_disc **disc,
iso_write_opts_set_output_charset(wopts, opts->output_charset);
iso_write_opts_set_fifo_size(wopts, fifo_chunks);
if (new_img) {
iso_write_opts_set_ms_block(wopts, 0);
opts->effective_lba= 0;
iso_write_opts_set_appendable(wopts, 0);
iso_write_opts_set_overwrite_buf(wopts, NULL);
} else {
int lba, nwa;
ret = isoburn_disc_track_lba_nwa(d, NULL, 0, &lba, &nwa);
if (ret != 1) {
burn_msgs_submit(0x00060000, "Cannot determine next writeable address", 0,
"FAILURE", NULL);
{ret= -3; goto ex;}
}
if (nwa == 0 && state == BURN_DISC_APPENDABLE) {
/* invalid nwa */
burn_msgs_submit(0x00060000,
"Encountered 0 as next writeable address of appendable",
0, "FAILURE", NULL);
{ret= -4; goto ex;}
}
iso_write_opts_set_ms_block(wopts, nwa);
opts->effective_lba= nwa;
iso_write_opts_set_appendable(wopts, 1);
iso_write_opts_set_overwrite_buf(wopts, o->target_iso_head);
}
ret = iso_image_create_burn_source(o->image, wopts, &wsrc);
ret = isoburn_disc_track_lba_nwa(out_d, NULL, 0, &lba, &nwa);
if (ret != 1) {
burn_msgs_submit(0x00060000, "Cannot determine next writeable address", 0,
"FAILURE", NULL);
{ret= -3; goto ex;}
}
if (nwa == 0 && state == BURN_DISC_APPENDABLE) {
burn_msgs_submit(0x00060000,
"Encountered 0 as next writeable address of appendable",
0, "FAILURE", NULL);
{ret= -4; goto ex;}
}
iso_write_opts_set_ms_block(wopts, nwa);
opts->effective_lba= nwa;
iso_write_opts_set_appendable(wopts, !new_img);
iso_write_opts_set_overwrite_buf(wopts,
nwa>0 ? out_o->target_iso_head : NULL);
ret = iso_image_create_burn_source(in_o->image, wopts, &wsrc);
if (ret < 0) {
isoburn_report_iso_error(ret, "Cannot create burn source", 0, "FAILURE", 0);
{ret= -1; goto ex;}
@ -393,20 +398,20 @@ int isoburn_prepare_disc_aux(struct burn_drive *d, struct burn_disc **disc,
/* TODO check return values for failure. propertly clean-up on error */
o->iso_source= wsrc;
out_o->iso_source= wsrc;
*disc = burn_disc_create();
session = burn_session_create();
burn_disc_add_session(*disc, session, BURN_POS_END);
track = burn_track_create();
burn_track_set_source(track, o->iso_source);
burn_track_set_source(track, out_o->iso_source);
burn_session_add_track(session, track, BURN_POS_END);
/* give up local references */
burn_track_free(track);
burn_session_free(session);
o->wrote_well= -1; /* neutral */
in_o->wrote_well= out_o->wrote_well= -1; /* neutral */
ret= 1;
ex:
if(wopts!=NULL)
@ -414,22 +419,27 @@ ex:
return ret;
}
int isoburn_prepare_disc(struct burn_drive *d, struct burn_disc **disc,
struct isoburn_imgen_opts *opts)
{
return isoburn_prepare_disc_aux(d, disc, opts, 0);
return isoburn_prepare_disc_aux(d, d, disc, opts, 0);
}
int isoburn_prepare_new_image(struct burn_drive *d, struct burn_disc **disc,
struct isoburn_imgen_opts *opts,
struct burn_drive *out_drive)
{
int ret;
struct isoburn *in_o, *out_o;
ret= isoburn_prepare_disc_aux(d, disc, opts, 1);
ret= isoburn_prepare_disc_aux(d, out_drive, disc, opts, 1);
if (ret<=0)
return ret;
#ifdef NIX
struct isoburn *in_o, *out_o;
/* Hand over source reference for optional fifo status inquiry */
if(out_drive==NULL)
return 1;
@ -443,6 +453,8 @@ int isoburn_prepare_new_image(struct burn_drive *d, struct burn_disc **disc,
burn_source_free(out_o->iso_source);
out_o->iso_source= in_o->iso_source;
in_o->iso_source= NULL;
#endif /* NIX */
return 1;
}

View File

@ -1 +1 @@
#define Xorriso_timestamP "2008.05.24.092546"
#define Xorriso_timestamP "2008.05.24.092853"