Ejemplo n.º 1
0
/*!
  Return a string containing the name of the driver in use.
  if CdIo is NULL (we haven't initialized a specific device driver), 
  then return NULL.
*/
bool
cdio_get_hwinfo (const CdIo_t *p_cdio, cdio_hwinfo_t *hw_info) 
{
  if (!p_cdio) return false;
  if (p_cdio->op.get_hwinfo) {
    return p_cdio->op.get_hwinfo (p_cdio, hw_info);
  } else {
    /* Perhaps driver forgot to initialize.  We are no worse off Using
      mmc than returning false here. */
    return mmc_get_hwinfo(p_cdio, hw_info);
  }
}
Ejemplo n.º 2
0
/**
  Get the CD-ROM hardware info via an MMC INQUIRY command.

  @return true if we were able to get hardware info, false if we had
  an error.
*/
bool mmcGetHwinfo ( /* out*/ cdio_hwinfo_t *p_hw_info )
{
    return mmc_get_hwinfo ( p_cdio, p_hw_info );
}
Ejemplo n.º 3
0
int
main(int argc, char *argv[])
{
  CdIo_t *p_cdio;

  driver_return_code_t rc = DRIVER_OP_SUCCESS;
  unsigned int i;

  init(argv[0]);
  
  parse_options(argc, argv);
  p_cdio = cdio_open (source_name, DRIVER_DEVICE);

  if (NULL == p_cdio) {
    printf("Couldn't find CD\n");
    return 1;
  } 

  for (i=0; i < last_op; i++) {
    const operation_t *p_op = &operation[i];
    switch (p_op->op) {
    case OP_SPEED:
      rc = mmc_set_speed(p_cdio, p_op->arg.i_num, 0);
      report(stdout, "%s (mmc_set_speed): %s\n", program_name, 
	     cdio_driver_errmsg(rc));
      break;
    case OP_BLOCKSIZE:
      if (p_op->arg.i_num) {
	driver_return_code_t rc = mmc_set_blocksize(p_cdio, p_op->arg.i_num);
	report(stdout, "%s (mmc_set_blocksize): %s\n", program_name, 
	       cdio_driver_errmsg(rc));
      } else {
	int i_blocksize = mmc_get_blocksize(p_cdio);
	if (i_blocksize > 0) {
	  report(stdout, "%s (mmc_get_blocksize): %d\n", program_name, 
		 i_blocksize);
	} else {
	  report(stdout, "%s (mmc_get_blocksize): can't retrieve.\n", 
		 program_name);
	}
      }
      break;
    case OP_MODE_SENSE_2A: 
      {
	uint8_t buf[30] = { 0, };    /* Place to hold returned data */
	if (p_op->arg.i_num == 10) {
	  rc = mmc_mode_sense_10(p_cdio, buf, sizeof(buf),
				 CDIO_MMC_CAPABILITIES_PAGE);
	} else {
	  rc = mmc_mode_sense_6(p_cdio, buf, sizeof(buf),
				 CDIO_MMC_CAPABILITIES_PAGE);
	}
	if (DRIVER_OP_SUCCESS == rc) {
	  print_mode_sense(p_op->arg.i_num, buf);
	} else {
	  report(stdout, "%s (mmc_mode_sense 2a - drive_cap %d): %s\n", 
		 program_name, p_op->arg.i_num, cdio_driver_errmsg(rc));
	}
      }
      break;
    case OP_CLOSETRAY:
      rc = mmc_close_tray(p_cdio);
      report(stdout, "%s (mmc_close_tray): %s\n", program_name, 
	     cdio_driver_errmsg(rc));
      free(p_op->arg.psz);
      break;
    case OP_EJECT:
      rc = mmc_eject_media(p_cdio);
      report(stdout, "%s (mmc_eject_media): %s\n", program_name, 
	     cdio_driver_errmsg(rc));
      if (p_op->arg.psz) free(p_op->arg.psz);
      break;
    case OP_IDLE:
      rc = mmc_start_stop_unit(p_cdio, false, false, true, 0);
      report(stdout, "%s (mmc_start_stop_media - powerdown): %s\n", 
	     program_name, cdio_driver_errmsg(rc));
      break;
    case OP_INQUIRY: 
      {
	cdio_hwinfo_t hw_info = { "", "", ""}; 
	if (mmc_get_hwinfo(p_cdio, &hw_info)) {
	  printf("%-8s: %s\n%-8s: %s\n%-8s: %s\n",
		 "Vendor"  , hw_info.psz_vendor, 
		 "Model"   , hw_info.psz_model, 
		 "Revision", hw_info.psz_revision);
	} else {
	  report(stdout, "%s (mmc_gpcmd_inquiry error)\n", program_name);
	}
      }
      break;
    case OP_MCN: 
      {
	char *psz_mcn = mmc_get_mcn(p_cdio);
	if (psz_mcn) {
	  report(stdout, "%s (mmc_get_mcn): %s\n", program_name, psz_mcn);
	  free(psz_mcn);
	} else
	  report(stdout, "%s (mmc_get_mcn): can't retrieve\n", program_name);
      }
      break;
    default:
      ;
    }
  }

  free(source_name);
  cdio_destroy(p_cdio);
  
  return rc;
}