diff --git a/include/cdio/mmc.h b/include/cdio/mmc.h index d6eb9a64..aae31e93 100644 --- a/include/cdio/mmc.h +++ b/include/cdio/mmc.h @@ -540,11 +540,13 @@ mmc_audio_read_subchannel (CdIo_t *p_cdio, /** Detects if a disc (CD or DVD) is erasable or not. @param p_user_data the CD object to be acted upon. + @param i_status on return will be set indicate whether the operation + was a success (DRIVER_OP_SUCCESS) or if not to some other value. @return true if the disc is detected as erasable (rewritable), false otherwise. */ - bool - mmc_get_disc_erasable( const CdIo_t *p_cdio ); + bool mmc_get_disc_erasable( const CdIo_t *p_cdio, + driver_return_code_t *i_status ); /** Get the lsn of the end of the CD @@ -620,7 +622,8 @@ mmc_audio_read_subchannel (CdIo_t *p_cdio, @return DRIVER_OP_SUCCESS (0) if we got the status. return codes are the same as driver_return_code_t */ - int mmc_get_event_status(const CdIo_t *p_cdio, uint8_t out_buf[2]); + driver_return_code_t mmc_get_event_status(const CdIo_t *p_cdio, + uint8_t out_buf[2]); /** Find out if media tray is open or closed. diff --git a/lib/driver/mmc.c b/lib/driver/mmc.c index 0d1e3ead..45219f2f 100644 --- a/lib/driver/mmc.c +++ b/lib/driver/mmc.c @@ -683,21 +683,22 @@ mmc_get_cmd_len(uint8_t scsi_cmd) /** Detects if a disc (CD or DVD) is erasable or not. @param p_user_data the CD object to be acted upon. + @param i_status on return will be set indicate whether the operation + was a success (DRIVER_OP_SUCCESS) or if not to some other value. @return true if the disc is detected as erasable (rewritable), false otherwise. */ bool -mmc_get_disc_erasable( const CdIo_t *p_cdio ) { + mmc_get_disc_erasable( const CdIo_t *p_cdio, driver_return_code_t *i_status ) { mmc_cdb_t cdb = {{0, }}; uint8_t buf[42] = { 0, }; - int i_status; CDIO_MMC_SET_COMMAND (cdb.field, CDIO_MMC_GPCMD_READ_DISC_INFO); CDIO_MMC_SET_READ_LENGTH8 (cdb.field, sizeof(buf)); - i_status = mmc_run_cmd (p_cdio, 0, &cdb, SCSI_MMC_DATA_READ, + *i_status = mmc_run_cmd (p_cdio, 0, &cdb, SCSI_MMC_DATA_READ, sizeof(buf), &buf); - if (i_status == 0) { + if (*i_status == 0) { if (buf[2] & 0x10) return true; else @@ -960,7 +961,8 @@ mmc_get_hwinfo ( const CdIo_t *p_cdio, @return DRIVER_OP_SUCCESS (0) if we got the status. return codes are the same as driver_return_code_t */ -int mmc_get_event_status(const CdIo_t *p_cdio, uint8_t out_buf[2]) +driver_return_code_t +mmc_get_event_status(const CdIo_t *p_cdio, uint8_t out_buf[2]) { mmc_cdb_t cdb = {{0, }}; uint8_t buf[8] = { 0, }; @@ -981,12 +983,11 @@ int mmc_get_event_status(const CdIo_t *p_cdio, uint8_t out_buf[2]) mmc_get_cmd_len(cdb.field[0]), &cdb, SCSI_MMC_DATA_READ, sizeof(buf), buf); - if(i_status == 0) { + if(i_status == DRIVER_OP_SUCCESS) { out_buf[0] = buf[4]; out_buf[1] = buf[5]; - return DRIVER_OP_SUCCESS; } - return DRIVER_OP_ERROR; + return i_status; } /** diff --git a/test/driver/mmc.c b/test/driver/mmc.c index dae94043..ca981a1c 100644 --- a/test/driver/mmc.c +++ b/test/driver/mmc.c @@ -45,8 +45,9 @@ static int tmmc_eject_load_cycle(CdIo_t *p_cdio, int flag); static int tmmc_eject_test_load(CdIo_t *p_cdio, int flag); -static void tmmc_get_disc_erasable(const CdIo_t *p_cdio, const char *psz_source, - int verbose); +static driver_return_code_t tmmc_get_disc_erasable(const CdIo_t *p_cdio, + const char *psz_source, + int verbose); static int tmmc_handle_outcome(CdIo_t *p_cdio, int i_status, int *sense_avail, @@ -78,12 +79,14 @@ static int tmmc_test(char *drive_path, int flag); /* ------------------------- Helper functions ---------------------------- */ -static void +static driver_return_code_t tmmc_get_disc_erasable(const CdIo_t *p_cdio, const char *psz_source, int verbose) { - bool b_erasable = mmc_get_disc_erasable(p_cdio); + driver_return_code_t drc; + bool b_erasable = mmc_get_disc_erasable(p_cdio, &drc); printf("disk is %serasable.\n", b_erasable ? "" : "not "); + return drc; } @@ -743,7 +746,10 @@ main(int argc, const char *argv[]) char **ppsz_drives=NULL; const char *psz_source = NULL; int ret; + int exitrc = 0; bool b_verbose = (argc > 1); + driver_return_code_t drc; + cdio_loglevel_default = b_verbose ? CDIO_LOG_DEBUG : CDIO_LOG_INFO; @@ -769,8 +775,12 @@ main(int argc, const char *argv[]) exit(1); } - tmmc_get_disc_erasable(p_cdio, psz_source, b_verbose); - + drc = tmmc_get_disc_erasable(p_cdio, psz_source, b_verbose); + if (DRIVER_OP_SUCCESS != drc) { + printf("Got status %d back from get_disc_erasable(%s)\n", + drc, psz_source); + } + if ( psz_have_mmc && 0 == strncmp("true", psz_have_mmc, sizeof("true")) && (DRIVER_WIN32 != cdio_get_driver_id(p_cdio)) ) { @@ -797,7 +807,7 @@ main(int argc, const char *argv[]) cdio_free_device_list(ppsz_drives); - return 0; + return exitrc; }