bool SystemConfig::isFlashMounted() { if (is166E()) { return isMounted("/media/mtd8/vfat.bin"); } else if (isImx508()) { return isMounted("/dev/mmcblk0p3"); } return isMounted("/dev/mtdblock5"); }
// Helper function, perform a sanity check on the device MythMediaError MythCDROMFreeBSD::testMedia() { bool OpenedHere = false; if (!isDeviceOpen()) { if (!openDevice()) { if (errno == EBUSY) { return isMounted() ? MEDIAERR_OK : MEDIAERR_FAILED; } else { return MEDIAERR_FAILED; } } OpenedHere = true; } // Be nice and close the device if we opened it, otherwise it might be locked when the user doesn't want it to be. if (OpenedHere) closeDevice(); return MEDIAERR_OK; }
void PCloudApp::openCloudDir(){ QString path = settings->get("path"); #ifdef Q_OS_WIN int retray = 5; char drive = path.toUtf8().at(0); if (drive >= 'A' && drive <= 'Z') drive -= 'A'; else if (drive >= 'a' && drive <= 'z') drive -= 'a'; else return; while (retray-- && !isConnected(drive)){ Sleep(1000); } if (!QProcess::startDetached("explorer.exe", QStringList(path))){ QDesktopServices::openUrl(QUrl::fromLocalFile(path)); } #else if (isMounted()){ QDesktopServices::openUrl(QUrl::fromLocalFile(path)); } #endif }
void mf::PlayAVInterface::umountUrl() { QString cmd; if (isMounted(m_mountPoint, m_preloadfs)) { cmd = "fusermount -u " + m_mountPoint + m_preloadfs; umount(cmd); } if (isMounted(m_mountPoint, m_httpfs)) { cmd = "fusermount -u " + m_mountPoint + m_httpfs; umount(cmd); } }
// Helper function, perform a sanity check on the device MediaError MythCDROMFreeBSD::testMedia() { //cout << "MythCDROMLinux::testMedia - "; bool OpenedHere = false; if (!isDeviceOpen()) { //cout << "Device is not open - "; if (!openDevice()) { //cout << "failed to open device - "; if (errno == EBUSY) { //cout << "errno == EBUSY" << endl; return isMounted(true) ? MEDIAERR_OK : MEDIAERR_FAILED; } else { return MEDIAERR_FAILED; } } //cout << "Opened it - "; OpenedHere = true; } // Be nice and close the device if we opened it, otherwise it might be locked when the user doesn't want it to be. if (OpenedHere) closeDevice(); return MEDIAERR_OK; }
void MenuItem::updateItem(){ //Update the item visuals, based upon current device status if( isConnected() ){ if( isMounted() ){ if(mountpoint.isEmpty()){ //detect the current mountpoint QString output = pcbsd::Utils::runShellCommandSearch("mount",device); mountpoint = output.section(" on ",1,1).section(" (",0,0).replace(" ","-"); } devIcon->setEnabled(TRUE); //Make the icon full color devIcon->setToolTip(device+"\n"+QString(tr("Mounted at %1")).arg(mountpoint)); pushMount->setText(tr("Eject")); pushMount->setIcon(QIcon(":icons/eject.png")); if(devType != "ISO"){ checkAutomount->setVisible(TRUE); } else{ checkAutomount->setVisible(FALSE); } }else{ devIcon->setEnabled(FALSE); //Grey out the icon if not mounted devIcon->setToolTip(device); pushMount->setText(tr("Mount")); pushMount->setIcon(QIcon(":icons/mount.png")); checkAutomount->setVisible(FALSE); } }else{ emit itemRemoved(device); return; } //Set visibility and sizes on progressbar updateSizes(); }
void MenuItem::unmountItem(bool force){ //Unmount the device //Check to see if the current mountpoint exists or if it is somewhere else if( !QFile::exists(mountpoint) ){ if( !isMounted() ){ //double check that it is actually mounted (and fix the mountpoint) //it is not mounted to begin with return; } } bool ok = umount(force, mountpoint); QString result, title; if(ok){ title = QString( tr("%1 has been successfully unmounted.") ).arg(devLabel->text()); if(devType == "ISO"){ result = tr("The ISO file has been detached from the system."); }else{ result = tr("It is now safe to remove the device"); } }else{ title = QString( tr("Error: %1 was not unmounted") ).arg(devLabel->text()); } //emit the proper signals if(ok){ qDebug() << " *Success*"; mountpoint.clear(); emit itemUnmounted(device); }else{ qDebug() << " *Failure*"; } emit newMessage(title, result); }
void StaticShape::interpolateTick(F32 delta) { if (isMounted()) { MatrixF mat; mMount.object->getRenderMountTransform( delta, mMount.node, mMount.xfm, &mat ); Parent::setRenderTransform(mat); } }
int Utility::unmount(string mountpoint) { if (mountpoint.empty()) return -1; if (!isMounted(mountpoint)) return 0; if (umount(mountpoint.c_str()) != 0) return -1; return 0; }
const char* TurretShape::getStateName() { if (mDamageState != Enabled) return "Dead"; if (isMounted()) return "Mounted"; return "Ready"; }
static int format(const char* path) { String16 string(path); if (isMounted(path)) return -EBUSY; gMountService->formatMedia(string); return 0; }
void SpawnSphere::advanceTime( F32 timeDelta ) { if ( isMounted() ) { MatrixF mat( true ); mMount.object->getRenderMountTransform( 0.f, mMount.node, mMount.xfm, &mat ); setTransform( mat ); } }
void SpawnSphere::processTick( const Move *move ) { if ( isServerObject() && isMounted() ) { MatrixF mat( true ); mMount.object->getRenderMountTransform( 0.f, mMount.node, mMount.xfm, &mat ); setTransform( mat ); } }
void LightBase::advanceTime( F32 timeDelta ) { if ( isMounted() ) { MatrixF mat( true ); mMount.object->getRenderMountTransform( 0.f, mMount.node, mMount.xfm, &mat ); mLight->setTransform( mat ); Parent::setTransform( mat ); } }
int Utility::mount(string device, string mountpoint, eFSType type) { if (device.empty() || mountpoint.empty()) return -1; if (isMounted(mountpoint)) return 0; if (::mount(device.c_str(), mountpoint.c_str(), getFsTypeStr(type).c_str(), 0, NULL) != 0) return -1; return 0; }
void MenuItem::slotAutoMount(){ //Just like slotMountClicked, but will only mount the device if appropriate (no removals); if( isConnected() ){ if( !isMounted() ){ mountItem(); } }else{ emit itemRemoved(device); } updateItem(); }
//----------------------------------------------------------------------------- // advanceTime //----------------------------------------------------------------------------- void ParticleEmitterNode::processTick(const Move* move) { Parent::processTick(move); if ( isMounted() ) { MatrixF mat; mMount.object->getMountTransform( mMount.node, mMount.xfm, &mat ); setTransform( mat ); } }
DeviceItem * PlatformUdisks2::buildDevice(QVariantMap &blockProperties, QVariantMap &driveProperties) { DeviceItem *devItem = new DeviceItem; QString path = blockProperties.value("path").toString(); devItem->setUDI(path.mid(path.lastIndexOf("/") + 1)); qDebug() << devItem->getUDI(); isMounted(devItem->getUDI()); devItem->setPath(path); devItem->setIsRemovable(driveProperties.value("removable").toBool()); devItem->setSize(blockProperties.value("size").toLongLong()); devItem->setModelString(driveProperties.value("model").toString()); QString vendor = driveProperties.value("vendor").toString(); if (vendor == "") { if (mKioskMode) devItem->setVendorString("SUSE Studio USB Key"); else devItem->setVendorString("Unknown Device"); } else { devItem->setVendorString(vendor); } QString newDisplayString = QString("%1 %2 - %3 (%4 MB)") .arg(devItem->getVendorString()) .arg(devItem->getModelString()) .arg(devItem->getPath()) .arg(devItem->getSize() / 1048576); devItem->setDisplayString(newDisplayString); if (mKioskMode) { if((devItem->getSize() / 1048576) > 200000) { delete devItem; return(NULL); } } // If a device is 0 megs we might as well just not list it if ((devItem->getSize() / 1048576) > 0) { itemList << devItem; } else { delete devItem; devItem = NULL; } return(devItem); }
//Cleanup function void MenuItem::cleanup(){ if( isMounted() ){ unmountItem(); //unmount and remove mountpoint }else{ //Just check for mountpoint removal if(QFile::exists(mountpoint) && mountedHere){ qDebug() << "Removing old mountpoint:" << mountpoint; QString output = systemCMD("rmdir "+mountpoint).join(" "); if(!output.isEmpty()){ qDebug() << " -Error:" <<output; } } } }
bool FileSystemActor::isValidDropTarget() { // Conditional List if (isFileSystemType(DeadLink)) return false; if (!isFileSystemType(Folder) && !isFileSystemType(Executable) && !isFileSystemType(Link)) return false; int iconType = winOS->GetIconTypeFromFileName(getFullPath()); if (isFileSystemType(Virtual) && (iconType != RecycleBin && iconType != MyDocuments)) return false; if (isFileSystemType(Link) && (isFileSystemType(Executable) || isFileSystemType(Folder))) return true; if (isFileSystemType(Removable) && !isMounted()) return false; return true; }
static int mount(const char* path) { String16 string(path); gMountService->mountMedia(string); for (int i = 0; i < 60; i++) { if (isMounted(path)) { return 0; } millisecondSleep(500); } fprintf(stderr, "failed to mount %s\n", path); return -1; }
/* PRIVATE FUNCTIONS */ void MenuItem::slotMountClicked(){ //Hide the parent menu emit itemWorking(); //Now if( isConnected() ){ if( !isMounted() ){ mountItem(); }else{ unmountItem(); } }else{ emit itemRemoved(device); } updateItem(); }
static int waitForMount(const char *mntPoint, int retries) { int ret, try = 0; while (try++ < retries) { ret = isMounted(mntPoint); if (ret < 0) { fprintf(stderr, "FUSE_TEST: waitForMount(%s, %d): isMounted returned " "error %d\n", mntPoint, retries, ret); } else if (ret == 1) { return 0; } sleepNoSig(2); } return -ETIMEDOUT; }
void StaticShape::processTick(const Move* move) { Parent::processTick(move); // Image Triggers if (move && mDamageState == Enabled) { setImageTriggerState(0,move->trigger[0]); setImageTriggerState(1,move->trigger[1]); } if (isMounted()) { MatrixF mat; mMount.object->getMountTransform( mMount.node, mMount.xfm, &mat ); Parent::setTransform(mat); Parent::setRenderTransform(mat); } }
void TurretShape::interpolateTick(F32 dt) { Parent::interpolateTick(dt); if (isMounted()) { MatrixF mat; mMount.object->getRenderMountTransform( dt, mMount.node, mMount.xfm, &mat ); ShapeBase::setRenderTransform(mat); } // Orientation Point3F rot = mTurretDelta.rot + mTurretDelta.rotVec * dt; // Make sure we don't interpolate past the limits _applyLimits(rot); _setRotation(rot); }
bool MenuItem::umount(bool force, QString mntpoint){ qDebug() << "Unmounting device from" << mntpoint; if(rootRequired){ qDebug() << " - prompt for root"; } QString runscript = createRemoveScript(mntpoint, force); //Run the commands QStringList output; QString result, title; bool ok = !runscript.isEmpty(); if(ok && rootRequired){ output = systemCMD("pc-su "+runscript); } else if(ok){ output = systemCMD(runscript); } else{ return false; } //could not even create the runscript //Check output if(output.filter("ERROR:UNMOUNT").isEmpty() && !isMounted() ){ //unmounting successful if( !output.filter("ERROR:RMDIR").isEmpty() ){ qDebug() << "pc-mounttray: Error removing mountpoint:" << mountpoint; qDebug() << " - Error message:" << output; } if( !output.filter("ERROR:MDDETACH").isEmpty() ){ qDebug() << "pc-mounttray: Error detaching MD device"; qDebug() << " - Error message:" << output; } ok = true; mountedHere = false; //not mounted by this app anymore }else if( !output.filter("Device busy").isEmpty() && !force){ qDebug() << " - Device Busy"; //Ask whether to force the removal if(QMessageBox::Yes == QMessageBox::question(0,tr("Device Busy"), tr("The device appears to be busy. Would you like to unmount it anyway?")+"\n\n"+tr("NOTE: This is generally not recommended unless you are sure that you don't have any applications using the device."), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) ){ ok = umount(true, mntpoint); //force the unmount recursively } }else{ qDebug() << "pc-mounttray: Error unmounting mountpoint:" << mountpoint; qDebug() << " - Error message:" << output; ok = false; } if(DEBUG_MODE){ qDebug() << " - output:" << output; } QFile::remove(runscript); return ok; }
void SceneObject::onCameraScopeQuery( NetConnection* connection, CameraScopeQuery* query ) { // Object itself is in scope. if( this->isScopeable() ) connection->objectInScope( this ); // If we're mounted to something, that object is in scope too. if( isMounted() ) connection->objectInScope( mMount.object ); // If we're added to a scene graph, let the graph do the scene scoping. // Otherwise just put everything in the server container in scope. if( getSceneManager() ) getSceneManager()->scopeScene( query, connection ); else gServerContainer.findObjects( 0xFFFFFFFF, scopeCallback, connection ); }
void PhysicsForce::processTick( const Move * ) { if ( isMounted() ) { MatrixF test( true ); test.setPosition( Point3F( 0, 4, 0 ) ); AssertFatal( test != mMount.xfm, "Error!" ); MatrixF mat( true ); mMount.object->getMountTransform( mMount.node, mMount.xfm, &mat ); setTransform( mat ); } // Nothing to do without a body or if physics hasn't ticked. if ( !mBody || !mPhysicsTick ) return; mPhysicsTick = false; // If we lost the body then release it. if ( !mBody->isDynamic() || !mBody->isSimulationEnabled() ) { detach(); return; } // Get our distance to the body. Point3F cMass = mBody->getCMassPosition(); Point3F vector = getPosition() - cMass; // Apply the force! F32 mass = mBody->getMass(); Point3F impulse = ( mass * vector ) / TickSec; // Counter balance the linear impulse. Point3F linVel = mBody->getLinVelocity(); Point3F currentForce = linVel * mass; // Apply it. mBody->applyImpulse( cMass, impulse - currentForce ); }
string getCdromVolname(string *rep_location) { bool hasMountedHere=false; if (!isMounted(CDROM_MOUNTPOINT)) { system("mount " + CDROM_DEVICE + " " + CDROM_MOUNTPOINT + " 2>/dev/null >/dev/null"); hasMountedHere=true; } string Svolname, repLoc; // check_volname: if (FileExists(CDROM_MOUNTPOINT + "/.volume_id")) { vector<string> tmp = ReadFileStrings(CDROM_MOUNTPOINT + "/.volume_id"); if (!tmp.empty()) { Svolname = cutSpaces(tmp[0]); } } if (rep_location!=NULL) { if (FileExists(CDROM_MOUNTPOINT + "/.repository")) { vector<string> tmp = ReadFileStrings(CDROM_MOUNTPOINT + "/.repository"); if (!tmp.empty()) { repLoc = cutSpaces(tmp[0]); } } } if (hasMountedHere) system("umount " + CDROM_MOUNTPOINT + " 2>/dev/null >/dev/null"); // Validating if (Svolname.find_first_of("\n\t/><| !@#$%%^&*()`\"\'")!=std::string::npos) { return ""; } if (rep_location!=NULL) { *rep_location = repLoc; } return Svolname; }
void MenuItem::updateSizes(){ //this method only works if the device is currently mounted bool ok = FALSE; if(isMounted()){ QString cmd = "df \""+mountpoint+"\""; QStringList output = systemCMD(cmd); //make sure we use the one with a 1K blocksize if(output.length() > 1){ //parse the output (1K blocks) and save them QString line = output[1].replace("\t"," "); //qDebug() << "df output:" << output << cmd; maxSize = line.section(" ",1,1,QString::SectionSkipEmpty).simplified(); currentSize = line.section(" ",2,2,QString::SectionSkipEmpty).simplified(); ok=TRUE; }else{ maxSize.clear(); currentSize.clear(); } }else{ maxSize.clear(); currentSize.clear(); } //Now setup the display progressbar display if(ok){ currentSpace->setMaximum( maxSize.toInt() ); currentSpace->setValue( currentSize.toInt() ); currentSpace->setVisible(TRUE); //display the actual size available in the tooltip QString diskAvailable = getSizeDisplay( maxSize.toInt() - currentSize.toInt() ); //qDebug() << "MaxSize:" << maxSize << maxSize.toInt(); //qDebug() << "CurrentSize:" << currentSize << currentSize.toInt(); //qDebug() << "Disk Available:" << diskAvailable; currentSpace->setToolTip( QString( tr("%1 of disk space available") ).arg(diskAvailable) ); }else{ currentSpace->setVisible(FALSE); } }