Replaced some large local variables by other means in
This commit is contained in:
parent
cc30f4043b
commit
31300231df
@ -518,26 +518,19 @@ int isoburn_drive_aquire(struct burn_drive_info *drive_infos[],
|
||||
{
|
||||
int ret, drive_grabbed= 0;
|
||||
struct isoburn *o= NULL;
|
||||
|
||||
#ifndef NIX
|
||||
|
||||
/* <<< should be obsolete by new drive addressing of libburn-0.5.2 */
|
||||
/* >>> but helps with kernel 2.4 to use /dev/sr */
|
||||
|
||||
int conv_ret;
|
||||
char libburn_drive_adr[BURN_DRIVE_ADR_LEN];
|
||||
char *libburn_drive_adr= NULL;
|
||||
|
||||
/* Should be obsolete by new drive addressing of libburn-0.5.2 */
|
||||
/* but helps with kernel 2.4 to use /dev/sr */
|
||||
libburn_drive_adr= calloc(1, BURN_DRIVE_ADR_LEN);
|
||||
if(libburn_drive_adr == NULL)
|
||||
{ret= -1; goto ex;}
|
||||
conv_ret= burn_drive_convert_fs_adr(adr, libburn_drive_adr);
|
||||
if(conv_ret<=0)
|
||||
strcpy(libburn_drive_adr, adr);
|
||||
|
||||
ret= burn_drive_scan_and_grab(drive_infos, libburn_drive_adr, flag&1);
|
||||
|
||||
#else
|
||||
|
||||
ret= burn_drive_scan_and_grab(drive_infos, adr, flag & 1);
|
||||
|
||||
#endif /* ! NIX */
|
||||
|
||||
if(ret<=0)
|
||||
goto ex;
|
||||
drive_grabbed= 1;
|
||||
@ -559,6 +552,8 @@ ex:
|
||||
burn_drive_release((*drive_infos)[0].drive, 0);
|
||||
isoburn_destroy(&o, 0);
|
||||
}
|
||||
if(libburn_drive_adr != NULL)
|
||||
free(libburn_drive_adr);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
@ -656,9 +651,16 @@ void isoburn_disc_erase(struct burn_drive *drive, int fast)
|
||||
int ret, do_pseudo_blank= 0, role;
|
||||
struct isoburn *o;
|
||||
enum burn_disc_status s;
|
||||
char zero_buffer[Libisoburn_target_head_sizE];
|
||||
char *zero_buffer= NULL;
|
||||
struct burn_multi_caps *caps= NULL;
|
||||
|
||||
zero_buffer= calloc(1, Libisoburn_target_head_sizE);
|
||||
if(zero_buffer == NULL) {
|
||||
/* To cause a negative reply with burn_drive_wrote_well() */
|
||||
burn_drive_cancel(drive);
|
||||
goto ex;
|
||||
}
|
||||
|
||||
ret= isoburn_find_emulator(&o, drive, 0);
|
||||
if(ret>0) {
|
||||
if(o->emulation_mode==-1) {
|
||||
@ -698,6 +700,8 @@ void isoburn_disc_erase(struct burn_drive *drive, int fast)
|
||||
ex:;
|
||||
if(caps!=NULL)
|
||||
burn_disc_free_multi_caps(&caps);
|
||||
if(zero_buffer != NULL)
|
||||
free(zero_buffer);
|
||||
}
|
||||
|
||||
|
||||
@ -836,15 +840,24 @@ void isoburn_disc_write(struct burn_write_opts *opts, struct burn_disc *disc)
|
||||
off_t nwa= 0;
|
||||
struct isoburn *o;
|
||||
struct burn_drive *drive;
|
||||
char reasons[BURN_REASONS_LEN],msg[160+BURN_REASONS_LEN];
|
||||
char adr[BURN_DRIVE_ADR_LEN];
|
||||
char *reasons= NULL, *msg= NULL, *adr= NULL;
|
||||
enum burn_write_types write_type;
|
||||
struct stat stbuf;
|
||||
|
||||
drive= burn_write_opts_get_drive(opts);
|
||||
|
||||
reasons= calloc(1, BURN_REASONS_LEN);
|
||||
msg= calloc(1, 160+BURN_REASONS_LEN);
|
||||
adr= calloc(1, BURN_DRIVE_ADR_LEN);
|
||||
if(reasons == NULL || msg == NULL || adr == NULL) {
|
||||
/* To cause a negative reply with burn_drive_wrote_well() */
|
||||
burn_drive_cancel(drive);
|
||||
goto ex;
|
||||
}
|
||||
|
||||
ret= isoburn_find_emulator(&o, drive, 0);
|
||||
if(ret<0)
|
||||
return;
|
||||
goto ex;
|
||||
if(o!=NULL) {
|
||||
o->wrote_well= -1;
|
||||
if(o->emulation_mode!=0) {
|
||||
@ -874,7 +887,7 @@ void isoburn_disc_write(struct burn_write_opts *opts, struct burn_disc *disc)
|
||||
"It might help to first deformat it and then format it again");
|
||||
isoburn_msgs_submit(o, 0x00060000, msg, 0, "HINT", 0);
|
||||
burn_drive_cancel(drive); /* mark run as failure */
|
||||
return;
|
||||
goto ex;
|
||||
}
|
||||
/* end of DVD-RW oriented check */
|
||||
burn_write_opts_set_start_byte(opts, nwa * (off_t) 2048);
|
||||
@ -890,7 +903,7 @@ void isoburn_disc_write(struct burn_write_opts *opts, struct burn_disc *disc)
|
||||
o->wrote_well= 0;
|
||||
/* To cause a negative reply with burn_drive_wrote_well() */
|
||||
burn_drive_cancel(drive);
|
||||
return;
|
||||
goto ex;
|
||||
}
|
||||
|
||||
sprintf(reasons, "%d", (int) write_type);
|
||||
@ -921,6 +934,13 @@ void isoburn_disc_write(struct burn_write_opts *opts, struct burn_disc *disc)
|
||||
}
|
||||
|
||||
burn_disc_write(opts, disc);
|
||||
ex:;
|
||||
if(reasons != NULL)
|
||||
free(reasons);
|
||||
if(msg != NULL)
|
||||
free(msg);
|
||||
if(adr != NULL)
|
||||
free(adr);
|
||||
}
|
||||
|
||||
|
||||
@ -1187,12 +1207,16 @@ int isoburn_read_iso_head_parse(struct burn_drive *d, unsigned char *data,
|
||||
int isoburn_read_iso_head(struct burn_drive *d, int lba,
|
||||
int *image_blocks, char *info, int flag)
|
||||
{
|
||||
unsigned char buffer[64*1024];
|
||||
unsigned char *buffer= NULL;
|
||||
int ret, info_mode, capacity, role;
|
||||
off_t data_count, to_read;
|
||||
enum burn_disc_status s;
|
||||
struct isoburn *o;
|
||||
|
||||
buffer= calloc(1, 64 * 1024);
|
||||
if(buffer == NULL)
|
||||
{ret= -1; goto ex;}
|
||||
|
||||
info_mode= flag&255;
|
||||
*image_blocks= 0;
|
||||
if(flag&(1<<13)) {
|
||||
@ -1204,7 +1228,7 @@ int isoburn_read_iso_head(struct burn_drive *d, int lba,
|
||||
if (role == 3 || role == 5)
|
||||
|
||||
/* >>> ??? return always 0 ? */
|
||||
return(-1*!!(flag&(1<<15)));
|
||||
{ret= (-1*!!(flag&(1<<15))); goto ex;}
|
||||
|
||||
ret = burn_get_read_capacity(d, &capacity, 0);
|
||||
if (ret <= 0 && (role == 2 || role == 4)) {
|
||||
@ -1218,7 +1242,7 @@ int isoburn_read_iso_head(struct burn_drive *d, int lba,
|
||||
ret= isoburn_find_emulator(&o, d, 0);
|
||||
if(ret > 0)
|
||||
if(o->media_read_error)
|
||||
return(-1 * !!(flag & (1 << 15)));
|
||||
{ret= (-1 * !!(flag & (1 << 15))); goto ex;}
|
||||
if(to_read >= (off_t) (64 * 1024))
|
||||
to_read= 64 * 1024;
|
||||
ret = burn_read_data(d, ((off_t) lba) * (off_t) 2048, (char *) buffer,
|
||||
@ -1226,7 +1250,7 @@ int isoburn_read_iso_head(struct burn_drive *d, int lba,
|
||||
} else
|
||||
ret= 0;
|
||||
if(ret<=0)
|
||||
return(-1*!!(flag&(1<<15)));
|
||||
{ret= (-1*!!(flag&(1<<15))); goto ex;}
|
||||
if(info_mode==2)
|
||||
memcpy(info, buffer, 64*1024);
|
||||
}
|
||||
@ -1234,15 +1258,19 @@ int isoburn_read_iso_head(struct burn_drive *d, int lba,
|
||||
if(flag&(1<<14)) {
|
||||
ret= isoburn_read_iso_head_parse(d, buffer, image_blocks, info, info_mode);
|
||||
if(ret<0)
|
||||
return(ret);
|
||||
goto ex;
|
||||
if(ret>0)
|
||||
return(2);
|
||||
{ret= 2; goto ex;}
|
||||
}
|
||||
ret= isoburn_read_iso_head_parse(d, buffer+32*1024, image_blocks, info,
|
||||
info_mode);
|
||||
if(ret<=0)
|
||||
return(ret);
|
||||
return(1);
|
||||
goto ex;
|
||||
ret= 1;
|
||||
ex:;
|
||||
if(buffer != NULL)
|
||||
free(buffer);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
||||
@ -1288,17 +1316,22 @@ int isoburn_emulate_toc(struct burn_drive *d, int flag)
|
||||
int scan_start= 0, scan_count= 0, probe_minus_16= 0, growisofs_nwa, role;
|
||||
int with_enclosure= 0, readable_blocks= -1;
|
||||
struct isoburn *o;
|
||||
char msg[160], size_text[80], *sev, volid[33], *volid_pt= NULL;
|
||||
char *msg= NULL, *size_text= NULL, *sev, volid[33], *volid_pt= NULL;
|
||||
time_t start_time, last_pacifier, now;
|
||||
|
||||
msg= calloc(1, 160);
|
||||
size_text= calloc(1, 80);
|
||||
if(msg == NULL || size_text == NULL)
|
||||
{ret= -1; goto ex;}
|
||||
|
||||
/* is the media emulated multi-session ? */
|
||||
ret= isoburn_find_emulator(&o, d, 0);
|
||||
if(ret<0)
|
||||
return(-1);
|
||||
{ret= -1; goto ex;}
|
||||
if(o==NULL)
|
||||
return(-1);
|
||||
{ret= -1; goto ex;}
|
||||
if(o->emulation_mode<=0 && !(flag&1))
|
||||
return(0);
|
||||
{ret= 0; goto ex;}
|
||||
|
||||
ret= burn_get_read_capacity(d, &readable_blocks, 0);
|
||||
if(ret <= 0) {
|
||||
@ -1425,7 +1458,7 @@ int isoburn_emulate_toc(struct burn_drive *d, int flag)
|
||||
sprintf(msg, "Found %d ISO sessions by scanning %s in %.f seconds",
|
||||
session_count, size_text, (double) (now - start_time));
|
||||
isoburn_msgs_submit(o, 0x00060000, msg, 0, sev, 0);
|
||||
return(1);
|
||||
{ret= 1; goto ex;}
|
||||
failure:;
|
||||
isoburn_toc_entry_destroy(&(o->toc), 1);
|
||||
if(with_enclosure && o->emulation_mode == 1) {
|
||||
@ -1438,6 +1471,11 @@ failure:;
|
||||
session_count= 0;
|
||||
ret= isoburn_make_toc_entry(o, &session_count, 0, image_size, NULL, 0);
|
||||
}
|
||||
ex:;
|
||||
if(msg != NULL)
|
||||
free(msg);
|
||||
if(size_text != NULL)
|
||||
free(size_text);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
@ -1775,7 +1813,7 @@ int isoburn_set_msc1(struct burn_drive *d, int adr_mode, char *adr_value,
|
||||
int ret, num_sessions= 0, num_tracks, adr_num, i, j, total_tracks;
|
||||
int lba, best_lba, size, re_valid= 0, track_count= 0;
|
||||
time_t start_time= 0, last_pacifier= 0, now;
|
||||
char volid[33], msg[160];
|
||||
char volid[33], *msg= NULL;
|
||||
struct isoburn *o;
|
||||
struct isoburn_toc_disc *disc= NULL;
|
||||
struct isoburn_toc_session **sessions= NULL;
|
||||
@ -1792,6 +1830,10 @@ int isoburn_set_msc1(struct burn_drive *d, int adr_mode, char *adr_value,
|
||||
if(o==NULL)
|
||||
return(-1);
|
||||
|
||||
msg= calloc(1, 160);
|
||||
if(msg == NULL)
|
||||
{ret= -1; goto ex;}
|
||||
|
||||
start_time= last_pacifier= time(NULL);
|
||||
adr_num= atoi(adr_value);
|
||||
if(adr_mode!=3 || (flag & 2)) {
|
||||
@ -1926,6 +1968,8 @@ ex:;
|
||||
isoburn_toc_disc_free(disc);
|
||||
if((flag & 4) && re_valid)
|
||||
regfree(&re);
|
||||
if(msg != NULL)
|
||||
free(msg);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
@ -404,7 +404,11 @@ int isoburn_prepare_disc_aux(struct burn_drive *in_d, struct burn_drive *out_d,
|
||||
int ret, fifo_chunks, lba, nwa, i, new_img, early_indev_release;
|
||||
uint32_t data_start= -1;
|
||||
size_t buffer_size= 0, buffer_free= 0;
|
||||
char msg[160];
|
||||
char *msg= NULL;
|
||||
|
||||
msg= calloc(1, 160);
|
||||
if(msg == NULL)
|
||||
{ret= -1; goto ex;}
|
||||
|
||||
new_img= flag&1;
|
||||
early_indev_release= flag&2;
|
||||
@ -608,6 +612,8 @@ int isoburn_prepare_disc_aux(struct burn_drive *in_d, struct burn_drive *out_d,
|
||||
ex:
|
||||
if(wopts!=NULL)
|
||||
{iso_write_opts_free(wopts); wopts= NULL;}
|
||||
if(msg != NULL)
|
||||
free(msg);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -1086,13 +1092,17 @@ int isoburn_igopt_set_untranslated_name_len(struct isoburn_imgen_opts *o,
|
||||
{
|
||||
int ret;
|
||||
IsoWriteOpts *opts = NULL;
|
||||
char msg[160];
|
||||
char *msg= NULL;
|
||||
|
||||
msg= calloc(1, 160);
|
||||
if(msg == NULL)
|
||||
{ret= -1; goto ex;}
|
||||
|
||||
ret= iso_write_opts_new(&opts, 0);
|
||||
if(ret < 0) {
|
||||
isoburn_msgs_submit(NULL, 0x00060000,
|
||||
"Cannot create libisofs write options object", 0, "FATAL", 0);
|
||||
return(0);
|
||||
{ret= 0; goto ex;}
|
||||
}
|
||||
ret= iso_write_opts_set_untranslated_name_len(opts, len);
|
||||
if(ret < 0) {
|
||||
@ -1102,11 +1112,15 @@ int isoburn_igopt_set_untranslated_name_len(struct isoburn_imgen_opts *o,
|
||||
len, ret);
|
||||
isoburn_msgs_submit(NULL, 0x00060000, msg, 0, "FAILURE", 0);
|
||||
iso_write_opts_free(opts);
|
||||
return(0);
|
||||
{ret= 0; goto ex;}
|
||||
}
|
||||
o->untranslated_name_len= ret; /* Normalized len value */
|
||||
iso_write_opts_free(opts);
|
||||
return(1);
|
||||
ret= 1;
|
||||
ex:;
|
||||
if(msg != NULL)
|
||||
free(msg);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
||||
|
@ -121,22 +121,24 @@ int isoburn_read_image(struct burn_drive *d,
|
||||
IsoReadOpts *ropts= NULL;
|
||||
IsoReadImageFeatures *features= NULL;
|
||||
uint32_t ms_block;
|
||||
char msg[160];
|
||||
char *msg= NULL;
|
||||
enum burn_disc_status status= BURN_DISC_BLANK;
|
||||
IsoDataSource *ds= NULL;
|
||||
struct isoburn *o= NULL;
|
||||
|
||||
msg= calloc(1, 160);
|
||||
|
||||
if(d != NULL) {
|
||||
ret = isoburn_find_emulator(&o, d, 0);
|
||||
if (ret < 0 || o == NULL)
|
||||
return 0;
|
||||
{ret= 0; goto ex;}
|
||||
status = isoburn_disc_get_status(d);
|
||||
}
|
||||
if(read_opts==NULL) {
|
||||
isoburn_msgs_submit(o, 0x00060000,
|
||||
"Program error: isoburn_read_image: read_opts==NULL",
|
||||
0, "FATAL", 0);
|
||||
return(-1);
|
||||
{ret= -1; goto ex;}
|
||||
}
|
||||
if (d == NULL || status == BURN_DISC_BLANK || read_opts->pretend_blank) {
|
||||
create_blank_image:;
|
||||
@ -150,13 +152,13 @@ create_blank_image:;
|
||||
isoburn_msgs_submit(o, 0x00060000,
|
||||
"Program error: isoburn_read_image: image==NULL",
|
||||
0, "FATAL", 0);
|
||||
return -1;
|
||||
{ret= -1; goto ex;}
|
||||
}
|
||||
/* create a new image */
|
||||
ret = iso_image_new("ISOIMAGE", image);
|
||||
if (ret < 0) {
|
||||
isoburn_report_iso_error(ret, "Cannot create image", 0, "FATAL", 0);
|
||||
return ret;
|
||||
goto ex;
|
||||
}
|
||||
iso_image_set_ignore_aclea(*image,
|
||||
(!!(read_opts->noacl)) | ((!!read_opts->noea) << 1) );
|
||||
@ -166,7 +168,7 @@ create_blank_image:;
|
||||
ret = iso_image_new("ISOIMAGE", &o->image);
|
||||
if (ret < 0) {
|
||||
isoburn_report_iso_error(ret, "Cannot create image", 0, "FATAL", 0);
|
||||
return ret;
|
||||
goto ex;
|
||||
}
|
||||
if (image != NULL) {
|
||||
*image = o->image;
|
||||
@ -175,21 +177,21 @@ create_blank_image:;
|
||||
iso_image_set_ignore_aclea(o->image,
|
||||
(!!(read_opts->noacl)) | ((!!read_opts->noea) << 1) );
|
||||
}
|
||||
return 1;
|
||||
{ret= 1; goto ex;}
|
||||
}
|
||||
|
||||
if (status != BURN_DISC_APPENDABLE && status != BURN_DISC_FULL) {
|
||||
isoburn_msgs_submit(o, 0x00060000,
|
||||
"Program error: isoburn_read_image: incorrect disc status",
|
||||
0, "FATAL", 0);
|
||||
return -4;
|
||||
{ret= -4; goto ex;}
|
||||
}
|
||||
|
||||
memset((char *) &ropts, 0, sizeof(ropts));
|
||||
|
||||
ret = isoburn_disc_get_msc1(d, &int_num);
|
||||
if (ret <= 0)
|
||||
return -2;
|
||||
{ret= -2; goto ex;}
|
||||
ms_block= int_num;
|
||||
ret = isoburn_read_iso_head(d, int_num, &dummy, NULL, 0);
|
||||
if (ret <= 0) {
|
||||
@ -205,7 +207,7 @@ create_blank_image:;
|
||||
displacement_rollover:;
|
||||
sprintf(msg, "Displacement offset leads outside 32 bit range.");
|
||||
isoburn_msgs_submit(o, 0x00060000, msg, 0, "FAILURE", 0);
|
||||
return 0;
|
||||
{ret= 0; goto ex;}
|
||||
}
|
||||
ms_block+= read_opts->displacement;
|
||||
} else {
|
||||
@ -220,7 +222,7 @@ displacement_rollover:;
|
||||
ret = iso_read_opts_new(&ropts, 0);
|
||||
if (ret < 0) {
|
||||
isoburn_report_iso_error(ret, "Cannot create write opts", 0, "FATAL", 0);
|
||||
return ret;
|
||||
goto ex;
|
||||
}
|
||||
|
||||
/* Important: do not return until iso_read_opts_free() */
|
||||
@ -253,7 +255,7 @@ displacement_rollover:;
|
||||
if (ds == NULL) {
|
||||
isoburn_report_iso_error(ret, "Cannot create IsoDataSource object", 0,
|
||||
"FATAL", 0);
|
||||
return ret;
|
||||
goto ex;
|
||||
}
|
||||
if(o->iso_data_source!=NULL)
|
||||
iso_data_source_unref(o->iso_data_source);
|
||||
@ -270,7 +272,7 @@ displacement_rollover:;
|
||||
|
||||
if (ret < 0) {
|
||||
isoburn_report_iso_error(ret, "Cannot import image", 0, "FAILURE", 0);
|
||||
return ret;
|
||||
goto ex;
|
||||
}
|
||||
/* Important: do not return until free(features) */
|
||||
if (image!=NULL) {
|
||||
@ -283,7 +285,11 @@ displacement_rollover:;
|
||||
read_opts->hasElTorito = iso_read_image_features_has_eltorito(features);
|
||||
read_opts->size = iso_read_image_features_get_size(features);
|
||||
iso_read_image_features_destroy(features);
|
||||
return 1;
|
||||
ret= 1;
|
||||
ex:;
|
||||
if(msg != NULL)
|
||||
free(msg);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
||||
@ -366,53 +372,58 @@ int isoburn_get_img_partition_offset(struct burn_drive *drive,
|
||||
static int isoburn_inspect_partition(struct isoburn *o, uint32_t img_size,
|
||||
int flag)
|
||||
{
|
||||
uint8_t *mbr, *part, buf[2048];
|
||||
uint8_t *mbr, *part, *buf= NULL;
|
||||
uint32_t offst, numsec;
|
||||
struct ecma119_pri_vol_desc *pvm;
|
||||
off_t data_count;
|
||||
int ret;
|
||||
char msg[160];
|
||||
char *msg= NULL;
|
||||
static int max_offst= 512 - 32;
|
||||
|
||||
buf= (uint8_t *) calloc(1, 2048);
|
||||
msg= calloc(1, 160);
|
||||
if(buf == NULL || msg == NULL)
|
||||
{ret= -1; goto ex;}
|
||||
|
||||
mbr= o->target_iso_head;
|
||||
part= mbr + 446;
|
||||
if(mbr[510] != 0x55 || mbr[511] != 0xAA)
|
||||
return(2); /* not an MBR */
|
||||
{ret= 2; goto ex;} /* not an MBR */
|
||||
|
||||
/* Does the first partition entry look credible ? */
|
||||
if(part[0] != 0x80 && part[0] != 0x00)
|
||||
return(2); /* Invalid partition status */
|
||||
{ret= 2; goto ex;} /* Invalid partition status */
|
||||
if(part[1] == 0 && part[2] == 0 && part[3] == 0)
|
||||
return(2); /* Zero C/H/S start address */
|
||||
{ret= 2; goto ex;} /* Zero C/H/S start address */
|
||||
|
||||
/* Does it match the normal ISO image ? */
|
||||
offst= iso_read_lsb(part + 8, 4);
|
||||
numsec= iso_read_lsb(part + 12, 4);
|
||||
if(offst < 64)
|
||||
return(2); /* Zero or unusably small partition start */
|
||||
{ret= 2; goto ex;} /* Zero or unusably small partition start */
|
||||
if((offst % 4) || (numsec % 4))
|
||||
return(2); /* Not aligned to 2k */
|
||||
{ret= 2; goto ex;} /* Not aligned to 2k */
|
||||
if(numsec < 72)
|
||||
return(2); /* No room for volume descriptors */
|
||||
{ret= 2; goto ex;} /* No room for volume descriptors */
|
||||
offst/= 4;
|
||||
numsec/= 4;
|
||||
if(offst + numsec != img_size)
|
||||
return(2); /* Partition end does not match image end */
|
||||
{ret= 2; goto ex;} /* Partition end does not match image end */
|
||||
|
||||
/* Is there a PVD at the partition start ? */
|
||||
ret = burn_read_data(o->drive, (off_t) (offst + 16) * (off_t) 2048,
|
||||
(char*) buf, 2048, &data_count, 2);
|
||||
if(ret <= 0)
|
||||
return(2);
|
||||
{ret= 2; goto ex;}
|
||||
pvm = (struct ecma119_pri_vol_desc *) buf;
|
||||
if (strncmp((char*) pvm->std_identifier, "CD001", 5) != 0)
|
||||
return(2); /* not a PVD */
|
||||
{ret= 2; goto ex;} /* not a PVD */
|
||||
if (pvm->vol_desc_type[0] != 1 || pvm->vol_desc_version[0] != 1
|
||||
|| pvm->file_structure_version[0] != 1 )
|
||||
return(2); /* failed sanity check */
|
||||
{ret= 2; goto ex;} /* failed sanity check */
|
||||
|
||||
if(iso_read_lsb(pvm->vol_space_size, 4) + offst != img_size)
|
||||
return(2); /* Image ends do not match */
|
||||
{ret= 2; goto ex;} /* Image ends do not match */
|
||||
|
||||
/* Now it is credible. Not yet clear is whether it is acceptable. */
|
||||
o->loaded_partition_offset= offst;
|
||||
@ -423,15 +434,21 @@ static int isoburn_inspect_partition(struct isoburn *o, uint32_t img_size,
|
||||
"Detected partition offset of %.f blocks. Maximum for load buffer is %d",
|
||||
(double) offst, max_offst);
|
||||
isoburn_msgs_submit(NULL, 0x00060000, msg, 0, "WARNING", 0);
|
||||
return(3);
|
||||
{ret= 3; goto ex;}
|
||||
}
|
||||
|
||||
/* Accept partition start and adjust buffer size */
|
||||
ret= isoburn_adjust_target_iso_head(o, offst, 0);
|
||||
if(ret <= 0)
|
||||
return(ret);
|
||||
goto ex;
|
||||
|
||||
return(1);
|
||||
ret= 1;
|
||||
ex:;
|
||||
if(buf != NULL)
|
||||
free(buf);
|
||||
if(msg != NULL)
|
||||
free(msg);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
||||
@ -449,13 +466,18 @@ int isoburn_start_emulation(struct isoburn *o, int flag)
|
||||
struct burn_drive *drive;
|
||||
struct ecma119_pri_vol_desc *pvm;
|
||||
enum burn_disc_status s;
|
||||
char path[BURN_DRIVE_ADR_LEN], msg[2 * BURN_DRIVE_ADR_LEN];
|
||||
|
||||
char *path= NULL, *msg= NULL;
|
||||
|
||||
path= calloc(1, BURN_DRIVE_ADR_LEN);
|
||||
msg= calloc(1, 2 * BURN_DRIVE_ADR_LEN);
|
||||
if(path == NULL || msg == NULL)
|
||||
{ret= -1; goto ex;}
|
||||
|
||||
if(o==NULL) {
|
||||
isoburn_msgs_submit(NULL, 0x00060000,
|
||||
"Program error: isoburn_start_emulation: o==NULL",
|
||||
0, "FATAL", 0);
|
||||
return -1;
|
||||
{ret= -1; goto ex;}
|
||||
}
|
||||
|
||||
drive= o->drive;
|
||||
@ -474,7 +496,7 @@ int isoburn_start_emulation(struct isoburn *o, int flag)
|
||||
s = burn_disc_get_status(drive);
|
||||
o->fabricated_disc_status= s;
|
||||
burn_disc_track_lba_nwa(drive, NULL, 0, &dummy, &(o->nwa));
|
||||
return 1;
|
||||
{ret= 1; goto ex;}
|
||||
} 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. */
|
||||
@ -500,13 +522,13 @@ int isoburn_start_emulation(struct isoburn *o, int flag)
|
||||
o->fabricated_disc_status= BURN_DISC_FULL;
|
||||
else if(!(flag & 1))
|
||||
o->fabricated_disc_status= BURN_DISC_BLANK;
|
||||
return 1;
|
||||
{ret= 1; goto ex;}
|
||||
}
|
||||
} else {
|
||||
/* No read capacity means blank media */
|
||||
if(!(flag & 1))
|
||||
o->fabricated_disc_status= BURN_DISC_BLANK;
|
||||
return 1;
|
||||
{ret= 1; goto ex;}
|
||||
}
|
||||
|
||||
/* check first 64K. If 0's, the disc is treated as a blank disc, and thus
|
||||
@ -518,7 +540,7 @@ int isoburn_start_emulation(struct isoburn *o, int flag)
|
||||
if (!i) {
|
||||
if(!(flag & 1))
|
||||
o->fabricated_disc_status= BURN_DISC_BLANK;
|
||||
return 1;
|
||||
{ret= 1; goto ex;}
|
||||
}
|
||||
|
||||
pvm = (struct ecma119_pri_vol_desc *)(o->target_iso_head + 16 * 2048);
|
||||
@ -531,14 +553,14 @@ int isoburn_start_emulation(struct isoburn *o, int flag)
|
||||
|| pvm->file_structure_version[0] != 1 ) {
|
||||
/* TODO for now I treat this as a full disc */
|
||||
o->fabricated_disc_status= BURN_DISC_FULL;
|
||||
return 1;
|
||||
{ret= 1; goto ex;}
|
||||
}
|
||||
|
||||
/* ok, PVM found, set size */
|
||||
size = (off_t) iso_read_lsb(pvm->vol_space_size, 4);
|
||||
ret= isoburn_inspect_partition(o, (uint32_t) size, 0);
|
||||
if (ret <= 0)
|
||||
return ret;
|
||||
goto ex;
|
||||
size *= (off_t) 2048; /* block size in bytes */
|
||||
isoburn_set_start_byte(o, size, 0);
|
||||
if(!(flag & 1))
|
||||
@ -554,7 +576,13 @@ int isoburn_start_emulation(struct isoburn *o, int flag)
|
||||
o->fabricated_disc_status= BURN_DISC_FULL;
|
||||
}
|
||||
|
||||
return 1;
|
||||
ret= 1;
|
||||
ex:;
|
||||
if(path != NULL)
|
||||
free(path);
|
||||
if(msg != NULL)
|
||||
free(msg);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1 +1 @@
|
||||
#define Xorriso_timestamP "2011.05.08.174805"
|
||||
#define Xorriso_timestamP "2011.05.09.155010"
|
||||
|
Loading…
Reference in New Issue
Block a user