Changeset 940aaf0


Ignore:
Timestamp:
Aug 6, 2013 11:05:06 AM (11 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, 9.2-release, releng/10.0, releng/10.0.1, releng/10.0.2
Children:
e6d5635
Parents:
7369d56
Message:

Fix up the mount tray to detect when a device has been automounted by something else and let the mounttray be able to unmount it when prompted

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src-qt4/pc-mounttray/menuItem.cpp

    r1620346 r940aaf0  
    106106bool MenuItem::isMounted(){ 
    107107  //Check if device is mounted 
     108  QStringList chk = pcbsd::Utils::runShellCommand("mount"); 
     109  bool mounted=false; 
     110  for(int i=0; i<chk.length(); i++){ 
     111    mounted = chk[i].contains(device) || chk[i].contains(devLabel->text()) || chk[i].contains(devLabel->text().replace(" ","-")); 
     112    if(mounted){  
     113      //Save the mountpoint if it is mounted 
     114      mountpoint = chk[i].section(" on ",1,10).section("(",0,0).simplified(); 
     115      break;  
     116    } 
     117  } 
     118  return mounted; 
     119  /* 
    108120  QString chk = pcbsd::Utils::runShellCommandSearch("mount",device);   
    109121  if(chk.isEmpty() ){ chk = pcbsd::Utils::runShellCommandSearch("mount",devLabel->text().replace(" ","-")); }  
    110  
    111122  if(chk.isEmpty() ){ return FALSE; } 
    112123  else{ return TRUE; } 
     124  */ 
    113125} 
    114126 
     
    248260void MenuItem::unmountItem(){ 
    249261  //Unmount the device 
    250  
     262         
    251263  //Check to see if the current mountpoint exists or if it is somewhere else 
    252264  if( !QFile::exists(mountpoint) ){ 
    253     if( isMounted() ){  //double check that it is actually mounted 
    254       //mounted someplace else - find it 
    255       QString output = pcbsd::Utils::runShellCommandSearch("mount",device); 
    256       mountpoint = output.section(" on ",1,1).section(" (",0,0).replace(" ","-"); 
    257     }else{ 
     265    if( !isMounted() ){  //double check that it is actually mounted (and fix the mountpoint) 
    258266      //it is not mounted to begin with 
    259267      return; 
    260268    } 
    261269  } 
    262    
    263   QString cmd1 = "umount " + mountpoint; 
    264   QString cmd2 = "rmdir " + mountpoint; 
     270  //Make sure there are no spaces in the mounpoint path 
     271  QString cmd1 = "umount \"" + mountpoint +"\""; 
     272  QString cmd2 = "rmdir \"" + mountpoint +"\""; 
    265273  qDebug() << "Unmounting device from" << mountpoint; 
    266274  //Run the commands 
     
    297305  bool ok = FALSE; 
    298306  if(isMounted()){ 
    299     QString cmd = "df "+mountpoint; 
     307    QString cmd = "df \""+mountpoint+"\""; 
    300308    QStringList output = systemCMD(cmd); //make sure we use the one with a 1K blocksize 
    301309    if(output.length() > 1){ 
Note: See TracChangeset for help on using the changeset viewer.