summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/backup/backuprestore.cpp51
-rw-r--r--share/backup/device_table-minimal.txt20
2 files changed, 55 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
@@ -277,17 +277,24 @@ void BackupAndRestore::backup()
277 backupRootFs(); 277 backupRootFs();
278} 278}
279 279
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;
291 QString mountpoint; 298 QString mountpoint;
292 { 299 {
293 QTextStream mounto( mountp, IO_ReadOnly ); 300 QTextStream mounto( mountp, IO_ReadOnly );
@@ -297,36 +304,35 @@ void BackupAndRestore::backupRootFs()
297 QString options; 304 QString options;
298 while ( !mounto.atEnd() ) 305 while ( !mounto.atEnd() )
299 { 306 {
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;
319#endif 324#endif
320 odebug << "root mtdblock seems to be '" << rootmtd << "'" << oendl; 325 odebug << "root mtdblock seems to be '" << rootmtd << "'" << oendl;
321 326
322 // scan /proc/mtd to gather the size and erasesize of the root mtdblock 327 // scan /proc/mtd to gather the size and erasesize of the root mtdblock
323 QFile procmtdf( "/proc/mtd" ); 328 QFile procmtdf( "/proc/mtd" );
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 );
330 for ( int i = 0; i <= rootmtd; ++i ) procmtd.readLine(); // skip uninteresting things 336 for ( int i = 0; i <= rootmtd; ++i ) procmtd.readLine(); // skip uninteresting things
331 QString dev; 337 QString dev;
332 QString size; 338 QString size;
@@ -353,21 +359,34 @@ void BackupAndRestore::backupRootFs()
353 QDateTime datetime = QDateTime::currentDateTime(); 359 QDateTime datetime = QDateTime::currentDateTime();
354 QString dateString = QString::number( datetime.date().year() ) + QString::number( datetime.date().month() ).rightJustify(2, '0') + 360 QString dateString = QString::number( datetime.date().year() ) + QString::number( datetime.date().month() ).rightJustify(2, '0') +
355 QString::number( datetime.date().day() ).rightJustify(2, '0'); 361 QString::number( datetime.date().day() ).rightJustify(2, '0');
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()
371{ 390{
372 QString backupFiles; 391 QString backupFiles;
373 if(getBackupFiles(backupFiles, NULL) == 0) 392 if(getBackupFiles(backupFiles, NULL) == 0)
diff --git a/share/backup/device_table-minimal.txt b/share/backup/device_table-minimal.txt
new file mode 100644
index 0000000..66cafae
--- a/dev/null
+++ b/share/backup/device_table-minimal.txt
@@ -0,0 +1,20 @@
1 /dev/initctl p 600 0 0 - - --
2 /dev/apm_bios c 660 0 46 10 134 - --
3 /dev/fb0 c 600 0 0 29 0 - --
4 /dev/hda b 660 0 6 3 0 - --
5 /dev/hda b 660 0 6 3 1 1 120
6 /dev/kmem c 640 0 15 1 2 - --
7 /dev/mem c 640 0 15 1 1 - --
8 /dev/null c 666 0 0 1 3 - --
9 /dev/ram b 640 0 0 1 0 0 14
10 /dev/tty c 662 0 5 5 0 - --
11 /dev/tty c 666 0 5 4 0 0 19
12 /dev/ttyS c 640 0 5 4 64 0 11
13 /dev/ttySA c 640 0 5 204 5 0 11
14 /dev/zero c 644 0 0 1 5 --
15 /dev/mtd c 660 0 6 90 0 0 28
16 /dev/mtdblock b 640 0 0 31 0 0 18
17 /dev/console c 662 0 5 5 1 --
18 /bin/tinylogin f 4755 0 0 - - --
19 /bin/mount f 4755 0 0 - - --
20 /bin/umount f 4755 0 0 - - --