summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorR. Bernstein <rocky@gnu.org>2012-10-02 17:46:38 -0400
committerR. Bernstein <rocky@gnu.org>2012-10-02 17:46:38 -0400
commit84e620fea262400f1660cb9c89524bd1a9cee146 (patch)
tree2f037cff4a774dac18e9ebb110674ea5f433dfbc
parent31914bd41726b548788600de88b370991ba14984 (diff)
Add mmc_cmd2str()
-rw-r--r--NEWS1
-rw-r--r--include/cdio/mmc.h12
-rw-r--r--lib/driver/gnu_linux.c6
-rw-r--r--lib/driver/libcdio.sym1
-rw-r--r--lib/driver/mmc/mmc.c207
-rwxr-xr-xmake-check-filter.rb2
-rw-r--r--test/driver/mmc_read.c10
7 files changed, 235 insertions, 4 deletions
diff --git a/NEWS b/NEWS
index e5cb73c9..143defb1 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,7 @@ version 0.90
- paranoia library removed as that is GPL 2-ish. This is now a separate project
- file names in cue files are relative to the cue file rather than cwd.
- Update mmc.h to include MMC-5 commands. (Or MMC-6 since it adds nothing new)
+- Add mmc_cmd2str() to show MMC command name. Show that in some errors
- bug fixes, more tests, update documentation
version 0.83
diff --git a/include/cdio/mmc.h b/include/cdio/mmc.h
index 6d6debae..decb3278 100644
--- a/include/cdio/mmc.h
+++ b/include/cdio/mmc.h
@@ -271,7 +271,6 @@ extern "C" {
CDIO_MMC_GPCMD_READ_ALL_SUBCODES = 0xdf /**< Vendor unique = command */
} cdio_mmc_gpcmd_t;
-
/**
Read Subchannel states
*/
@@ -808,6 +807,17 @@ driver_return_code_t mmc_audio_get_volume (CdIo_t *p_cdio, /*out*/
*/
driver_return_code_t mmc_set_blocksize ( const CdIo_t *p_cdio,
uint16_t i_blocksize);
+
+ /**
+ Get string name for MMC command
+
+ @param command cdio_mmc_gpcmd_t command value
+ @return string name of command
+
+ */
+ const char *mmc_cmd2str(uint8_t command);
+
+
#ifdef __cplusplus
}
diff --git a/lib/driver/gnu_linux.c b/lib/driver/gnu_linux.c
index 0ee71ded..a2e98dfc 100644
--- a/lib/driver/gnu_linux.c
+++ b/lib/driver/gnu_linux.c
@@ -1296,8 +1296,10 @@ run_mmc_cmd_linux(void *p_user_data,
if (0 == i_rc) return DRIVER_OP_SUCCESS;
if (-1 == i_rc) {
- cdio_info ("ioctl CDROM_SEND_PACKET for command code 0x%x failed:\n\t%s",
- p_cdb->field[0], strerror(errno));
+ cdio_info("ioctl CDROM_SEND_PACKET for command %s (0x%0x) failed:\n\t%s",
+ mmc_cmd2str((uint8_t) p_cdb->field[0]),
+ p_cdb->field[0],
+ strerror(errno));
switch (errno) {
case EPERM:
return DRIVER_OP_NOT_PERMITTED;
diff --git a/lib/driver/libcdio.sym b/lib/driver/libcdio.sym
index f2aff961..80856bae 100644
--- a/lib/driver/libcdio.sym
+++ b/lib/driver/libcdio.sym
@@ -202,6 +202,7 @@ libcdio_version_num
mmc_audio_read_subchannel
mmc_audio_state2str
mmc_close_tray
+mmc_cmd2str
mmc_eject_media
mmc_feature2str
mmc_feature_profile2str
diff --git a/lib/driver/mmc/mmc.c b/lib/driver/mmc/mmc.c
index 1e078798..b60dc058 100644
--- a/lib/driver/mmc/mmc.c
+++ b/lib/driver/mmc/mmc.c
@@ -48,6 +48,213 @@
# include <errno.h>
#endif
+const char
+*mmc_cmd2str(uint8_t command)
+{
+ switch( command ) {
+ case CDIO_MMC_GPCMD_TEST_UNIT_READY:
+ return "TEST UNIT READY";
+
+ case CDIO_MMC_GPCMD_REQUEST_SENSE:
+ return "REQUEST SENSE";
+
+ case CDIO_MMC_GPCMD_FORMAT_UNIT:
+ return "FORMAT UNIT";
+
+ case CDIO_MMC_GPCMD_INQUIRY:
+ return "INQUIRY";
+
+ case CDIO_MMC_GPCMD_MODE_SELECT_6:
+ return "MODE SELECT (6)";
+
+ case CDIO_MMC_GPCMD_MODE_SENSE_6:
+ return "MODE SENSE (6)";
+
+ case CDIO_MMC_GPCMD_START_STOP_UNIT:
+ return "START STOP UNIT";
+
+ case CDIO_MMC_GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL:
+ return "PREVENT ALLOW MEDIUM REMOVAL";
+
+ case CDIO_MMC_GPCMD_READ_FORMAT_CAPACITIES:
+ return "READ FORMAT CAPACITIES";
+
+ case CDIO_MMC_GPCMD_READ_CAPACITIY:
+ return "READ_CAPACITIY";
+
+ case CDIO_MMC_GPCMD_READ_10:
+ return "READ (10)";
+
+ case CDIO_MMC_GPCMD_WRITE_10:
+ return "WRITE (10)";
+
+ case CDIO_MMC_GPCMD_SEEK_10:
+ return "SEEK (10)";
+
+ case CDIO_MMC_GPCMD_ERASE_10:
+ return "ERASE (10)";
+
+ case CDIO_MMC_GPCMD_WRITE_AND_VERIFY_10:
+ return "WRITE AND VERIFY (10)";
+
+ case CDIO_MMC_GPCMD_VERIFY_10:
+ return "VERIFY (10)";
+
+ case CDIO_MMC_GPCMD_SYNCHRONIZE_CACHE:
+ return "SYNCHRONIZE CACHE";
+
+ case CDIO_MMC_GPCMD_WRITE_BUFFER:
+ return "WRITE BUFFER";
+
+ case CDIO_MMC_GPCMD_READ_BUFFER:
+ return "READ_BUFFER";
+
+ case CDIO_MMC_GPCMD_READ_SUBCHANNEL:
+ return "READ_SUBCHANNEL";
+
+ case CDIO_MMC_GPCMD_READ_TOC:
+ return "READ TOC";
+
+ case CDIO_MMC_GPCMD_READ_HEADER:
+ return "READ_HEADER";
+
+ case CDIO_MMC_GPCMD_PLAY_AUDIO_10:
+ return "PLAY AUDIO (10)";
+
+ case CDIO_MMC_GPCMD_GET_CONFIGURATION:
+ return "GET_CONFIGURATION";
+
+ case CDIO_MMC_GPCMD_PLAY_AUDIO_MSF:
+ return "PLAY AUDIO MSF";
+
+ case CDIO_MMC_GPCMD_PLAY_AUDIO_TI:
+ return "PLAY_AUDIO TI";
+
+ case CDIO_MMC_GPCMD_PLAY_TRACK_REL_10:
+ return "PLAY TRACK REL (10)";
+
+ case CDIO_MMC_GPCMD_GET_EVENT_STATUS:
+ return "GET EVENT STATUS";
+
+ case CDIO_MMC_GPCMD_PAUSE_RESUME:
+ return "PAUSE RESUME";
+
+ case CDIO_MMC_GPCMD_READ_DISC_INFORMATION:
+ return "READ DISC INFORMATION";
+
+ case CDIO_MMC_GPCMD_READ_TRACK_INFORMATION:
+ return "READ TRACK INFORMATION";
+
+ case CDIO_MMC_GPCMD_RESERVE_TRACK:
+ return "RESERVE TRACK";
+
+ case CDIO_MMC_GPCMD_SEND_OPC_INFORMATION:
+ return "SEND OPC INFORMATION";
+
+ case CDIO_MMC_GPCMD_MODE_SELECT_10:
+ return "MODE SELECT (10)";
+
+ case CDIO_MMC_GPCMD_REPAIR_TRACK:
+ return "REPAIR_TRACK";
+
+ case CDIO_MMC_GPCMD_MODE_SENSE_10:
+ return "MODE SENSE (10)";
+
+ case CDIO_MMC_GPCMD_CLOSE_TRACK_SESSION:
+ return "CLOSE TRACK SESSION";
+
+ case CDIO_MMC_GPCMD_READ_BUFFER_CAPACITY:
+ return "READ_BUFFER CAPACITY";
+
+ case CDIO_MMC_GPCMD_SEND_CUE_SHEET:
+ return "SEND_CUE SHEET";
+
+ case CDIO_MMC_GPCMD_REPORT_LUNS:
+ return "REPORT LUNS";
+
+ case CDIO_MMC_GPCMD_BLANK:
+ return "BLANK";
+
+ case CDIO_MMC_GPCMD_SECURITY_PROTOCOL_IN:
+ return "SECURITY PROTOCOL IN";
+
+ case CDIO_MMC_GPCMD_SEND_KEY:
+ return "SEND KEY";
+
+ case CDIO_MMC_GPCMD_REPORT_KEY:
+ return "REPORT KEY";
+
+ case CDIO_MMC_GPCMD_PLAY_AUDIO_12:
+ return "PLAY_AUDIO (12)";
+
+ case CDIO_MMC_GPCMD_LOAD_UNLOAD:
+ return "LOAD UNLOAD";
+
+ case CDIO_MMC_GPCMD_SET_READ_AHEAD:
+ return "SET READ AHEAD";
+
+ case CDIO_MMC_GPCMD_READ_12:
+ return "READ (12)";
+
+ case CDIO_MMC_GPCMD_PLAY_TRACK_REL_12:
+ return "PLAY_TRACK REL (12)";
+
+ case CDIO_MMC_GPCMD_WRITE_12:
+ return "WRITE (12)";
+
+ case CDIO_MMC_GPCMD_READ_MEDIA_SERIAL_12:
+ return "READ MEDIA SERIAL (12)";
+
+ case CDIO_MMC_GPCMD_GET_PERFORMANCE:
+ return "GET PERFORMANCE";
+
+ case CDIO_MMC_GPCMD_READ_DVD_STRUCTURE:
+ return "READ DVD STRUCTURE";
+
+ case CDIO_MMC_GPCMD_SECURITY_PROTOCOL_OUT:
+ return "SECURITY PROTOCOL_OUT";
+
+ case CDIO_MMC_GPCMD_SET_STREAMING:
+ return "SET STREAMING";
+
+ case CDIO_MMC_GPCMD_READ_MSF:
+ return "READ MSF";
+
+ case CDIO_MMC_GPCMD_SET_SPEED:
+ return "SET SPEED";
+
+ case CDIO_MMC_GPCMD_MECHANISM_STATUS:
+ return "MECHANISM STATUS";
+
+ case CDIO_MMC_GPCMD_READ_CD:
+ return "READ CD";
+
+ case CDIO_MMC_GPCMD_SEND_DISC_STRUCTURE:
+ return "SEND DISC STRUCTURE";
+
+ case CDIO_MMC_GPCMD_CD_PLAYBACK_STATUS:
+ return "CD PLAYBACK STATUS";
+
+ case CDIO_MMC_GPCMD_PLAYBACK_CONTROL:
+ return "PLAYBACK CONTROL";
+
+ case CDIO_MMC_GPCMD_READ_CDDA:
+ return "READ CDDA";
+
+ case CDIO_MMC_GPCMD_READ_CDXA:
+ return "READ CDXA";
+
+ case CDIO_MMC_GPCMD_READ_ALL_SUBCODES:
+ return "READ ALL SUBCODES";
+
+ default:
+ {
+ char buf[30];
+ snprintf(buf, sizeof(buf), "Unknown 0x%x", command);
+ return strdup(buf);
+ }
+ }
+}
/*************************************************************************
MMC CdIo Operations which a driver may use.
diff --git a/make-check-filter.rb b/make-check-filter.rb
index 01b56d4b..d1070393 100755
--- a/make-check-filter.rb
+++ b/make-check-filter.rb
@@ -17,6 +17,8 @@ pats = '(' +
"^ vcd_demo.right",
'^-- ',
'^-+$',
+ '^<<+$',
+ '^>>+$',
'^\s*$',
].join('|') + ')'
# puts pats
diff --git a/test/driver/mmc_read.c b/test/driver/mmc_read.c
index 20af068f..5f7c728b 100644
--- a/test/driver/mmc_read.c
+++ b/test/driver/mmc_read.c
@@ -411,12 +411,20 @@ main(int argc, const char *argv[])
cdio_loglevel_default = b_verbose ? CDIO_LOG_DEBUG : CDIO_LOG_INFO;
+ if (0 !=
+ strncmp("TEST UNIT READY", mmc_cmd2str(CDIO_MMC_GPCMD_TEST_UNIT_READY),
+ sizeof("TEST UNIT READY"))) {
+ printf("Expecting mmc_cmd2str to give 'TEST UNIT READY' for code 0x%x\n",
+ CDIO_MMC_GPCMD_TEST_UNIT_READY);
+ exit(1);
+ }
+
ppsz_drives = cdio_get_devices(DRIVER_DEVICE);
if (!ppsz_drives) {
printf("Can't find a CD-ROM drive. Skipping test.\n");
exit(SKIP_TEST);
}
-
+
p_cdio = cdio_open(ppsz_drives[0], DRIVER_DEVICE);
if (p_cdio) {
const char *psz_have_mmc = cdio_get_arg(p_cdio, "mmc-supported?");