@ -199,6 +199,10 @@ unsigned long TDEStorageDevice::deviceSize() {
blocksize = stream . readLine ( ) ;
bsfile . close ( ) ;
}
else {
// Drat, I can't get a gauranteed block size. Assume a block size of 512, as everything I have read indicates that /sys/block/<dev>/size is given in terms of a 512 byte block...
blocksize = " 512 " ;
}
TQString dsnodename = systemPath ( ) ;
dsnodename . append ( " /size " ) ;
@ -299,7 +303,12 @@ TQString TDEStorageDevice::mountPath() {
return TQString : : null ;
}
TQString TDEStorageDevice : : mountDevice ( TQString mediaName ) {
TQString TDEStorageDevice : : mountDevice ( TQString mediaName , TQString mountOptions , TQString * errRet , int * retcode ) {
int internal_retcode ;
if ( ! retcode ) {
retcode = & internal_retcode ;
}
TQString ret = mountPath ( ) ;
if ( ! ret . isNull ( ) ) {
@ -310,19 +319,36 @@ TQString TDEStorageDevice::mountDevice(TQString mediaName) {
KTempFile passwordFile ( TQString : : null , " tmp " , 0600 ) ;
passwordFile . setAutoDelete ( true ) ;
TQString command = TQString ( " pmount -p %1 %2 " ) . arg ( passwordFile . name ( ) ) . arg ( deviceNode ( ) ) ;
TQString command = TQString ( " pmount -p %1 %2 %3 2>&1 " ) . arg ( passwordFile . name ( ) ) . arg ( mountOptions ) . arg ( deviceNode ( ) ) ;
if ( ! mediaName . isNull ( ) ) {
command . append ( mediaName ) ;
}
if ( system ( command . ascii ( ) ) = = 0 ) {
FILE * exepipe = popen ( command . ascii ( ) , " r " ) ;
if ( exepipe ) {
TQString pmount_output ;
char buffer [ 8092 ] ;
pmount_output = fgets ( buffer , sizeof ( buffer ) , exepipe ) ;
* retcode = pclose ( exepipe ) ;
if ( * retcode = = 0 ) {
ret = mountPath ( ) ;
}
else {
if ( errRet ) {
* errRet = pmount_output ;
}
}
}
return ret ;
}
TQString TDEStorageDevice : : mountEncryptedDevice ( TQString passphrase , TQString mediaName ) {
TQString TDEStorageDevice : : mountEncryptedDevice ( TQString passphrase , TQString mediaName , TQString mountOptions , TQString * errRet , int * retcode ) {
int internal_retcode ;
if ( ! retcode ) {
retcode = & internal_retcode ;
}
TQString ret = mountPath ( ) ;
if ( ! ret . isNull ( ) ) {
@ -340,29 +366,58 @@ TQString TDEStorageDevice::mountEncryptedDevice(TQString passphrase, TQString me
pwFile - > writeBlock ( passphrase . ascii ( ) , passphrase . length ( ) ) ;
pwFile - > flush ( ) ;
TQString command = TQString ( " pmount -p %1 %2 " ) . arg ( passwordFile . name ( ) ) . arg ( deviceNode ( ) ) ;
TQString command = TQString ( " pmount -p %1 %2 %3 2>&1 " ) . arg ( passwordFile . name ( ) ) . arg ( mountOptions ) . arg ( deviceNode ( ) ) ;
if ( ! mediaName . isNull ( ) ) {
command . append ( mediaName ) ;
}
if ( system ( command . ascii ( ) ) = = 0 ) {
FILE * exepipe = popen ( command . ascii ( ) , " r " ) ;
if ( exepipe ) {
TQString pmount_output ;
char buffer [ 8092 ] ;
pmount_output = fgets ( buffer , sizeof ( buffer ) , exepipe ) ;
* retcode = pclose ( exepipe ) ;
if ( * retcode = = 0 ) {
ret = mountPath ( ) ;
}
else {
if ( errRet ) {
* errRet = pmount_output ;
}
}
}
return ret ;
}
bool TDEStorageDevice : : unmountDevice ( ) {
bool TDEStorageDevice : : unmountDevice ( TQString * errRet , int * retcode ) {
int internal_retcode ;
if ( ! retcode ) {
retcode = & internal_retcode ;
}
TQString mountpoint = mountPath ( ) ;
if ( mountpoint . isNull ( ) ) {
return true ;
}
TQString command = TQString ( " pumount %1 " ) . arg ( mountpoint ) ;
if ( system ( command . ascii ( ) ) = = 0 ) {
TQString command = TQString ( " pumount %1 2>&1 " ) . arg ( mountpoint ) ;
FILE * exepipe = popen ( command . ascii ( ) , " r " ) ;
if ( exepipe ) {
TQString pmount_output ;
char buffer [ 8092 ] ;
pmount_output = fgets ( buffer , sizeof ( buffer ) , exepipe ) ;
* retcode = pclose ( exepipe ) ;
if ( * retcode = = 0 ) {
return true ;
}
else {
if ( errRet ) {
* errRet = pmount_output ;
}
}
}
return false ;
}
@ -386,6 +441,18 @@ TDEHardwareDevices::TDEHardwareDevices() {
m_devScanNotifier = new TQSocketNotifier ( udev_monitor_get_fd ( m_udevMonitorStruct ) , TQSocketNotifier : : Read , this ) ;
connect ( m_devScanNotifier , TQT_SIGNAL ( activated ( int ) ) , this , TQT_SLOT ( processHotPluggedHardware ( ) ) ) ;
// Read in the current mount table
// Yes, a race condition exists between this and the mount monitor start below, but it shouldn't be a problem 99.99% of the time
m_mountTable . clear ( ) ;
TQFile file ( " /proc/mounts " ) ;
if ( file . open ( IO_ReadOnly ) ) {
TQTextStream stream ( & file ) ;
while ( ! stream . atEnd ( ) ) {
m_mountTable . append ( stream . readLine ( ) ) ;
}
file . close ( ) ;
}
// Monitor for changed mounts
m_procMountsFd = open ( " /proc/mounts " , O_RDONLY , 0 ) ;
m_mountScanNotifier = new TQSocketNotifier ( m_procMountsFd , TQSocketNotifier : : Exception , this ) ;
@ -415,6 +482,17 @@ TDEGenericDevice* TDEHardwareDevices::findBySystemPath(TQString syspath) {
return 0 ;
}
TDEGenericDevice * TDEHardwareDevices : : findByDeviceNode ( TQString devnode ) {
TDEGenericDevice * hwdevice ;
for ( hwdevice = m_deviceList . first ( ) ; hwdevice ; hwdevice = m_deviceList . next ( ) ) {
if ( hwdevice - > deviceNode ( ) = = devnode ) {
return hwdevice ;
}
}
return 0 ;
}
TDEStorageDevice * TDEHardwareDevices : : findDiskByUID ( TQString uid ) {
TDEGenericDevice * hwdevice ;
for ( hwdevice = m_deviceList . first ( ) ; hwdevice ; hwdevice = m_deviceList . next ( ) ) {
@ -448,7 +526,7 @@ void TDEHardwareDevices::processHotPluggedHardware() {
if ( device ) {
m_deviceList . append ( device ) ;
emit hardwareAdded ( * device ) ;
emit hardwareAdded ( device ) ;
}
}
else if ( actionevent = = " remove " ) {
@ -457,12 +535,24 @@ void TDEHardwareDevices::processHotPluggedHardware() {
TDEGenericDevice * hwdevice ;
for ( hwdevice = m_deviceList . first ( ) ; hwdevice ; hwdevice = m_deviceList . next ( ) ) {
if ( hwdevice - > systemPath ( ) = = systempath ) {
emit hardwareRemoved ( * hwdevice ) ;
emit hardwareRemoved ( hwdevice ) ;
m_deviceList . remove ( hwdevice ) ;
break ;
}
}
}
else if ( actionevent = = " change " ) {
// Update device and emit change event
TQString systempath ( udev_device_get_syspath ( dev ) ) ;
TDEGenericDevice * hwdevice ;
for ( hwdevice = m_deviceList . first ( ) ; hwdevice ; hwdevice = m_deviceList . next ( ) ) {
if ( hwdevice - > systemPath ( ) = = systempath ) {
classifyUnknownDevice ( dev , hwdevice ) ;
// emit hardwareUpdated(hwdevice); // FIXME certain devices (***cough U3 system fake CD cough*** spam this quite badly, locking up anything monitoring hardwareUpdated()
break ;
}
}
}
}
}
@ -471,99 +561,82 @@ void TDEHardwareDevices::processModifiedMounts() {
// Detect what changed between the old mount table and the new one,
// and emit appropriate events
emit mountTableModified ( ) ;
TQStringList deletedEntries = m_mountTable ;
// Read in the new mount table
m_mountTable . clear ( ) ;
TQFile file ( " /proc/mounts " ) ;
if ( file . open ( IO_ReadOnly ) ) {
TQTextStream stream ( & file ) ;
while ( ! stream . atEnd ( ) ) {
m_mountTable . append ( stream . readLine ( ) ) ;
}
file . close ( ) ;
}
TDEGenericDevice * TDEHardwareDevices : : classifyUnknownDevice ( udev_device * dev ) {
// Classify device and create TDEW device object
TQString devicename ( udev_device_get_sysname ( dev ) ) ;
TQString devicetype ( udev_device_get_devtype ( dev ) ) ;
TQString devicedriver ( udev_device_get_driver ( dev ) ) ;
TQString devicesubsystem ( udev_device_get_subsystem ( dev ) ) ;
TQString devicenode ( udev_device_get_devnode ( dev ) ) ;
TQString systempath ( udev_device_get_syspath ( dev ) ) ;
bool removable = false ;
TDEGenericDevice * device = 0 ;
TQStringList addedEntries = m_mountTable ;
// Remove all entries that are identical in both tables
processModifiedMounts_removeagain :
for ( TQStringList : : Iterator delit = deletedEntries . begin ( ) ; delit ! = deletedEntries . end ( ) ; + + delit ) {
for ( TQStringList : : Iterator addit = addedEntries . begin ( ) ; addit ! = addedEntries . end ( ) ; + + addit ) {
if ( ( * delit ) = = ( * addit ) ) {
deletedEntries . remove ( delit ) ;
addedEntries . remove ( addit ) ;
// Reset iterators to prevent bugs/crashes
// FIXME
// Only a small subset of devices are classified right now
// Figure out the remaining udev logic to classify the rest!
// Helpful file: http://www.enlightenment.org/svn/e/trunk/PROTO/enna-explorer/src/bin/udev.c
if ( ( devicetype = = " disk " ) | | ( devicetype = = " partition " ) ) {
// Determine if disk is removable
TQString removablenodename = udev_device_get_syspath ( dev ) ;
removablenodename . append ( " /removable " ) ;
FILE * fp = fopen ( removablenodename . ascii ( ) , " r " ) ;
if ( fp ) {
if ( fgetc ( fp ) = = ' 1 ' ) {
removable = true ;
// Is there any way to completely reset both loops without using goto?
goto processModifiedMounts_removeagain ;
}
}
fclose ( fp ) ;
}
// See if any other devices are exclusively using this device, such as the Device Mapper|
TQStringList holdingDeviceNodes ;
TQString holdersnodename = udev_device_get_syspath ( dev ) ;
holdersnodename . append ( " /holders/ " ) ;
T QDir holdersdir ( holdersnodename ) ;
holdersdir . setFilter ( TQDir : : All ) ;
const TQFileInfoList * dirlist = holdersdir . entryInfoList ( ) ;
if ( dirlist ) {
TQFileInfoListIterator holdersdirit ( * dirlist ) ;
TQFileInfo * dirfi ;
while ( ( dirfi = holdersdirit . current ( ) ) ! = 0 ) {
if ( dirfi - > isSymLink ( ) ) {
char * collapsedPath = realpath ( ( holdersnodename + dirfi - > readLink ( ) ) . ascii ( ) , NULL ) ;
holdingDeviceNodes . append ( TQString ( collapsedPath ) ) ;
free ( collapsedPath ) ;
TQStringList : : Iterator it ;
for ( it = addedEntries . begin ( ) ; it ! = addedEntries . end ( ) ; + + it ) {
TQStringList mountInfo = TQStringList : : split ( " " , ( * it ) , true ) ;
// Try to find a device that matches the altered node
TDEGenericDevice * hwdevice = findByDeviceNode ( * mountInfo . at ( 0 ) ) ;
if ( hwdevice ) {
emit hardwareUpdated ( hwdevice ) ;
// If the device is a storage device and has a slave, update it as well
if ( hwdevice - > type ( ) = = TDEGenericDeviceType : : Disk ) {
TDEStorageDevice * sdevice = static_cast < TDEStorageDevice * > ( hwdevice ) ;
TQStringList slavedevices = sdevice - > slaveDevices ( ) ;
for ( TQStringList : : Iterator slaveit = addedEntries . begin ( ) ; slaveit ! = addedEntries . end ( ) ; + + slaveit ) {
TDEGenericDevice * slavedevice = findBySystemPath ( * slaveit ) ;
if ( slavedevice ) {
emit hardwareUpdated ( slavedevice ) ;
}
+ + holdersdirit ;
}
}
// See if any other physical devices underlie this device, for example when the Device Mapper is in use
TQStringList slaveDeviceNodes ;
TQString slavesnodename = udev_device_get_syspath ( dev ) ;
slavesnodename . append ( " /slaves/ " ) ;
TQDir slavedir ( slavesnodename ) ;
slavedir . setFilter ( TQDir : : All ) ;
dirlist = slavedir . entryInfoList ( ) ;
if ( dirlist ) {
TQFileInfoListIterator slavedirit ( * dirlist ) ;
TQFileInfo * dirfi ;
while ( ( dirfi = slavedirit . current ( ) ) ! = 0 ) {
if ( dirfi - > isSymLink ( ) ) {
char * collapsedPath = realpath ( ( slavesnodename + dirfi - > readLink ( ) ) . ascii ( ) , NULL ) ;
slaveDeviceNodes . append ( TQString ( collapsedPath ) ) ;
free ( collapsedPath ) ;
}
+ + slavedirit ;
}
for ( it = deletedEntries . begin ( ) ; it ! = deletedEntries . end ( ) ; + + it ) {
TQStringList mountInfo = TQStringList : : split ( " " , ( * it ) , true ) ;
// Try to find a device that matches the altered node
TDEGenericDevice * hwdevice = findByDeviceNode ( * mountInfo . at ( 0 ) ) ;
if ( hwdevice ) {
emit hardwareUpdated ( hwdevice ) ;
// If the device is a storage device and has a slave, update it as well
if ( hwdevice - > type ( ) = = TDEGenericDeviceType : : Disk ) {
TDEStorageDevice * sdevice = static_cast < TDEStorageDevice * > ( hwdevice ) ;
TQStringList slavedevices = sdevice - > slaveDevices ( ) ;
for ( TQStringList : : Iterator slaveit = addedEntries . begin ( ) ; slaveit ! = addedEntries . end ( ) ; + + slaveit ) {
TDEGenericDevice * slavedevice = findBySystemPath ( * slaveit ) ;
if ( slavedevice ) {
emit hardwareUpdated ( slavedevice ) ;
}
}
}
}
}
device = new TDEStorageDevice ( TDEGenericDeviceType : : Disk ) ;
// Determine generic disk information
TQString devicevendor ( udev_device_get_property_value ( dev , " ID_VENDOR " ) ) ;
TQString devicemodel ( udev_device_get_property_value ( dev , " ID_MODEL " ) ) ;
TQString devicebus ( udev_device_get_property_value ( dev , " ID_BUS " ) ) ;
// Get disk specific info
TQString disktypestring ( udev_device_get_property_value ( dev , " ID_TYPE " ) ) ;
TQString disklabel ( udev_device_get_property_value ( dev , " ID_FS_LABEL " ) ) ;
TQString diskuuid ( udev_device_get_property_value ( dev , " ID_FS_UUID " ) ) ;
TQString filesystemtype ( udev_device_get_property_value ( dev , " ID_FS_TYPE " ) ) ;
TQString filesystemusage ( udev_device_get_property_value ( dev , " ID_FS_USAGE " ) ) ;
device - > setVendorName ( devicevendor ) ;
device - > setVendorModel ( devicemodel ) ;
device - > setDeviceBus ( devicebus ) ;
TDEStorageDevice * sdevice = static_cast < TDEStorageDevice * > ( device ) ;
emit mountTableModified ( ) ;
}
TDEDiskDeviceType : : TDEDiskDeviceType classifyDiskType ( udev_device * dev , const TQString & devicebus , const TQString & disktypestring , const TQString & systempath , const TQString & devicevendor , const TQString & devicemodel , const TQString & filesystemtype ) {
// Classify a disk device type to the best of our ability
TDEDiskDeviceType : : TDEDiskDeviceType disktype = ( TDEDiskDeviceType : : TDEDiskDeviceType ) 0 ;
TDEDiskDeviceStatus : : TDEDiskDeviceStatus diskstatus = ( TDEDiskDeviceStatus : : TDEDiskDeviceStatus ) 0 ;
if ( devicebus . upper ( ) = = " USB " ) {
disktype = disktype | TDEDiskDeviceType : : USB ;
@ -674,15 +747,14 @@ TDEGenericDevice* TDEHardwareDevices::classifyUnknownDevice(udev_device* dev) {
if ( ( TQString ( udev_device_get_property_value ( dev , " ID_CDROM_MEDIA_VCD " ) ) = = " 1 " ) | | ( TQString ( udev_device_get_property_value ( dev , " ID_CDROM_MEDIA_SDVD " ) ) = = " 1 " ) ) {
disktype = disktype | TDEDiskDeviceType : : CDVideo ;
}
if ( TQString ( udev_device_get_property_value ( dev , " ID_CDROM_MEDIA_STATE " ) ) . upper ( ) = = " BLANK " ) {
diskstatus = diskstatus | TDEDiskDeviceStatus : : Blank ;
}
sdevice - > setMediaInserted ( ! ( TQString ( udev_device_get_property_value ( dev , " ID_CDROM_MEDIA " ) ) = = " 0 " ) ) ;
// Detect RAM and Loop devices, since udev can't seem to...
if ( systempath . startsWith ( " /sys/devices/virtual/block/ram " ) ) {
disktype = disktype | TDEDiskDeviceType : : RAM ;
}
if ( removable ) {
diskstatus = diskstatus | TDEDiskDeviceStatus : : Removable ;
if ( systempath . startsWith ( " /sys/devices/virtual/block/loop " ) ) {
disktype = disktype | TDEDiskDeviceType : : Loop ;
}
if ( filesystemtype . upper ( ) = = " CRYPTO_LUKS " ) {
@ -691,16 +763,116 @@ TDEGenericDevice* TDEHardwareDevices::classifyUnknownDevice(udev_device* dev) {
else if ( filesystemtype . upper ( ) = = " CRYPTO " ) {
disktype = disktype | TDEDiskDeviceType : : OtherCrypted ;
}
else if ( ! filesystemtype . isNull ( ) ) {
diskstatus = diskstatus | TDEDiskDeviceStatus : : ContainsFilesystem ;
return disktype ;
}
// Detect RAM and Loop devices, since udev can't seem to...
if ( systempath . startsWith ( " /sys/devices/virtual/block/ram " ) ) {
disktype = disktype | TDEDiskDeviceType : : RAM ;
TDEGenericDevice * TDEHardwareDevices : : classifyUnknownDevice ( udev_device * dev , TDEGenericDevice * existingdevice ) {
// Classify device and create TDEW device object
TQString devicename ( udev_device_get_sysname ( dev ) ) ;
TQString devicetype ( udev_device_get_devtype ( dev ) ) ;
TQString devicedriver ( udev_device_get_driver ( dev ) ) ;
TQString devicesubsystem ( udev_device_get_subsystem ( dev ) ) ;
TQString devicenode ( udev_device_get_devnode ( dev ) ) ;
TQString systempath ( udev_device_get_syspath ( dev ) ) ;
bool removable = false ;
TDEGenericDevice * device = existingdevice ;
// FIXME
// Only a small subset of devices are classified right now
// Figure out the remaining udev logic to classify the rest!
// Helpful file: http://www.enlightenment.org/svn/e/trunk/PROTO/enna-explorer/src/bin/udev.c
if ( ( devicetype = = " disk " ) | | ( devicetype = = " partition " ) ) {
// Determine if disk is removable
TQString removablenodename = udev_device_get_syspath ( dev ) ;
removablenodename . append ( " /removable " ) ;
FILE * fp = fopen ( removablenodename . ascii ( ) , " r " ) ;
if ( fp ) {
if ( fgetc ( fp ) = = ' 1 ' ) {
removable = true ;
}
if ( systempath . startsWith ( " /sys/devices/virtual/block/loop " ) ) {
disktype = disktype | TDEDiskDeviceType : : Loop ;
fclose ( fp ) ;
}
// See if any other devices are exclusively using this device, such as the Device Mapper|
TQStringList holdingDeviceNodes ;
TQString holdersnodename = udev_device_get_syspath ( dev ) ;
holdersnodename . append ( " /holders/ " ) ;
TQDir holdersdir ( holdersnodename ) ;
holdersdir . setFilter ( TQDir : : All ) ;
const TQFileInfoList * dirlist = holdersdir . entryInfoList ( ) ;
if ( dirlist ) {
TQFileInfoListIterator holdersdirit ( * dirlist ) ;
TQFileInfo * dirfi ;
while ( ( dirfi = holdersdirit . current ( ) ) ! = 0 ) {
if ( dirfi - > isSymLink ( ) ) {
char * collapsedPath = realpath ( ( holdersnodename + dirfi - > readLink ( ) ) . ascii ( ) , NULL ) ;
holdingDeviceNodes . append ( TQString ( collapsedPath ) ) ;
free ( collapsedPath ) ;
}
+ + holdersdirit ;
}
}
// See if any other physical devices underlie this device, for example when the Device Mapper is in use
TQStringList slaveDeviceNodes ;
TQString slavesnodename = udev_device_get_syspath ( dev ) ;
slavesnodename . append ( " /slaves/ " ) ;
TQDir slavedir ( slavesnodename ) ;
slavedir . setFilter ( TQDir : : All ) ;
dirlist = slavedir . entryInfoList ( ) ;
if ( dirlist ) {
TQFileInfoListIterator slavedirit ( * dirlist ) ;
TQFileInfo * dirfi ;
while ( ( dirfi = slavedirit . current ( ) ) ! = 0 ) {
if ( dirfi - > isSymLink ( ) ) {
char * collapsedPath = realpath ( ( slavesnodename + dirfi - > readLink ( ) ) . ascii ( ) , NULL ) ;
slaveDeviceNodes . append ( TQString ( collapsedPath ) ) ;
free ( collapsedPath ) ;
}
+ + slavedirit ;
}
}
if ( ! device ) device = new TDEStorageDevice ( TDEGenericDeviceType : : Disk ) ;
// Determine generic disk information
TQString devicevendor ( udev_device_get_property_value ( dev , " ID_VENDOR " ) ) ;
TQString devicemodel ( udev_device_get_property_value ( dev , " ID_MODEL " ) ) ;
TQString devicebus ( udev_device_get_property_value ( dev , " ID_BUS " ) ) ;
// Get disk specific info
TQString disktypestring ( udev_device_get_property_value ( dev , " ID_TYPE " ) ) ;
TQString disklabel ( udev_device_get_property_value ( dev , " ID_FS_LABEL " ) ) ;
TQString diskuuid ( udev_device_get_property_value ( dev , " ID_FS_UUID " ) ) ;
TQString filesystemtype ( udev_device_get_property_value ( dev , " ID_FS_TYPE " ) ) ;
TQString filesystemusage ( udev_device_get_property_value ( dev , " ID_FS_USAGE " ) ) ;
device - > setVendorName ( devicevendor ) ;
device - > setVendorModel ( devicemodel ) ;
device - > setDeviceBus ( devicebus ) ;
TDEStorageDevice * sdevice = static_cast < TDEStorageDevice * > ( device ) ;
TDEDiskDeviceType : : TDEDiskDeviceType disktype = ( TDEDiskDeviceType : : TDEDiskDeviceType ) 0 ;
TDEDiskDeviceStatus : : TDEDiskDeviceStatus diskstatus = ( TDEDiskDeviceStatus : : TDEDiskDeviceStatus ) 0 ;
disktype = classifyDiskType ( dev , devicebus , disktypestring , systempath , devicevendor , devicemodel , filesystemtype ) ;
if ( disktypestring . upper ( ) = = " CD " ) {
if ( TQString ( udev_device_get_property_value ( dev , " ID_CDROM_MEDIA_STATE " ) ) . upper ( ) = = " BLANK " ) {
diskstatus = diskstatus | TDEDiskDeviceStatus : : Blank ;
}
sdevice - > setMediaInserted ( ! ( TQString ( udev_device_get_property_value ( dev , " ID_CDROM_MEDIA " ) ) = = " 0 " ) ) ;
}
if ( removable ) {
diskstatus = diskstatus | TDEDiskDeviceStatus : : Removable ;
}
if ( ( filesystemtype . upper ( ) ! = " CRYPTO_LUKS " ) & & ( filesystemtype . upper ( ) ! = " CRYPTO " ) & & ( ! filesystemtype . isNull ( ) ) ) {
diskstatus = diskstatus | TDEDiskDeviceStatus : : ContainsFilesystem ;
}
// Set mountable flag if device is likely to be mountable
@ -732,6 +904,8 @@ TDEGenericDevice* TDEHardwareDevices::classifyUnknownDevice(udev_device* dev) {
TQString slavediskfstype ( udev_device_get_property_value ( slavedev , " ID_FS_TYPE " ) ) ;
if ( ( slavediskfstype . upper ( ) = = " CRYPTO_LUKS " ) | | ( slavediskfstype . upper ( ) = = " CRYPTO " ) ) {
disktype = disktype | TDEDiskDeviceType : : UnlockedCrypt ;
// Set disk type based on parent device
disktype = disktype | classifyDiskType ( slavedev , TQString ( udev_device_get_property_value ( dev , " ID_BUS " ) ) , TQString ( udev_device_get_property_value ( dev , " ID_TYPE " ) ) , ( * slaveit ) , TQString ( udev_device_get_property_value ( dev , " ID_VENDOR " ) ) , TQString ( udev_device_get_property_value ( dev , " ID_MODEL " ) ) , TQString ( udev_device_get_property_value ( dev , " ID_FS_TYPE " ) ) ) ;
}
udev_device_unref ( slavedev ) ;
}
@ -768,56 +942,54 @@ TDEGenericDevice* TDEHardwareDevices::classifyUnknownDevice(udev_device* dev) {
}
sdevice - > setDiskLabel ( disklabel ) ;
printf ( " DISK DEVICE name: %s type: %s subsystem: %s vendor: %s model: %s bus: %s label: %s filesystem: %s disk type: %s disk type flags: 0x%08x media inserted: %d [Node Path: %s] [Syspath: %s] \n \r \n \r " , devicename . ascii ( ) , devicetype . ascii ( ) , devicesubsystem . ascii ( ) , devicevendor . ascii ( ) , devicemodel . ascii ( ) , devicebus . ascii ( ) , disklabel . ascii ( ) , filesystemtype . ascii ( ) , disktypestring . ascii ( ) , disktype , sdevice - > mediaInserted ( ) , devicenode . ascii ( ) , udev_device_get_syspath ( dev ) ) ; fflush ( stdout ) ;
}
else if ( devicetype . isNull ( ) ) {
if ( devicesubsystem = = " acpi " ) {
device = new TDEGenericDevice ( TDEGenericDeviceType : : OtherACPI ) ;
if ( ! device ) device = new TDEGenericDevice ( TDEGenericDeviceType : : OtherACPI ) ;
}
else if ( devicesubsystem = = " input " ) {
// Figure out if this device is a mouse, keyboard, or something else
// Check for mouse
// udev doesn't reliably help here, so guess from the device name
if ( systempath . contains ( " /mouse " ) ) {
device = new TDEGenericDevice ( TDEGenericDeviceType : : Mouse ) ;
if ( ! device ) device = new TDEGenericDevice ( TDEGenericDeviceType : : Mouse ) ;
}
if ( ! device ) {
// Second mouse check
// Look for ID_INPUT_MOUSE property presence
if ( udev_device_get_property_value ( dev , " ID_INPUT_MOUSE " ) ! = 0 ) {
device = new TDEGenericDevice ( TDEGenericDeviceType : : Mouse ) ;
if ( ! device ) device = new TDEGenericDevice ( TDEGenericDeviceType : : Mouse ) ;
}
}
if ( ! device ) {
// Check for keyboard
// Look for ID_INPUT_KEYBOARD property presence
if ( udev_device_get_property_value ( dev , " ID_INPUT_KEYBOARD " ) ! = 0 ) {
device = new TDEGenericDevice ( TDEGenericDeviceType : : Keyboard ) ;
if ( ! device ) device = new TDEGenericDevice ( TDEGenericDeviceType : : Keyboard ) ;
}
}
if ( ! device ) {
device = new TDEGenericDevice ( TDEGenericDeviceType : : HID ) ;
if ( ! device ) device = new TDEGenericDevice ( TDEGenericDeviceType : : HID ) ;
}
}
else if ( devicesubsystem = = " tty " ) {
device = new TDEGenericDevice ( TDEGenericDeviceType : : TextIO ) ;
if ( ! device ) device = new TDEGenericDevice ( TDEGenericDeviceType : : TextIO ) ;
}
else if ( devicesubsystem = = " thermal " ) {
// FIXME
// Figure out a way to differentiate between ThermalControl (fans and coolers) and ThermalSensor types
device = new TDEGenericDevice ( TDEGenericDeviceType : : ThermalControl ) ;
if ( ! device ) device = new TDEGenericDevice ( TDEGenericDeviceType : : ThermalControl ) ;
}
else if ( devicesubsystem = = " hwmon " ) {
// FIXME
// This might pick up thermal sensors
device = new TDEGenericDevice ( TDEGenericDeviceType : : OtherSensor ) ;
if ( ! device ) device = new TDEGenericDevice ( TDEGenericDeviceType : : OtherSensor ) ;
}
}
if ( device = = 0 ) {
// Unhandled
device = new TDEGenericDevice ( TDEGenericDeviceType : : Other ) ;
if ( ! device ) device = new TDEGenericDevice ( TDEGenericDeviceType : : Other ) ;
printf ( " [FIXME] UNCLASSIFIED DEVICE name: %s type: %s subsystem: %s driver: %s [Node Path: %s] [Syspath: %s] \n \r " , devicename . ascii ( ) , devicetype . ascii ( ) , devicesubsystem . ascii ( ) , devicedriver . ascii ( ) , devicenode . ascii ( ) , udev_device_get_syspath ( dev ) ) ; fflush ( stdout ) ;
}
device - > setName ( devicename ) ;