summaryrefslogtreecommitdiff
path: root/noncore/tools/formatter/formatter.cpp
authorllornkcor <llornkcor>2002-04-25 13:24:10 (UTC)
committer llornkcor <llornkcor>2002-04-25 13:24:10 (UTC)
commit48dbc8fb69a5d19f466ea757207e42c3861b4dee (patch) (unidiff)
treede6f9b02ba305545b2b31edf01cabe64f0909d0b /noncore/tools/formatter/formatter.cpp
parentaa68d832dbae9ec85ac7f9478bc8b2165e43c969 (diff)
downloadopie-48dbc8fb69a5d19f466ea757207e42c3861b4dee.zip
opie-48dbc8fb69a5d19f466ea757207e42c3861b4dee.tar.gz
opie-48dbc8fb69a5d19f466ea757207e42c3861b4dee.tar.bz2
added x86 testing stuff changed output to more verbose
Diffstat (limited to 'noncore/tools/formatter/formatter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/tools/formatter/formatter.cpp125
1 files changed, 97 insertions, 28 deletions
diff --git a/noncore/tools/formatter/formatter.cpp b/noncore/tools/formatter/formatter.cpp
index 8c8ef2a..0dd42c8 100644
--- a/noncore/tools/formatter/formatter.cpp
+++ b/noncore/tools/formatter/formatter.cpp
@@ -48,2 +48,4 @@
48#include <mntent.h> 48#include <mntent.h>
49#include <string.h>
50#include <errno.h>
49 51
@@ -177,21 +179,35 @@ void FormatterApp::doFormat() {
177 QString currentText = storageComboBox->currentText(); 179 QString currentText = storageComboBox->currentText();
178 QString cmd = currentText.right( currentText.length() - currentText.find(" -> ",0,TRUE) - 4); 180 QString cmd;
181 QString diskDevice = currentText.right( currentText.length() - currentText.find(" -> ",0,TRUE) - 4);
182 QString diskName = currentText.left(currentText.find(" -> ",0,TRUE));
179 QString fs = fileSystemsCombo->currentText(); 183 QString fs = fileSystemsCombo->currentText();
180 184
185#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) // lets test on something cheap
186#else
187 currentText = diskDevice = "/dev/fd0";
188 umountS = "umount -v /floppy 2>&1";
189 remountS = "mount -v /floppy 2>&1";
190#endif
191
181 if( currentText.find("CF",0,TRUE) != -1) { 192 if( currentText.find("CF",0,TRUE) != -1) {
182 umountS = "/sbin/cardctl eject"; 193 umountS = "umount ";
183 remountS = "/sbin/cardctl insert"; 194 remountS = "mount ";
195
196// umountS = "/sbin/cardctl eject";
197// remountS = "/sbin/cardctl insert";
184 } 198 }
185 if( currentText.find("SD",0,TRUE) != -1) { 199 if( currentText.find("SD",0,TRUE) != -1) {
186 umountS = "/etc/sdcontrol compeject"; 200 umountS = "umount ";
187 remountS = "/etc/sdcontrol insert"; 201 remountS = "mount ";
202// umountS = "/etc/sdcontrol compeject";
203// remountS = "/etc/sdcontrol insert";
188 } 204 }
189 205
190 switch ( QMessageBox::warning(this,tr("Format?!?"),tr("Really format\n") + currentText + 206 switch ( QMessageBox::warning(this,tr("Format?!?"),tr("Really format\n") +diskName+" "+ currentText +
191 tr("\nwith ") + fs + tr(" filesystem?!?"),tr("Yes"),tr("No"),0,1,1) ) { 207 tr("\nwith ") + fs + tr(" filesystem?!?\nYou will loose all data!!"),tr("Yes"),tr("No"),0,1,1) ) {
192 case 0: { 208 case 0: {
193 if(fs == "vfat") 209 if(fs == "vfat")
194 cmd = "mkdosfs " + cmd; 210 cmd = "mkdosfs -v " + diskDevice+" 2>&1";
195 else if(fs == "ext2") 211 else if(fs == "ext2")
196 cmd = "mke2fs " + cmd; 212 cmd = "mke2fs -v " + diskDevice+" 2>&1";
197 else { 213 else {
@@ -207,8 +223,12 @@ void FormatterApp::doFormat() {
207 char line[130]; 223 char line[130];
208 outDlg->OutputEdit->append( tr("Trying to eject.") + currentText ); 224 outDlg->OutputEdit->append( tr("Trying to umount.") + currentText );
225 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
226
209 sleep(1); 227 sleep(1);
210 fp = popen( (const char *) umountS, "r"); 228 qDebug("Command is "+umountS);
229 fp = popen( (const char *) umountS, "r");
230 qDebug("%d", fp);
211 if ( !fp ) { 231 if ( !fp ) {
212 qDebug("Could not execute '" + umountS + "'! err=%d", fp); 232 qDebug("Could not execute '" + umountS + "'! err=%d\n" +(QString)strerror(errno), err);
213 QMessageBox::warning( this, tr("CardMonitor"), tr("Card eject failed!"), tr("&OK") ); 233 QMessageBox::warning( this, tr("Formatter"), tr("umount failed!"), tr("&OK") );
214 pclose(fp); 234 pclose(fp);
@@ -216,6 +236,16 @@ void FormatterApp::doFormat() {
216 } else { 236 } else {
217 outDlg->OutputEdit->append( currentText + tr("\nhas been successfully ejected.")); 237// outDlg->OutputEdit->append( currentText + tr("\nhas been successfully umounted."));
218 238// outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
219 while ( fgets( line, sizeof line, fp)) { 239 while ( fgets( line, sizeof line, fp)) {
220 outDlg->OutputEdit->append(line); 240 if( ((QString)line).find("busy",0,TRUE) != -1) {
241 qDebug("Could not find '" + umountS);
242 QMessageBox::warning( this, tr("Formatter"), tr("Could not umount.\nDevice is busy!"), tr("&OK") );
243 pclose(fp);
244 return;
245 } else {
246 QString lineStr = line;
247 lineStr=lineStr.left(lineStr.length()-1);
248 outDlg->OutputEdit->append(lineStr);
249 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
250 }
221 } 251 }
@@ -223,3 +253,2 @@ void FormatterApp::doFormat() {
223 pclose(fp); 253 pclose(fp);
224// err = system( (const char *) umountS);
225 254
@@ -227,2 +256,3 @@ void FormatterApp::doFormat() {
227 outDlg->OutputEdit->append( tr("Trying to format.") ); 256 outDlg->OutputEdit->append( tr("Trying to format.") );
257 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
228 258
@@ -230,17 +260,34 @@ void FormatterApp::doFormat() {
230 while ( fgets( line, sizeof line, fp)) { 260 while ( fgets( line, sizeof line, fp)) {
231 outDlg->OutputEdit->append(line); 261 if( ((QString)line).find("No such device",0,TRUE) != -1) {
262 qDebug("No such device '" + umountS);
263 QMessageBox::warning( this, tr("Formatter"), tr("No such device!"), tr("&OK") );
264 pclose(fp);
265// outDlg->OutputEdit->append("No such device");
266// outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
267 return;
268 } else {
269 QString lineStr = line;
270 lineStr=lineStr.left(lineStr.length()-1);
271 outDlg->OutputEdit->append(lineStr);
272 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
273 }
232 } 274 }
233 outDlg->OutputEdit->append( currentText + tr("\nhas been successfully formatted.")); 275 outDlg->OutputEdit->append( currentText + tr("\nhas been successfully formatted."));
276 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
234 pclose(fp); 277 pclose(fp);
235 278
236 outDlg->OutputEdit->append( tr("Trying to insert.") + currentText ); 279 outDlg->OutputEdit->append( tr("Trying to mount.") + currentText );
280 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
237 fp = popen( (const char *) remountS, "r"); 281 fp = popen( (const char *) remountS, "r");
238 if ( !fp) { 282 if ( !fp) {
239 qDebug("Could not execute '" + remountS + "'! err=%d", err); 283 qDebug("Could not execute '" + remountS + "'! err=%d\n" +(QString)strerror(errno), err);
240 QMessageBox::warning( this, tr("Formatter"), tr("Card insert failed!"), tr("&OK") ); 284 QMessageBox::warning( this, tr("Formatter"), tr("Card mount failed!"), tr("&OK") );
241 285
242 } else { 286 } else {
243 outDlg->OutputEdit->append( currentText + tr("\nhas been successfully inserted.")); 287 outDlg->OutputEdit->append( currentText + tr("\nhas been successfully mounted."));
244 while ( fgets( line, sizeof line, fp)) { 288 while ( fgets( line, sizeof line, fp)) {
245 outDlg->OutputEdit->append(line); 289 QString lineStr = line;
290 lineStr=lineStr.left(lineStr.length()-1);
291 outDlg->OutputEdit->append(lineStr);
292 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
246 } 293 }
@@ -251,5 +298,6 @@ void FormatterApp::doFormat() {
251 outDlg->OutputEdit->append(tr("You can now close the output window.")); 298 outDlg->OutputEdit->append(tr("You can now close the output window."));
252 outDlg->close(); 299 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
253 if(outDlg) 300// outDlg->close();
254 delete outDlg; 301// if(outDlg)
302// delete outDlg;
255 } 303 }
@@ -259,2 +307,7 @@ void FormatterApp::doFormat() {
259 307
308bool FormatterApp::doFdisk() {
309 return FALSE;
310
311}
312
260void FormatterApp::fillCombos() { 313void FormatterApp::fillCombos() {
@@ -408,3 +461,3 @@ QString FormatterApp::getFileSystemType(const QString &currentText) {
408 461
409void FormatterApp::doFsck() { 462bool FormatterApp::doFsck() {
410 463
@@ -418,2 +471,18 @@ void FormatterApp::doFsck() {
418 471
472
473 return FALSE;
474}
475
476bool FormatterApp::doFsckCheck() {
477 return FALSE;
478}
479
480int FormatterApp::formatCheck(const QString &deviceStr) {
481
482 return -1;
483}
484
485int FormatterApp::runCommand(const QString &command) {
486
487 return -1;
419} 488}