Skip to content
This repository has been archived by the owner on Dec 4, 2020. It is now read-only.

Commit

Permalink
Clean up the device naming scheme in the mount tray:
Browse files Browse the repository at this point in the history
1) Do not use glabel for NTFS devices (when mounted through fuse glabel is not consistent in giving the label)
2) Use device's camcontrol identifyier for SATA devices as well as USB devices. This should provide a more specific name than "SATA-Device".
3) For a camcontrol name, append "-" followed by the partition number (so ada0s1a will have a "-1a" appended to the end. Again, this should help devices have unique names.
  • Loading branch information
Ken Moore committed Feb 4, 2014
1 parent 9cf580a commit e417b8a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
19 changes: 15 additions & 4 deletions src-qt4/pc-mounttray/devCheck.cpp
Expand Up @@ -71,6 +71,7 @@ QString DevCheck::devLabel(QString node, QString filesystem){
}
index = glout.indexOf("Geom name: "+node, index); //move to the next index if there is one
}
dlabel.replace("%20", " "); //quick check to make sure it does not have that special character
return dlabel;
}

Expand Down Expand Up @@ -100,9 +101,18 @@ bool DevCheck::devInfo(QString dev, QString* type, QString* label, QString* file
QString camctl;
if(detType == "USB" && QFile::exists(fullDev)){
//make sure that it is not a SCSI device
camctl = pcbsd::Utils::runShellCommand( QString("camcontrol inquiry ")+node ).join(" ");
if(camctl.contains(" Fixed Direct Access SCSI")){ detType = "SCSI"; } //USB devices do not have any output
camctl = pcbsd::Utils::runShellCommand( QString("camcontrol inquiry ")+node.section("s",0,0) ).join(" ");
if(camctl.contains(" Fixed Direct Access SCSI")){ detType = "SCSI"; }
if(camctl.contains("camcontrol")){ camctl.clear(); } //error or invalid device type
}else if(detType == "SATA" && QFile::exists(fullDev)){
camctl = pcbsd::Utils::runShellCommand( QString("camcontrol identify ")+node.section("s",0,0) ).join(" ");
if(camctl.contains("camcontrol")){ camctl.clear(); } //error or invalid device type
}
if(!camctl.isEmpty()){
//Alternate Device name for label later
camctl = camctl.section(">",0,0).section("<",-1).section(" ",0,0).simplified();
QString partition = node.section("s",1,1);
if(!partition.isEmpty()){ camctl.append("-"+partition); }
}
//Make sure we quit before running commands on any invalid device nodes
if(detType.isEmpty() || !QFile::exists(fullDev) ){return FALSE;}
Expand Down Expand Up @@ -182,13 +192,14 @@ bool DevCheck::devInfo(QString dev, QString* type, QString* label, QString* file
//Now get the device label (if there is one) using glabel
bool hasLabel = FALSE;
QString glabel;
if(!isCD){ glabel = devLabel(node, filesys); }
//Don't use glabel for SATA devices right now because it is inconsistent
if(!isCD && filesys!="NTFS"){ glabel = devLabel(node, filesys); }
//Check to see if we have a label, otherwise assign one
if( !glabel.isEmpty() ){ dlabel = glabel; hasLabel = TRUE; } //glabel
else if(!dlabel.isEmpty()){ hasLabel = TRUE; } //file -s label
else if( !camctl.isEmpty() ){
//not necessarily a "detected" label, but just an alternate fallback name
dlabel = camctl.section(">",0,0).section("<",-1).section(" ",0,0).simplified();
dlabel = camctl;
}else{
//Assign a device label
if(isCD){
Expand Down
4 changes: 3 additions & 1 deletion src-qt4/pc-mounttray/menuItem.cpp
Expand Up @@ -18,7 +18,6 @@ MenuItem::MenuItem(QWidget* parent, QString newdevice, QString newlabel, QString
devLabel = new QLabel;
devLabel->setToolTip(device);
devLabel->setText(newlabel);

devIcon = new QLabel;
devIcon->setToolTip(device);
currentSpace = new QProgressBar;
Expand Down Expand Up @@ -113,6 +112,9 @@ bool MenuItem::isMounted(){
bool mounted=false;
for(int i=0; i<chk.length(); i++){
mounted = chk[i].contains(device) || chk[i].contains(devLabel->text()) || chk[i].contains(devLabel->text().replace(" ","-"));
if(!mounted && chk[i].startsWith("/dev/fuse on ") ){
//No method of probing fuse devices to find the original parent (yet)
}
if(mounted){
//Save the mountpoint if it is mounted
mountpoint = chk[i].section(" on ",1,10).section("(",0,0).simplified();
Expand Down

0 comments on commit e417b8a

Please sign in to comment.