libcdio-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Libcdio-devel] Re: Submission of new mmc function for libcdio


From: Frank Endres
Subject: Re: [Libcdio-devel] Re: Submission of new mmc function for libcdio
Date: Thu, 28 Jan 2010 15:49:28 -0100

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]