summaryrefslogtreecommitdiff
path: root/noncore/settings/backup/backuprestore.cpp
Unidiff
Diffstat (limited to 'noncore/settings/backup/backuprestore.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/backup/backuprestore.cpp51
1 files changed, 35 insertions, 16 deletions
diff --git a/noncore/settings/backup/backuprestore.cpp b/noncore/settings/backup/backuprestore.cpp
index 869c1b8..d028379 100644
--- a/noncore/settings/backup/backuprestore.cpp
+++ b/noncore/settings/backup/backuprestore.cpp
@@ -280,11 +280,18 @@ void BackupAndRestore::backup()
280 280
281void BackupAndRestore::backupRootFs() 281void BackupAndRestore::backupRootFs()
282{ 282{
283//#define MDEBUG 283 if ( ( ODevice::inst()->model() != Model_Zaurus_SL5000 ) && ( ODevice::inst()->model() != Model_Zaurus_SL5500 ) )
284#ifndef MDEBUG 284 {
285 QMessageBox::critical( this, "Opie-Backup", "<qt>This feature is not yet implemented.</qt>", "Bummer!" ); 285 QMessageBox::critical( this, "Not yet implemented!", "<qt>Sorry, support for this model is not yet done.</qt>", "Ok" );
286 return; 286 return;
287#endif 287 }
288
289 if ( !QFile::exists( "/usr/bin/mkfs.jffs2" ) && !QFile::exists( "/usr/sbin/mkfs.jffs2" ) )
290 {
291 QMessageBox::critical( this, "Can't find utility!", "<qt>Can't find mkfs.jffs2 - Install mtd-utils.</qt>", "Ok" );
292 return;
293 }
294
288 // call 'mount' and parse its output to gather the device on which the root partition is mounted 295 // call 'mount' and parse its output to gather the device on which the root partition is mounted
289 FILE* mountp = popen( "mount", "r" ); 296 FILE* mountp = popen( "mount", "r" );
290 QString device; 297 QString device;
@@ -300,19 +307,17 @@ void BackupAndRestore::backupRootFs()
300 mounto >> device >> on >> mountpoint >> type >> filesystem >> options; 307 mounto >> device >> on >> mountpoint >> type >> filesystem >> options;
301 if ( mountpoint == "/" ) break; 308 if ( mountpoint == "/" ) break;
302 } 309 }
303 odebug << device << " is formatted w/ " << filesystem << " and mounted on " << mountpoint << oendl; 310 odebug << device << " is formatted w/ '" << filesystem << "' and mounted on '" << mountpoint << "'" << oendl;
304 311
305 if ( !mountpoint.startsWith( "/dev/mtdblock" ) ) 312 if ( !device.startsWith( "/dev/mtdblock" ) )
306 { 313 {
307 QMessageBox::critical( this, "Can't backup!", QString( "<qt>unsupported rootfs %1 - needs to be /dev/mtdblockN</qt>").arg( device ), "Ok" ); 314 QMessageBox::critical( this, "Can't backup!", QString( "<qt>unsupported root device '%1' - needs to be /dev/mtdblockN</qt>").arg( device ), "Ok" );
308#ifndef MDEBUG
309 return; 315 return;
310#endif
311 } 316 }
312 } // at this point, the QTextStream has been destroy and we can close the FILE* 317 } // at this point, the QTextStream has been destroy and we can close the FILE*
313 pclose( mountp ); 318 pclose( mountp );
314 319
315#ifndef MDEBUG 320#if 1
316 int rootmtd = device.right( 1 ).toInt(); 321 int rootmtd = device.right( 1 ).toInt();
317#else 322#else
318 int rootmtd = 0; 323 int rootmtd = 0;
@@ -324,6 +329,7 @@ void BackupAndRestore::backupRootFs()
324 if ( !procmtdf.open( IO_ReadOnly ) ) 329 if ( !procmtdf.open( IO_ReadOnly ) )
325 { 330 {
326 QMessageBox::critical( this, "Can't backup!", "<qt>Can't open /proc/mtd</qt>", "Ok" ); 331 QMessageBox::critical( this, "Can't backup!", "<qt>Can't open /proc/mtd</qt>", "Ok" );
332 return;
327 } 333 }
328 334
329 QTextStream procmtd( &procmtdf ); 335 QTextStream procmtd( &procmtdf );
@@ -356,15 +362,28 @@ void BackupAndRestore::backupRootFs()
356 outputFile += "/initrd.bin-" + dateString; 362 outputFile += "/initrd.bin-" + dateString;
357 363
358 // call mkfs.jffs2 to create the backup 364 // call mkfs.jffs2 to create the backup
359 QString cmdline = QString( "mkfs.jffs2 --root=/ %1 --little-endian %2 %3 -n" ).arg( outputFile ).arg( pad ).arg( eraseblock ); 365 QString cmdline = QString( "mkfs.jffs2 --faketime --root=/ %1 --little-endian %2 %3 -n" ).arg( outputFile ).arg( pad ).arg( eraseblock );
366 cmdline.append( " --ignore=/tmp --ignore=/mnt --ignore=/var --ignore=/proc" );
360 owarn << "Calling '" << cmdline << "'" << oendl; 367 owarn << "Calling '" << cmdline << "'" << oendl;
361 368
362#ifndef MDEBUG 369 OWait *owait = new OWait();
363 ::system( cmdline ); 370 Global::statusMessage( tr( "Backing up..." ) );
364#endif 371 owait->show();
372 qApp->processEvents();
365 373
366 // FIXME: Add image postprocessing for C7x0 and C8x0, for Beagle, for SIMpad 374 int r = ::system( cmdline );
375
376 owait->hide();
377 delete owait;
378
379 if ( r != 0 )
380 {
381 perror("Error: ");
382 QString errorMsg = QString( tr( "<qt>%1</qt>" ).arg( strerror( errno ) ) );
383 QMessageBox::critical(this, tr( "Backup Failed!" ), errorMsg, QString( tr( "Ok" ) ) );
384 }
367 385
386 // FIXME: Add image postprocessing for C7x0 and C8x0, for Beagle, for SIMpad
368} 387}
369 388
370void BackupAndRestore::backupUserData() 389void BackupAndRestore::backupUserData()