summaryrefslogtreecommitdiff
path: root/noncore
Side-by-side diff
Diffstat (limited to 'noncore') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/backup/backuprestore.cpp49
1 files changed, 34 insertions, 15 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
@@ -277,17 +277,24 @@ void BackupAndRestore::backup()
backupRootFs();
}
void BackupAndRestore::backupRootFs()
{
-//#define MDEBUG
-#ifndef MDEBUG
- QMessageBox::critical( this, "Opie-Backup", "<qt>This feature is not yet implemented.</qt>", "Bummer!" );
+ 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;
-#endif
+ }
+
+ 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" );
QString device;
QString mountpoint;
{
QTextStream mounto( mountp, IO_ReadOnly );
@@ -297,36 +304,35 @@ void BackupAndRestore::backupRootFs()
QString options;
while ( !mounto.atEnd() )
{
mounto >> device >> on >> mountpoint >> type >> filesystem >> options;
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
int rootmtd = 0;
#endif
odebug << "root mtdblock seems to be '" << rootmtd << "'" << oendl;
// scan /proc/mtd to gather the size and erasesize of the root mtdblock
QFile procmtdf( "/proc/mtd" );
if ( !procmtdf.open( IO_ReadOnly ) )
{
QMessageBox::critical( this, "Can't backup!", "<qt>Can't open /proc/mtd</qt>", "Ok" );
+ return;
}
QTextStream procmtd( &procmtdf );
for ( int i = 0; i <= rootmtd; ++i ) procmtd.readLine(); // skip uninteresting things
QString dev;
QString size;
@@ -353,21 +359,34 @@ void BackupAndRestore::backupRootFs()
QDateTime datetime = QDateTime::currentDateTime();
QString dateString = QString::number( datetime.date().year() ) + QString::number( datetime.date().month() ).rightJustify(2, '0') +
QString::number( datetime.date().day() ).rightJustify(2, '0');
outputFile += "/initrd.bin-" + dateString;
// 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
}
void BackupAndRestore::backupUserData()
{
QString backupFiles;
if(getBackupFiles(backupFiles, NULL) == 0)