-rw-r--r-- | noncore/tools/formatter/formatter.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/noncore/tools/formatter/formatter.cpp b/noncore/tools/formatter/formatter.cpp index d52a4be..bd0bb01 100644 --- a/noncore/tools/formatter/formatter.cpp +++ b/noncore/tools/formatter/formatter.cpp | |||
@@ -449,59 +449,60 @@ void FormatterApp::parsetab(const QString &fileName) { | |||
449 | // QString filesystemType= s.left(0,s.find(BLANK) ); | 449 | // QString filesystemType= s.left(0,s.find(BLANK) ); |
450 | // } | 450 | // } |
451 | // } | 451 | // } |
452 | // } | 452 | // } |
453 | // f.close(); | 453 | // f.close(); |
454 | // } | 454 | // } |
455 | } | 455 | } |
456 | 456 | ||
457 | QString FormatterApp::getFileSystemType(const QString ¤tText) { | 457 | QString FormatterApp::getFileSystemType(const QString ¤tText) { |
458 | 458 | ||
459 | parsetab("/etc/mtab"); //why did TT forget filesystem type? | 459 | parsetab("/etc/mtab"); //why did TT forget filesystem type? |
460 | 460 | ||
461 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { | 461 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { |
462 | QString temp = (*it); | 462 | QString temp = (*it); |
463 | if( temp.find( currentText,0,TRUE) != -1) { | 463 | if( temp.find( currentText,0,TRUE) != -1) { |
464 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | 464 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); |
465 | // qDebug(fsType); | 465 | // qDebug(fsType); |
466 | } | 466 | } |
467 | } | 467 | } |
468 | return ""; | 468 | return ""; |
469 | } | 469 | } |
470 | 470 | ||
471 | bool FormatterApp::doFsck() { | 471 | bool FormatterApp::doFsck() { |
472 | 472 | ||
473 | Output *outDlg; | 473 | Output *outDlg; |
474 | QString selectedDevice; | 474 | QString selectedDevice; |
475 | //f defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) // lets test on something cheap | 475 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) |
476 | selectedDevice = deviceComboBox->currentText(); | 476 | selectedDevice = deviceComboBox->currentText(); |
477 | //#else | 477 | #else |
478 | // for testing | ||
478 | // currentText = diskDevice = "/dev/fd0"; | 479 | // currentText = diskDevice = "/dev/fd0"; |
479 | QString umountS = "umount -v /floppy 2>&1"; | 480 | QString umountS = "umount -v /floppy 2>&1"; |
480 | QString remountS = "mount -v /floppy 2>&1"; | 481 | QString remountS = "mount -v /floppy 2>&1"; |
481 | selectedDevice ="/dev/fd0"; | 482 | selectedDevice ="/dev/fd0"; |
482 | 483 | ||
483 | //#endif | 484 | #endif |
484 | 485 | ||
485 | QString fsType = getFileSystemType((const QString &)selectedDevice); | 486 | QString fsType = getFileSystemType((const QString &)selectedDevice); |
486 | QString cmd; | 487 | QString cmd; |
487 | qDebug( selectedDevice +" "+ fsType); | 488 | qDebug( selectedDevice +" "+ fsType); |
488 | if(fsType == "vfat") cmd = "dosfsck -vy "; | 489 | if(fsType == "vfat") cmd = "dosfsck -vy "; |
489 | if(fsType == "ext2") cmd = "e2fsck -cpvy "; | 490 | if(fsType == "ext2") cmd = "e2fsck -cpvy "; |
490 | cmd += selectedDevice + " 2>&1"; | 491 | cmd += selectedDevice + " 2>&1"; |
491 | 492 | ||
492 | outDlg = new Output(this, tr("Formatter Output"),FALSE); | 493 | outDlg = new Output(this, tr("Formatter Output"),FALSE); |
493 | outDlg->showMaximized(); | 494 | outDlg->showMaximized(); |
494 | outDlg->show(); | 495 | outDlg->show(); |
495 | qApp->processEvents(); | 496 | qApp->processEvents(); |
496 | FILE *fp; | 497 | FILE *fp; |
497 | char line[130]; | 498 | char line[130]; |
498 | outDlg->OutputEdit->append( tr("Trying to umount.")); | 499 | outDlg->OutputEdit->append( tr("Trying to umount.")); |
499 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 500 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
500 | 501 | ||
501 | sleep(1); | 502 | sleep(1); |
502 | // qDebug("Command is "+umountS); | 503 | // qDebug("Command is "+umountS); |
503 | fp = popen( (const char *) umountS, "r"); | 504 | fp = popen( (const char *) umountS, "r"); |
504 | // qDebug("%d", fp); | 505 | // qDebug("%d", fp); |
505 | if ( !fp ) { | 506 | if ( !fp ) { |
506 | qDebug("Could not execute '" + umountS + "'!\n" +(QString)strerror(errno)); | 507 | qDebug("Could not execute '" + umountS + "'!\n" +(QString)strerror(errno)); |
507 | QMessageBox::warning( this, tr("Formatter"), tr("umount failed!"), tr("&OK") ); | 508 | QMessageBox::warning( this, tr("Formatter"), tr("umount failed!"), tr("&OK") ); |