improve mapping from scsi index to scsi device

This commit is contained in:
Chris Danford
2004-10-15 13:47:54 +00:00
parent f212eeb458
commit c23c0bec17
@@ -327,10 +327,17 @@ void MemoryCardDriverThreaded_Linux::MountThreadDoOneUpdate()
// read name
this->Mount( &d, TEMP_MOUNT_POINT );
FILEMAN->FlushDirCache( TEMP_MOUNT_POINT );
#if 1
Profile profile;
CString sProfileDir = TEMP_MOUNT_POINT + PREFSMAN->m_sMemoryCardProfileSubdir + '/';
profile.LoadEditableDataFromDir( sProfileDir );
d.sName = profile.GetDisplayName();
#else
/* XXX read a file anyway */
CString sProfileDir = TEMP_MOUNT_POINT + PREFSMAN->m_sMemoryCardProfileSubdir + '/';
d.sName = "foo";
#endif
UnmountMountPoint( TEMP_MOUNT_POINT );
LOG->Trace( "WriteTest: %s, Name: %s", d.bWriteTestSucceeded ? "succeeded" : "failed", d.sName.c_str() );
@@ -529,7 +536,9 @@ void GetNewStorageDevices( vector<UsbStorageDevice>& vDevicesOut )
vDevicesOut.clear();
{
// Bus 002 Device 001: ID 0000:0000
// Discover what storage class devices are connected. Output looks like:
// Bus 002 Device 001: ID 0a03:0b05
// Port 4
// iSerial 3 1125198948886
// bInterfaceClass 8 Mass Storage
@@ -612,6 +621,7 @@ void GetNewStorageDevices( vector<UsbStorageDevice>& vDevicesOut )
}
}
{
// Find the usb-storage device index for all storage class devices.
@@ -635,9 +645,24 @@ void GetNewStorageDevices( vector<UsbStorageDevice>& vDevicesOut )
}
closedir( dirp );
dirp = NULL;
}
else
{
// 2.4 kernel style
// Find the usb-storage device index for all storage class devices.
for( unsigned i=0; true; i++ )
{
CString fn = ssprintf( "/proc/scsi/usb-storage-%d/%d", i, i );
if( !ReadUsbStorageDescriptor( fn, i, vDevicesOut ) )
break;
}
}
}
// Get the mapping from Scsi device number to Scsi file device. Requires "sg-utils".
{
// Get the mapping from Scsi device number to Scsi file device. Requires sg-utils's
// sg_scan. It looks like:
// /dev/sg0: scsi47 channel=0 id=0 lun=0 [em] type=0
@@ -678,28 +703,10 @@ void GetNewStorageDevices( vector<UsbStorageDevice>& vDevicesOut )
}
}
}
else
{
// 2.4 kernel style
// Find the usb-storage device index for all storage class devices.
for( unsigned i=0; true; i++ )
{
CString fn = ssprintf( "/proc/scsi/usb-storage-%d/%d", i, i );
if( !ReadUsbStorageDescriptor( fn, i, vDevicesOut ) )
break;
}
for( unsigned i=0; i<vDevicesOut.size(); i++ )
{
UsbStorageDevice& usbd = vDevicesOut[i];
usbd.sScsiDevice = ssprintf("/dev/sd%c",'a'+(char)usbd.iScsiIndex);
}
}
}
{
// Find where each device is mounted. Output looks like:
// Get the mapping from SCSI device to fs mount point. Output looks like:
// /dev/sda1 /mnt/flash1 auto noauto,owner 0 0
// /dev/sdb1 /mnt/flash2 auto noauto,owner 0 0