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

bool K3bDevice::Device::modeSense ( unsigned char **  pageData,
int &  pageLen,
int  page 
) const

if true is returned pageLen specifies the actual length of *pageData which needs to be deleted after using.

Definition at line 607 of file k3bdevice_mmc.cpp.

References blockDeviceName().

Referenced by determineMaximalWriteSpeed().

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

  ScsiCommand cmd( this );
  cmd[0] = MMC_MODE_SENSE;
  cmd[1] = 0x08;        // Disable Block Descriptors
  cmd[2] = page;
  cmd[8] = 8;           // first we determine the data length
  if( cmd.transport( TR_DIR_READ, header, 8 ) == 0 ) {
    // again with real length
    pageLen = 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( pageLen == 8 ) {
      cmd[7] = 2048>>8;
      cmd[8] = 2048;
      if( cmd.transport( TR_DIR_READ, header, 2048 ) == 0 )
      pageLen = from2Byte( header ) + 2;
    }

    *pageData = new unsigned char[pageLen];
    ::memset( *pageData, 0, pageLen );

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

  return false;
}


Generated by  Doxygen 1.6.0   Back to index