Rectified use of burn_drive.mdata->valid

This commit is contained in:
Thomas Schmitt 2009-06-02 16:28:33 +00:00
parent 474c4cddd7
commit 38994b62c0
6 changed files with 48 additions and 22 deletions

View File

@ -1 +1 @@
#define Cdrskin_timestamP "2009.05.17.144304" #define Cdrskin_timestamP "2009.06.02.162841"

View File

@ -559,7 +559,7 @@ void burn_disc_write(struct burn_write_opts *opts, struct burn_disc *disc)
} }
/* ts A61007 : obsolete Assert in spc_select_write_params() */ /* ts A61007 : obsolete Assert in spc_select_write_params() */
if (d->drive_role == 1 && !d->mdata->valid) { if (d->drive_role == 1 && d->mdata->valid <= 0) {
libdax_msgs_submit(libdax_messenger, libdax_msgs_submit(libdax_messenger,
d->global_index, 0x00020113, d->global_index, 0x00020113,
LIBDAX_MSGS_SEV_SORRY, LIBDAX_MSGS_PRIO_HIGH, LIBDAX_MSGS_SEV_SORRY, LIBDAX_MSGS_PRIO_HIGH,

View File

@ -418,6 +418,9 @@ int burn_drive_unregister(struct burn_drive *d)
struct burn_drive *burn_drive_finish_enum(struct burn_drive *d) struct burn_drive *burn_drive_finish_enum(struct burn_drive *d)
{ {
struct burn_drive *t; struct burn_drive *t;
char msg[BURN_DRIVE_ADR_LEN + 160];
int ret;
/* ts A60821 /* ts A60821
<<< debug: for tracing calls which might use open drive fds */ <<< debug: for tracing calls which might use open drive fds */
int mmc_function_spy(struct burn_drive *d, char * text); int mmc_function_spy(struct burn_drive *d, char * text);
@ -430,13 +433,19 @@ struct burn_drive *burn_drive_finish_enum(struct burn_drive *d)
mmc_function_spy(NULL, "enumerate_common : -------- doing grab"); mmc_function_spy(NULL, "enumerate_common : -------- doing grab");
/* try to get the drive info */ /* try to get the drive info */
if (t->grab(t)) { ret = t->grab(t);
if (ret) {
burn_print(2, "getting drive info\n"); burn_print(2, "getting drive info\n");
t->getcaps(t); t->getcaps(t);
t->unlock(t); t->unlock(t);
t->released = 1; t->released = 1;
} else { } else {
burn_print(2, "unable to grab new located drive\n"); /* ts A90602 */
d->mdata->valid = -1;
sprintf(msg, "Unable to grab scanned drive %s", d->devname);
libdax_msgs_submit(libdax_messenger, d->global_index,
0x0002016f, LIBDAX_MSGS_SEV_DEBUG,
LIBDAX_MSGS_PRIO_LOW, msg, 0, 0);
burn_drive_unregister(t); burn_drive_unregister(t);
t = NULL; t = NULL;
} }
@ -855,7 +864,7 @@ static int drive_getcaps(struct burn_drive *d, struct burn_drive_info *out)
a ssert(d->mdata); a ssert(d->mdata);
#endif #endif
if (!d->idata->valid || !d->mdata->valid) if(d->idata->valid <= 0 || d->mdata->valid <= 0)
return 0; return 0;
id = (struct burn_scsi_inquiry_data *)d->idata; id = (struct burn_scsi_inquiry_data *)d->idata;
@ -978,10 +987,15 @@ int burn_drive_scan_sync(struct burn_drive_info *drives[],
if (drive_array[i].global_index < 0) if (drive_array[i].global_index < 0)
continue; /* invalid device */ continue; /* invalid device */
/* ts A90602 : This old loop is not plausible. See A70907.
while (!drive_getcaps(&drive_array[i], while (!drive_getcaps(&drive_array[i],
&(*drives)[*n_drives])) { &(*drives)[*n_drives])) {
sleep(1); sleep(1);
} }
*/
/* ts A90602 : A single call shall do (rather than a loop) */
drive_getcaps(&drive_array[i], &(*drives)[*n_drives]);
(*n_drives)++; (*n_drives)++;
scanned[i / 8] |= 1 << (i % 8); scanned[i / 8] |= 1 << (i % 8);
} }
@ -1140,14 +1154,14 @@ void burn_sectors_to_msf(int sectors, int *m, int *s, int *f)
int burn_drive_get_read_speed(struct burn_drive *d) int burn_drive_get_read_speed(struct burn_drive *d)
{ {
if(!d->mdata->valid) if(d->mdata->valid <= 0)
return 0; return 0;
return d->mdata->max_read_speed; return d->mdata->max_read_speed;
} }
int burn_drive_get_write_speed(struct burn_drive *d) int burn_drive_get_write_speed(struct burn_drive *d)
{ {
if(!d->mdata->valid) if(d->mdata->valid <= 0)
return 0; return 0;
return d->mdata->max_write_speed; return d->mdata->max_write_speed;
} }
@ -1155,7 +1169,7 @@ int burn_drive_get_write_speed(struct burn_drive *d)
/* ts A61021 : New API function */ /* ts A61021 : New API function */
int burn_drive_get_min_write_speed(struct burn_drive *d) int burn_drive_get_min_write_speed(struct burn_drive *d)
{ {
if(!d->mdata->valid) if(d->mdata->valid <= 0)
return 0; return 0;
return d->mdata->min_write_speed; return d->mdata->min_write_speed;
} }
@ -2082,7 +2096,7 @@ int burn_drive_get_speedlist(struct burn_drive *d,
struct burn_speed_descriptor *sd, *csd = NULL; struct burn_speed_descriptor *sd, *csd = NULL;
(*speed_list) = NULL; (*speed_list) = NULL;
if(!d->mdata->valid) if(d->mdata->valid <= 0)
return 0; return 0;
for (sd = d->mdata->speed_descriptors; sd != NULL; sd = sd->next) { for (sd = d->mdata->speed_descriptors; sd != NULL; sd = sd->next) {
ret = burn_speed_descriptor_new(&csd, NULL, csd, 0); ret = burn_speed_descriptor_new(&csd, NULL, csd, 0);
@ -2107,7 +2121,7 @@ int burn_drive_get_best_speed(struct burn_drive *d, int speed_goal,
if (speed_goal < 0) if (speed_goal < 0)
best_speed = 2000000000; best_speed = 2000000000;
*best_descr = NULL; *best_descr = NULL;
if(!d->mdata->valid) if(d->mdata->valid <= 0)
return 0; return 0;
for (sd = d->mdata->speed_descriptors; sd != NULL; sd = sd->next) { for (sd = d->mdata->speed_descriptors; sd != NULL; sd = sd->next) {
if (flag & 1) if (flag & 1)

View File

@ -545,7 +545,8 @@ Range "scdbackup" : 0x00020000 to 0x0002ffff
0x0002016a (FAILURE,HIGH) = No MMC transport adapter is present 0x0002016a (FAILURE,HIGH) = No MMC transport adapter is present
0x0002016b (WARNING,HIGH) = No MMC transport adapter is present 0x0002016b (WARNING,HIGH) = No MMC transport adapter is present
0x0002016c (DEBUG,HIGH) = No MMC transport adapter is present 0x0002016c (DEBUG,HIGH) = No MMC transport adapter is present
0x0002016e (DEBUG,HIGH) = MODE SENSE page 2A too short
0x0002016f (DEBUG,HIGH) = Unable to grab scanned drive
0x00020170 (NOTE,HIGH) = Closing open session before writing new one 0x00020170 (NOTE,HIGH) = Closing open session before writing new one
0x00020171 (NOTE,HIGH) = Closing BD-R with accidently open session 0x00020171 (NOTE,HIGH) = Closing BD-R with accidently open session

View File

@ -143,7 +143,7 @@ int burn_write_opts_set_simulate(struct burn_write_opts *opts, int sim)
int burn_write_opts_set_underrun_proof(struct burn_write_opts *opts, int burn_write_opts_set_underrun_proof(struct burn_write_opts *opts,
int underrun_proof) int underrun_proof)
{ {
if (!opts->drive->mdata->valid) if (opts->drive->mdata->valid <= 0)
return 0; return 0;
if (opts->drive->mdata->underrun_proof) { if (opts->drive->mdata->underrun_proof) {
opts->underrun_proof = underrun_proof; opts->underrun_proof = underrun_proof;

View File

@ -303,6 +303,7 @@ static int spc_sense_caps_al(struct burn_drive *d, int *alloc_len, int flag)
unsigned char *page; unsigned char *page;
struct command c; struct command c;
struct burn_speed_descriptor *sd; struct burn_speed_descriptor *sd;
char msg[BURN_DRIVE_ADR_LEN + 160];
/* ts A61225 : 1 = report about post-MMC-1 speed descriptors */ /* ts A61225 : 1 = report about post-MMC-1 speed descriptors */
static int speed_debug = 0; static int speed_debug = 0;
@ -310,6 +311,11 @@ static int spc_sense_caps_al(struct burn_drive *d, int *alloc_len, int flag)
if (*alloc_len < 8) if (*alloc_len < 8)
return 0; return 0;
/* ts A90602 : Clearing mdata before command execution */
m = d->mdata;
m->valid = 0;
burn_mdata_free_subs(m);
memset(&buf, 0, sizeof(buf)); memset(&buf, 0, sizeof(buf));
scsi_init_command(&c, SPC_MODE_SENSE, sizeof(SPC_MODE_SENSE)); scsi_init_command(&c, SPC_MODE_SENSE, sizeof(SPC_MODE_SENSE));
/* /*
@ -328,12 +334,11 @@ static int spc_sense_caps_al(struct burn_drive *d, int *alloc_len, int flag)
d->issue_command(d, &c); d->issue_command(d, &c);
if (c.error) { if (c.error) {
memset(&buf, 0, sizeof(buf)); memset(&buf, 0, sizeof(buf));
d->mdata->valid = -1; m->valid = -1;
was_error = 1; was_error = 1;
} }
size = c.page->data[0] * 256 + c.page->data[1]; size = c.page->data[0] * 256 + c.page->data[1];
m = d->mdata;
page = c.page->data + 8; page = c.page->data + 8;
/* ts A61225 : /* ts A61225 :
@ -349,11 +354,16 @@ static int spc_sense_caps_al(struct burn_drive *d, int *alloc_len, int flag)
return !was_error; return !was_error;
if (page_length + 8 > old_alloc_len) if (page_length + 8 > old_alloc_len)
page_length = old_alloc_len - 8; page_length = old_alloc_len - 8;
if (page_length < 22) if (page_length < 22) {
/* ts A90602 */
m->valid = -1;
sprintf(msg, "MODE SENSE page 2A too short: %s : %d",
d->devname, page_length);
libdax_msgs_submit(libdax_messenger, d->global_index,
0x0002016e, LIBDAX_MSGS_SEV_DEBUG,
LIBDAX_MSGS_PRIO_LOW, msg, 0, 0);
return 0; return 0;
}
m->valid = 0;
burn_mdata_free_subs(m);
m->buffer_size = page[12] * 256 + page[13]; m->buffer_size = page[12] * 256 + page[13];
m->dvdram_read = page[2] & 32; m->dvdram_read = page[2] & 32;
@ -384,6 +394,7 @@ static int spc_sense_caps_al(struct burn_drive *d, int *alloc_len, int flag)
m->min_end_lba = 0x7fffffff; m->min_end_lba = 0x7fffffff;
m->max_end_lba = 0; m->max_end_lba = 0;
if (!was_error)
m->valid = 1; m->valid = 1;
mmc_get_configuration(d); mmc_get_configuration(d);