source: MondoRescue/branches/2.2.10/mondo/src/mondorestore/mondorestore.c@ 2334

Last change on this file since 2334 was 2334, checked in by Bruno Cornec, 15 years ago

r3369@localhost: bruno | 2009-08-18 16:57:27 +0200

  • Transform bout 100 strcpy in dyn. allocation. Quality is improving
  • function figure_out_kernel_path_interactively_if_necessary now return a dynamically allocated string
  • mondoarchive checked with valgrind in text an newt modes
  • Property svn:keywords set to Id
File size: 93.6 KB
Line 
1/***************************************************************************
2$Id: mondorestore.c 2334 2009-08-18 15:28:18Z bruno $
3restores mondoarchive data
4The main file for mondorestore.
5***************************************************************************/
6
7/**************************************************************************
8 * #include statements *
9 **************************************************************************/
10#include <pthread.h>
11#include "my-stuff.h"
12#include "mr_mem.h"
13#include "../common/mondostructures.h"
14#include "../common/libmondo.h"
15#include "mr-externs.h"
16#include "mondo-restore.h"
17#include "mondorestore.h"
18#include "mondo-rstr-compare-EXT.h"
19#include "mondo-rstr-tools-EXT.h"
20
21extern void twenty_seconds_til_yikes(void);
22
23/* Let mr_cleanup pojnt to finish for the moment */
24void (*mr_cleanup)(int) = finish;
25
26/* Reference to global bkpinfo */
27struct s_bkpinfo *bkpinfo;
28
29
30/* For use in other programs (ex. XMondo) */
31#ifdef MONDORESTORE_MODULE
32#define main __mondorestore_main
33#define g_ISO_restore_mode __mondorestore_g_ISO_restore_mode
34#endif
35
36//static char cvsid[] = "$Id: mondorestore.c 2334 2009-08-18 15:28:18Z bruno $";
37
38/**************************************************************************
39 * Globals *
40 **************************************************************************/
41/*
42extern char *g_tmpfs_mountpt; // declared in libmondo-tools.c
43*/
44extern bool g_text_mode;
45extern FILE *g_fprep;
46extern double g_kernel_version;
47extern int g_partition_table_locked_up;
48extern int g_noof_rows;
49
50extern int partition_everything(struct mountlist_itself *mountlist);
51extern int handle_incoming_parameters(int argc, char *argv[]);
52
53/**
54 * @name Restore-Time Globals
55 * @ingroup globalGroup
56 * @{
57 */
58
59/**
60 * If TRUE, then we're restoring from ISOs or an NFS server.
61 * If FALSE, then we're restoring from some kind of real media (tape, CD, etc.)
62 */
63bool g_ISO_restore_mode = FALSE; /* are we in Iso Mode? */
64
65/**
66 * If TRUE, then we have had a successful "nuke" restore.
67 */
68bool g_I_have_just_nuked = FALSE;
69
70/**
71 * The device to mount to get at the ISO images. Ignored unless @p g_ISO_restore_mode.
72 */
73char *g_isodir_device;
74
75/**
76 * The format of @p g_isodir_device. Ignored unless @p g_ISO_restore_mode.
77 */
78char *g_isodir_format;
79
80/**
81 * The location of 'biggielist.txt', containing the biggiefiles on the current archive set.
82 */
83char *g_biggielist_txt;
84
85/**
86 * The location of 'filelist.full', containing all files (<em>including biggiefiles</em>) on
87 * the current archive set.
88 */
89char *g_filelist_full;
90
91/**
92 * The location of a file containing a list of the devices that were archived
93 * as images, not as individual files.
94 */
95char *g_filelist_imagedevs;
96
97/**
98 * The location of a file containing a list of imagedevs to actually restore.
99 * @see g_filelist_imagedevs
100 */
101char *g_imagedevs_restthese;
102
103/**
104 * The location of 'mondo-restore.cfg', containing the metadata
105 * information for this backup.
106 */
107char *g_mondo_cfg_file;
108
109/**
110 * The location of 'mountlist.txt', containing the information on the
111 * user's partitions and hard drives.
112 */
113char *g_mountlist_fname;
114
115/**
116 * Mondo's home directory during backup. Unused in mondorestore; included
117 * to avoid link errors.
118 */
119char *g_mondo_home;
120
121extern char *g_getfacl;
122extern char *g_getfattr;
123
124/* @} - end of "Restore-Time Globals" in globalGroup */
125
126
127
128extern int copy_from_src_to_dest(FILE * f_orig, FILE * f_archived,
129 char direction);
130
131
132
133/**************************************************************************
134 * COMPAQ PROLIANT Stuff: needs some special help *
135**************************************************************************/
136
137/**
138 * The message to display if we detect that the user is using a Compaq Proliant.
139 */
140#define COMPAQ_PROLIANTS_SUCK "Partition and format your disk using Compaq's disaster recovery CD. After you've done that, please reboot with your Mondo media in Interactive Mode."
141
142
143
144
145/**
146 * Allow the user to modify the mountlist before we partition & format their drives.
147 * @param bkpinfo The backup information structure. @c disaster_recovery is the only field used.
148 * @param mountlist The mountlist to let the user modify.
149 * @param raidlist The raidlist that goes with @p mountlist.
150 * @return 0 for success, nonzero for failure.
151 * @ingroup restoreGuiGroup
152 */
153int let_user_edit_the_mountlist(struct mountlist_itself *mountlist,
154 struct raidlist_itself *raidlist)
155{
156 int retval = 0, res = 0;
157
158 log_msg(2, "let_user_edit_the_mountlist() --- starting");
159
160 assert(bkpinfo != NULL);
161 assert(mountlist != NULL);
162 assert(raidlist != NULL);
163 if (!bkpinfo->disaster_recovery) {
164 strcpy(g_mountlist_fname, "/tmp/mountlist.txt");
165 log_msg(2, "I guess you're testing edit_mountlist()");
166 }
167 if (!does_file_exist(g_mountlist_fname)) {
168 log_to_screen(g_mountlist_fname);
169 log_to_screen("does not exist");
170 return (1);
171 }
172
173 retval = load_mountlist(mountlist, g_mountlist_fname);
174 load_raidtab_into_raidlist(raidlist, RAIDTAB_FNAME);
175 if (retval) {
176 log_to_screen
177 ("Warning - load_raidtab_into_raidlist returned an error");
178 }
179 res = edit_mountlist(g_mountlist_fname, mountlist, raidlist);
180 if (res) {
181 return (1);
182 }
183
184 save_mountlist_to_disk(mountlist, g_mountlist_fname);
185 save_raidlist_to_raidtab(raidlist, RAIDTAB_FNAME);
186
187 log_to_screen("I have finished editing the mountlist for you.");
188
189 return (retval);
190}
191
192
193
194
195
196/**
197 * Determine whether @p mountlist contains a Compaq diagnostic partition.
198 * @param mountlist The mountlist to examine.
199 * @return TRUE if there's a Compaq diagnostic partition; FALSE if not.
200 * @ingroup restoreUtilityGroup
201 */
202bool
203partition_table_contains_Compaq_diagnostic_partition(struct
204 mountlist_itself *
205 mountlist)
206{
207 int i;
208
209 assert(mountlist != NULL);
210
211 for (i = 0; i < mountlist->entries; i++) {
212 if (strstr(mountlist->el[i].format, "ompaq")) {
213 log_msg(2, "mountlist[%d] (%s) is %s (Compaq alert!)",
214 i, mountlist->el[i].device, mountlist->el[i].format);
215
216 return (TRUE);
217 }
218 }
219 return (FALSE);
220}
221
222/**************************************************************************
223 *END_PARTITION_TABLE_CONTAINS_COMPAQ_DIAGNOSTIC_PARTITION *
224 **************************************************************************/
225
226
227/**
228 * Allow the user to abort the backup if we find that there is a Compaq diagnostic partition.
229 * @note This function does not actually check for the presence of a Compaq partition.
230 * @ingroup restoreUtilityGroup
231 */
232void offer_to_abort_because_Compaq_Proliants_suck(void)
233{
234 popup_and_OK(COMPAQ_PROLIANTS_SUCK);
235 if (ask_me_yes_or_no
236 ("Would you like to reboot and use your Compaq CD to prep your hard drive?"))
237 {
238 fatal_error
239 ("Aborting. Please reboot and prep your hard drive with your Compaq CD.");
240 }
241}
242
243/**************************************************************************
244 *END_OFFER_TO_ABORT_BECAUSE_COMPAQ_PROLIANTS_SUCK *
245 **************************************************************************/
246
247
248
249/**
250 * Call interactive_mode(), nuke_mode(), or compare_mode() depending on the user's choice.
251 * @param bkpinfo The backup information structure. Most fields are used.
252 * @param mountlist The mountlist containing information about the user's partitions.
253 * @param raidlist The raidlist to go with @p mountlist.
254 * @return The return code from the mode function called.
255 * @ingroup restoreGroup
256 */
257int
258catchall_mode(struct mountlist_itself *mountlist,
259 struct raidlist_itself *raidlist)
260{
261 char c;
262 char *tmp = NULL;
263 int retval = 0;
264
265 log_it("inside catchall");
266 assert(bkpinfo != NULL);
267 assert(mountlist != NULL);
268 assert(raidlist != NULL);
269 log_it("pre wrm");
270 c = which_restore_mode();
271 log_it("post wrm");
272 if (c == 'I' || c == 'C') {
273 interactively_obtain_media_parameters_from_user(FALSE);
274 } else if (c == 'N') {
275 // Auto mode nothing special to do
276 } else {
277 popup_and_OK("No restoring or comparing will take place today.");
278 if (is_this_device_mounted("/mnt/cdrom")) {
279 run_program_and_log_output("umount /mnt/cdrom", FALSE);
280 }
281 if (g_ISO_restore_mode) {
282 mr_asprintf(tmp, "umount %s", bkpinfo->isodir);
283 run_program_and_log_output(tmp, FALSE);
284 mr_free(tmp);
285 }
286 paranoid_MR_finish(0);
287 }
288
289 log_it("post int");
290
291 if (bkpinfo->backup_media_type == iso) {
292 if (iso_fiddly_bits((c == 'N') ? TRUE : FALSE)) {
293 log_msg(2,
294 "catchall_mode --- iso_fiddly_bits returned w/ error");
295 return (1);
296 } else {
297 log_msg(2, "catchall_mode --- iso_fiddly_bits ok");
298 }
299 }
300
301 if (c == 'I') {
302 log_msg(2, "IM selected");
303 retval += interactive_mode(mountlist, raidlist);
304 } else if (c == 'N') {
305 log_msg(2, "NM selected");
306 retval += nuke_mode(mountlist, raidlist);
307 } else if (c == 'C') {
308 log_msg(2, "CM selected");
309 retval += compare_mode(mountlist, raidlist);
310 }
311 return (retval);
312}
313
314/**************************************************************************
315 *END_CATCHALL_MODE *
316 **************************************************************************/
317
318/**************************************************************************
319 *END_ EXTRACT_CONFIG_FILE_FROM_RAMDISK *
320 **************************************************************************/
321
322
323/**
324 * Locate an executable in the directory structure rooted at @p restg.
325 * @param out_path Where to put the executable.
326 * @param fname The basename of the executable.
327 * @param restg The directory structure to look in.
328 * @note If it could not be found in @p restg then @p fname is put in @p out_path.
329 * @ingroup restoreUtilityGroup
330 */
331void
332find_pathname_of_executable_preferably_in_RESTORING(char *out_path,
333 char *fname,
334 char *restg)
335{
336 assert(out_path != NULL);
337 assert_string_is_neither_NULL_nor_zerolength(fname);
338
339 sprintf(out_path, "%s/sbin/%s", restg, fname);
340 if (does_file_exist(out_path)) {
341 sprintf(out_path, "%s/usr/sbin/%s", restg, fname);
342 if (does_file_exist(out_path)) {
343 sprintf(out_path, "%s/bin/%s", restg, fname);
344 if (does_file_exist(out_path)) {
345 sprintf(out_path, "%s/usr/bin/%s", restg, fname);
346 if (does_file_exist(out_path)) {
347 strcpy(out_path, fname);
348 }
349 }
350 }
351 }
352}
353
354/**************************************************************************
355 *END_FIND_PATHNAME_OF_EXECUTABLE_PREFERABLY_IN_RESTORING *
356 **************************************************************************/
357
358static void clean_blkid() {
359
360 char *tmp1 = NULL;
361
362 if (bkpinfo->restore_path) {
363 /* Clean up blkid cache file if they exist */
364 mr_asprintf(tmp1,"%s/etc/blkid.tab",bkpinfo->restore_path);
365 (void)unlink(tmp1);
366 paranoid_free(tmp1);
367 mr_asprintf(tmp1,"%s/etc/blkid.tab.old",bkpinfo->restore_path);
368 (void)unlink(tmp1);
369 paranoid_free(tmp1);
370 }
371}
372
373
374static void clean_multipathconf() {
375
376 char *tmp1 = NULL;
377 char *editor = NULL;
378
379 if (bkpinfo->restore_path) {
380 /* Clean up multiconf cache file if they exist */
381 mr_asprintf(tmp1,"%s/var/lib/multipath/bindings",bkpinfo->restore_path);
382 (void)unlink(tmp1);
383 paranoid_free(tmp1);
384 }
385
386 /* Edit multipath.conf if needed to adapt wwid */
387 mr_asprintf(tmp1,"%s/etc/multipath.conf", MNT_RESTORING);
388 if (does_file_exist(tmp1)) {
389 log_msg(2, "We may need to clean /etc/multipath.conf");
390 } else {
391 paranoid_free(tmp1);
392 return;
393 }
394 paranoid_free(tmp1);
395
396 if (bkpinfo->restore_mode != nuke) {
397 mr_asprintf(editor, "%s", find_my_editor());
398 mr_asprintf(tmp1,"chroot %s %s /etc/multipath.conf", MNT_RESTORING, editor);
399 popup_and_OK("You will now edit multipath.conf");
400 if (!g_text_mode) {
401 newtSuspend();
402 }
403 paranoid_system(tmp1);
404 if (!g_text_mode) {
405 newtResume();
406 }
407 paranoid_free(tmp1);
408 paranoid_free(editor);
409 } else {
410 log_to_screen("Non-interactive mode: no way to give you the keyboard so that you edit your multipath.conf. Hope it's OK");
411 log_msg(1,"Non-interactive mode: no way to give you the keyboard so that you edit your multipath.conf. Hope it's OK");
412 }
413}
414
415
416
417
418/**
419 * @addtogroup restoreGroup
420 * @{
421 */
422/**
423 * Restore the user's data, in a disaster recovery situation, prompting the
424 * user about whether or not to do every step.
425 * The user can edit the mountlist, choose files to restore, etc.
426 * @param bkpinfo The backup information structure. Most fields are used.
427 * @param mountlist The mountlist containing information about the user's partitions.
428 * @param raidlist The raidlist to go with @p mountlist.
429 * @return 0 for success, or the number of errors encountered.
430 */
431int interactive_mode(struct mountlist_itself *mountlist, struct raidlist_itself *raidlist)
432{
433 int retval = 0;
434 int res;
435 int ptn_errs = 0;
436 int fmt_errs = 0;
437
438 bool done;
439 bool restore_all;
440
441 /** needs malloc **********/
442 char *tmp;
443 char *p = NULL;
444 char *tmp1 = NULL;
445 char *fstab_fname = NULL;
446 char *old_restpath = NULL;
447
448 struct s_node *filelist;
449
450 /* try to partition and format */
451
452 log_msg(2, "interactive_mode --- starting (great, assertions OK)");
453
454 malloc_string(tmp);
455 assert(bkpinfo != NULL);
456 assert(mountlist != NULL);
457 assert(raidlist != NULL);
458
459 log_msg(2, "interactive_mode --- assertions OK");
460
461 if (g_text_mode) {
462 if (!ask_me_yes_or_no("Interactive Mode + textonly = experimental! Proceed anyway?")) {
463 fatal_error("Wise move.");
464 }
465 }
466
467 log_it("About to load config file");
468 get_cfg_file_from_archive_or_bust();
469 read_cfg_file_into_bkpinfo(g_mondo_cfg_file);
470 log_it("Done loading config file; resizing ML");
471
472 if (strstr(call_program_and_get_last_line_of_output("cat " CMDLINE), "noresize")) {
473 log_msg(1, "Not resizing mountlist.");
474 } else {
475 resize_mountlist_proportionately_to_suit_new_drives(mountlist);
476 }
477 for (done = FALSE; !done;) {
478 log_it("About to edit mountlist");
479 if (g_text_mode) {
480 save_mountlist_to_disk(mountlist, g_mountlist_fname);
481 mr_asprintf(tmp1, "%s %s", find_my_editor(), g_mountlist_fname);
482 res = system(tmp1);
483 mr_free(tmp1);
484 load_mountlist(mountlist, g_mountlist_fname);
485 } else {
486 res = edit_mountlist(g_mountlist_fname, mountlist, raidlist);
487 }
488 log_it("Finished editing mountlist");
489 if (res) {
490 paranoid_MR_finish(1);
491 }
492 log_msg(2, "Proceeding...");
493 save_mountlist_to_disk(mountlist, g_mountlist_fname);
494 save_raidlist_to_raidtab(raidlist, RAIDTAB_FNAME);
495 mvaddstr_and_log_it(1, 30, "Restoring Interactively");
496 if (bkpinfo->differential) {
497 log_to_screen("Because this is a differential backup, disk");
498 log_to_screen
499 (" partitioning and formatting will not take place.");
500 done = TRUE;
501 } else {
502 if (ask_me_yes_or_no
503 ("Do you want to erase and partition your hard drives?")) {
504 if (partition_table_contains_Compaq_diagnostic_partition
505 (mountlist)) {
506 offer_to_abort_because_Compaq_Proliants_suck();
507 done = TRUE;
508 } else {
509 twenty_seconds_til_yikes();
510 g_fprep = fopen("/tmp/prep.sh", "w");
511 ptn_errs = partition_everything(mountlist);
512 if (ptn_errs) {
513 log_to_screen
514 ("Warning. Errors occurred during disk partitioning.");
515 }
516
517 fmt_errs = format_everything(mountlist, FALSE, raidlist);
518 if (!fmt_errs) {
519 log_to_screen
520 ("Errors during disk partitioning were handled OK.");
521 log_to_screen
522 ("Partitions were formatted OK despite those errors.");
523 ptn_errs = 0;
524 }
525 if (!ptn_errs && !fmt_errs) {
526 done = TRUE;
527 }
528 }
529 paranoid_fclose(g_fprep);
530 } else {
531 mvaddstr_and_log_it(g_currentY++, 0,
532 "User opted not to partition the devices");
533 if (ask_me_yes_or_no
534 ("Do you want to format your hard drives?")) {
535 fmt_errs = format_everything(mountlist, TRUE, raidlist);
536 if (!fmt_errs) {
537 done = TRUE;
538 }
539 } else {
540 ptn_errs = fmt_errs = 0;
541 done = TRUE;
542 }
543 }
544 if (fmt_errs) {
545 mvaddstr_and_log_it(g_currentY++,
546 0,
547 "Errors occurred. Please repartition and format drives manually.");
548 done = FALSE;
549 }
550 if (ptn_errs & !fmt_errs) {
551 mvaddstr_and_log_it(g_currentY++,
552 0,
553 "Errors occurred during partitioning. Formatting, however, went OK.");
554 done = TRUE;
555 }
556 if (!done) {
557 if (!ask_me_yes_or_no("Re-edit the mountlist?")) {
558 retval++;
559 goto end_of_func;
560 }
561 }
562 }
563 }
564
565 /* mount */
566 if (mount_all_devices(mountlist, TRUE)) {
567 unmount_all_devices(mountlist);
568 retval++;
569 goto end_of_func;
570 }
571 /* restore */
572 if ((restore_all = ask_me_yes_or_no("Do you want me to restore all of your data?"))) {
573 log_msg(1, "Restoring all data");
574 retval += restore_everything(NULL);
575 } else if ((restore_all = ask_me_yes_or_no("Do you want me to restore _some_ of your data?"))) {
576 mr_asprintf(old_restpath, "%s", bkpinfo->restore_path);
577 for (done = FALSE; !done;) {
578 unlink("/tmp/filelist.full");
579 filelist = process_filelist_and_biggielist();
580 /* Now you have /tmp/tmpfs/filelist.restore-these and /tmp/tmpfs/biggielist.restore-these;
581 the former is a list of regular files; the latter, biggiefiles and imagedevs.
582 */
583 if (filelist) {
584 gotos_suck:
585 strcpy(tmp, old_restpath);
586 // (NB: %s is where your filesystem is mounted now, by default)", MNT_RESTORING);
587 p = popup_and_get_string("Restore path", "Restore files to where?", tmp);
588 if (p != NULL) {
589 strcpy(tmp, p);
590 if (!strcmp(tmp, "/")) {
591 if (!ask_me_yes_or_no("Are you sure?")) {
592 goto gotos_suck;
593 }
594 tmp[0] = '\0'; // so we restore to [blank]/file/name :)
595 }
596 mr_free(bkpinfo->restore_path);
597 mr_asprintf(bkpinfo->restore_path, "%s", tmp);
598 log_msg(1, "Restoring subset");
599 retval += restore_everything(filelist);
600 } else {
601 mr_free(bkpinfo->restore_path);
602 mr_asprintf(bkpinfo->restore_path, "%s", old_restpath);
603 }
604 free_filelist(filelist);
605 mr_free(p);
606
607 if (!ask_me_yes_or_no("Restore another subset of your backup?")) {
608 done = TRUE;
609 }
610 } else {
611 done = TRUE;
612 }
613 }
614 mr_free(old_restpath);
615 } else {
616 mvaddstr_and_log_it(g_currentY++, 0, "User opted not to restore any data. ");
617 }
618 if (retval) {
619 mvaddstr_and_log_it(g_currentY++, 0, "Errors occurred during the restore phase. ");
620 }
621
622 clean_multipathconf();
623 if (ask_me_yes_or_no("Initialize the boot loader?")) {
624 run_boot_loader(TRUE);
625 } else {
626 mvaddstr_and_log_it(g_currentY++,
627 0,
628 "User opted not to initialize the boot loader.");
629 }
630
631 clean_blkid();
632 protect_against_braindead_sysadmins();
633 retval += unmount_all_devices(mountlist);
634
635 /* if (restore_some || restore_all || */
636 if (ask_me_yes_or_no
637 ("Label/Identify your ext2/ext3/ext4 partitions if necessary?")) {
638 mvaddstr_and_log_it(g_currentY, 0,
639 "Using tune2fs to identify your ext2,3,4 partitions");
640 if (does_file_exist("/tmp/fstab.new")) {
641 mr_asprintf(fstab_fname, "/tmp/fstab.new");
642 } else {
643 mr_asprintf(fstab_fname, "/tmp/fstab");
644 }
645 mr_asprintf(tmp1, "label-partitions-as-necessary %s < %s >> %s 2>> %s", g_mountlist_fname, fstab_fname, MONDO_LOGFILE, MONDO_LOGFILE);
646 mr_free(fstab_fname);
647
648 res = system(tmp1);
649 mr_free(tmp1);
650 if (res) {
651 log_to_screen
652 ("label-partitions-as-necessary returned an error");
653 mvaddstr_and_log_it(g_currentY++, 74, "Failed.");
654 } else {
655 mvaddstr_and_log_it(g_currentY++, 74, "Done.");
656 }
657 retval += res;
658 }
659
660 log_it("About to leave interactive_mode()");
661 if (retval) {
662 mvaddstr_and_log_it(g_currentY++,
663 0,
664 "Warning - errors occurred during the restore phase.");
665 }
666 end_of_func:
667 paranoid_free(tmp);
668 log_it("Leaving interactive_mode()");
669 return (retval);
670}
671
672/**************************************************************************
673 *END_INTERACTIVE_MODE *
674 **************************************************************************/
675
676
677
678/**
679 * Run an arbitrary restore mode (prompt the user), but from ISO images
680 * instead of real media.
681 * @param mountlist The mountlist containing information about the user's partitions.
682 * @param raidlist The raidlist that goes with @p mountlist.
683 * @param nuke_me_please If TRUE, we plan to run Nuke Mode.
684 * @return 0 for success, or the number of errors encountered.
685 */
686int
687iso_mode(struct mountlist_itself *mountlist,
688 struct raidlist_itself *raidlist, bool nuke_me_please)
689{
690 char c;
691 int retval = 0;
692
693 assert(mountlist != NULL);
694 assert(raidlist != NULL);
695 if (iso_fiddly_bits(nuke_me_please)) {
696 log_msg(1, "iso_mode --- returning w/ error");
697 return (1);
698 } else {
699 c = which_restore_mode();
700 if (c == 'I' || c == 'N' || c == 'C') {
701 interactively_obtain_media_parameters_from_user(FALSE);
702 }
703 if (c == 'I') {
704 retval += interactive_mode(mountlist, raidlist);
705 } else if (c == 'N') {
706 retval += nuke_mode(mountlist, raidlist);
707 } else if (c == 'C') {
708 retval += compare_mode(mountlist, raidlist);
709 } else {
710 log_to_screen("OK, I shan't restore/compare any files.");
711 }
712 }
713 if (is_this_device_mounted(MNT_CDROM)) {
714 paranoid_system("umount " MNT_CDROM);
715 }
716// if (! already_mounted)
717// {
718 if (system("umount /tmp/isodir 2> /dev/null")) {
719 log_to_screen
720 ("WARNING - unable to unmount device where the ISO files are stored.");
721 }
722// }
723 return (retval);
724}
725
726/**************************************************************************
727 *END_ISO_MODE *
728 **************************************************************************/
729
730
731/* MONDO - saving your a$$ since Feb 18th, 2000 */
732
733
734
735
736/**
737 * Restore the user's data automatically (no prompts), after a twenty-second
738 * warning period.
739 * @param bkpinfo The backup information structure. Most fields are used.
740 * @param mountlist The mountlist containing information about the user's partitions.
741 * @param raidlist The raidlist that goes with @p mountlist.
742 * @return 0 for success, or the number of errors encountered.
743 * @warning <b><i>THIS WILL ERASE ALL EXISTING DATA!</i></b>
744 */
745int
746nuke_mode(struct mountlist_itself *mountlist,
747 struct raidlist_itself *raidlist)
748{
749 int retval = 0;
750 int res = 0;
751 bool boot_loader_installed = FALSE;
752 /** malloc **/
753 char *tmp = NULL;
754 char *tmpA = NULL;
755 char *tmpB = NULL;
756 char *tmpC = NULL;
757
758 assert(bkpinfo != NULL);
759 assert(mountlist != NULL);
760 assert(raidlist != NULL);
761
762 mr_asprintf(tmpA, "%s", " ");
763 mr_asprintf(tmpB, "%s", " ");
764 mr_asprintf(tmpC, "%s", " ");
765
766 log_msg(2, "nuke_mode --- starting");
767
768 get_cfg_file_from_archive_or_bust();
769 load_mountlist(mountlist, g_mountlist_fname); // in case read_cfg_file_into_bkpinfo updated the mountlist
770 if (strstr(call_program_and_get_last_line_of_output("cat " CMDLINE), "noresize")) {
771 log_msg(2, "Not resizing mountlist.");
772 } else {
773 resize_mountlist_proportionately_to_suit_new_drives(mountlist);
774 }
775 if (!evaluate_mountlist(mountlist, tmpA, tmpB, tmpC)) {
776 mr_asprintf(tmp, "Mountlist analyzed. Result: \"%s %s %s\" Switch to Interactive Mode?", tmpA, tmpB, tmpC);
777 res = ask_me_yes_or_no(tmp);
778 mr_free(tmp);
779 if (res) {
780 retval = interactive_mode(mountlist, raidlist);
781 goto after_the_nuke;
782 } else {
783 fatal_error("Nuke Mode aborted. ");
784 }
785 }
786 save_mountlist_to_disk(mountlist, g_mountlist_fname);
787 mvaddstr_and_log_it(1, 30, "Restoring Automatically");
788 if (bkpinfo->differential) {
789 log_to_screen("Because this is a differential backup, disk");
790 log_to_screen("partitioning and formatting will not take place.");
791 res = 0;
792 } else {
793 if (partition_table_contains_Compaq_diagnostic_partition
794 (mountlist)) {
795 offer_to_abort_because_Compaq_Proliants_suck();
796 } else {
797 twenty_seconds_til_yikes();
798 g_fprep = fopen("/tmp/prep.sh", "w");
799 if (strstr(call_program_and_get_last_line_of_output("cat " CMDLINE), "nopart")) {
800 log_msg(2,
801 "Not partitioning drives due to 'nopart' option.");
802 res = 0;
803 } else {
804 res = partition_everything(mountlist);
805 if (res) {
806 log_to_screen
807 ("Warning. Errors occurred during partitioning.");
808 res = 0;
809 }
810 }
811 retval += res;
812 if (!res) {
813 log_to_screen("Preparing to format your disk(s)");
814 sleep(1);
815 system("sync");
816 log_to_screen("Please wait. This may take a few minutes.");
817 res += format_everything(mountlist, FALSE, raidlist);
818 }
819 paranoid_fclose(g_fprep);
820 }
821 }
822 retval += res;
823 if (res) {
824 mvaddstr_and_log_it(g_currentY++,
825 0,
826 "Failed to partition and/or format your hard drives.");
827
828 if (ask_me_yes_or_no("Try in interactive mode instead?")) {
829 retval = interactive_mode(mountlist, raidlist);
830 goto after_the_nuke;
831 } else
832 if (!ask_me_yes_or_no
833 ("Would you like to try to proceed anyway?")) {
834 return (retval);
835 }
836 }
837 retval = mount_all_devices(mountlist, TRUE);
838 if (retval) {
839 unmount_all_devices(mountlist);
840 log_to_screen
841 ("Unable to mount all partitions. Sorry, I cannot proceed.");
842 return (retval);
843 }
844 log_it("Restoring everything");
845 retval += restore_everything(NULL);
846 clean_multipathconf();
847 if (!run_boot_loader(FALSE)) {
848 log_msg(1,
849 "Great! Boot loader was installed. No need for msg at end.");
850 boot_loader_installed = TRUE;
851 }
852 clean_blkid();
853 protect_against_braindead_sysadmins();
854 retval += unmount_all_devices(mountlist);
855 mvaddstr_and_log_it(g_currentY,
856 0,
857 "Using tune2fs to identify your ext2,3 partitions");
858
859 mr_asprintf(tmp, "label-partitions-as-necessary %s < /tmp/fstab", g_mountlist_fname);
860 res = run_program_and_log_output(tmp, TRUE);
861 mr_free(tmp);
862 if (res) {
863 log_to_screen("label-partitions-as-necessary returned an error");
864 mvaddstr_and_log_it(g_currentY++, 74, "Failed.");
865 } else {
866 mvaddstr_and_log_it(g_currentY++, 74, "Done.");
867 }
868 retval += res;
869
870 after_the_nuke:
871 if (retval) {
872 log_to_screen("Errors occurred during the nuke phase.");
873 } else if (strstr(call_program_and_get_last_line_of_output("cat " CMDLINE), "RESTORE")) {
874 log_to_screen
875 ("PC was restored successfully. Thank you for using Mondo Rescue.");
876 log_to_screen
877 ("Please visit our website at http://www.mondorescue.org for more information.");
878 } else {
879 mr_asprintf(tmp,"%s","Mondo has restored your system.\n\nPlease wait for the command prompt. Then remove the backup media and reboot.\n\nPlease visit our website at http://www.mondorescue.org for more information.");
880 popup_and_OK(tmp);
881 mr_free(tmp);
882 log_to_screen("Mondo has restored your system. Please wait for the command prompt.");
883 log_to_screen("Then remove the backup media and reboot.");
884 log_to_screen("Please visit our website at http://www.mondorescue.org for more information.");
885 }
886 g_I_have_just_nuked = TRUE;
887 return (retval);
888}
889
890/**************************************************************************
891 *END_NUKE_MODE *
892 **************************************************************************/
893
894
895
896/**
897 * Restore the user's data (or a subset of it) to the live filesystem.
898 * This should not be called if we're booted from CD!
899 * @param bkpinfo The backup information structure. Most fields are used.
900 * @return 0 for success, or the number of errors encountered.
901 */
902int restore_to_live_filesystem()
903{
904 int retval = 0;
905
906 char *old_restpath = NULL;
907 char *p = NULL;
908
909 struct mountlist_itself *mountlist = NULL;
910 struct raidlist_itself *raidlist = NULL;
911 struct s_node *filelist = NULL;
912
913 log_msg(1, "restore_to_live_filesystem() - starting");
914 assert(bkpinfo != NULL);
915 mountlist = malloc(sizeof(struct mountlist_itself));
916 raidlist = malloc(sizeof(struct raidlist_itself));
917 if (!mountlist || !raidlist) {
918 fatal_error("Cannot malloc() mountlist and/or raidlist");
919 }
920
921 mr_free(bkpinfo->restore_path);
922 mr_asprintf(bkpinfo->restore_path, "/");
923 if (!g_restoring_live_from_cd && !g_restoring_live_from_nfs) {
924 popup_and_OK
925 ("Please insert tape/CD/USB Key, then hit 'OK' to continue.");
926 sleep(1);
927 }
928 if (!g_restoring_live_from_nfs) {
929 interactively_obtain_media_parameters_from_user(FALSE);
930 }
931 if (!bkpinfo->media_device) {
932 log_msg(2, "WARNING: failed to find media dev");
933 } else {
934 log_msg(2, "bkpinfo->media_device = %s", bkpinfo->media_device);
935 }
936
937
938 log_msg(2, "bkpinfo->isodir = %s", bkpinfo->isodir);
939
940 open_evalcall_form("Thinking...");
941
942 get_cfg_file_from_archive_or_bust();
943 read_cfg_file_into_bkpinfo(g_mondo_cfg_file);
944 load_mountlist(mountlist, g_mountlist_fname); // in case read_cfg_file_into_bkpinfo
945
946 close_evalcall_form();
947 retval = load_mountlist(mountlist, g_mountlist_fname);
948 load_raidtab_into_raidlist(raidlist, RAIDTAB_FNAME);
949
950 if (!g_restoring_live_from_nfs && (filelist = process_filelist_and_biggielist())) {
951 save_filelist(filelist, "/tmp/selected-files.txt");
952 mr_asprintf(old_restpath, "%s", bkpinfo->restore_path);
953 p = popup_and_get_string("Restore path", "Restore files to where? )", bkpinfo->restore_path);
954 if (p != NULL) {
955 mr_free(bkpinfo->restore_path);
956 bkpinfo->restore_path = p;
957
958 log_it("Restoring everything");
959 retval += restore_everything(filelist);
960 }
961 free_filelist(filelist);
962 mr_free(bkpinfo->restore_path);
963 bkpinfo->restore_path = old_restpath;
964 } else {
965 if (filelist != NULL) {
966 retval += restore_everything(NULL);
967 }
968 }
969 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
970 log_msg(2,
971 "Tape : I don't need to unmount or eject the CD-ROM.");
972 } else {
973 run_program_and_log_output("umount " MNT_CDROM, FALSE);
974 if (!bkpinfo->please_dont_eject) {
975 eject_device(bkpinfo->media_device);
976 }
977 }
978 run_program_and_log_output("umount " MNT_CDROM, FALSE);
979 if (!bkpinfo->please_dont_eject) {
980 eject_device(bkpinfo->media_device);
981 }
982 free(mountlist);
983 free(raidlist);
984 return (retval);
985}
986
987/**************************************************************************
988 *END_RESTORE_TO_LIVE_FILESYSTEM *
989 **************************************************************************/
990
991/* @} - end of restoreGroup */
992
993
994#include <utime.h>
995/**
996 * @addtogroup LLrestoreGroup
997 * @{
998 */
999/**
1000 * Restore biggiefile @p bigfileno from the currently mounted CD.
1001 * @param bkpinfo The backup information structure. Fields used:
1002 * - @c bkpinfo->backup_media_type
1003 * - @c bkpinfo->restore_path
1004 * @param bigfileno The biggiefile number (starting from 0) to restore.
1005 * @param filelist The node structure containing the list of files to restore.
1006 * If the biggiefile is not in this list, it will be skipped (return value will
1007 * still indicate success).
1008 * @return 0 for success (or skip), nonzero for failure.
1009 */
1010int
1011restore_a_biggiefile_from_CD(long bigfileno,
1012 struct s_node *filelist,
1013 char *pathname_of_last_file_restored)
1014{
1015 FILE *fin;
1016 FILE *fout;
1017 FILE *fbzip2;
1018
1019 /** malloc ***/
1020 char *checksum = NULL;
1021 char *outfile_fname = NULL;
1022 char *tmp = NULL;
1023 char *bzip2_command = NULL;
1024 char *ntfsprog_command;
1025 char *suffix = NULL;
1026 char *sz_devfile = NULL;
1027 char *bigblk;
1028 char *mds = NULL;
1029 int retval = 0;
1030 int finished = FALSE;
1031 long sliceno;
1032 long siz;
1033 char *ntfsprog_fifo = NULL;
1034 char *file_to_openout = NULL;
1035 struct s_filename_and_lstat_info biggiestruct;
1036 struct utimbuf the_utime_buf, *ubuf;
1037 bool use_ntfsprog_hack = FALSE;
1038 pid_t pid;
1039 int res = 0;
1040 int old_loglevel;
1041 struct s_node *node;
1042
1043 old_loglevel = g_loglevel;
1044 ubuf = &the_utime_buf;
1045 assert(bkpinfo != NULL);
1046
1047 malloc_string(ntfsprog_command);
1048
1049 pathname_of_last_file_restored[0] = '\0';
1050 if (!(bigblk = malloc(TAPE_BLOCK_SIZE))) {
1051 fatal_error("Cannot malloc bigblk");
1052 }
1053
1054 if (!(fin = fopen(slice_fname(bigfileno, 0, ARCHIVES_PATH, ""), "r"))) {
1055 log_to_screen("Cannot even open bigfile's info file");
1056 return (1);
1057 }
1058
1059 memset((void *) &biggiestruct, 0, sizeof(biggiestruct));
1060 if (fread((void *) &biggiestruct, 1, sizeof(biggiestruct), fin) <
1061 sizeof(biggiestruct)) {
1062 log_msg(2, "Warning - unable to get biggiestruct of bigfile #%d",
1063 bigfileno + 1);
1064 }
1065 paranoid_fclose(fin);
1066
1067 mr_asprintf(checksum, "%s", biggiestruct.checksum);
1068 if (!checksum[0]) {
1069 log_msg(3, "Warning - bigfile %ld does not have a checksum", bigfileno + 1);
1070 }
1071 mr_free(checksum);
1072
1073 if (!strncmp(biggiestruct.filename, "/dev/", 5)) // Whether NTFS or not :)
1074 {
1075 mr_asprintf(outfile_fname, "%s", biggiestruct.filename);
1076 } else {
1077 mr_asprintf(outfile_fname, "%s/%s", bkpinfo->restore_path, biggiestruct.filename);
1078 }
1079
1080 /* skip file if we have a selective restore subset & it doesn't match */
1081 if (filelist != NULL) {
1082 node = find_string_at_node(filelist, biggiestruct.filename);
1083 if (!node) {
1084 log_msg(0, "Skipping %s (name isn't in filelist)", biggiestruct.filename);
1085 pathname_of_last_file_restored[0] = '\0';
1086 return (0);
1087 } else if (!(node->selected)) {
1088 log_msg(1, "Skipping %s (name isn't in biggielist subset)", biggiestruct.filename);
1089 pathname_of_last_file_restored[0] = '\0';
1090 return (0);
1091 }
1092 }
1093
1094 /* otherwise, continue */
1095 log_msg(1, "DEFINITELY restoring %s", biggiestruct.filename);
1096 if (biggiestruct.use_ntfsprog) {
1097 if (strncmp(biggiestruct.filename, "/dev/", 5)) {
1098 log_msg(1, "I was in error when I set biggiestruct.use_ntfsprog to TRUE.");
1099 log_msg(1, "%s isn't even in /dev", biggiestruct.filename);
1100 biggiestruct.use_ntfsprog = FALSE;
1101 }
1102 }
1103
1104 if (biggiestruct.use_ntfsprog) // if it's an NTFS device
1105 {
1106 g_loglevel = 4;
1107 use_ntfsprog_hack = TRUE;
1108 log_msg(2, "Calling ntfsclone in background because %s is an NTFS /dev entry", outfile_fname);
1109 mr_asprintf(sz_devfile, "/tmp/%d.%d.000", (int) (random() % 32768), (int) (random() % 32768));
1110 mkfifo(sz_devfile, 0x770);
1111 mr_asprintf(ntfsprog_fifo, "%s", sz_devfile);
1112 mr_free(sz_devfile);
1113 file_to_openout = ntfsprog_fifo;
1114 switch (pid = fork()) {
1115 case -1:
1116 fatal_error("Fork failure");
1117 case 0:
1118 log_msg(3, "CHILD - fip - calling feed_outfrom_ntfsprog(%s, %s)", biggiestruct.filename, ntfsprog_fifo);
1119 res = feed_outfrom_ntfsprog(biggiestruct.filename, ntfsprog_fifo);
1120 mr_free(ntfsprog_fifo);
1121 exit(res);
1122 break;
1123 default:
1124 log_msg(3, "feed_into_ntfsprog() called in background --- pid=%ld", (long int) (pid));
1125 }
1126 mr_free(ntfsprog_fifo);
1127 } else {
1128 use_ntfsprog_hack = FALSE;
1129 file_to_openout = outfile_fname;
1130 if (!does_file_exist(outfile_fname)) // yes, it looks weird with the '!' but it's correct that way
1131 {
1132 make_hole_for_file(outfile_fname);
1133 }
1134 }
1135
1136 log_msg(2, "Reassembling big file %ld (%s)", bigfileno + 1, outfile_fname);
1137
1138 /*
1139 last slice is zero-length and uncompressed; when we find it, we stop.
1140 We DON'T wait until there are no more slices; if we did that,
1141 We might stop at end of CD, not at last slice (which is 0-len and uncompd)
1142 */
1143
1144 strncpy(pathname_of_last_file_restored, biggiestruct.filename, MAX_STR_LEN - 1);
1145 pathname_of_last_file_restored[MAX_STR_LEN - 1] = '\0';
1146
1147 log_msg(3, "file_to_openout = %s", file_to_openout);
1148 if (!(fout = fopen(file_to_openout, "w"))) {
1149 log_to_screen("Cannot openout outfile_fname - hard disk full?");
1150 return (1);
1151 }
1152 log_msg(3, "Opened out to %s", outfile_fname); // CD/DVD --> mondorestore --> ntfsclone --> hard disk itself
1153
1154 for (sliceno = 1, finished = FALSE; !finished;) {
1155 if (!does_file_exist(slice_fname(bigfileno, sliceno, ARCHIVES_PATH, "")) &&
1156 !does_file_exist(slice_fname(bigfileno, sliceno, ARCHIVES_PATH, "lzo")) &&
1157 !does_file_exist(slice_fname(bigfileno, sliceno, ARCHIVES_PATH, "gz")) &&
1158 !does_file_exist(slice_fname(bigfileno, sliceno, ARCHIVES_PATH, "bz2"))) {
1159 log_msg(3, "Cannot find a data slice or terminator slice on CD %d", g_current_media_number);
1160 g_current_media_number++;
1161 mds = media_descriptor_string(bkpinfo->backup_media_type);
1162 log_msg(2, "Asking for %s #%d so that I may read slice #%ld\n", mds, g_current_media_number, sliceno);
1163 mr_free(mds);
1164
1165 log_to_screen("Restoring from %s #%d", mds, g_current_media_number);
1166
1167 insist_on_this_cd_number(g_current_media_number);
1168 log_to_screen("Continuing to restore.");
1169 } else {
1170 mr_asprintf(tmp, "%s", slice_fname(bigfileno, sliceno, ARCHIVES_PATH, ""));
1171 if (does_file_exist(tmp) && length_of_file(tmp) == 0) {
1172 log_msg(2, "End of bigfile # %ld (slice %ld is the terminator)", bigfileno + 1, sliceno);
1173 finished = TRUE;
1174 mr_free(tmp);
1175 continue;
1176 } else {
1177 if (does_file_exist(slice_fname(bigfileno, sliceno, ARCHIVES_PATH, "lzo"))) {
1178 mr_asprintf(bzip2_command, "lzop");
1179 mr_asprintf(suffix, "lzo");
1180 } else
1181 if (does_file_exist(slice_fname(bigfileno, sliceno, ARCHIVES_PATH, "gz"))) {
1182 mr_asprintf(bzip2_command, "gzip");
1183 mr_asprintf(suffix, "gz");
1184 } else
1185 if (does_file_exist(slice_fname(bigfileno, sliceno, ARCHIVES_PATH, "bz2"))) {
1186 mr_asprintf(bzip2_command, "bzip2");
1187 mr_asprintf(suffix, "bz2");
1188 } else
1189 if (does_file_exist(slice_fname(bigfileno, sliceno, ARCHIVES_PATH, ""))) {
1190 mr_asprintf(bzip2_command, "");
1191 mr_asprintf(suffix, "");
1192 } else {
1193 log_to_screen("OK, that's pretty fsck0red...");
1194 mr_free(tmp);
1195 return (1);
1196 }
1197 }
1198 mr_free(tmp);
1199 if (bzip2_command != NULL) {
1200 mr_strcat(bzip2_command, " -dc %s 2>> %s", slice_fname(bigfileno, sliceno, ARCHIVES_PATH, suffix), MONDO_LOGFILE);
1201 } else {
1202 mr_asprintf(bzip2_command, "cat %s 2>> %s", slice_fname(bigfileno, sliceno, ARCHIVES_PATH, suffix), MONDO_LOGFILE);
1203 }
1204 mr_free(suffix);
1205
1206 mds = media_descriptor_string(bkpinfo->backup_media_type);
1207 mr_asprintf(tmp, "Working on %s #%d, file #%ld, slice #%ld ", mds, g_current_media_number, bigfileno + 1, sliceno);
1208 mr_free(mds);
1209 log_msg(2, tmp);
1210
1211 if (!g_text_mode) {
1212 newtDrawRootText(0, g_noof_rows - 2, tmp);
1213 newtRefresh();
1214 strip_spaces(tmp);
1215 update_progress_form(tmp);
1216 }
1217 mr_free(tmp);
1218
1219 if (!(fbzip2 = popen(bzip2_command, "r"))) {
1220 fatal_error("Can't run popen command");
1221 }
1222 mr_free(bzip2_command);
1223
1224 while (!feof(fbzip2)) {
1225 siz = fread(bigblk, 1, TAPE_BLOCK_SIZE, fbzip2);
1226 if (siz > 0) {
1227 siz = fwrite(bigblk, 1, siz, fout);
1228 }
1229 }
1230 paranoid_pclose(fbzip2);
1231
1232
1233 sliceno++;
1234 g_current_progress++;
1235 }
1236 }
1237 paranoid_fclose(fout);
1238 g_loglevel = old_loglevel;
1239
1240 if (use_ntfsprog_hack) {
1241 log_msg(3, "Waiting for ntfsclone to finish");
1242 mr_asprintf(tmp, " ps | grep \" ntfsclone \" | grep -v grep > /dev/null 2> /dev/null");
1243 while (system(tmp) == 0) {
1244 sleep(1);
1245 }
1246 mr_free(tmp);
1247 log_it("OK, ntfsclone has really finished");
1248 }
1249
1250 if (strcmp(outfile_fname, "/dev/null")) {
1251 chown(outfile_fname, biggiestruct.properties.st_uid, biggiestruct.properties.st_gid);
1252 chmod(outfile_fname, biggiestruct.properties.st_mode);
1253 ubuf->actime = biggiestruct.properties.st_atime;
1254 ubuf->modtime = biggiestruct.properties.st_mtime;
1255 utime(outfile_fname, ubuf);
1256 }
1257 mr_free(outfile_fname);
1258 paranoid_free(bigblk);
1259 paranoid_free(ntfsprog_command);
1260
1261 return (retval);
1262}
1263
1264/**************************************************************************
1265 *END_ RESTORE_A_BIGGIEFILE_FROM_CD *
1266 **************************************************************************/
1267
1268
1269
1270/**
1271 * Restore a biggiefile from the currently opened stream.
1272 * @param bkpinfo The backup information structure. Fields used:
1273 * - @c bkpinfo->restore_path
1274 * - @c bkpinfo->zip_exe
1275 * @param orig_bf_fname The original filename of the biggiefile.
1276 * @param biggiefile_number The number of the biggiefile (starting from 0).
1277 * @param orig_checksum Unused.
1278 * @param biggiefile_size Unused.
1279 * @param filelist The node structure containing the list of files to be restored.
1280 * If @p orig_bf_fname is not in the list, it will be ignored.
1281 * @return 0 for success (or skip), nonzero for failure.
1282 * @bug orig_checksum and biggiefile_size are unused (except to check that they are non-NULL).
1283 */
1284int restore_a_biggiefile_from_stream(char *orig_bf_fname, long biggiefile_number, char *orig_checksum, //UNUSED
1285 long long biggiefile_size, //UNUSED
1286 struct s_node *filelist,
1287 int use_ntfsprog,
1288 char *pathname_of_last_file_restored)
1289{
1290 FILE *pout;
1291 FILE *fin;
1292
1293 /** mallocs ********/
1294 char *tmp = NULL;
1295 char *tmp1 = NULL;
1296 char *command = NULL;
1297 char *outfile_fname = NULL;
1298 char *ntfsprog_command;
1299 char *sz_devfile = NULL;
1300 char *ntfsprog_fifo = NULL;
1301 char *file_to_openout = NULL;
1302
1303 struct s_node *node;
1304
1305 int old_loglevel;
1306 long current_slice_number = 0;
1307 int retval = 0;
1308 int res = 0;
1309 int ctrl_chr = '\0';
1310 long long slice_siz;
1311 bool dummy_restore = FALSE;
1312 bool use_ntfsprog_hack = FALSE;
1313 pid_t pid;
1314 struct s_filename_and_lstat_info biggiestruct;
1315 struct utimbuf the_utime_buf, *ubuf;
1316 ubuf = &the_utime_buf;
1317
1318 malloc_string(tmp);
1319 malloc_string(ntfsprog_command);
1320 old_loglevel = g_loglevel;
1321 assert(bkpinfo != NULL);
1322 assert(orig_bf_fname != NULL);
1323 assert(orig_checksum != NULL);
1324
1325 pathname_of_last_file_restored[0] = '\0';
1326 if (use_ntfsprog == BLK_START_A_PIHBIGGIE) {
1327 use_ntfsprog = 1;
1328 log_msg(1, "%s --- pih=YES", orig_bf_fname);
1329 } else if (use_ntfsprog == BLK_START_A_NORMBIGGIE) {
1330 use_ntfsprog = 0;
1331 log_msg(1, "%s --- pih=NO", orig_bf_fname);
1332 } else {
1333 use_ntfsprog = 0;
1334 log_msg(1, "%s --- pih=NO (weird marker though)", orig_bf_fname);
1335 }
1336
1337 strncpy(pathname_of_last_file_restored, orig_bf_fname,
1338 MAX_STR_LEN - 1);
1339 pathname_of_last_file_restored[MAX_STR_LEN - 1] = '\0';
1340
1341 /* open out to biggiefile to be restored (or /dev/null if biggiefile is not to be restored) */
1342
1343 if (filelist != NULL) {
1344 node = find_string_at_node(filelist, orig_bf_fname);
1345 if (!node) {
1346 dummy_restore = TRUE;
1347 log_msg(1,
1348 "Skipping big file %ld (%s) - not in biggielist subset",
1349 biggiefile_number + 1, orig_bf_fname);
1350 pathname_of_last_file_restored[0] = '\0';
1351 } else if (!(node->selected)) {
1352 dummy_restore = TRUE;
1353 log_msg(1, "Skipping %s (name isn't in biggielist subset)",
1354 orig_bf_fname);
1355 pathname_of_last_file_restored[0] = '\0';
1356 }
1357 }
1358
1359 if (use_ntfsprog) {
1360 if (strncmp(orig_bf_fname, "/dev/", 5)) {
1361 log_msg(1,
1362 "I was in error when I set use_ntfsprog to TRUE.");
1363 log_msg(1, "%s isn't even in /dev", orig_bf_fname);
1364 use_ntfsprog = FALSE;
1365 }
1366 }
1367
1368 if (use_ntfsprog) {
1369 g_loglevel = 4;
1370 mr_asprintf(outfile_fname, "%s", orig_bf_fname);
1371 use_ntfsprog_hack = TRUE;
1372 log_msg(2, "Calling ntfsclone in background because %s is a /dev entry", outfile_fname);
1373 mr_asprintf(sz_devfile, "%s/%d.%d.000", bkpinfo->tmpdir, (int) (random() % 32768), (int) (random() % 32768));
1374 mkfifo(sz_devfile, 0x770);
1375 mr_asprintf(ntfsprog_fifo, "%s", sz_devfile);
1376 mr_free(sz_devfile);
1377
1378 file_to_openout = ntfsprog_fifo;
1379 switch (pid = fork()) {
1380 case -1:
1381 fatal_error("Fork failure");
1382 case 0:
1383 log_msg(3, "CHILD - fip - calling feed_outfrom_ntfsprog(%s, %s)", outfile_fname, ntfsprog_fifo);
1384 res = feed_outfrom_ntfsprog(outfile_fname, ntfsprog_fifo);
1385 mr_free(ntfsprog_fifo);
1386 exit(res);
1387 break;
1388 default:
1389 log_msg(3, "feed_into_ntfsprog() called in background --- pid=%ld", (long int) (pid));
1390 }
1391 mr_free(ntfsprog_fifo);
1392 } else {
1393 if (!strncmp(orig_bf_fname, "/dev/", 5)) {
1394 // non-NTFS partition
1395 mr_asprintf(outfile_fname, "%s", orig_bf_fname);
1396 } else {
1397 // biggiefile
1398 mr_asprintf(outfile_fname, "%s/%s", bkpinfo->restore_path, orig_bf_fname);
1399 }
1400 use_ntfsprog_hack = FALSE;
1401 file_to_openout = outfile_fname;
1402 if (!does_file_exist(outfile_fname)) // yes, it looks weird with the '!' but it's correct that way
1403 {
1404 make_hole_for_file(outfile_fname);
1405 }
1406 log_msg(2, "Reassembling big file %ld (%s)", biggiefile_number + 1, orig_bf_fname);
1407 }
1408
1409 if (dummy_restore) {
1410 mr_free(outfile_fname);
1411 mr_asprintf(outfile_fname, "/dev/null");
1412 }
1413
1414 if (bkpinfo->zip_exe == NULL) {
1415 mr_asprintf(command, "cat > \"%s\"", file_to_openout);
1416 } else {
1417 mr_asprintf(command, "%s -dc > \"%s\" 2>> %s", bkpinfo->zip_exe, file_to_openout, MONDO_LOGFILE);
1418 if (strcmp(bkpinfo->zip_exe, "gzip") == 0) {
1419 /* Ignore SIGPIPE for gzip as it causes errors on big files
1420 * Cf: http://trac.mondorescue.org/ticket/244 */
1421 signal(SIGPIPE,SIG_IGN);
1422 }
1423 }
1424 log_msg(3, "Pipe command = '%s'", command);
1425
1426 /* restore biggiefile, one slice at a time */
1427 if (!(pout = popen(command, "w"))) {
1428 fatal_error("Cannot pipe out");
1429 }
1430 mr_free(command);
1431
1432 for (res = read_header_block_from_stream(&slice_siz, tmp, &ctrl_chr);
1433 ctrl_chr != BLK_STOP_A_BIGGIE;
1434 res = read_header_block_from_stream(&slice_siz, tmp, &ctrl_chr)) {
1435 if (ctrl_chr != BLK_START_AN_AFIO_OR_SLICE) {
1436 wrong_marker(BLK_START_AN_AFIO_OR_SLICE, ctrl_chr);
1437 }
1438 log_msg(2, "Working on file #%ld, slice #%ld ", biggiefile_number + 1, current_slice_number);
1439 if (!g_text_mode) {
1440 newtDrawRootText(0, g_noof_rows - 2, tmp);
1441 newtRefresh();
1442 }
1443 strip_spaces(tmp);
1444 update_progress_form(tmp);
1445 if (current_slice_number == 0) {
1446 res =
1447 read_file_from_stream_to_file("/tmp/biggie-blah.txt",
1448 slice_siz);
1449 if (!(fin = fopen("/tmp/biggie-blah.txt", "r"))) {
1450 log_OS_error("blah blah");
1451 } else {
1452 if (fread
1453 ((void *) &biggiestruct, 1, sizeof(biggiestruct),
1454 fin) < sizeof(biggiestruct)) {
1455 log_msg(2,
1456 "Warning - unable to get biggiestruct of bigfile #%d",
1457 biggiefile_number + 1);
1458 }
1459 paranoid_fclose(fin);
1460 }
1461 } else {
1462 res =
1463 read_file_from_stream_to_stream(pout, slice_siz);
1464 }
1465 retval += res;
1466 res = read_header_block_from_stream(&slice_siz, tmp, &ctrl_chr);
1467 if (ctrl_chr != BLK_STOP_AN_AFIO_OR_SLICE) {
1468 wrong_marker(BLK_STOP_AN_AFIO_OR_SLICE, ctrl_chr);
1469 }
1470 current_slice_number++;
1471 g_current_progress++;
1472 }
1473 paranoid_pclose(pout);
1474
1475 if (bkpinfo->zip_exe != NULL) {
1476 if (strcmp(bkpinfo->zip_exe, "gzip") == 0) {
1477 /* Re-enable SIGPIPE for gzip */
1478 signal(SIGPIPE, terminate_daemon);
1479 }
1480 }
1481
1482 log_msg(1, "pathname_of_last_file_restored is now %s",
1483 pathname_of_last_file_restored);
1484
1485 if (use_ntfsprog_hack) {
1486 log_msg(3, "Waiting for ntfsclone to finish");
1487 mr_asprintf(tmp1, " ps | grep \" ntfsclone \" | grep -v grep > /dev/null 2> /dev/null");
1488 while (system(tmp1) == 0) {
1489 sleep(1);
1490 }
1491 mr_free(tmp1);
1492 log_msg(3, "OK, ntfsclone has really finished");
1493 }
1494
1495 log_msg(3, "biggiestruct.filename = %s", biggiestruct.filename);
1496 log_msg(3, "biggiestruct.checksum = %s", biggiestruct.checksum);
1497 if (strcmp(outfile_fname, "/dev/null")) {
1498 chmod(outfile_fname, biggiestruct.properties.st_mode);
1499 chown(outfile_fname, biggiestruct.properties.st_uid, biggiestruct.properties.st_gid);
1500 ubuf->actime = biggiestruct.properties.st_atime;
1501 ubuf->modtime = biggiestruct.properties.st_mtime;
1502 utime(outfile_fname, ubuf);
1503 }
1504 mr_free(outfile_fname);
1505
1506 paranoid_free(tmp);
1507 paranoid_free(ntfsprog_command);
1508 g_loglevel = old_loglevel;
1509 return (retval);
1510}
1511
1512/**************************************************************************
1513 *END_RESTORE_A_BIGGIEFILE_FROM_STREAM *
1514 **************************************************************************/
1515
1516
1517
1518/**
1519 * Restore @p tarball_fname from CD.
1520 * @param tarball_fname The filename of the tarball to restore (in /mnt/cdrom).
1521 * This will be used unmodified.
1522 * @param current_tarball_number The number (starting from 0) of the fileset
1523 * we're restoring now.
1524 * @param filelist The node structure containing the list of files to be
1525 * restored. If no file in the afioball is in this list, afio will still be
1526 * called, but nothing will be written.
1527 * @return 0 for success, nonzero for failure.
1528 */
1529int
1530restore_a_tarball_from_CD(char *tarball_fname,
1531 long current_tarball_number,
1532 struct s_node *filelist)
1533{
1534 int retval = 0;
1535 int res;
1536 char *p;
1537
1538 /** malloc **/
1539 char *command = NULL;
1540 char *tmp = NULL;
1541 char *filelist_name = NULL;
1542 char *filelist_subset_fname = NULL;
1543 char *executable = NULL;
1544 char *temp_log = NULL;
1545 long matches = 0;
1546 bool use_star;
1547 char *xattr_fname = NULL;
1548 char *acl_fname = NULL;
1549
1550 assert_string_is_neither_NULL_nor_zerolength(tarball_fname);
1551
1552 log_msg(5, "Entering");
1553 use_star = (strstr(tarball_fname, ".star")) ? TRUE : FALSE;
1554 mr_asprintf(command, "mkdir -p %s/tmp", MNT_RESTORING);
1555 run_program_and_log_output(command, 9);
1556 paranoid_free(command);
1557
1558 mr_asprintf(filelist_name, MNT_CDROM "/archives/filelist.%ld", current_tarball_number);
1559 if (length_of_file(filelist_name) <= 2) {
1560 log_msg(2, "There are _zero_ files in filelist '%s'", filelist_name);
1561 log_msg(2, "This is a bit silly (ask dev-team to fix mondo_makefilelist, please)");
1562 log_msg(2, "but it's non-critical. It's cosmetic. Don't worry about it.");
1563 retval = 0;
1564 mr_free(filelist_name);
1565 log_msg(5, "Leaving");
1566 return(0);
1567 }
1568 if (count_lines_in_file(filelist_name) <= 0 || length_of_file(tarball_fname) <= 0) {
1569 log_msg(3, "length_of_file(%s) = %llu", tarball_fname, length_of_file(tarball_fname));
1570 log_msg(3, "count_lines_in_file(%s) = %llu", tarball_fname, count_lines_in_file(tarball_fname));
1571 log_to_screen("Unable to restore fileset #%ld (CD I/O error)", current_tarball_number);
1572 mr_free(filelist_name);
1573 log_msg(5, "Leaving");
1574 return(1);
1575 }
1576
1577 if (filelist) {
1578 mr_asprintf(filelist_subset_fname, "/tmp/filelist-subset-%ld.tmp", current_tarball_number);
1579 if ((matches =
1580 save_filelist_entries_in_common(filelist_name, filelist,
1581 filelist_subset_fname,
1582 use_star)) <= 0) {
1583 log_msg(1, "Skipping fileset %ld", current_tarball_number);
1584 } else {
1585 log_msg(3, "Saved fileset %ld's subset to %s", current_tarball_number, filelist_subset_fname);
1586 }
1587 log_to_screen("Tarball #%ld --- %ld matches", current_tarball_number, matches);
1588 }
1589 mr_free(filelist_name);
1590
1591 if (filelist == NULL || matches > 0) {
1592 if (g_getfattr) {
1593 mr_asprintf(xattr_fname, XATTR_LIST_FNAME_RAW_SZ, MNT_CDROM "/archives", current_tarball_number);
1594 }
1595 if (g_getfacl) {
1596 mr_asprintf(acl_fname, ACL_LIST_FNAME_RAW_SZ, MNT_CDROM "/archives", current_tarball_number);
1597 }
1598 if (strstr(tarball_fname, ".bz2")) {
1599 mr_asprintf(executable, "bzip2");
1600 } else if (strstr(tarball_fname, ".gz")) {
1601 mr_asprintf(executable, "gzip");
1602 } else if (strstr(tarball_fname, ".lzo")) {
1603 mr_asprintf(executable, "lzop");
1604 }
1605 if (executable) {
1606 mr_asprintf(tmp, "which %s > /dev/null 2> /dev/null", executable);
1607 res = run_program_and_log_output(tmp, FALSE);
1608 mr_free(tmp);
1609
1610 if (res) {
1611 log_to_screen("(compare_a_tarball) Compression program %s not found - oh no!", executable);
1612 paranoid_MR_finish(1);
1613 }
1614 tmp = executable;
1615 mr_asprintf(executable, "-P %s -Z", tmp);
1616 mr_free(tmp);
1617 }
1618#ifdef __FreeBSD__
1619#define BUFSIZE 512
1620#else
1621#define BUFSIZE (1024L*1024L)/TAPE_BLOCK_SIZE
1622#endif
1623
1624 if (use_star) {
1625 mr_asprintf(command, "star -x -force-remove -U " STAR_ACL_SZ " errctl= file=%s", tarball_fname);
1626 if (strstr(tarball_fname, ".bz2")) {
1627 mr_strcat(command, " -bz");
1628 }
1629 } else {
1630 if (! executable) {
1631 log_msg(2, "Mo executable, this shouldn't happen !");
1632 } else {
1633 if (filelist_subset_fname != NULL) {
1634 mr_asprintf(command, "afio -i -M 8m -b %ld -c %ld %s -w '%s' %s", TAPE_BLOCK_SIZE, BUFSIZE, executable, filelist_subset_fname, tarball_fname);
1635 } else {
1636 mr_asprintf(command, "afio -i -b %ld -c %ld -M 8m %s %s", TAPE_BLOCK_SIZE, BUFSIZE, executable, tarball_fname);
1637 }
1638 }
1639 }
1640 mr_free(executable);
1641
1642#undef BUFSIZE
1643 mr_asprintf(temp_log, "/tmp/%d.%d", (int) (random() % 32768), (int) (random() % 32768));
1644
1645 mr_strcat(command, " 2>> %s >> %s", temp_log, temp_log);
1646 log_msg(1, "command = '%s'", command);
1647 unlink(temp_log);
1648 res = system(command);
1649 if (res) {
1650 p = strstr(command, "-acl ");
1651 if (p) {
1652 p[0] = p[1] = p[2] = p[3] = ' ';
1653 log_msg(1, "new command = '%s'", command);
1654 res = system(command);
1655 }
1656 }
1657 paranoid_free(command);
1658
1659 if (res && length_of_file(temp_log) < 5) {
1660 res = 0;
1661 }
1662
1663 if (g_getfattr) {
1664 log_msg(1, "Setting fattr list %s", xattr_fname);
1665 if (length_of_file(xattr_fname) > 0) {
1666 res = set_fattr_list(filelist_subset_fname, xattr_fname);
1667 if (res) {
1668 log_to_screen("Errors occurred while setting extended attributes");
1669 } else {
1670 log_msg(1, "I set xattr OK");
1671 }
1672 retval += res;
1673 }
1674 }
1675 if (g_getfacl) {
1676 log_msg(1, "Setting acl list %s", acl_fname);
1677 if (length_of_file(acl_fname) > 0) {
1678 res = set_acl_list(filelist_subset_fname, acl_fname);
1679 if (res) {
1680 log_to_screen
1681 ("Errors occurred while setting access control lists");
1682 } else {
1683 log_msg(1, "I set ACL OK");
1684 }
1685 retval += res;
1686 }
1687 }
1688 if (retval) {
1689 mr_asprintf(command, "cat %s >> %s", temp_log, MONDO_LOGFILE);
1690 system(command);
1691 paranoid_free(command);
1692
1693 log_msg(2, "Errors occurred while processing fileset #%d",
1694 current_tarball_number);
1695 } else {
1696 log_msg(2, "Fileset #%d processed OK", current_tarball_number);
1697 }
1698 unlink(temp_log);
1699 mr_free(temp_log);
1700 }
1701 if (does_file_exist("/PAUSE")) {
1702 popup_and_OK
1703 ("Press ENTER to go on. Delete /PAUSE to stop these pauses.");
1704 }
1705 unlink(filelist_subset_fname);
1706 mr_free(filelist_subset_fname);
1707 if (g_getfattr) {
1708 unlink(xattr_fname);
1709 mr_free(xattr_fname);
1710 }
1711 if (g_getfacl) {
1712 unlink(acl_fname);
1713 mr_free(acl_fname);
1714 }
1715
1716 log_msg(5, "Leaving");
1717 return (retval);
1718}
1719
1720/**************************************************************************
1721 *END_RESTORE_A_TARBALL_FROM_CD *
1722 **************************************************************************/
1723
1724
1725/**
1726 * Restore a tarball from the currently opened stream.
1727 * @param bkpinfo The backup information structure. Fields used:
1728 * - @c bkpinfo->backup_media_type
1729 * - @c bkpinfo->media_device
1730 * - @c bkpinfo->zip_exe
1731 * @param tarball_fname The filename of the afioball to restore.
1732 * @param current_tarball_number The number (starting from 0) of the fileset
1733 * we're restoring now.
1734 * @param filelist The node structure containing the list of files to be
1735 * restored. If no file in the afioball is in this list, afio will still be
1736 * called, but nothing will be written.
1737 * @param size The size (in @b bytes) of the afioball.
1738 * @return 0 for success, nonzero for failure.
1739 */
1740int
1741restore_a_tarball_from_stream(char *tarball_fname,
1742 long current_tarball_number,
1743 struct s_node *filelist,
1744 long long size, char *xattr_fname,
1745 char *acl_fname)
1746{
1747 int retval = 0;
1748 int res = 0;
1749
1750 /** malloc add ***/
1751 char *mds = NULL;
1752 char *command = NULL;
1753 char *afio_fname = NULL;
1754 char *filelist_fname = NULL;
1755 char *filelist_subset_fname = NULL;
1756 char *executable = NULL;
1757 long matches = 0;
1758 bool restore_this_fileset = FALSE;
1759 bool use_star;
1760
1761 assert(bkpinfo != NULL);
1762 assert_string_is_neither_NULL_nor_zerolength(tarball_fname);
1763
1764 /* to do it with a file... */
1765 use_star = (strstr(tarball_fname, ".star")) ? TRUE : FALSE;
1766 mds = media_descriptor_string(bkpinfo->backup_media_type);
1767 log_msg(2, "Restoring from fileset #%ld (%ld KB) on %s #%d",
1768 current_tarball_number, (long) size >> 10, mds, g_current_media_number);
1769 mr_free(mds);
1770
1771 run_program_and_log_output("mkdir -p " MNT_RESTORING "/tmp", FALSE);
1772
1773 /****************************************************************************
1774 * Use RAMDISK's /tmp; saves time; oh wait, it's too small *
1775 * Well, pipe from tape to afio, then; oh wait, can't do that either: bug *
1776 * in afio or someting; oh darn.. OK, use tmpfs :-) *
1777 ****************************************************************************/
1778 mr_asprintf(afio_fname, "/tmp/tmpfs/archive.tmp.%ld", current_tarball_number);
1779 mr_asprintf(filelist_fname, "%s/filelist.%ld", bkpinfo->tmpdir, current_tarball_number);
1780 mr_asprintf(filelist_subset_fname, "%s/filelist-subset-%ld.tmp", bkpinfo->tmpdir, current_tarball_number);
1781
1782 res = read_file_from_stream_to_file(afio_fname, size);
1783 if (strstr(tarball_fname, ".star")) {
1784 bkpinfo->use_star = TRUE;
1785 }
1786 if (res) {
1787 log_msg(1, "Warning - error reading afioball from tape");
1788 }
1789 if (bkpinfo->compression_level == 0) {
1790 mr_asprintf(executable, "%s", "");
1791 } else {
1792 if (bkpinfo->use_star) {
1793 mr_asprintf(executable, "%s", " -bz");
1794 } else {
1795 mr_asprintf(executable, "-P %s -Z", bkpinfo->zip_exe);
1796 }
1797 }
1798
1799 if (!filelist) // if unconditional restore then restore entire fileset
1800 {
1801 restore_this_fileset = TRUE;
1802 } else // If restoring selectively then get TOC from tarball
1803 {
1804 if (strstr(tarball_fname, ".star.")) {
1805 use_star = TRUE;
1806 mr_asprintf(command, "star -t file=%s %s", afio_fname, executable);
1807 } else {
1808 use_star = FALSE;
1809 mr_asprintf(command, "afio -t -M 8m -b %ld %s %s", TAPE_BLOCK_SIZE, executable, afio_fname);
1810 }
1811 mr_strcat(command, " > %s 2>> %s", filelist_fname, MONDO_LOGFILE);
1812 log_msg(1, "command = %s", command);
1813 if (system(command)) {
1814 log_msg(4, "Warning - error occurred while retrieving TOC");
1815 }
1816 mr_free(command);
1817
1818 if ((matches =
1819 save_filelist_entries_in_common(filelist_fname, filelist,
1820 filelist_subset_fname,
1821 use_star))
1822 <= 0 || length_of_file(filelist_subset_fname) < 2) {
1823 if (length_of_file(filelist_subset_fname) < 2) {
1824 log_msg(1, "No matches found in fileset %ld",
1825 current_tarball_number);
1826 }
1827 log_msg(2, "Skipping fileset %ld", current_tarball_number);
1828 restore_this_fileset = FALSE;
1829 } else {
1830 log_msg(5, "%ld matches. Saved fileset %ld's subset to %s",
1831 matches, current_tarball_number,
1832 filelist_subset_fname);
1833 restore_this_fileset = TRUE;
1834 }
1835 }
1836
1837// Concoct the call to star/afio to restore files
1838 if (strstr(tarball_fname, ".star.")) {
1839 // star
1840 mr_asprintf(command, "star -x file=%s %s", afio_fname, executable);
1841 if (filelist) {
1842 mr_strcat(command, " list=%s", filelist_subset_fname);
1843 }
1844 } else {
1845 // afio
1846 mr_asprintf(command, "afio -i -M 8m -b %ld %s", TAPE_BLOCK_SIZE, executable);
1847 if (filelist) {
1848 mr_strcat(command, " -w %s", filelist_subset_fname);
1849 }
1850 mr_strcat(command, " %s", afio_fname);
1851 }
1852 mr_strcat(command, " 2>> %s", MONDO_LOGFILE);
1853 mr_free(executable);
1854
1855// Call if IF there are files to restore (selectively/unconditionally)
1856 if (restore_this_fileset) {
1857 log_msg(1, "Calling command='%s'", command);
1858 paranoid_system(command);
1859
1860 if (g_getfattr) {
1861 log_it("Restoring xattr stuff");
1862 res = set_fattr_list(filelist_subset_fname, xattr_fname);
1863 if (res) {
1864 log_msg(1, "Errors occurred while setting xattr");
1865 } else {
1866 log_msg(1, "I set xattr OK");
1867 }
1868 retval += res;
1869 }
1870
1871 if (g_getfacl) {
1872 log_it("Restoring acl stuff");
1873 res = set_acl_list(filelist_subset_fname, acl_fname);
1874 if (res) {
1875 log_msg(1, "Errors occurred while setting ACL");
1876 } else {
1877 log_msg(1, "I set ACL OK");
1878 }
1879 retval += res;
1880 }
1881
1882 } else {
1883 log_msg(1, "NOT CALLING '%s'", command);
1884 }
1885 mr_free(command);
1886
1887 if (does_file_exist("/PAUSE") && current_tarball_number >= 50) {
1888 log_to_screen("Paused after set %ld", current_tarball_number);
1889 popup_and_OK("Pausing. Press ENTER to continue.");
1890 }
1891
1892 unlink(filelist_subset_fname);
1893 mr_free(filelist_subset_fname);
1894 unlink(filelist_fname);
1895 mr_free(filelist_fname);
1896 unlink(afio_fname);
1897 mr_free(afio_fname);
1898
1899 return (retval);
1900}
1901
1902/**************************************************************************
1903 *END_RESTORE_A_TARBALL_FROM_STREAM *
1904 **************************************************************************/
1905
1906
1907
1908
1909/**
1910 * Restore all biggiefiles from all media in this CD backup.
1911 * The CD with the last afioball should be currently mounted.
1912 * @param bkpinfo The backup information structure. @c backup_media_type is the
1913 * only field used in this function.
1914 * @param filelist The node structure containing the list of files to be
1915 * restored. If a prospective biggiefile is not in this list, it will be ignored.
1916 * @return 0 for success, nonzero for failure.
1917 */
1918int
1919restore_all_biggiefiles_from_CD(struct s_node *filelist)
1920{
1921 int retval = 0;
1922 int res = 0;
1923 long noof_biggiefiles, bigfileno = 0, total_slices;
1924 /** malloc **/
1925 char *tmp1 = NULL;
1926 char *mds = NULL;
1927 bool just_changed_cds = FALSE;
1928 char *xattr_fname = NULL;
1929 char *acl_fname = NULL;
1930 char *biggies_whose_EXATs_we_should_set = NULL; // EXtended ATtributes
1931 char *pathname_of_last_biggie_restored;
1932 FILE *fbw = NULL;
1933
1934 malloc_string(pathname_of_last_biggie_restored);
1935 assert(bkpinfo != NULL);
1936
1937 mr_asprintf(biggies_whose_EXATs_we_should_set, "%s/biggies-whose-EXATs-we-should-set", bkpinfo->tmpdir);
1938 if (!(fbw = fopen(biggies_whose_EXATs_we_should_set, "w"))) {
1939 log_msg(1, "Warning - cannot openout %s", biggies_whose_EXATs_we_should_set);
1940 }
1941
1942 tmp1 = read_cfg_var(g_mondo_cfg_file, "total-slices");
1943 total_slices = atol(tmp1);
1944 mr_free(tmp1);
1945
1946 mr_asprintf(tmp1, "Reassembling large files ");
1947 mvaddstr_and_log_it(g_currentY, 0, tmp1);
1948 mr_free(tmp1);
1949
1950 if (length_of_file(BIGGIELIST) < 6) {
1951 log_msg(1, "OK, no biggielist; not restoring biggiefiles");
1952 return (0);
1953 }
1954 noof_biggiefiles = count_lines_in_file(BIGGIELIST);
1955 if (noof_biggiefiles <= 0) {
1956 log_msg(2, "OK, no biggiefiles in biggielist; not restoring biggiefiles");
1957 return (0);
1958 }
1959 log_msg(2, "OK, there are %ld biggiefiles in the archives", noof_biggiefiles);
1960
1961 open_progress_form("Reassembling large files",
1962 "I am now reassembling all the large files.",
1963 "Please wait. This may take some time.",
1964 "", total_slices);
1965 for (bigfileno = 0 ; bigfileno < noof_biggiefiles ;) {
1966 log_msg(2, "Thinking about restoring bigfile %ld", bigfileno + 1);
1967 if (!does_file_exist(slice_fname(bigfileno, 0, ARCHIVES_PATH, ""))) {
1968 log_msg(3, "...but its first slice isn't on this CD. Perhaps this was a selective restore?");
1969 mds = media_descriptor_string(bkpinfo->backup_media_type);
1970 log_msg(3, "Cannot find bigfile #%ld 's first slice on %s #%d", bigfileno + 1, mds, g_current_media_number);
1971 log_msg(3, "Slicename would have been %s",
1972 slice_fname(bigfileno, 0, ARCHIVES_PATH, ""));
1973 // I'm not positive 'just_changed_cds' is even necessary...
1974 if (just_changed_cds) {
1975 just_changed_cds = FALSE;
1976 log_msg(3, "I'll continue to scan this CD for bigfiles to be restored.");
1977 } else if (does_file_exist(MNT_CDROM "/archives/NOT-THE-LAST")) {
1978 insist_on_this_cd_number(++g_current_media_number);
1979 log_to_screen("Restoring from %s #%d", mds, g_current_media_number);
1980 just_changed_cds = TRUE;
1981 } else {
1982 /* That big file doesn't exist, but the followings may */
1983 /* So we need to continue looping */
1984 log_msg(2, "There was no bigfile #%ld. That's OK.", bigfileno + 1);
1985 log_msg(2, "I'm going to stop restoring bigfiles now.");
1986 retval++;
1987 bigfileno++;
1988 }
1989 mr_free(mds);
1990 } else {
1991 just_changed_cds = FALSE;
1992 mr_asprintf(tmp1, "Restoring big file %ld", bigfileno + 1);
1993 update_progress_form(tmp1);
1994 mr_free(tmp1);
1995 res = restore_a_biggiefile_from_CD(bigfileno, filelist, pathname_of_last_biggie_restored);
1996 log_it("%s",pathname_of_last_biggie_restored);
1997 if (fbw && pathname_of_last_biggie_restored[0]) {
1998 fprintf(fbw, "%s\n", pathname_of_last_biggie_restored);
1999 }
2000 retval += res;
2001 bigfileno++;
2002
2003 }
2004 }
2005
2006 if (fbw) {
2007 fclose(fbw);
2008 if (g_getfattr) {
2009 mr_asprintf(xattr_fname, XATTR_BIGGLST_FNAME_RAW_SZ, ARCHIVES_PATH);
2010 if (length_of_file(xattr_fname) > 0) {
2011 set_fattr_list(biggies_whose_EXATs_we_should_set, xattr_fname);
2012 }
2013 mr_free(xattr_fname);
2014 }
2015 if (g_getfacl) {
2016 mr_asprintf(acl_fname, ACL_BIGGLST_FNAME_RAW_SZ, ARCHIVES_PATH);
2017 if (length_of_file(acl_fname) > 0) {
2018 set_acl_list(biggies_whose_EXATs_we_should_set, acl_fname);
2019 }
2020 mr_free(acl_fname);
2021 }
2022 }
2023 mr_free(biggies_whose_EXATs_we_should_set);
2024
2025 if (does_file_exist("/PAUSE")) {
2026 popup_and_OK("Press ENTER to go on. Delete /PAUSE to stop these pauses.");
2027 }
2028 close_progress_form();
2029 if (retval) {
2030 mvaddstr_and_log_it(g_currentY++, 74, "Errors.");
2031 } else {
2032 mvaddstr_and_log_it(g_currentY++, 74, "Done.");
2033 }
2034 paranoid_free(pathname_of_last_biggie_restored);
2035 return (retval);
2036}
2037
2038/**************************************************************************
2039 *END_RESTORE_ALL_BIGGIFILES_FROM_CD *
2040 **************************************************************************/
2041
2042
2043
2044/**
2045 * Restore all afioballs from all CDs in the backup.
2046 * The first CD should be inserted (if not, it will be asked for).
2047 * @param bkpinfo The backup information structure. @c backup_media_type is the
2048 * only field used in @e this function.
2049 * @param filelist The node structure containing the list of files to be
2050 * restored. If no file in some particular afioball is in this list, afio will
2051 * still be called for that fileset, but nothing will be written.
2052 * @return 0 for success, or the number of filesets that failed.
2053 */
2054int
2055restore_all_tarballs_from_CD(struct s_node *filelist)
2056{
2057 int retval = 0;
2058 int res;
2059 int attempts;
2060 long current_tarball_number = 0;
2061 long max_val;
2062 /**malloc ***/
2063 char *mds = NULL;
2064 char *tmp1 = NULL;
2065 char *tarball_fname = NULL;
2066 char *progress_str = NULL;
2067
2068 assert(bkpinfo != NULL);
2069
2070 mvaddstr_and_log_it(g_currentY, 0, "Restoring from archives");
2071 log_msg(2, "Insisting on 1st CD, so that I can have a look at LAST-FILELIST-NUMBER");
2072 if (g_current_media_number != 1) {
2073 log_msg(3, "OK, that's jacked up.");
2074 g_current_media_number = 1;
2075 }
2076 insist_on_this_cd_number(g_current_media_number);
2077 tmp1 = read_cfg_var(g_mondo_cfg_file, "last-filelist-number");
2078 max_val = atol(tmp1) + 1;
2079 mr_free(tmp1);
2080
2081 mds = media_descriptor_string(bkpinfo->backup_media_type);
2082 mr_asprintf(progress_str, "Restoring from %s #%d", mds, g_current_media_number);
2083
2084 log_to_screen(progress_str);
2085 open_progress_form("Restoring from archives",
2086 "Restoring data from the archives.",
2087 "Please wait. This may take some time.",
2088 progress_str, max_val);
2089 for (;;) {
2090 insist_on_this_cd_number(g_current_media_number);
2091 update_progress_form(progress_str);
2092 mr_free(progress_str);
2093
2094 mr_asprintf(tarball_fname, MNT_CDROM "/archives/%ld.afio.bz2", current_tarball_number);
2095 if (!does_file_exist(tarball_fname)) {
2096 mr_free(tarball_fname);
2097 mr_asprintf(tarball_fname, MNT_CDROM "/archives/%ld.afio.gz", current_tarball_number);
2098 }
2099 if (!does_file_exist(tarball_fname)) {
2100 mr_free(tarball_fname);
2101 mr_asprintf(tarball_fname, MNT_CDROM "/archives/%ld.afio.lzo", current_tarball_number);
2102 }
2103 if (!does_file_exist(tarball_fname)) {
2104 mr_free(tarball_fname);
2105 mr_asprintf(tarball_fname, MNT_CDROM "/archives/%ld.afio.", current_tarball_number);
2106 }
2107 if (!does_file_exist(tarball_fname)) {
2108 mr_free(tarball_fname);
2109 mr_asprintf(tarball_fname, MNT_CDROM "/archives/%ld.star.bz2", current_tarball_number);
2110 }
2111 if (!does_file_exist(tarball_fname)) {
2112 mr_free(tarball_fname);
2113 mr_asprintf(tarball_fname, MNT_CDROM "/archives/%ld.star.", current_tarball_number);
2114 }
2115 if (!does_file_exist(tarball_fname)) {
2116 if (current_tarball_number == 0) {
2117 log_to_screen
2118 ("No tarballs. Strange. Maybe you only backed up freakin' big files?");
2119 mr_free(tarball_fname);
2120 return (0);
2121 }
2122 if (!does_file_exist(MNT_CDROM "/archives/NOT-THE-LAST")
2123 || system("find " MNT_CDROM
2124 "/archives/slice* > /dev/null 2> /dev/null") ==
2125 0) {
2126 break;
2127 }
2128 g_current_media_number++;
2129 mr_asprintf(progress_str, "Restoring from %s #%d", media_descriptor_string(bkpinfo->backup_media_type), g_current_media_number);
2130 log_to_screen(progress_str);
2131 } else {
2132 mr_asprintf(progress_str, "Restoring from fileset #%ld on %s #%d", current_tarball_number, mds, g_current_media_number);
2133 for (res = 999, attempts = 0; attempts < 3 && res != 0; attempts++) {
2134 res = restore_a_tarball_from_CD(tarball_fname, current_tarball_number, filelist);
2135 }
2136 mr_asprintf(tmp1, "%s #%d, fileset #%ld - restore ", mds, g_current_media_number, current_tarball_number);
2137 if (res) {
2138 mr_strcat(tmp1, "reported errors");
2139 } else if (attempts > 1) {
2140 mr_strcat(tmp1, "succeeded");
2141 } else {
2142 mr_strcat(tmp1, "succeeded");
2143 }
2144 if (attempts > 1) {
2145 mr_strcat(tmp1, " (%d attempts) - review logs", attempts);
2146 }
2147 if (attempts > 1) {
2148 log_to_screen(tmp1);
2149 }
2150 mr_free(tmp1);
2151
2152 retval += res;
2153 current_tarball_number++;
2154 g_current_progress++;
2155 }
2156 mr_free(tarball_fname);
2157 }
2158 mr_free(mds);
2159 mr_free(progress_str);
2160
2161 close_progress_form();
2162 if (retval) {
2163 mvaddstr_and_log_it(g_currentY++, 74, "Errors.");
2164 } else {
2165 mvaddstr_and_log_it(g_currentY++, 74, "Done.");
2166 }
2167
2168 return (retval);
2169}
2170
2171/**************************************************************************
2172 *END_RESTORE_ALL_TARBALLS_FROM_CD *
2173 **************************************************************************/
2174
2175
2176
2177/**
2178 * Restore all biggiefiles from the currently opened stream.
2179 * @param bkpinfo The backup information structure. Passed to other functions.
2180 * @param filelist The node structure containing the list of files to be
2181 * restored. If a prospective biggiefile is not in the list, it will be ignored.
2182 * @return 0 for success, or the number of biggiefiles that failed.
2183 */
2184int
2185restore_all_biggiefiles_from_stream(struct s_node *filelist)
2186{
2187 long noof_biggiefiles;
2188 long current_bigfile_number = 0;
2189 long total_slices;
2190
2191 int retval = 0;
2192 int res = 0;
2193 int ctrl_chr;
2194
2195 /** malloc add ****/
2196 char *tmp1 = NULL;
2197 char *biggie_fname;
2198 char *biggie_cksum;
2199 char *xattr_fname = NULL;
2200 char *acl_fname = NULL;
2201 char *p;
2202 char *pathname_of_last_biggie_restored;
2203 char *biggies_whose_EXATs_we_should_set = NULL; // EXtended ATtributes
2204 long long biggie_size;
2205 FILE *fbw = NULL;
2206
2207 malloc_string(biggie_fname);
2208 malloc_string(biggie_cksum);
2209 malloc_string(pathname_of_last_biggie_restored);
2210 assert(bkpinfo != NULL);
2211
2212 tmp1 = read_cfg_var(g_mondo_cfg_file, "total-slices");
2213 total_slices = atol(tmp1);
2214 mr_free(tmp1);
2215
2216 if (g_getfattr) {
2217 mr_asprintf(xattr_fname, XATTR_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);
2218 }
2219 if (g_getfacl) {
2220 mr_asprintf(acl_fname, ACL_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);
2221 }
2222 mr_asprintf(tmp1, "Reassembling large files ");
2223 mvaddstr_and_log_it(g_currentY, 0, tmp1);
2224 mr_free(tmp1);
2225
2226 mr_asprintf(biggies_whose_EXATs_we_should_set, "%s/biggies-whose-EXATs-we-should-set", bkpinfo->tmpdir);
2227 if (!(fbw = fopen(biggies_whose_EXATs_we_should_set, "w"))) {
2228 log_msg(1, "Warning - cannot openout %s", biggies_whose_EXATs_we_should_set);
2229 }
2230
2231 // get xattr and acl files if they're there
2232 res = read_header_block_from_stream(&biggie_size, biggie_fname, &ctrl_chr);
2233 if (ctrl_chr == BLK_START_EXTENDED_ATTRIBUTES) {
2234 res =
2235 read_EXAT_files_from_tape(&biggie_size, biggie_fname, &ctrl_chr, xattr_fname, acl_fname);
2236 }
2237
2238 noof_biggiefiles = atol(biggie_fname);
2239 log_msg(2, "OK, there are %ld biggiefiles in the archives", noof_biggiefiles);
2240 open_progress_form("Reassembling large files",
2241 "I am now reassembling all the large files.",
2242 "Please wait. This may take some time.",
2243 "", total_slices);
2244
2245 for (res =
2246 read_header_block_from_stream(&biggie_size, biggie_fname,
2247 &ctrl_chr);
2248 ctrl_chr != BLK_STOP_BIGGIEFILES;
2249 res =
2250 read_header_block_from_stream(&biggie_size, biggie_fname,
2251 &ctrl_chr)) {
2252 if (ctrl_chr != BLK_START_A_NORMBIGGIE
2253 && ctrl_chr != BLK_START_A_PIHBIGGIE) {
2254 wrong_marker(BLK_START_A_NORMBIGGIE, ctrl_chr);
2255 }
2256 p = strrchr(biggie_fname, '/');
2257 if (!p) {
2258 p = biggie_fname;
2259 } else {
2260 p++;
2261 }
2262 mr_asprintf(tmp1, "Restoring big file %ld (%lld K)", current_bigfile_number + 1, biggie_size / 1024);
2263 update_progress_form(tmp1);
2264 mr_free(tmp1);
2265 res = restore_a_biggiefile_from_stream(biggie_fname,
2266 current_bigfile_number,
2267 biggie_cksum,
2268 biggie_size,
2269 filelist, ctrl_chr,
2270 pathname_of_last_biggie_restored);
2271 log_msg(1, "I believe I have restored %s",
2272 pathname_of_last_biggie_restored);
2273 if (fbw && pathname_of_last_biggie_restored[0]) {
2274 fprintf(fbw, "%s\n", pathname_of_last_biggie_restored);
2275 }
2276 retval += res;
2277 current_bigfile_number++;
2278
2279 }
2280 if (current_bigfile_number != noof_biggiefiles
2281 && noof_biggiefiles != 0) {
2282 log_msg(1, "Warning - bigfileno=%ld but noof_biggiefiles=%ld\n", current_bigfile_number, noof_biggiefiles);
2283 } else {
2284 log_msg(1, "%ld biggiefiles in biggielist.txt; %ld biggiefiles processed today.", noof_biggiefiles, current_bigfile_number);
2285 }
2286
2287 if (fbw) {
2288 fclose(fbw);
2289 if (length_of_file(biggies_whose_EXATs_we_should_set) > 2) {
2290 log_it("Setting biggie-EXATs");
2291 if (g_getfattr) {
2292 if (length_of_file(xattr_fname) > 0) {
2293 log_msg(1, "set_fattr_List(%s,%s)", biggies_whose_EXATs_we_should_set, xattr_fname);
2294 set_fattr_list(biggies_whose_EXATs_we_should_set, xattr_fname);
2295 }
2296 }
2297 if (g_getfacl) {
2298 if (length_of_file(acl_fname) > 0) {
2299 log_msg(1, "set_acl_list(%s,%s)", biggies_whose_EXATs_we_should_set, acl_fname);
2300 set_acl_list(biggies_whose_EXATs_we_should_set, acl_fname);
2301 }
2302 }
2303 } else {
2304 log_it("No biggiefiles selected. So, no biggie-EXATs to set.");
2305 }
2306 }
2307 mr_free(xattr_fname);
2308 mr_free(acl_fname);
2309 mr_free(biggies_whose_EXATs_we_should_set);
2310
2311 if (does_file_exist("/PAUSE")) {
2312 popup_and_OK
2313 ("Press ENTER to go on. Delete /PAUSE to stop these pauses.");
2314 }
2315
2316 close_progress_form();
2317 if (retval) {
2318 mvaddstr_and_log_it(g_currentY++, 74, "Errors.");
2319 } else {
2320 mvaddstr_and_log_it(g_currentY++, 74, "Done.");
2321 }
2322 paranoid_free(pathname_of_last_biggie_restored);
2323 paranoid_free(biggie_fname);
2324 paranoid_free(biggie_cksum);
2325 return (retval);
2326}
2327
2328/**************************************************************************
2329 *END_RESTORE_ALL_BIGGIEFILES_FROM_STREAM *
2330 **************************************************************************/
2331
2332
2333
2334
2335
2336
2337/**
2338 * Restore all afioballs from the currently opened tape stream.
2339 * @param bkpinfo The backup information structure. Fields used:
2340 * - @c bkpinfo->backup_media_type
2341 * - @c bkpinfo->restore_path
2342 * @param filelist The node structure containing the list of files to be
2343 * restored. If no file in an afioball is in this list, afio will still be
2344 * called for that fileset, but nothing will be written.
2345 * @return 0 for success, or the number of filesets that failed.
2346 */
2347int restore_all_tarballs_from_stream(struct s_node *filelist)
2348{
2349 int retval = 0;
2350 int res;
2351 long current_afioball_number = 0;
2352 int ctrl_chr;
2353 long max_val /*, total_noof_files */ ;
2354
2355 /** malloc **/
2356 char *tmp = NULL;
2357 char *mds = NULL;
2358 char *progress_str = NULL;
2359 char *tmp_fname;
2360 char *xattr_fname = NULL;
2361 char *acl_fname = NULL;
2362
2363 long long tmp_size;
2364
2365 malloc_string(tmp_fname);
2366 assert(bkpinfo != NULL);
2367 mvaddstr_and_log_it(g_currentY, 0, "Restoring from archives");
2368 tmp = read_cfg_var(g_mondo_cfg_file, "last-filelist-number");
2369 max_val = atol(tmp) + 1;
2370 mr_free(tmp);
2371
2372 chdir(bkpinfo->restore_path); /* I don't know why this is needed _here_ but it seems to be. -HR, 02/04/2002 */
2373
2374 run_program_and_log_output("pwd", 5);
2375
2376 mr_asprintf(progress_str, "Restoring from media #%d", g_current_media_number);
2377 log_to_screen(progress_str);
2378 open_progress_form("Restoring from archives",
2379 "Restoring data from the archives.",
2380 "Please wait. This may take some time.",
2381 progress_str, max_val);
2382
2383 log_msg(3, "hey");
2384
2385 res = read_header_block_from_stream(&tmp_size, tmp_fname, &ctrl_chr);
2386 if (res) {
2387 log_msg(2, "Warning - error reading afioball from tape");
2388 }
2389 retval += res;
2390 if (ctrl_chr != BLK_START_AFIOBALLS) {
2391 wrong_marker(BLK_START_AFIOBALLS, ctrl_chr);
2392 }
2393 log_msg(2, "ho");
2394 res = read_header_block_from_stream(&tmp_size, tmp_fname, &ctrl_chr);
2395 while (ctrl_chr != BLK_STOP_AFIOBALLS) {
2396 update_progress_form(progress_str);
2397 if (g_getfattr) {
2398 mr_asprintf(xattr_fname, "%s/xattr-subset-%ld.tmp", bkpinfo->tmpdir, current_afioball_number);
2399 unlink(xattr_fname);
2400 }
2401 if (g_getfacl) {
2402 mr_asprintf(acl_fname, "%s/acl-subset-%ld.tmp", bkpinfo->tmpdir, current_afioball_number);
2403 unlink(acl_fname);
2404 }
2405 if (ctrl_chr == BLK_START_EXTENDED_ATTRIBUTES) {
2406 log_it("Reading EXAT files from tape");
2407 res = read_EXAT_files_from_tape(&tmp_size, tmp_fname, &ctrl_chr, xattr_fname, acl_fname);
2408 }
2409 if (ctrl_chr != BLK_START_AN_AFIO_OR_SLICE) {
2410 wrong_marker(BLK_START_AN_AFIO_OR_SLICE, ctrl_chr);
2411 }
2412 log_msg(4, "Restoring from fileset #%ld (name=%s, size=%ld K)", current_afioball_number, tmp_fname, (long) tmp_size >> 10);
2413 res = restore_a_tarball_from_stream(tmp_fname, current_afioball_number, filelist, tmp_size, xattr_fname, acl_fname);
2414 retval += res;
2415 if (res) {
2416 log_to_screen("Fileset %ld - errors occurred", current_afioball_number);
2417 }
2418 res =
2419 read_header_block_from_stream(&tmp_size, tmp_fname, &ctrl_chr);
2420 if (ctrl_chr != BLK_STOP_AN_AFIO_OR_SLICE) {
2421 wrong_marker(BLK_STOP_AN_AFIO_OR_SLICE, ctrl_chr);
2422 }
2423
2424 current_afioball_number++;
2425 g_current_progress++;
2426 mds = media_descriptor_string(bkpinfo->backup_media_type),
2427
2428 mr_free(progress_str);
2429 mr_asprintf(progress_str, "Restoring from fileset #%ld on %s #%d", current_afioball_number, mds, g_current_media_number);
2430 mr_free(mds);
2431 res = read_header_block_from_stream(&tmp_size, tmp_fname, &ctrl_chr);
2432 if (g_getfattr) {
2433 unlink(xattr_fname);
2434 }
2435 if (g_getfacl) {
2436 unlink(acl_fname);
2437 }
2438 } // next
2439 mr_free(progress_str);
2440 if (g_getfattr) {
2441 mr_free(xattr_fname);
2442 }
2443 if (g_getfacl) {
2444 mr_free(acl_fname);
2445 }
2446
2447 log_msg(1, "All done with afioballs");
2448 close_progress_form();
2449 if (retval) {
2450 mvaddstr_and_log_it(g_currentY++, 74, "Errors.");
2451 } else {
2452 mvaddstr_and_log_it(g_currentY++, 74, "Done.");
2453 }
2454 paranoid_free(tmp_fname);
2455 return (retval);
2456}
2457
2458/**************************************************************************
2459 *END_ RESTORE_ALL_TARBALLS_FROM_STREAM *
2460 **************************************************************************/
2461
2462/* @} - end of LLrestoreGroup */
2463
2464
2465/**
2466 * Restore all files in @p filelist.
2467 * @param bkpinfo The backup information structure. Most fields are used.
2468 * @param filelist The node structure containing the list of files to be
2469 * restored.
2470 * @return 0 for success, or the number of afioballs and biggiefiles that failed.
2471 * @ingroup restoreGroup
2472 */
2473int restore_everything(struct s_node *filelist)
2474{
2475 int resA;
2476 int resB;
2477
2478 /** mallco ***/
2479 char *cwd;
2480 char *newpath;
2481 char *tmp = NULL;
2482 assert(bkpinfo != NULL);
2483
2484 malloc_string(cwd);
2485 malloc_string(newpath);
2486 log_msg(2, "restore_everything() --- starting");
2487 g_current_media_number = 1;
2488 getcwd(cwd, MAX_STR_LEN - 1);
2489 mr_asprintf(tmp, "mkdir -p %s", bkpinfo->restore_path);
2490 run_program_and_log_output(tmp, FALSE);
2491 mr_free(tmp);
2492
2493 log_msg(1, "Changing dir to %s", bkpinfo->restore_path);
2494 chdir(bkpinfo->restore_path);
2495 getcwd(newpath, MAX_STR_LEN - 1);
2496 log_msg(1, "path is now %s", newpath);
2497 log_msg(1, "restoring everything");
2498 tmp = find_home_of_exe("petris");
2499 if (!tmp && !g_text_mode) {
2500 newtDrawRootText(0, g_noof_rows - 2,
2501 "Press ALT-<left cursor> twice to play Petris :-) ");
2502 newtRefresh();
2503 }
2504 mr_free(tmp);
2505
2506 mvaddstr_and_log_it(g_currentY, 0, "Preparing to read your archives");
2507 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
2508 mount_media();
2509 mvaddstr_and_log_it(g_currentY++, 0,
2510 "Restoring OS and data from streaming media");
2511 if (bkpinfo->backup_media_type == cdstream) {
2512 openin_cdstream();
2513 } else {
2514 openin_tape();
2515 }
2516 resA = restore_all_tarballs_from_stream(filelist);
2517 resB = restore_all_biggiefiles_from_stream(filelist);
2518 if (bkpinfo->backup_media_type == cdstream) {
2519 closein_cdstream();
2520 } else {
2521 closein_tape();
2522 }
2523 } else {
2524 mvaddstr_and_log_it(g_currentY++, 0,
2525 "Restoring OS and data from CD/USB ");
2526 mount_media();
2527 resA = restore_all_tarballs_from_CD(filelist);
2528 resB = restore_all_biggiefiles_from_CD(filelist);
2529 }
2530 chdir(cwd);
2531 if (resA + resB) {
2532 log_to_screen("Errors occurred while data was being restored.");
2533 }
2534 if (length_of_file("/etc/raidtab") > 0) {
2535 log_msg(2, "Copying local raidtab to restored filesystem");
2536 run_program_and_log_output("cp -f /etc/raidtab " MNT_RESTORING
2537 "/etc/raidtab", FALSE);
2538 }
2539 kill_petris();
2540 log_msg(2, "restore_everything() --- leaving");
2541 paranoid_free(cwd);
2542 paranoid_free(newpath);
2543 return (resA + resB);
2544}
2545
2546/**************************************************************************
2547 *END_RESTORE_EVERYTHING *
2548 **************************************************************************/
2549
2550
2551extern void wait_until_software_raids_are_prepped(char *, int);
2552
2553
2554char which_restore_mode(void);
2555
2556
2557/**
2558 * Log a "don't panic" message to the logfile.
2559 */
2560void welcome_to_mondorestore()
2561{
2562 log_msg(0, "-------------- Mondo Restore v%s -------------", PACKAGE_VERSION);
2563 log_msg(0, "DON'T PANIC! Mondorestore logs almost everything, so please ");
2564 log_msg(0, "don't break out in a cold sweat just because you see a few ");
2565 log_msg(0, "error messages in the log. Read them; analyze them; see if ");
2566 log_msg(0, "they are significant; above all, verify your backups! Please");
2567 log_msg(0, "attach a compressed copy of this log to any e-mail you send ");
2568 log_msg(0, "to the Mondo mailing list when you are seeking technical ");
2569 log_msg(0, "support. Without it, we can't help you. - DevTeam");
2570 log_msg(0, "------------------------------------------------------------");
2571 log_msg(0, "BTW, despite (or perhaps because of) the wealth of messages,");
2572 log_msg(0, "some users are inclined to stop reading this log. If Mondo ");
2573 log_msg(0, "stopped for some reason, chances are it's detailed here. ");
2574 log_msg(0, "More than likely there's a message at the very end of this ");
2575 log_msg(0, "log that will tell you what is wrong. Please read it! ");
2576 log_msg(0, "------------------------------------------------------------");
2577}
2578
2579
2580
2581/**
2582 * Restore the user's data.
2583 * What did you think it did, anyway? :-)
2584 */
2585int main(int argc, char *argv[])
2586{
2587 FILE *fin;
2588 FILE *fout;
2589 int retval = 0;
2590 int res;
2591 char *tmp = NULL;
2592
2593 struct mountlist_itself *mountlist;
2594 struct raidlist_itself *raidlist;
2595 struct s_node *filelist;
2596 char *tmp1 = NULL;
2597 char *tmp2 = NULL;
2598 bool run_postnuke = FALSE;
2599
2600 if (getuid() != 0) {
2601 fprintf(stderr, "Please run as root.\r\n");
2602 exit(127);
2603 }
2604 bkpinfo = (struct s_bkpinfo *)mr_malloc(sizeof(struct s_bkpinfo));
2605 init_bkpinfo();
2606
2607 g_loglevel = DEFAULT_MR_LOGLEVEL;
2608
2609 /* Configure global variables */
2610 malloc_libmondo_global_strings();
2611 if (strstr(call_program_and_get_last_line_of_output("cat " CMDLINE), "textonly"))
2612 {
2613 g_text_mode = TRUE;
2614 log_msg(1, "TEXTONLY MODE");
2615 } else {
2616 g_text_mode = FALSE;
2617 } // newt :-)
2618
2619 /* Init GUI */
2620 setup_newt_stuff(); /* call newtInit and setup screen log */
2621
2622 strcpy(g_mondo_home, call_program_and_get_last_line_of_output("which mondorestore"));
2623 g_current_media_number = 1; // precaution
2624
2625 run_program_and_log_output("mkdir -p " MNT_CDROM, FALSE);
2626
2627 setup_MR_global_filenames(); // malloc() and set globals, using bkpinfo->tmpdir etc.
2628 bkpinfo->backup_media_type = none; // in case boot disk was made for one backup type but user wants to restore from another backup type
2629 bkpinfo->restore_data = TRUE; // Well, yeah :-)
2630 if (am_I_in_disaster_recovery_mode()) {
2631 run_program_and_log_output("mount / -o remount,rw", 2);
2632 } // for b0rken distros
2633 g_main_pid = getpid();
2634 srandom((int) (time(NULL)));
2635 set_signals(TRUE);
2636 g_kernel_version = get_kernel_version();
2637
2638 log_msg(1, "FYI - g_mountlist_fname = %s", g_mountlist_fname);
2639 if (strlen(g_mountlist_fname) < 3) {
2640 fatal_error("Serious error in malloc()'ing. Could be a bug in your glibc.");
2641 }
2642 mkdir(MNT_CDROM, 0x770);
2643 make_hole_for_dir(MONDO_CACHE);
2644
2645 /* Backup original mountlist.txt */
2646 mr_asprintf(tmp, "%s.orig", g_mountlist_fname);
2647 if (!does_file_exist(g_mountlist_fname)) {
2648 log_msg(2, "%ld: Warning - g_mountlist_fname (%s) does not exist yet", __LINE__, g_mountlist_fname);
2649 } else if (!does_file_exist(tmp)) {
2650 mr_free(tmp);
2651 mr_asprintf(tmp, "cp -f %s %s.orig", g_mountlist_fname, g_mountlist_fname);
2652 run_program_and_log_output(tmp, FALSE);
2653 }
2654 mr_free(tmp);
2655
2656 /* Init directories */
2657 make_hole_for_dir("/var/log");
2658 make_hole_for_dir("/tmp/tmpfs"); /* just in case... */
2659 run_program_and_log_output("umount " MNT_CDROM, FALSE);
2660
2661 run_program_and_log_output("rm -Rf /tmp/tmpfs/mondo.tmp.*", FALSE);
2662
2663 welcome_to_mondorestore();
2664 if (bkpinfo->disaster_recovery) {
2665 log_msg(1, "I am in disaster recovery mode");
2666 } else {
2667 log_msg(1, "I am in normal, live mode");
2668 }
2669
2670 log_it("what time is it");
2671
2672 mountlist = (struct mountlist_itself *)mr_malloc(sizeof(struct mountlist_itself));
2673 raidlist = (struct raidlist_itself *)mr_malloc(sizeof(struct raidlist_itself));
2674
2675 /* Process command-line parameters */
2676 if (argc == 2 && strcmp(argv[1], "--edit-mountlist") == 0) {
2677#ifdef __FreeBSD__
2678 system("mv -f /tmp/raidconf.txt /etc/raidtab");
2679 if (!does_file_exist("/etc/raidtab"))
2680 system("vinum printconfig > /etc/raidtab");
2681#endif
2682 load_raidtab_into_raidlist(raidlist, RAIDTAB_FNAME);
2683 if (!does_file_exist(g_mountlist_fname)) {
2684 strcpy(g_mountlist_fname, "/tmp/mountlist.txt");
2685 }
2686 res = let_user_edit_the_mountlist(mountlist, raidlist);
2687#ifdef __FreeBSD__
2688 system("mv -f /etc/raidtab /tmp/raidconf.txt");
2689#endif
2690 paranoid_MR_finish(res);
2691 }
2692
2693 if (argc == 3 && strcmp(argv[1], "--echo-to-screen") == 0) {
2694 fout = fopen("/tmp/out.txt", "w");
2695 fput_string_one_char_at_a_time(stderr, argv[2]);
2696 finish(0);
2697 }
2698
2699 if (argc == 3 && strcmp(argv[1], "--gendf") == 0) {
2700 make_grub_install_scriptlet(argv[2]);
2701 finish(0);
2702 }
2703
2704 if (argc == 5 && strcmp(argv[1], "--common") == 0) {
2705 g_loglevel = 6;
2706 filelist = load_filelist(argv[2]);
2707 if (!filelist) {
2708 fatal_error("Failed to load filelist");
2709 }
2710 toggle_node_selection(filelist, FALSE);
2711 toggle_all_root_dirs_on(filelist);
2712 // BERLIOS: /usr/lib ???
2713 toggle_path_selection(filelist, "/usr/share", TRUE);
2714 save_filelist(filelist, "/tmp/out.txt");
2715 mr_asprintf(tmp1, "%s", argv[3]);
2716 mr_asprintf(tmp2, "%s", argv[4]);
2717
2718 res = save_filelist_entries_in_common(tmp1, filelist, tmp2, FALSE);
2719 mr_free(tmp1);
2720 mr_free(tmp2);
2721
2722 free_filelist(filelist);
2723 printf("res = %d", res);
2724 finish(0);
2725 }
2726
2727 if (argc == 3 && strcmp(argv[1], "--popuplist") == 0) {
2728 popup_changelist_from_file(argv[2]);
2729 paranoid_MR_finish(0);
2730 }
2731
2732 if (argc == 5 && strcmp(argv[1], "--copy") == 0) {
2733 log_msg(1, "SCORE");
2734 g_loglevel = 10;
2735 if (strstr(argv[2], "save")) {
2736 log_msg(1, "Saving from %s to %s", argv[3], argv[4]);
2737 fin = fopen(argv[3], "r");
2738 fout = fopen(argv[4], "w");
2739 copy_from_src_to_dest(fin, fout, 'w');
2740 fclose(fin);
2741 fin = fopen(argv[3], "r");
2742 copy_from_src_to_dest(fin, fout, 'w');
2743 fclose(fout);
2744 fclose(fin);
2745 } else if (strstr(argv[2], "restore")) {
2746 fout = fopen(argv[3], "w");
2747 fin = fopen(argv[4], "r");
2748 copy_from_src_to_dest(fout, fin, 'r');
2749 fclose(fin);
2750 fin = fopen(argv[4], "r");
2751 copy_from_src_to_dest(fout, fin, 'r');
2752 fclose(fout);
2753 fclose(fin);
2754 } else {
2755 fatal_error("Unknown additional param");
2756 }
2757 finish(0);
2758 }
2759
2760 if (argc == 3 && strcmp(argv[1], "--mdstat") == 0) {
2761 wait_until_software_raids_are_prepped(argv[2], 100);
2762 finish(0);
2763 }
2764
2765 if (argc == 3 && strcmp(argv[1], "--mdconv") == 0) {
2766 finish(create_raidtab_from_mdstat(argv[2]));
2767 }
2768
2769 if (argc == 2 && strcmp(argv[1], "--live-grub") == 0) {
2770 retval = run_grub(FALSE, "/dev/hda");
2771 if (retval) {
2772 log_to_screen("Failed to write Master Boot Record");
2773 }
2774 paranoid_MR_finish(0);
2775 }
2776 if (argc == 3 && strcmp(argv[1], "--paa") == 0) {
2777 g_current_media_number = atoi(argv[2]);
2778 pause_and_ask_for_cdr(5, NULL);
2779 paranoid_MR_finish(0);
2780 }
2781 if ((argc == 2 && strcmp(argv[1], "--partition-only") == 0) && (bkpinfo->disaster_recovery)) {
2782 log_msg(0, "Partitioning only.");
2783 load_raidtab_into_raidlist(raidlist, RAIDTAB_FNAME);
2784 strcpy(g_mountlist_fname, "/tmp/mountlist.txt");
2785 load_mountlist(mountlist, g_mountlist_fname);
2786 res = partition_everything(mountlist);
2787 finish(res);
2788 }
2789
2790 if ((argc == 2 && strcmp(argv[1], "--format-only") == 0) && (bkpinfo->disaster_recovery)) {
2791 log_msg(0, "Formatting only.");
2792 load_raidtab_into_raidlist(raidlist, RAIDTAB_FNAME);
2793 strcpy(g_mountlist_fname, "/tmp/mountlist.txt");
2794 load_mountlist(mountlist, g_mountlist_fname);
2795 res = format_everything(mountlist, FALSE, raidlist);
2796 finish(res);
2797 }
2798
2799 if ((argc == 2 && strcmp(argv[1], "--stop-lvm-and-raid") == 0) && (bkpinfo->disaster_recovery)) {
2800 log_msg(0, "Stopping LVM and RAID");
2801 load_raidtab_into_raidlist(raidlist, RAIDTAB_FNAME);
2802 strcpy(g_mountlist_fname, "/tmp/mountlist.txt");
2803 load_mountlist(mountlist, g_mountlist_fname);
2804 res = do_my_funky_lvm_stuff(TRUE, FALSE);
2805 res += stop_all_raid_devices(mountlist);
2806 finish(res);
2807 }
2808
2809 if ((argc > 1 && strcmp(argv[argc - 1], "--live-from-cd") == 0) && (!bkpinfo->disaster_recovery)) {
2810 g_restoring_live_from_cd = TRUE;
2811 }
2812
2813 // Handle params here first
2814 handle_incoming_parameters(argc,argv);
2815
2816 if (!bkpinfo->disaster_recovery) { // live!
2817 log_msg(1, "I am in normal, live mode.");
2818 log_msg(2, "FYI, MOUNTLIST_FNAME = %s", g_mountlist_fname);
2819 mount_boot_if_necessary(); /* for Gentoo users */
2820 log_msg(2, "Still here.");
2821 if (bkpinfo->backup_media_type == nfs) {
2822 g_restoring_live_from_nfs = TRUE;
2823 }
2824 /* Adding an initialisation in order to avoid to hndle NULL pointer later */
2825 mr_free(bkpinfo->restore_path);
2826 mr_asprintf(bkpinfo->restore_path, "%s", "/tmp");
2827
2828 log_msg(2, "Calling restore_to_live_filesystem()");
2829 retval = restore_to_live_filesystem();
2830
2831 log_msg(2, "Still here. Yay.");
2832 if ((strlen(bkpinfo->tmpdir) > 0) && (strstr(bkpinfo->tmpdir,"mondo.tmp.") != NULL)) {
2833 mr_asprintf(tmp, "rm -Rf %s/*", bkpinfo->tmpdir);
2834 run_program_and_log_output(tmp, FALSE);
2835 mr_free(tmp);
2836 }
2837 unmount_boot_if_necessary(); /* for Gentoo users */
2838 paranoid_MR_finish(retval);
2839 } else {
2840 /* Disaster recovery mode (must be) */
2841 log_msg(1, "I must be in disaster recovery mode.");
2842 log_msg(2, "FYI, MOUNTLIST_FNAME = %s ", g_mountlist_fname);
2843
2844 log_it("About to call load_mountlist and load_raidtab");
2845 mr_free(bkpinfo->restore_path);
2846 mr_asprintf(bkpinfo->restore_path, "%s", MNT_RESTORING);
2847 read_cfg_file_into_bkpinfo(g_mondo_cfg_file);
2848 retval = load_mountlist(mountlist, g_mountlist_fname);
2849 retval += load_raidtab_into_raidlist(raidlist, RAIDTAB_FNAME);
2850 log_it("Returned from calling load_mountlist and load_raidtab successfully");
2851
2852 // BCO:To be reviewed
2853 if ((bkpinfo->restore_mode == compare) || (bkpinfo->restore_mode == nuke)) {
2854 if (bkpinfo->backup_media_type == nfs && bkpinfo->nfs_mount && !is_this_device_mounted(bkpinfo->nfs_mount)) {
2855 log_msg(1, "Mounting nfs dir");
2856 mr_free(bkpinfo->isodir);
2857 mr_asprintf(bkpinfo->isodir, "/tmp/isodir");
2858 run_program_and_log_output("mkdir -p /tmp/isodir", 5);
2859 mr_asprintf(tmp, "mount %s -t nfs -o nolock,ro /tmp/isodir", bkpinfo->nfs_mount);
2860 run_program_and_log_output(tmp, 1);
2861 mr_free(tmp);
2862 }
2863 }
2864
2865 if (retval) {
2866 log_to_screen("Warning - load_raidtab_into_raidlist returned an error");
2867 }
2868
2869 log_msg(1, "Send in the clowns.");
2870
2871
2872 if (bkpinfo->restore_mode == nuke) {
2873 log_it("nuking");
2874 retval += nuke_mode(mountlist, raidlist);
2875 } else if (bkpinfo->restore_mode == interactive) {
2876 log_it("catchall");
2877 retval += catchall_mode(mountlist, raidlist);
2878 } else if (bkpinfo->restore_mode == compare) {
2879 log_it("compare");
2880 retval += compare_mode(mountlist, raidlist);
2881 } else if (bkpinfo->restore_mode == isoonly) {
2882 log_it("iso");
2883 retval = iso_mode(mountlist, raidlist, FALSE);
2884 } else if (bkpinfo->restore_mode == mbr) {
2885 log_it("mbr");
2886 retval = mount_all_devices(mountlist, TRUE);
2887 if (!retval) {
2888 retval += run_boot_loader(FALSE);
2889 retval += unmount_all_devices(mountlist);
2890 }
2891 if (retval) {
2892 log_to_screen("Failed to write Master Boot Record");
2893 }
2894 } else if (bkpinfo->restore_mode == isonuke) {
2895 log_it("isonuke");
2896 retval = iso_mode(mountlist, raidlist, TRUE);
2897 } else {
2898 log_it("catchall (no mode specified in command-line call");
2899 retval += catchall_mode(mountlist, raidlist);
2900 }
2901 }
2902
2903 /* clean up at the end */
2904 if (retval) {
2905 if (does_file_exist(MONDO_CACHE"/changed.files")) {
2906 log_to_screen
2907 ("See "MONDO_CACHE"/changed.files for list of files that have changed.");
2908 }
2909 mvaddstr_and_log_it(g_currentY++,
2910 0,
2911 "Run complete. Errors were reported. Please review the logfile.");
2912 } else {
2913 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
2914 mvaddstr_and_log_it(g_currentY++,
2915 0,
2916 "Run complete. Please remove media and reboot.");
2917 } else {
2918 run_program_and_log_output("sync", FALSE);
2919 if (is_this_device_mounted(MNT_CDROM)) {
2920 run_program_and_log_output("umount " MNT_CDROM, FALSE);
2921 }
2922
2923 if (!bkpinfo->please_dont_eject) {
2924 (void)eject_device("/dev/cdrom");
2925 }
2926 mvaddstr_and_log_it(g_currentY++,
2927 0,
2928 "Run complete. Please remove media and reboot.");
2929 }
2930 }
2931
2932// g_I_have_just_nuked is set true by nuke_mode() just before it returns
2933 if (!system("which post-nuke > /dev/null 2> /dev/null")) {
2934 log_msg(1, "post-nuke found; find out whether we should run it...");
2935 if (g_I_have_just_nuked || does_file_exist("/POST-NUKE-ANYWAY")) {
2936 run_postnuke = TRUE;
2937 log_msg(1, "Yes, will run post-nuke because in nuke mode or file /POST-NUKE-ANYWAY exists.");
2938 } else if (ask_me_yes_or_no("post-nuke script found. Do you want to run it?")) {
2939 run_postnuke = TRUE;
2940 log_msg(1, "Yes, will run post-nuke because user interactively asked for it.");
2941 } else {
2942 run_postnuke = FALSE;
2943 log_msg(1, "No, will not run post-nuke.");
2944 }
2945 } else {
2946 log_msg(1, "No post-nuke found.");
2947 }
2948 if (run_postnuke) {
2949 log_to_screen("Running post-nuke...");
2950 if (mount_all_devices(mountlist, TRUE)) {
2951 log_to_screen
2952 ("Unable to re-mount partitions for post-nuke stuff");
2953 } else {
2954 log_msg(1, "Re-mounted partitions for post-nuke stuff");
2955 mr_asprintf(tmp, "post-nuke %s %d", bkpinfo->restore_path, retval);
2956 log_msg(2, "Calling '%s'", tmp);
2957 if ((res = run_program_and_log_output(tmp, 0))) {
2958 log_OS_error(tmp);
2959 }
2960 mr_free(tmp);
2961 log_msg(1, "post-nuke returned w/ res=%d", res);
2962 }
2963 unmount_all_devices(mountlist);
2964 log_to_screen("I've finished post-nuking.");
2965 }
2966
2967/*
2968 log_to_screen("If you are REALLY in a hurry, hit Ctrl-Alt-Del now.");
2969 log_to_screen("Otherwise, please wait until the RAID disks are done.");
2970 wait_until_software_raids_are_prepped("/proc/mdstat", 100);
2971 log_to_screen("Thank you.");
2972*/
2973 unlink("/tmp/mondo-run-prog.tmp");
2974 set_signals(FALSE);
2975 log_to_screen("Restore log (%s) copied to /var/log on your hard disk", MONDO_LOGFILE);
2976 log_to_screen("Mondo-restore is exiting (retval=%d) ", retval);
2977
2978 mr_asprintf(tmp, "umount %s", bkpinfo->isodir);
2979 run_program_and_log_output(tmp, 5);
2980 mr_free(tmp);
2981
2982 paranoid_free(mountlist);
2983 paranoid_free(raidlist);
2984 if (am_I_in_disaster_recovery_mode()) {
2985 run_program_and_log_output("mount / -o remount,rw", 2);
2986 } // for b0rken distros
2987 if (strstr(bkpinfo->tmpdir,"mondo.tmp.") != NULL) {
2988 mr_asprintf(tmp, "rm -Rf %s", bkpinfo->tmpdir);
2989 system(tmp);
2990 mr_free(tmp);
2991 }
2992 paranoid_MR_finish(retval); // frees global stuff plus bkpinfo
2993 free_libmondo_global_strings(); // it's fine to have this here :) really :)
2994
2995 unlink("/tmp/filelist.full");
2996 unlink("/tmp/filelist.full.gz");
2997
2998 exit(retval);
2999}
3000
3001/**************************************************************************
3002 *END_MAIN *
3003 **************************************************************************/
3004
3005
3006
3007
3008
3009/**************************************************************************
3010 *END_MONDO-RESTORE.C *
3011 **************************************************************************/
Note: See TracBrowser for help on using the repository browser.