void KovanTestWindow::openLogFile() { #ifdef linux QString mountPoint; while (1) { qApp->processEvents(); QFile mounts("/proc/mounts"); QString line; mounts.open(QIODevice::ReadOnly | QIODevice::Text); for (line = mounts.readLine(); !line.isNull(); line = mounts.readLine()) { if (!line.contains("/media/sd")) continue; QString testDirectory; QString testFile; QString serial = engine->serialNumber(); QFile currentFile; mountPoint = line.split(' ')[1]; QDir currentDir(mountPoint); qDebug() << "Current dir (mountPoint):" << currentDir.path(); testDirectory = "kovan-logs/"; testDirectory.append(serial.split('-')[0]); if (!currentDir.mkpath(testDirectory)) { qDebug() << "Unable to make directory"; continue; } testFile = testDirectory; testFile.append("/"); testFile.append(serial); testFile.append(".html"); logFile.setFileName(currentDir.absoluteFilePath(testFile)); if (!logFile.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text)) { qDebug() << "Unable to create logfile" << logFile.fileName(); continue; } logFile.write("<p>Started a new test\n"); logFile.flush(); return; } } #endif return; }
void Device::DriveInfo() { EraseDriveInfo(); for(QStorageInfo i: QStorageInfo::mountedVolumes()) { if(i.device() == path) { size = i.bytesTotal(); // model = "UND"; // serial = "UND"; // firmware = "UND"; fs = true; fstype = i.fileSystemType(); mountpoint = i.rootPath(); } } // Old way reading only for filesystem mount options QFile mounts("/proc/mounts"); if(mounts.open(QFile::ReadOnly | QIODevice::Text)) { while(true) { // read all mounts lines QString line = mounts.readLine(); // get line // check line end - this is not normal file atEnd() won`t help if(line.length() == 0) break; QStringList list = line.split(' '); // split line to fields // if this line describes selected device if((list.size() == 6) && ((!QFile::symLinkTarget(list[0]).compare(path)) || (!path.compare(list[0])))) { fsoptions = (QString)(list[3]).trimmed().replace(",","\n"); break; } } mounts.close(); } // get info about kernel utsname buf; memset(&buf, 0, sizeof(utsname)); if(!uname(&buf)) { kernel = QString::fromLatin1(buf.sysname) + " - " + QString::fromLatin1(buf.release); } }
void diskSt(long long * diskStat, string fn){ // first finding base directory for the file int pos=fn.find('/',2); string dis; dis=fn.substr(0, pos); cout<<"\nmount point from fn: "<<dis<<endl; // finding which device has this mount string na, nb, nc, nd; int i1; ifstream mounts ("/proc/mounts", ios::in); if (mounts.is_open()){ while(!mounts.eof()){ mounts>>na>>nb>>nc>>nd>>i1>>i1; if (nb.compare(dis)==0) { cout<<na<<"\t"<<nb<<"\t"; if (na.substr(0,5).compare("/dev/")==0) na=na.substr(5); cout<<na<<endl; break; } } } ifstream file ("/proc/diskstats", ios::in); if (file.is_open()){ while(!file.eof()){ string name=""; file>>i1>>i1>>name; // cout<<name<<"\t"; for (int c=0;c<11;c++) { file>>diskStat[c]; // cout<<diskStat[c]<<"\t"; } // cout<<endl; if (!name.compare(na)) { // for (int c=0;c<11;c++) cout<<diskStat[c]<<"\t"; cout<<endl; break; }; } } file.close(); }
#endif /* Re-declare these as non-extern since we're providing the symbols */ PyObject *PsiExc_AttrNotAvailableError = NULL; PyObject *PsiExc_AttrInsufficientPrivsError = NULL; PyObject *PsiExc_AttrNotImplementedError = NULL; /* More contstants */ static char MODULE_NAME[] = "psi.mount"; PyDoc_STRVAR(MODULE_DOC, "Module for system mount information"); PyDoc_STRVAR(psi_mount_mounts__doc, "\ mounts(remote=False) -> iterator\n\ \n\ Return an iterator containing ojects representing mounted filesystems. The\n\ remote argument is a boolean value that can be used to control if remote\n\ filesystems should be included or not. Remote filesystems might take longer\n\ to be created or suffer from timeouts collecting information from them.\n\ "); static PyObject * psi_mount_mounts(PyObject *self, PyObject *args, PyObject *kwds) { static char *kwlist[] = {"remote", NULL}; psi_mountlist_t *mountlist; PyObject *mount; PyObject *list; PyObject *iter; ssize_t i;
uint64 nglPath::GetVolumes(std::list<nglPathVolume>& rVolumes, uint64 Flags) { #if (defined _CARBON_ || defined _COCOA_) nglPathVolume::UpdateVolumes(rVolumes); #else #define DEVICE tokens[0] #define MPOINT tokens[1] #define FSTYPE tokens[2] // Parse /etc/fstab to list all potential mount points nglString line; nglIFile fstab("/etc/fstab"); if (fstab.GetState() == eStreamError) return 0; while (fstab.ReadLine(line)) { if (line[0] == _T('#')) continue; std::vector<nglString> tokens; nglPathVolume vol; line.Tokenize(tokens, _T(" \t")); if (tokens.size() < 4) continue; if (tokens.size() && nglPath_SetVolume(vol, tokens[1], tokens[0], tokens[2], tokens[3])) rVolumes.push_front(vol); } // Parse /proc/mounts to list all mounted items nglIFile mounts("/proc/mounts"); if (mounts.GetState() == eStreamError) return rVolumes.size(); while (mounts.ReadLine(line)) { std::vector<nglString> tokens; std::list<nglPathVolume>::iterator i; nglPathVolume newvol; nglPathVolume* vol; line.Tokenize(tokens, _T(" \t")); for (i = rVolumes.begin(); (i != rVolumes.end()) && ((*i).mPath != tokens[1]); i++); if (i != rVolumes.end()) vol = &(*i); // Already in list else { // Create new entry if (tokens.size() && nglPath_SetVolume(newvol, tokens[1], tokens[0], tokens[2], tokens[3])) rVolumes.push_front(newvol); vol = &newvol; } vol->mFlags &= ~nglPathVolume::Offline; if (nglPath_IsRO(tokens[3])) vol->mFlags |= nglPathVolume::ReadOnly; } #endif nglVolume::GetVolumes(rVolumes, Flags); return rVolumes.size(); }