Changeset 6135fc9


Ignore:
Timestamp:
01/08/15 07:56:13 (8 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, enter/10, releng/10.1.1, releng/10.1.2, releng/10.2, stable/10
Children:
422df85
Parents:
fac2206
Message:

Add the ability to detect the current size of a mounted device (current/total (percent)) to pc-sysconfig.

Location:
src-sh/pcbsd-utils/pc-sysconfig
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src-sh/pcbsd-utils/pc-sysconfig/client/MainClient.cpp

    r7f4196d r6135fc9  
    3232  qDebug() << " \"list-mounteddev\": List all removable devices that are currently mounted"; 
    3333  qDebug() << " \"supportedfilesystems\": List all the filesystems that are currently detected/supported by pc-sysconfig"; 
    34   qDebug() << " \"devinfo <device> [skiplabel]\": Fetch device information (Filesystem, Label, Type)\n"; 
     34  qDebug() << " \"devinfo <device> [skiplabel]\": Fetch device information (Filesystem, Label, Type)"; 
     35  qDebug() << " \"devsize <device>\": Fetch device space (must be mounted)\n"; 
    3536  qDebug() << "Available Action Commands:"; 
    3637  qDebug() << " \"mount <device> [<filesystem>] [<mountpoint>]\":"; 
  • src-sh/pcbsd-utils/pc-sysconfig/daemon/Backend-remdev.cpp

    r7f4196d r6135fc9  
    283283} 
    284284 
     285QString Backend::getDeviceSizeInfo(QString nodedir){ 
     286  //can use node *or* mntdir 
     287  updateIntMountPoints(); 
     288  QStringList found = IntMountPoints.filter(nodedir+DELIM); 
     289  QString out = "%1/%2 (%3)"; //<used>/<total> (<percent>) 
     290  if(found.length()>0){ 
     291    QString dir = found[0].section(DELIM,2,2); 
     292    //This might not work properly for ZFS file systems (FIX LATER) 
     293    QStringList info = runShellCommand("df -h \""+dir+"\""); 
     294    if(info.length()>1){  
     295      //first line is the labels (Filesystem, Size, Used, Avail, Capacity, Mounted On) 
     296      info[1] = info[1].replace("\t"," "); 
     297      QStringList stats = info[1].split(" ", QString::SkipEmptyParts); 
     298      if(stats.length() >= 5){ 
     299        out = out.arg(stats[2], stats[1], stats[4]); 
     300      }else{ 
     301        out = out.arg("??","??","??"); 
     302      } 
     303    }else{ 
     304      out = out.arg("??","??","??"); 
     305    } 
     306  }else{ 
     307    out = out.arg("??","??","??"); 
     308  } 
     309  return out; 
     310} 
     311 
    285312QString Backend::mountRemDev(QString node, QString mntdir, QString fs){ 
    286313  //See if we need to probe the device here and adjust inputs 
  • src-sh/pcbsd-utils/pc-sysconfig/daemon/Backend.h

    r7f4196d r6135fc9  
    3636          }else if(req.length() ==2){ 
    3737            if(req[0] == "devinfo"){ outputs = getRemDevInfo(req[1]); } 
     38            else if(req[0] == "devsize"){ outputs << getDeviceSizeInfo(req[1]); } 
    3839            else if(req[0] == "mount"){ outputs << mountRemDev(req[1],"",""); } //fully-auto mounting of device "mount <dev>" 
    3940            else if(req[0] == "unmount"){ outputs << unmountRemDev(req[1],false); } //"unmount <dev or dir>" 
     
    8586        QStringList listMountedNodes(); 
    8687        QString generateGenericLabel(QString type); 
     88        QString getDeviceSizeInfo(QString nodedir); 
    8789         
    8890        QString mountRemDev(QString node, QString mntdir, QString fs); 
Note: See TracChangeset for help on using the changeset viewer.