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

bool K3bDevice::Device::readTrackInformation ( unsigned char **  data,
int &  dataLen,
int  type,
unsigned long  value 
) const

Parameters:
type specifies what value means:
  • 00b - value refers to a logical block adress
  • 01b - value refers to a track number where 0 will treat the lead-in as if it were a logical track and ffh will read the invisible or incomplete track.
  • 10b - value refers to a session number

Definition at line 249 of file k3bdevice_mmc.cpp.

References blockDeviceName().

Referenced by diskInfo().

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

  ScsiCommand cmd( this );
  cmd[0] = MMC_READ_TRACK_INFORMATION;

  switch( type ) {
  case 0:
  case 1:
  case 2:
    cmd[1] = type & 0x3;
    cmd[2] = value>>24;
    cmd[3] = value>>16;
    cmd[4] = value>>8;
    cmd[5] = value;
    break;
  default:
    kdDebug() << "(K3bDevice::readTrackInformation) wrong type parameter: " << type << endl;
    return false;
  }

  cmd[8] = 4;      // first we read the header
  if( cmd.transport( TR_DIR_READ, header, 4 ) == 0 ) {
    // again with real length
    dataLen = from2Byte( header ) + 2;

    //
    // 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 == 4 ) {
      cmd[7] = 2048>>8;
      cmd[8] = 2048;
      if( cmd.transport( TR_DIR_READ, header, 2048 ) == 0 )
      dataLen = from2Byte( header ) + 2;
    }

    *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() << ": READ TRACK INFORMATION with real length "
            << dataLen << " failed." << endl;
      delete [] *data;
    }
  }
  else
    kdDebug() << "(K3bDevice::Device) " << blockDeviceName() << ": READ TRACK INFORMATION length det failed." << endl;

  return false;
}


Generated by  Doxygen 1.6.0   Back to index