summaryrefslogtreecommitdiff
path: root/noncore/settings/backup/backuprestore.cpp
Side-by-side diff
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
@@ -281,9 +281,16 @@ void BackupAndRestore::backup()
void BackupAndRestore::backupRootFs()
{
-//#define MDEBUG
-#ifndef MDEBUG
- QMessageBox::critical( this, "Opie-Backup", "<qt>This feature is not yet implemented.</qt>", "Bummer!" );
- return;
-#endif
+ if ( ( ODevice::inst()->model() != Model_Zaurus_SL5000 ) && ( ODevice::inst()->model() != Model_Zaurus_SL5500 ) )
+ {
+ QMessageBox::critical( this, "Not yet implemented!", "<qt>Sorry, support for this model is not yet done.</qt>", "Ok" );
+ return;
+ }
+
+ if ( !QFile::exists( "/usr/bin/mkfs.jffs2" ) && !QFile::exists( "/usr/sbin/mkfs.jffs2" ) )
+ {
+ QMessageBox::critical( this, "Can't find utility!", "<qt>Can't find mkfs.jffs2 - Install mtd-utils.</qt>", "Ok" );
+ return;
+ }
+
// call 'mount' and parse its output to gather the device on which the root partition is mounted
FILE* mountp = popen( "mount", "r" );
@@ -301,17 +308,15 @@ void BackupAndRestore::backupRootFs()
if ( mountpoint == "/" ) break;
}
- odebug << device << " is formatted w/ " << filesystem << " and mounted on " << mountpoint << oendl;
+ odebug << device << " is formatted w/ '" << filesystem << "' and mounted on '" << mountpoint << "'" << oendl;
- if ( !mountpoint.startsWith( "/dev/mtdblock" ) )
+ if ( !device.startsWith( "/dev/mtdblock" ) )
{
- QMessageBox::critical( this, "Can't backup!", QString( "<qt>unsupported rootfs %1 - needs to be /dev/mtdblockN</qt>").arg( device ), "Ok" );
-#ifndef MDEBUG
+ QMessageBox::critical( this, "Can't backup!", QString( "<qt>unsupported root device '%1' - needs to be /dev/mtdblockN</qt>").arg( device ), "Ok" );
return;
-#endif
}
} // at this point, the QTextStream has been destroy and we can close the FILE*
pclose( mountp );
-#ifndef MDEBUG
+#if 1
int rootmtd = device.right( 1 ).toInt();
#else
@@ -325,4 +330,5 @@ void BackupAndRestore::backupRootFs()
{
QMessageBox::critical( this, "Can't backup!", "<qt>Can't open /proc/mtd</qt>", "Ok" );
+ return;
}
@@ -357,13 +363,26 @@ void BackupAndRestore::backupRootFs()
// call mkfs.jffs2 to create the backup
- QString cmdline = QString( "mkfs.jffs2 --root=/ %1 --little-endian %2 %3 -n" ).arg( outputFile ).arg( pad ).arg( eraseblock );
+ QString cmdline = QString( "mkfs.jffs2 --faketime --root=/ %1 --little-endian %2 %3 -n" ).arg( outputFile ).arg( pad ).arg( eraseblock );
+ cmdline.append( " --ignore=/tmp --ignore=/mnt --ignore=/var --ignore=/proc" );
owarn << "Calling '" << cmdline << "'" << oendl;
-#ifndef MDEBUG
- ::system( cmdline );
-#endif
+ OWait *owait = new OWait();
+ Global::statusMessage( tr( "Backing up..." ) );
+ owait->show();
+ qApp->processEvents();
- // FIXME: Add image postprocessing for C7x0 and C8x0, for Beagle, for SIMpad
+ int r = ::system( cmdline );
+
+ owait->hide();
+ delete owait;
+
+ if ( r != 0 )
+ {
+ perror("Error: ");
+ QString errorMsg = QString( tr( "<qt>%1</qt>" ).arg( strerror( errno ) ) );
+ QMessageBox::critical(this, tr( "Backup Failed!" ), errorMsg, QString( tr( "Ok" ) ) );
+ }
+ // FIXME: Add image postprocessing for C7x0 and C8x0, for Beagle, for SIMpad
}