Add PictBridge camera support

pull/16/head
Timothy Pearson 13 years ago
parent 2a415e33e0
commit 936c9c64fc

@ -502,6 +502,10 @@ TQString TDEStorageDevice::friendlyName() {
return devicename; return devicename;
} }
if (isDiskOfType(TDEDiskDeviceType::Camera)) {
return TDEGenericDevice::friendlyName();
}
if (isDiskOfType(TDEDiskDeviceType::Floppy)) { if (isDiskOfType(TDEDiskDeviceType::Floppy)) {
return friendlyDeviceType(); return friendlyDeviceType();
} }
@ -559,6 +563,9 @@ TQString TDEStorageDevice::friendlyDeviceType() {
if (isDiskOfType(TDEDiskDeviceType::Tape)) { if (isDiskOfType(TDEDiskDeviceType::Tape)) {
ret = i18n("Tape Drive"); ret = i18n("Tape Drive");
} }
if (isDiskOfType(TDEDiskDeviceType::Camera)) {
ret = i18n("Digital Camera");
}
if (isDiskOfType(TDEDiskDeviceType::HDD)) { if (isDiskOfType(TDEDiskDeviceType::HDD)) {
ret = i18n("Hard Disk Drive"); ret = i18n("Hard Disk Drive");
@ -613,6 +620,9 @@ TQPixmap TDEStorageDevice::icon(KIcon::StdSizes size) {
if (isDiskOfType(TDEDiskDeviceType::Tape)) { if (isDiskOfType(TDEDiskDeviceType::Tape)) {
ret = DesktopIcon("tape_unmount", size); ret = DesktopIcon("tape_unmount", size);
} }
if (isDiskOfType(TDEDiskDeviceType::Camera)) {
ret = DesktopIcon("camera_unmount");
}
if (isDiskOfType(TDEDiskDeviceType::HDD)) { if (isDiskOfType(TDEDiskDeviceType::HDD)) {
ret = DesktopIcon("hdd_unmount", size); ret = DesktopIcon("hdd_unmount", size);
@ -743,10 +753,7 @@ TQString TDEStorageDevice::mountDevice(TQString mediaName, TQString mountOptions
KTempFile passwordFile(TQString::null, "tmp", 0600); KTempFile passwordFile(TQString::null, "tmp", 0600);
passwordFile.setAutoDelete(true); passwordFile.setAutoDelete(true);
TQString command = TQString("pmount -p %1 %2 %3 2>&1").arg(passwordFile.name()).arg(mountOptions).arg(deviceNode()); TQString command = TQString("pmount -p %1 %2 %3 %4 2>&1").arg(passwordFile.name()).arg(mountOptions).arg(deviceNode()).arg(mediaName);
if (!mediaName.isNull()) {
command.append(mediaName);
}
FILE *exepipe = popen(command.ascii(), "r"); FILE *exepipe = popen(command.ascii(), "r");
if (exepipe) { if (exepipe) {
@ -790,10 +797,7 @@ TQString TDEStorageDevice::mountEncryptedDevice(TQString passphrase, TQString me
pwFile->writeBlock(passphrase.ascii(), passphrase.length()); pwFile->writeBlock(passphrase.ascii(), passphrase.length());
pwFile->flush(); pwFile->flush();
TQString command = TQString("pmount -p %1 %2 %3 2>&1").arg(passwordFile.name()).arg(mountOptions).arg(deviceNode()); TQString command = TQString("pmount -p %1 %2 %3 %4 2>&1").arg(passwordFile.name()).arg(mountOptions).arg(deviceNode()).arg(mediaName);
if (!mediaName.isNull()) {
command.append(mediaName);
}
FILE *exepipe = popen(command.ascii(), "r"); FILE *exepipe = popen(command.ascii(), "r");
if (exepipe) { if (exepipe) {
@ -3231,7 +3235,31 @@ TDEGenericDevice* TDEHardwareDevices::classifyUnknownDevice(udev_device* dev, TD
// Likely inaccurate and sweeping // Likely inaccurate and sweeping
if ((devicesubsystem == "usb") if ((devicesubsystem == "usb")
|| (devicesubsystem == "usbmon")) { || (devicesubsystem == "usbmon")) {
if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::OtherUSB); // Get USB interface protocol for further classification
int usbInterfaceProtocol = -1;
TQFile ifaceprotofile(current_path + "/bInterfaceProtocol");
if (ifaceprotofile.open(IO_ReadOnly)) {
TQTextStream stream( &ifaceprotofile );
usbInterfaceProtocol = stream.readLine().toUInt();
ifaceprotofile.close();
}
if (usbInterfaceProtocol == 1) {
// PictBridge
if (!device) {
device = new TDEStorageDevice(TDEGenericDeviceType::Disk);
TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(device);
sdevice->internalSetDiskType(TDEDiskDeviceType::Camera);
TQString parentsyspathudev = systempath;
parentsyspathudev.truncate(parentsyspathudev.length()-1); // Remove trailing slash
parentsyspathudev.truncate(parentsyspathudev.findRev("/"));
struct udev_device *parentdev;
parentdev = udev_device_new_from_syspath(m_udevStruct, parentsyspathudev.ascii());
devicenode = (udev_device_get_devnode(parentdev));
}
}
else {
if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::OtherUSB);
}
} }
if (devicesubsystem == "pci") { if (devicesubsystem == "pci") {
if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::OtherPeripheral); if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::OtherPeripheral);
@ -3272,273 +3300,279 @@ TDEGenericDevice* TDEHardwareDevices::classifyUnknownDevice(udev_device* dev, TD
} }
if (device->type() == TDEGenericDeviceType::Disk) { if (device->type() == TDEGenericDeviceType::Disk) {
bool removable = false; TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(device);
bool hotpluggable = false; if (sdevice->diskType() & TDEDiskDeviceType::Camera) {
// PictBridge cameras are special and should not be classified by standard rules
// We can get the removable flag, but we have no idea if the device has the ability to notify on media insertion/removal sdevice->internalSetDiskStatus(TDEDiskDeviceStatus::Removable);
// If there is no such notification possible, then we should not set the removable flag sdevice->internalSetFileSystemName("pictbridge");
// udev can be such an amazing pain at times
// It exports a /capabilities node with no info on what the bits actually mean
// This information is very poorly documented as a set of #defines in include/linux/genhd.h
// We are specifically interested in GENHD_FL_REMOVABLE and GENHD_FL_MEDIA_CHANGE_NOTIFY
// The "removable" flag should also really be renamed to "hotpluggable", as that is far more precise...
TQString capabilitynodename = systempath;
capabilitynodename.append("/capability");
TQFile capabilityfile( capabilitynodename );
unsigned int capabilities = 0;
if ( capabilityfile.open( IO_ReadOnly ) ) {
TQTextStream stream( &capabilityfile );
TQString capabilitystring;
capabilitystring = stream.readLine();
capabilities = capabilitystring.toUInt();
capabilityfile.close();
}
if (capabilities & GENHD_FL_REMOVABLE) {
// FIXME
// For added fun this is not always true; i.e. GENHD_FL_REMOVABLE can be set when the device cannot be hotplugged (floppy drives).
hotpluggable = true;
}
if (capabilities & GENHD_FL_MEDIA_CHANGE_NOTIFY) {
removable = true;
} }
else {
// See if any other devices are exclusively using this device, such as the Device Mapper bool removable = false;
TQStringList holdingDeviceNodes; bool hotpluggable = false;
TQString holdersnodename = udev_device_get_syspath(dev);
holdersnodename.append("/holders/"); // We can get the removable flag, but we have no idea if the device has the ability to notify on media insertion/removal
TQDir holdersdir(holdersnodename); // If there is no such notification possible, then we should not set the removable flag
holdersdir.setFilter(TQDir::All); // udev can be such an amazing pain at times
const TQFileInfoList *dirlist = holdersdir.entryInfoList(); // It exports a /capabilities node with no info on what the bits actually mean
if (dirlist) { // This information is very poorly documented as a set of #defines in include/linux/genhd.h
TQFileInfoListIterator holdersdirit(*dirlist); // We are specifically interested in GENHD_FL_REMOVABLE and GENHD_FL_MEDIA_CHANGE_NOTIFY
TQFileInfo *dirfi; // The "removable" flag should also really be renamed to "hotpluggable", as that is far more precise...
while ( (dirfi = holdersdirit.current()) != 0 ) { TQString capabilitynodename = systempath;
if (dirfi->isSymLink()) { capabilitynodename.append("/capability");
char* collapsedPath = realpath((holdersnodename + dirfi->readLink()).ascii(), NULL); TQFile capabilityfile( capabilitynodename );
holdingDeviceNodes.append(TQString(collapsedPath)); unsigned int capabilities = 0;
free(collapsedPath); if ( capabilityfile.open( IO_ReadOnly ) ) {
} TQTextStream stream( &capabilityfile );
++holdersdirit; TQString capabilitystring;
capabilitystring = stream.readLine();
capabilities = capabilitystring.toUInt();
capabilityfile.close();
}
if (capabilities & GENHD_FL_REMOVABLE) {
// FIXME
// For added fun this is not always true; i.e. GENHD_FL_REMOVABLE can be set when the device cannot be hotplugged (floppy drives).
hotpluggable = true;
} }
} if (capabilities & GENHD_FL_MEDIA_CHANGE_NOTIFY) {
removable = true;
// 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); // See if any other devices are exclusively using this device, such as the Device Mapper
slavesnodename.append("/slaves/"); TQStringList holdingDeviceNodes;
TQDir slavedir(slavesnodename); TQString holdersnodename = udev_device_get_syspath(dev);
slavedir.setFilter(TQDir::All); holdersnodename.append("/holders/");
dirlist = slavedir.entryInfoList(); TQDir holdersdir(holdersnodename);
if (dirlist) { holdersdir.setFilter(TQDir::All);
TQFileInfoListIterator slavedirit(*dirlist); const TQFileInfoList *dirlist = holdersdir.entryInfoList();
TQFileInfo *dirfi; if (dirlist) {
while ( (dirfi = slavedirit.current()) != 0 ) { TQFileInfoListIterator holdersdirit(*dirlist);
if (dirfi->isSymLink()) { TQFileInfo *dirfi;
char* collapsedPath = realpath((slavesnodename + dirfi->readLink()).ascii(), NULL); while ( (dirfi = holdersdirit.current()) != 0 ) {
slaveDeviceNodes.append(TQString(collapsedPath)); if (dirfi->isSymLink()) {
free(collapsedPath); char* collapsedPath = realpath((holdersnodename + dirfi->readLink()).ascii(), NULL);
holdingDeviceNodes.append(TQString(collapsedPath));
free(collapsedPath);
}
++holdersdirit;
} }
++slavedirit;
} }
}
// See if any other physical devices underlie this device, for example when the Device Mapper is in use
// Determine generic disk information TQStringList slaveDeviceNodes;
TQString devicevendor(udev_device_get_property_value(dev, "ID_VENDOR")); TQString slavesnodename = udev_device_get_syspath(dev);
TQString devicemodel(udev_device_get_property_value(dev, "ID_MODEL")); slavesnodename.append("/slaves/");
TQString devicebus(udev_device_get_property_value(dev, "ID_BUS")); TQDir slavedir(slavesnodename);
slavedir.setFilter(TQDir::All);
// Get disk specific info dirlist = slavedir.entryInfoList();
TQString disklabel(udev_device_get_property_value(dev, "ID_FS_LABEL")); if (dirlist) {
TQString diskuuid(udev_device_get_property_value(dev, "ID_FS_UUID")); TQFileInfoListIterator slavedirit(*dirlist);
TQString filesystemtype(udev_device_get_property_value(dev, "ID_FS_TYPE"));
TQString filesystemusage(udev_device_get_property_value(dev, "ID_FS_USAGE"));
device->internalSetVendorName(devicevendor);
device->internalSetVendorModel(devicemodel);
device->internalSetDeviceBus(devicebus);
TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(device);
TDEDiskDeviceType::TDEDiskDeviceType disktype = sdevice->diskType();
TDEDiskDeviceStatus::TDEDiskDeviceStatus diskstatus = TDEDiskDeviceStatus::Null;
if (force_full_classification) {
disktype = classifyDiskType(dev, devicebus, devicetypestring, systempath, devicevendor, devicemodel, filesystemtype, devicedriver);
sdevice->internalSetDiskType(disktype);
device = classifyUnknownDeviceByExternalRules(dev, device, true); // Check external rules for possible subtype overrides
disktype = sdevice->diskType(); // The type can be overridden by an external rule
}
if ((disktype & TDEDiskDeviceType::CDROM)
|| (disktype & TDEDiskDeviceType::CDRW)
|| (disktype & TDEDiskDeviceType::DVDROM)
|| (disktype & TDEDiskDeviceType::DVDRAM)
|| (disktype & TDEDiskDeviceType::DVDRW)
|| (disktype & TDEDiskDeviceType::BDROM)
|| (disktype & TDEDiskDeviceType::BDRW)
|| (disktype & TDEDiskDeviceType::CDAudio)
|| (disktype & TDEDiskDeviceType::CDVideo)
|| (disktype & TDEDiskDeviceType::DVDVideo)
|| (disktype & TDEDiskDeviceType::BDVideo)
) {
// These drives are guaranteed to be optical
disktype = disktype | TDEDiskDeviceType::Optical;
}
if (disktype & TDEDiskDeviceType::Floppy) {
// Floppy drives don't work well under udev
// I have to look for the block device name manually
TQString floppyblknodename = systempath;
floppyblknodename.append("/block");
TQDir floppyblkdir(floppyblknodename);
floppyblkdir.setFilter(TQDir::All);
const TQFileInfoList *floppyblkdirlist = floppyblkdir.entryInfoList();
if (floppyblkdirlist) {
TQFileInfoListIterator floppyblkdirit(*floppyblkdirlist);
TQFileInfo *dirfi; TQFileInfo *dirfi;
while ( (dirfi = floppyblkdirit.current()) != 0 ) { while ( (dirfi = slavedirit.current()) != 0 ) {
if ((dirfi->fileName() != ".") && (dirfi->fileName() != "..")) { if (dirfi->isSymLink()) {
// Does this routine work with more than one floppy drive in the system? char* collapsedPath = realpath((slavesnodename + dirfi->readLink()).ascii(), NULL);
devicenode = TQString("/dev/").append(dirfi->fileName()); slaveDeviceNodes.append(TQString(collapsedPath));
free(collapsedPath);
} }
++floppyblkdirit; ++slavedirit;
} }
} }
// Some interesting information can be gleaned from the CMOS type file // Determine generic disk information
// 0 : Defaults TQString devicevendor(udev_device_get_property_value(dev, "ID_VENDOR"));
// 1 : 5 1/4 DD TQString devicemodel(udev_device_get_property_value(dev, "ID_MODEL"));
// 2 : 5 1/4 HD TQString devicebus(udev_device_get_property_value(dev, "ID_BUS"));
// 3 : 3 1/2 DD
// 4 : 3 1/2 HD // Get disk specific info
// 5 : 3 1/2 ED TQString disklabel(udev_device_get_property_value(dev, "ID_FS_LABEL"));
// 6 : 3 1/2 ED TQString diskuuid(udev_device_get_property_value(dev, "ID_FS_UUID"));
// 16 : unknown or not installed TQString filesystemtype(udev_device_get_property_value(dev, "ID_FS_TYPE"));
TQString floppycmsnodename = systempath; TQString filesystemusage(udev_device_get_property_value(dev, "ID_FS_USAGE"));
floppycmsnodename.append("/cmos");
TQFile floppycmsfile( floppycmsnodename ); device->internalSetVendorName(devicevendor);
TQString cmosstring; device->internalSetVendorModel(devicemodel);
if ( floppycmsfile.open( IO_ReadOnly ) ) { device->internalSetDeviceBus(devicebus);
TQTextStream stream( &floppycmsfile );
cmosstring = stream.readLine(); TDEDiskDeviceType::TDEDiskDeviceType disktype = sdevice->diskType();
floppycmsfile.close(); TDEDiskDeviceStatus::TDEDiskDeviceStatus diskstatus = TDEDiskDeviceStatus::Null;
if (force_full_classification) {
disktype = classifyDiskType(dev, devicebus, devicetypestring, systempath, devicevendor, devicemodel, filesystemtype, devicedriver);
sdevice->internalSetDiskType(disktype);
device = classifyUnknownDeviceByExternalRules(dev, device, true); // Check external rules for possible subtype overrides
disktype = sdevice->diskType(); // The type can be overridden by an external rule
} }
// FIXME
// Do something with the information in cmosstring if ((disktype & TDEDiskDeviceType::CDROM)
|| (disktype & TDEDiskDeviceType::CDRW)
if (devicenode.isNull()) { || (disktype & TDEDiskDeviceType::DVDROM)
// This floppy drive cannot be mounted, so ignore it || (disktype & TDEDiskDeviceType::DVDRAM)
disktype = disktype & ~TDEDiskDeviceType::Floppy; || (disktype & TDEDiskDeviceType::DVDRW)
|| (disktype & TDEDiskDeviceType::BDROM)
|| (disktype & TDEDiskDeviceType::BDRW)
|| (disktype & TDEDiskDeviceType::CDAudio)
|| (disktype & TDEDiskDeviceType::CDVideo)
|| (disktype & TDEDiskDeviceType::DVDVideo)
|| (disktype & TDEDiskDeviceType::BDVideo)
) {
// These drives are guaranteed to be optical
disktype = disktype | TDEDiskDeviceType::Optical;
} }
}
if (disktype & TDEDiskDeviceType::Floppy) {
if (devicetypestring.upper() == "CD") { // Floppy drives don't work well under udev
if (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_STATE")).upper() == "BLANK") { // I have to look for the block device name manually
diskstatus = diskstatus | TDEDiskDeviceStatus::Blank; TQString floppyblknodename = systempath;
floppyblknodename.append("/block");
TQDir floppyblkdir(floppyblknodename);
floppyblkdir.setFilter(TQDir::All);
const TQFileInfoList *floppyblkdirlist = floppyblkdir.entryInfoList();
if (floppyblkdirlist) {
TQFileInfoListIterator floppyblkdirit(*floppyblkdirlist);
TQFileInfo *dirfi;
while ( (dirfi = floppyblkdirit.current()) != 0 ) {
if ((dirfi->fileName() != ".") && (dirfi->fileName() != "..")) {
// Does this routine work with more than one floppy drive in the system?
devicenode = TQString("/dev/").append(dirfi->fileName());
}
++floppyblkdirit;
}
}
// Some interesting information can be gleaned from the CMOS type file
// 0 : Defaults
// 1 : 5 1/4 DD
// 2 : 5 1/4 HD
// 3 : 3 1/2 DD
// 4 : 3 1/2 HD
// 5 : 3 1/2 ED
// 6 : 3 1/2 ED
// 16 : unknown or not installed
TQString floppycmsnodename = systempath;
floppycmsnodename.append("/cmos");
TQFile floppycmsfile( floppycmsnodename );
TQString cmosstring;
if ( floppycmsfile.open( IO_ReadOnly ) ) {
TQTextStream stream( &floppycmsfile );
cmosstring = stream.readLine();
floppycmsfile.close();
}
// FIXME
// Do something with the information in cmosstring
if (devicenode.isNull()) {
// This floppy drive cannot be mounted, so ignore it
disktype = disktype & ~TDEDiskDeviceType::Floppy;
}
} }
sdevice->internalSetMediaInserted((TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA")) != ""));
} if (devicetypestring.upper() == "CD") {
if (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_STATE")).upper() == "BLANK") {
if (disktype & TDEDiskDeviceType::Zip) { diskstatus = diskstatus | TDEDiskDeviceStatus::Blank;
// A Zip drive does not advertise its status via udev, but it can be guessed from the size parameter }
TQString zipnodename = systempath; sdevice->internalSetMediaInserted((TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA")) != ""));
zipnodename.append("/size");
TQFile namefile( zipnodename );
TQString zipsize;
if ( namefile.open( IO_ReadOnly ) ) {
TQTextStream stream( &namefile );
zipsize = stream.readLine();
namefile.close();
} }
if (!zipsize.isNull()) {
sdevice->internalSetMediaInserted((zipsize.toInt() != 0)); if (disktype & TDEDiskDeviceType::Zip) {
// A Zip drive does not advertise its status via udev, but it can be guessed from the size parameter
TQString zipnodename = systempath;
zipnodename.append("/size");
TQFile namefile( zipnodename );
TQString zipsize;
if ( namefile.open( IO_ReadOnly ) ) {
TQTextStream stream( &namefile );
zipsize = stream.readLine();
namefile.close();
}
if (!zipsize.isNull()) {
sdevice->internalSetMediaInserted((zipsize.toInt() != 0));
}
} }
}
if (removable) {
if (removable) { diskstatus = diskstatus | TDEDiskDeviceStatus::Removable;
diskstatus = diskstatus | TDEDiskDeviceStatus::Removable;
}
if (hotpluggable) {
diskstatus = diskstatus | TDEDiskDeviceStatus::Hotpluggable;
}
if ((filesystemtype.upper() != "CRYPTO_LUKS") && (filesystemtype.upper() != "CRYPTO") && (!filesystemtype.isNull())) {
diskstatus = diskstatus | TDEDiskDeviceStatus::ContainsFilesystem;
}
// Set mountable flag if device is likely to be mountable
diskstatus = diskstatus | TDEDiskDeviceStatus::Mountable;
if ((devicetypestring.upper().isNull()) && (disktype & TDEDiskDeviceType::HDD)) {
diskstatus = diskstatus & ~TDEDiskDeviceStatus::Mountable;
}
if (removable) {
if (sdevice->mediaInserted()) {
diskstatus = diskstatus | TDEDiskDeviceStatus::Inserted;
} }
else { if (hotpluggable) {
diskstatus = diskstatus & ~TDEDiskDeviceStatus::Mountable; diskstatus = diskstatus | TDEDiskDeviceStatus::Hotpluggable;
} }
}
// If certain disk types do not report the presence of a filesystem, they are likely not mountable if ((filesystemtype.upper() != "CRYPTO_LUKS") && (filesystemtype.upper() != "CRYPTO") && (!filesystemtype.isNull())) {
if ((disktype & TDEDiskDeviceType::HDD) || (disktype & TDEDiskDeviceType::Optical)) { diskstatus = diskstatus | TDEDiskDeviceStatus::ContainsFilesystem;
if (!(diskstatus & TDEDiskDeviceStatus::ContainsFilesystem)) { }
// Set mountable flag if device is likely to be mountable
diskstatus = diskstatus | TDEDiskDeviceStatus::Mountable;
if ((devicetypestring.upper().isNull()) && (disktype & TDEDiskDeviceType::HDD)) {
diskstatus = diskstatus & ~TDEDiskDeviceStatus::Mountable; diskstatus = diskstatus & ~TDEDiskDeviceStatus::Mountable;
} }
} if (removable) {
if (sdevice->mediaInserted()) {
if (holdingDeviceNodes.count() > 0) { diskstatus = diskstatus | TDEDiskDeviceStatus::Inserted;
diskstatus = diskstatus | TDEDiskDeviceStatus::UsedByDevice; }
} else {
diskstatus = diskstatus & ~TDEDiskDeviceStatus::Mountable;
if (slaveDeviceNodes.count() > 0) { }
diskstatus = diskstatus | TDEDiskDeviceStatus::UsesDevice;
}
// See if any slaves were crypted
for ( TQStringList::Iterator slaveit = slaveDeviceNodes.begin(); slaveit != slaveDeviceNodes.end(); ++slaveit ) {
struct udev_device *slavedev;
slavedev = udev_device_new_from_syspath(m_udevStruct, (*slaveit).ascii());
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")), TQString(udev_device_get_driver(dev)));
} }
udev_device_unref(slavedev); // If certain disk types do not report the presence of a filesystem, they are likely not mountable
} if ((disktype & TDEDiskDeviceType::HDD) || (disktype & TDEDiskDeviceType::Optical)) {
if (!(diskstatus & TDEDiskDeviceStatus::ContainsFilesystem)) {
sdevice->internalSetDiskType(disktype); diskstatus = diskstatus & ~TDEDiskDeviceStatus::Mountable;
sdevice->internalSetDiskUUID(diskuuid); }
sdevice->internalSetDiskStatus(diskstatus); }
sdevice->internalSetFileSystemName(filesystemtype);
sdevice->internalSetFileSystemUsage(filesystemusage); if (holdingDeviceNodes.count() > 0) {
sdevice->internalSetSlaveDevices(slaveDeviceNodes); diskstatus = diskstatus | TDEDiskDeviceStatus::UsedByDevice;
sdevice->internalSetHoldingDevices(holdingDeviceNodes); }
// Clean up disk label if (slaveDeviceNodes.count() > 0) {
if ((sdevice->isDiskOfType(TDEDiskDeviceType::CDROM)) diskstatus = diskstatus | TDEDiskDeviceStatus::UsesDevice;
|| (sdevice->isDiskOfType(TDEDiskDeviceType::CDRW)) }
|| (sdevice->isDiskOfType(TDEDiskDeviceType::DVDROM))
|| (sdevice->isDiskOfType(TDEDiskDeviceType::DVDRW)) // See if any slaves were crypted
|| (sdevice->isDiskOfType(TDEDiskDeviceType::BDROM)) for ( TQStringList::Iterator slaveit = slaveDeviceNodes.begin(); slaveit != slaveDeviceNodes.end(); ++slaveit ) {
|| (sdevice->isDiskOfType(TDEDiskDeviceType::BDRW)) struct udev_device *slavedev;
|| (sdevice->isDiskOfType(TDEDiskDeviceType::CDAudio)) slavedev = udev_device_new_from_syspath(m_udevStruct, (*slaveit).ascii());
|| (sdevice->isDiskOfType(TDEDiskDeviceType::CDVideo)) TQString slavediskfstype(udev_device_get_property_value(slavedev, "ID_FS_TYPE"));
|| (sdevice->isDiskOfType(TDEDiskDeviceType::DVDVideo)) if ((slavediskfstype.upper() == "CRYPTO_LUKS") || (slavediskfstype.upper() == "CRYPTO")) {
|| (sdevice->isDiskOfType(TDEDiskDeviceType::BDVideo)) disktype = disktype | TDEDiskDeviceType::UnlockedCrypt;
) { // Set disk type based on parent device
if (disklabel == "" && sdevice->diskLabel().isNull()) { 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")), TQString(udev_device_get_driver(dev)));
// Read the volume label in via volname, since udev couldn't be bothered to do this on its own }
FILE *exepipe = popen(((TQString("volname %1").arg(devicenode).ascii())), "r"); udev_device_unref(slavedev);
if (exepipe) { }
char buffer[8092];
disklabel = fgets(buffer, sizeof(buffer), exepipe); sdevice->internalSetDiskType(disktype);
pclose(exepipe); sdevice->internalSetDiskUUID(diskuuid);
sdevice->internalSetDiskStatus(diskstatus);
sdevice->internalSetFileSystemName(filesystemtype);
sdevice->internalSetFileSystemUsage(filesystemusage);
sdevice->internalSetSlaveDevices(slaveDeviceNodes);
sdevice->internalSetHoldingDevices(holdingDeviceNodes);
// Clean up disk label
if ((sdevice->isDiskOfType(TDEDiskDeviceType::CDROM))
|| (sdevice->isDiskOfType(TDEDiskDeviceType::CDRW))
|| (sdevice->isDiskOfType(TDEDiskDeviceType::DVDROM))
|| (sdevice->isDiskOfType(TDEDiskDeviceType::DVDRW))
|| (sdevice->isDiskOfType(TDEDiskDeviceType::BDROM))
|| (sdevice->isDiskOfType(TDEDiskDeviceType::BDRW))
|| (sdevice->isDiskOfType(TDEDiskDeviceType::CDAudio))
|| (sdevice->isDiskOfType(TDEDiskDeviceType::CDVideo))
|| (sdevice->isDiskOfType(TDEDiskDeviceType::DVDVideo))
|| (sdevice->isDiskOfType(TDEDiskDeviceType::BDVideo))
) {
if (disklabel == "" && sdevice->diskLabel().isNull()) {
// Read the volume label in via volname, since udev couldn't be bothered to do this on its own
FILE *exepipe = popen(((TQString("volname %1").arg(devicenode).ascii())), "r");
if (exepipe) {
char buffer[8092];
disklabel = fgets(buffer, sizeof(buffer), exepipe);
pclose(exepipe);
}
} }
} }
sdevice->internalSetDiskLabel(disklabel);
} }
sdevice->internalSetDiskLabel(disklabel);
} }
if (device->type() == TDEGenericDeviceType::Network) { if (device->type() == TDEGenericDeviceType::Network) {

Loading…
Cancel
Save