Logo Search packages:      
Sourcecode: k9copy version File versions  Download package

bool K3bDevice::Device::getFeature ( unsigned char **  data,
int &  dataLen,
unsigned int  feature 
) const

Read a single feature. data will be filled with the feature header and the descriptor

Definition at line 37 of file k3bdevice_mmc.cpp.

References blockDeviceName().

Referenced by featureCurrent().

{
  unsigned char header[2048];
  ::memset( header, 0, 2048 );

  ScsiCommand cmd( this );
  cmd[0] = MMC_GET_CONFIGURATION;
  cmd[1] = 2;      // read only specified feature
  cmd[2] = feature>>8;
  cmd[3] = feature;
  cmd[8] = 8;      // we only read the data length first
  if( cmd.transport( TR_DIR_READ, header, 8 ) ) {
    // again with real length
    dataLen = from4Byte( header ) + 4;

    //
    // Some buggy firmwares do not return the size of the available data
    // but the returned data. So we use a high power of 2 to be on the safe side
    // with these buggy drives.
    // We cannot use this as default since many firmwares fail with a too high data length.
    //
    if( dataLen == 8 ) {
      cmd[7] = 2048>>8;
      cmd[8] = 2048;
      if( cmd.transport( TR_DIR_READ, header, 2048 ) == 0 )
      dataLen = from2Byte( header ) + 4;
    }

    *data = new unsigned char[dataLen];
    ::memset( *data, 0, dataLen );

    cmd[7] = dataLen>>8;
    cmd[8] = dataLen;
    if( cmd.transport( TR_DIR_READ, *data, dataLen ) == 0 ) {
      return true;
    }
    else {
      kdDebug() << "(K3bDevice::Device) " << blockDeviceName() << ": GET CONFIGURATION with real length "
            << dataLen << " failed." << endl;
      delete [] *data;
    }
  }
  else
    kdDebug() << "(K3bDevice::Device) " << blockDeviceName() << ": GET CONFIGURATION length det failed." << endl;

  return false;
}


Generated by  Doxygen 1.6.0   Back to index