Changeset 2991492


Ignore:
Timestamp:
01/23/15 08:49:43 (6 weeks ago)
Author:
Ken Moore <ken@…>
Branches:
releng/10.1.1
Children:
b35765f
Parents:
9107eac
Message:

Clean up how memory disks are handles in pc-sysconfig. Now the swap device will always be filtered out (added to the active device list), and ISO files will properly be detected/mounted again.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src-sh/pcbsd-utils/pc-sysconfig/daemon/Backend-remdev.cpp

    re70d432 r2991492  
    110110    if(QFile::exists("/dev/"+dev)){ activeDevs << dev; } 
    111111  } 
     112  //Use "mdconfig" to filter out any SWAP devices 
     113  info = runShellCommand("mdconfig -l -v").filter("/swap"); 
     114  for(int i=0; i<info.length(); i++){ 
     115    info[i].replace("\t", " "); 
     116    activeDevs << info[i].section(" ",0,0).simplified(); 
     117  } 
    112118  activeDevs.removeDuplicates(); 
    113119  //qDebug() << "Active Devices:" << activeDevs; 
     
    131137      if( subdevs[i].startsWith(CPART[j]) ){ ok = false; break; } 
    132138    } 
    133     //Make sure this is a bottom level device 
     139    //Make sure this is a bottom level device for non-memory disks 
    134140    if(ok){  
    135         QStringList filter = subdevs.filter(subdevs[i]);  
    136         for(int f=0; f<filter.length(); f++){  
    137           if( filter[f].startsWith(subdevs[i]) && (filter[f]!=subdevs[i]) ){ ok = false; break; } 
     141        if( subdevs[i].startsWith("md") ){ 
     142          //loaded ISO files Memory disks need to be top-level devices: 
     143          if(subdevs[i].contains("p") || subdevs[i].contains("s") ){ ok = false; break; } 
     144        }else{ 
     145          QStringList filter = subdevs.filter(subdevs[i]);  
     146          for(int f=0; f<filter.length(); f++){  
     147            if( filter[f].startsWith(subdevs[i]) && (filter[f]!=subdevs[i]) ){ ok = false; break; } 
     148          } 
    138149        } 
    139150    } 
    140151    //Finally, ensure that there is actually something attached to the device  
    141152    // (existance is not good enough for things like CD drives or USB card readers/hubs) 
    142    if(ok){  
     153   if(ok && !subdevs[i].startsWith("md") ){  
    143154      ok = VerifyDevice("/dev/"+subdevs[i], DEVDB::deviceTypeByNode(subdevs[i]) );  
    144       if(!ok && subdevs[i].startsWith("md") && (subdevs[i].contains("p") || subdevs[i].contains("s")) ){ badmd << subdevs[i]; } //add ot the list for later 
     155      //if(!ok && subdevs[i].startsWith("md") && (subdevs[i].contains("p") || subdevs[i].contains("s")) ){ badmd << subdevs[i]; } //add ot the list for later 
    145156   } 
    146157    //If ok, add it to the output list 
     
    236247  QStringList info = runShellCommand("disktype /dev/"+node); 
    237248  //In case there are multiple partitions on the device, remove all the invalid ones (EFI boot partitions for instance) 
    238   QStringList parts = info.join("\n").split("Partition "); 
     249  QStringList parts = info.join("\n").split("\nPartition "); 
     250  //qDebug() << "DiskType Partitions:" << node << parts; 
    239251  if(parts.filter("Volume name ").length()>0){ 
    240252    parts = parts.filter("Volume name "); 
     
    247259    info = parts[0].split("\n"); //only use the first partition with both a label and a file system 
    248260  } 
     261  //qDebug() << " - Filtered:" << info; 
    249262  //qDebug() << "Disktype Detection:" << node; 
    250263  QStringList dsDetection = DEVDB::disktypeDetectionStrings(); 
     
    262275      blankDisk = true; 
    263276      //qDebug() << " - Blank disk"; 
    264     }else if( info[i].contains("file system") && fs.isEmpty() ){ 
    265       QString tmp = info[i].section("file system",0,0); 
    266       for(int j=0; j<dsDetection.length(); j++){ 
    267         if(tmp.contains(dsDetection[j].section("::::",0,0))){ fs = dsDetection[j].section("::::",1,1); break; } 
     277    }else if( info[i].contains("file system") ){ 
     278      if(fs.isEmpty() || !fs.contains("(hints")){ 
     279        QString tmp = info[i].section("file system",0,0); 
     280        for(int j=0; j<dsDetection.length(); j++){ 
     281          if(tmp.contains(dsDetection[j].section("::::",0,0))){ fs = dsDetection[j].section("::::",1,1); break; } 
     282        } 
    268283      } 
    269284      //qDebug() << " - File System:" << fs; 
Note: See TracChangeset for help on using the changeset viewer.