Thanks for the code; this has now been committed in git. If there are further embellishments that can probably be easily accommodated.
As is my current custom now, any new code generally gets some sort of test associated with it, even if here the test is just to see that if the driver has MMC available we can call the routine and not SEGV. The specific test has been added to test/driver/mmc which will show results when run in verbose mode. On Thu, Jan 28, 2010 at 11:49 AM, Frank Endres <[email protected]>wrote: > Maybe this version is more reliable (no more unportable guess on buffer > state in case of error). I think it is simplier to return false in case of > an error, it is also possible to return an error code (see comments). > > /*! > Detects if a disc (CD or DVD) is erasable or not. > @return true if the disc is detected as erasable (rewritable), false > otherwise. > */ > bool /* int */ > mmc_get_disc_erasable ( const CdIo_t *p_cdio) { > 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, sizeof(buf), > &buf); > if (i_status == 0) { > if (buf[2] & 0x10) > return true; > else > return false; > } else > return false; /* return DRIVER_OP_ERROR; */ /* return i_status; */ > } > > Frank Endres >
