From dd0ceb6720b8fe6b0a5e9fe21fa9da3538e7586b Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Tue, 4 Feb 2014 11:31:12 +0000 Subject: [PATCH] Implemented a generic verification whether a SPC device is a MMC device --- cdrskin/cdrskin_timestamp.h | 2 +- libburn/spc.c | 35 +++++++++++++++++++++++++++++++++++ libburn/spc.h | 7 ++++++- libburn/transport.h | 7 +++++++ 4 files changed, 49 insertions(+), 2 deletions(-) diff --git a/cdrskin/cdrskin_timestamp.h b/cdrskin/cdrskin_timestamp.h index 0754d22..e2e25d5 100644 --- a/cdrskin/cdrskin_timestamp.h +++ b/cdrskin/cdrskin_timestamp.h @@ -1 +1 @@ -#define Cdrskin_timestamP "2014.01.15.174907" +#define Cdrskin_timestamP "2014.02.04.112944" diff --git a/libburn/spc.c b/libburn/spc.c index ee9c065..0ebc826 100644 --- a/libburn/spc.c +++ b/libburn/spc.c @@ -352,6 +352,8 @@ void spc_inquiry(struct burn_drive *d) c->dir = FROM_DRIVE; d->issue_command(d, c); id = (struct burn_scsi_inquiry_data *)d->idata; + id->peripheral = 0x7f; /* SPC-3: incabable undefined peripheral type */ + id->version = 0; /* SPC-3: no claim for conformance */ memset(id->vendor, 0, 9); memset(id->product, 0, 17); memset(id->revision, 0, 5); @@ -359,6 +361,8 @@ void spc_inquiry(struct burn_drive *d) id->valid = -1; goto ex; } + id->peripheral = ((char *) c->page->data)[0]; + id->version = ((char *) c->page->data)[2]; memcpy(id->vendor, c->page->data + 8, 8); memcpy(id->product, c->page->data + 16, 16); memcpy(id->revision, c->page->data + 32, 4); @@ -1840,3 +1844,34 @@ ex:; BURN_FREE_MEM(msg); return done; } + + +int spc_confirm_cd_drive(struct burn_drive *d, int flag) +{ + char *msg = NULL; + int ret; + + BURN_ALLOC_MEM(msg, char, strlen(d->devname) + 1024); + + spc_inquiry(d); + if (d->idata->valid < 0) { + sprintf(msg, "INQUIRY failed with drive '%s'", d->devname); + libdax_msgs_submit(libdax_messenger, -1, 0x0002000a, + LIBDAX_MSGS_SEV_FAILURE, + LIBDAX_MSGS_PRIO_HIGH, msg, 0,0); + ret = 0; goto ex; + } + if (d->idata->peripheral != 0x5) { + sprintf(msg, "Does not identify itself as CD-ROM drive '%s'", + d->devname); + libdax_msgs_submit(libdax_messenger, -1, 0x0002000a, + LIBDAX_MSGS_SEV_FAILURE, + LIBDAX_MSGS_PRIO_HIGH, msg, 0,0); + ret = 0; goto ex; + } + ret = 1; +ex:; + BURN_FREE_MEM(msg); + return ret; +} + diff --git a/libburn/spc.h b/libburn/spc.h index 81491ed..769bdae 100644 --- a/libburn/spc.h +++ b/libburn/spc.h @@ -1,7 +1,7 @@ /* -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 8; -*- */ /* Copyright (c) 2004 - 2006 Derek Foreman, Ben Jansens - Copyright (c) 2006 - 2013 Thomas Schmitt + Copyright (c) 2006 - 2014 Thomas Schmitt Provided under GPL version 2 or later. */ @@ -116,6 +116,11 @@ int scsi_eval_cmd_outcome(struct burn_drive *d, struct command *c, void *fp_in, time_t start_time, int timeout_ms, int loop_count, int flag); +/* ts B40204 */ +/* Verify by INQUIRY that the drive is indeed a MMC device. +*/ +int spc_confirm_cd_drive(struct burn_drive *d, int flag); + /* The waiting time before eventually retrying a failed SCSI command. Before each retry wait Libburn_scsi_retry_incR longer than with diff --git a/libburn/transport.h b/libburn/transport.h index 8bbd702..a02c20a 100644 --- a/libburn/transport.h +++ b/libburn/transport.h @@ -73,9 +73,16 @@ struct command struct burn_scsi_inquiry_data { + char peripheral; /* bit0-4: device type should be 5 + bit5-7: qualifier must be 0 */ + + char version; /* should be 3 (SPC-1) to 5 (SPC-3) (or higher ?) + but is often 0. */ + char vendor[9]; char product[17]; char revision[5]; + int valid; };