Ignore:
Timestamp:
01/28/14 12:53:50 (11 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, releng/10.0.1, releng/10.0.2, releng/10.0.3, releng/10.1
Children:
1178be8
Parents:
2c7fba6
Message:

Adjust the mount tray unmounting routine to first unmount any additional nullfs mounts of the original mountpoint before unmounting the mountpoint. This still needs testing on 10.0 (since 10.x PBI's do the additional nullfs mounts).

File:
1 edited

Legend:

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

    r065b890 rdb3bc52  
    280280    } 
    281281  } 
     282   
     283  //Unmount all the NULLFS mountpoints first (in case it has been mounted into a PBI container) 
     284  QStringList nullfs = systemCMD("mount").filter(mountpoint).filter("nullfs"); 
     285  bool ok= true; 
     286  for(int i=0; i<nullfs.length() && ok; i++){ 
     287    QString nfspoint = nullfs[i].section(" on ",1,10).section("(",0,0).simplified(); 
     288    ok = umount(force, nfspoint); 
     289  } 
     290  //If successful, also unmount the main mountpoint 
     291  if(ok){ 
     292    ok = umount(force, mountpoint); 
     293  } 
    282294  //Make sure there are no spaces in the mounpoint path 
    283   QString cmd1 = "umount \"" + mountpoint +"\""; 
    284   if(force){ cmd1.replace("umount ","umount -f "); } 
    285   QString cmd2 = "rmdir \"" + mountpoint +"\""; 
    286   qDebug() << "Unmounting device from" << mountpoint; 
     295  //QString cmd1 = "umount \"" + mountpoint +"\""; 
     296  //if(force){ cmd1.replace("umount ","umount -f "); } 
     297  //QString cmd2 = "rmdir \"" + mountpoint +"\""; 
     298  //qDebug() << "Unmounting device from" << mountpoint; 
    287299  //Run the commands 
    288   QStringList output; 
     300  //QStringList output; 
    289301  QString result, title; 
    290   bool ok = FALSE; 
     302  /*bool ok = umount(force, mountpoint); 
    291303  output = pcbsd::Utils::runShellCommand(cmd1); 
    292304  if(output.join(" ").simplified().isEmpty()){ 
     
    299311      qDebug() << " - Error message:" << output; 
    300312    } 
    301     ok = TRUE; 
     313    ok = TRUE;*/ 
     314  if(ok){ 
    302315    title = QString( tr("%1 has been successfully unmounted.") ).arg(devLabel->text()); 
    303316    if(devType == "ISO"){ 
     
    315328      } 
    316329    } 
    317     qDebug() << "pc-mounttray: Error unmounting mountpoint:" << mountpoint; 
    318     qDebug() << " - Error message:" << output; 
     330    //qDebug() << "pc-mounttray: Error unmounting mountpoint:" << mountpoint; 
     331    //qDebug() << " - Error message:" << output; 
    319332    title = QString( tr("Error: %1 could not be unmounted") ).arg(devLabel->text()); 
    320     result = output.join(" "); 
     333    //result = output.join(" "); 
    321334  } 
    322335  //emit the proper signals 
     
    406419   return out; 
    407420} 
     421 
     422bool MenuItem::umount(bool force, QString mntpoint){ 
     423  QString cmd1 = "umount \"" + mntpoint +"\""; 
     424  if(force){ cmd1.replace("umount ","umount -f "); } 
     425  QString cmd2 = "rmdir \"" + mountpoint +"\""; 
     426  qDebug() << "Unmounting device from" << mntpoint; 
     427  //Run the commands 
     428  QStringList output; 
     429  QString result, title; 
     430  bool ok = FALSE; 
     431  output = systemCMD(cmd1); 
     432  if(output.join(" ").simplified().isEmpty()){ 
     433    //unmounting successful, remove the mount point directory 
     434    if(mountpoint != "/mnt" && mountpoint != "/media"){ //make sure not to remove base directories 
     435      output = systemCMD(cmd2); 
     436    } 
     437    if(!output.join(" ").simplified().isEmpty()){ 
     438      qDebug() << "pc-mounttray: Error removing mountpoint:" << mountpoint; 
     439      qDebug() << " - Error message:" << output; 
     440    } 
     441    ok = TRUE; 
     442  }else{ 
     443    qDebug() << "pc-mounttray: Error unmounting mountpoint:" << mountpoint; 
     444    qDebug() << " - Error message:" << output; 
     445  } 
     446  return ok; 
     447} 
     448 
Note: See TracChangeset for help on using the changeset viewer.