[PC-BSD Commits] r19917 - pcbsd/current/src-qt4/pc-mounttray
svn at pcbsd.org
svn at pcbsd.org
Wed Oct 24 12:03:23 PDT 2012
Author: kenmoore
Date: 2012-10-24 19:03:23 +0000 (Wed, 24 Oct 2012)
New Revision: 19917
Modified:
pcbsd/current/src-qt4/pc-mounttray/menuItem.cpp
pcbsd/current/src-qt4/pc-mounttray/mountTray.cpp
Log:
Commit some detection method improvements to the 9.2 mounttray
Modified: pcbsd/current/src-qt4/pc-mounttray/menuItem.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-mounttray/menuItem.cpp 2012-10-24 17:35:28 UTC (rev 19916)
+++ pcbsd/current/src-qt4/pc-mounttray/menuItem.cpp 2012-10-24 19:03:23 UTC (rev 19917)
@@ -123,16 +123,18 @@
validdev << "da" << "ad" << "mmcsd" << "cd" << "acd";
devtype << "USB"<<"SATA"<< "SD" << "CD9660" << "CD9660";
QString node = dev.section("/",-1);
+ QString detType;
for(int i=0; i<validdev.length(); i++){
- if(node.startsWith(validdev[i])){ type->append(devtype[i]); break; }
+ if(node.startsWith(validdev[i])){ detType = devtype[i]; break; }
}
//Make sure we quit before running commands on any invalid device nodes
- if(type->isEmpty() || !QFile::exists(dev) ){return;}
+ if(detType.isEmpty() || !QFile::exists(dev) ){return;}
+ else{type->append(detType);}
//Read the Device Info using "file -s <device>"
QString cmd = "file -s "+dev;
QString output = Utils::runShellCommand(cmd).join(" ");
- //qDebug() << "File -s output:" << output;
+ //qDebug() << "File -s output:" << output;
// ** Get the max storage size **
QStringList tmp = output.split(",");
@@ -140,8 +142,10 @@
//qDebug() << "tmp:" << tmp;
if( !tmp.filter("partition ").isEmpty() ){
kb = 0; //Do not recognize the base harddrive if there are partitions on it
+ type->clear(); //disable the flag for output
}else if( !tmp.filter("last mounted on /").isEmpty() ){
kb = 0; //Do not recognize partitions that are currently mounted
+ type->clear(); //disable the type flag for output
}else if( !tmp.filter("number of data blocks").isEmpty() ){
tmp = tmp.filter("number of data blocks");
kb = tmp[0].remove("number of data blocks").simplified().toInt();
@@ -151,10 +155,11 @@
}else if( !tmp.filter("hidden sectors").isEmpty()){
tmp = tmp.filter("hidden sectors");
kb = tmp[0].remove("hidden sectors").simplified().toInt();
- }else if( !tmp.filter("sectors ").isEmpty()){
- tmp = tmp.filter("sectors ");
- kb = tmp[0].remove("sectors ").section("(",0,0).simplified().toInt();
- }else{ kb = 1; }
+ }else if( !tmp.filter("sectors").isEmpty()){
+ tmp = tmp.filter("sectors");
+ qDebug() << "Det Sectors line:"<<tmp;
+ kb = tmp[0].remove("sectors").section("(",0,0).simplified().toInt();
+ }else{ kb = -1; }
maxsize->append( QString::number(kb) );
// ** Get the device label **
@@ -173,7 +178,7 @@
if(dlabel.isEmpty()){
dlabel = output.section("label: \"",1,1).section("\"",0,0).simplified(); //device name
}
-
+ //qDebug() <<"Detected Size:"<<kb<<"Label:"<<dlabel;
//Set the Device Name/label
if(dlabel.isEmpty()){
dlabel = *type+"-Device";
Modified: pcbsd/current/src-qt4/pc-mounttray/mountTray.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-mounttray/mountTray.cpp 2012-10-24 17:35:28 UTC (rev 19916)
+++ pcbsd/current/src-qt4/pc-mounttray/mountTray.cpp 2012-10-24 19:03:23 UTC (rev 19917)
@@ -105,10 +105,12 @@
MenuItem::getDevInfo(allDevs[i], &dType, &dLabel, &dFS, &dSize);
if( !dType.isEmpty() ){ // ignore devices that fail the information check
//Allow all filesystems for the moment (could remove UNKNOWN's in the future)
- //Filter out all devices with limited storage (1 block ~= 8kB usually)
- if( dSize.toInt() > 512 ){ //Use 512 blocks as the cutoff for the moment
+ //Filter out all devices with basically no storage (1 block ~= 8kB usually)
+ if( dSize.toInt() > 60 ){
//Add the device to the menu list
addDevice(allDevs[i], dLabel);
+ }else if(dSize != "-1"){
+ qDebug() << "Ignoring Device (<60 blocks/sectors):"<<allDevs[i]<<dType<<dLabel<<dFS<<dSize;
}
}
}
@@ -202,13 +204,13 @@
if(deviceFound){
if(isAttached){
qDebug() << "New device detected:" << dlab << cdev << cdevtype << dfs << dmax +" blocks";
- if(dmax.toInt() > 512){
+ if(dmax.toInt() > 60){
addDevice(cdev,dlab);
QString title = tr("New Device");
QString message = QString( tr("%1 can now be accessed")).arg(dlab);
slotDisplayPopup(title, message);
}else{
- qDebug() << " - Ignoring device (less than 512 blocks of storage detected)";
+ qDebug() << " - Ignoring device (less than 60 blocks/sectors detected)";
}
}else{
removeDevice(cdev);
More information about the Commits
mailing list