Exemplo n.º 1
0
int
main(int argc, const char *argv[])
{
  CdIo_t *p_cdio;
  const char *psz_drive = NULL;

  if (argc > 1) psz_drive = argv[1];
  p_cdio = cdio_open (psz_drive, DRIVER_UNKNOWN);

  if (!p_cdio) {
    printf("Couldn't find CD\n");
    return 1;
  } else {
    uint8_t buf[22] = { 0, };    /* Place to hold returned data */
    char *psz_cd = cdio_get_default_device(p_cdio);
    if (DRIVER_OP_SUCCESS == mmc_mode_sense_6(p_cdio, buf, sizeof(buf),
					      CDIO_MMC_CAPABILITIES_PAGE) ) {
      print_mode_sense(psz_cd, "6", buf);
    } else {
      printf("Couldn't get MODE_SENSE 6 data.\n");
    }
    if (DRIVER_OP_SUCCESS == mmc_mode_sense_10(p_cdio, buf, sizeof(buf),
					       CDIO_MMC_CAPABILITIES_PAGE) ) {
      print_mode_sense(psz_cd, "10", buf);
    } else {
      printf("Couldn't get MODE_SENSE 10 data.\n");
    }
    free(psz_cd);
  }
  
  cdio_destroy(p_cdio);
  
  return 0;
}
Exemplo n.º 2
0
/**
    Run a MODE_SENSE command (10-byte version)
    and put the results in p_buf
    @return DRIVER_OP_SUCCESS if we ran the command ok.
*/
int mmcModeSense10( /*out*/ void *p_buf, int i_size, int page)
{
    return mmc_mode_sense_10( p_cdio, /*out*/ p_buf, i_size, page);
}
Exemplo 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;
}