source: MondoRescue/branches/3.0/mondo/src/mondorestore/mondo-rstr-compare.c@ 3185

Last change on this file since 3185 was 3185, checked in by Bruno Cornec, 11 years ago

Simplify the interface of mr_getline and mr_asprintf. With 3.1 compatibility now will allow backports from this branch into 3.0

  • Property svn:keywords set to Id
File size: 22.2 KB
Line 
1/***************************************************************************
2 cvsid : $Id: mondo-rstr-compare.c 3185 2013-09-20 12:29:57Z bruno $
3***************************************************************************/
4
5#include <pthread.h>
6#include "my-stuff.h"
7#include "mr_mem.h"
8#include "../common/mondostructures.h"
9#include "../common/libmondo.h"
10//#include "../../config.h"
11#include "mr-externs.h"
12#include "mondo-rstr-compare.h"
13#include "mondo-restore-EXT.h"
14#include "mondo-rstr-tools-EXT.h"
15
16extern char *MONDO_LOGFILE;
17
18/* Reference to global bkpinfo */
19extern struct s_bkpinfo *bkpinfo;
20
21extern char *g_mountlist_fname;
22
23//static char cvsid[] = "$Id: mondo-rstr-compare.c 3185 2013-09-20 12:29:57Z bruno $";
24
25void popup_changelist_from_file(char *);
26
27
28/**
29 * @addtogroup LLcompareGroup
30 * @{
31 */
32/**
33 * Compare biggiefile number @p bigfileno with the filesystem mounted on @p MNT_RESTORING.
34 * @param bkpinfo The backup information structure. Only used in insist_on_this_cd_number().
35 * @param bigfileno The biggiefile number (starting from 0) to compare.
36 * @note This function uses an MD5 checksum.
37 */
38int compare_a_biggiefile(long bigfileno)
39{
40
41 FILE *fin;
42 FILE *fout;
43
44 /** needs malloc *******/
45 char *checksum_ptr;
46 char *original_cksum_ptr;
47 char *bigfile_fname_ptr;
48 char *tmp_ptr = NULL;
49 char *command_ptr;
50
51 char *checksum, *original_cksum, *bigfile_fname, *tmp, *command;
52
53 char *p;
54 int i;
55 int retval = 0;
56
57 struct s_filename_and_lstat_info biggiestruct;
58
59 malloc_string(checksum);
60 malloc_string(original_cksum);
61 malloc_string(bigfile_fname);
62 malloc_string(tmp);
63 malloc_string(command);
64 malloc_string(checksum_ptr);
65 malloc_string(original_cksum_ptr);
66 malloc_string(bigfile_fname_ptr);
67 malloc_string(command_ptr);
68
69 /*********************************************************************
70 * allocate memory clear test sab 16 feb 2003 *
71 *********************************************************************/
72 assert(bkpinfo != NULL);
73 memset(checksum_ptr, '\0', sizeof(checksum));
74 memset(original_cksum_ptr, '\0', sizeof(original_cksum));
75 memset(bigfile_fname_ptr, '\0', sizeof(bigfile_fname));
76 memset(command_ptr, '\0', sizeof(command));
77 /** end **/
78
79 if (!does_file_exist(slice_fname(bigfileno, 0, ARCHIVES_PATH, ""))) {
80 if (does_file_exist(MNT_CDROM "/archives/NOT-THE-LAST")) {
81 insist_on_this_cd_number((++g_current_media_number));
82 } else {
83 mr_asprintf(tmp_ptr, "No CD's left. No biggiefiles left. No prob, Bob.");
84 log_msg(2, tmp_ptr);
85 paranoid_free(tmp_ptr);
86 return (0);
87 }
88 }
89 if (!(fin = fopen(slice_fname(bigfileno, 0, ARCHIVES_PATH, ""), "r"))) {
90 mr_asprintf(tmp_ptr, "Cannot open bigfile %ld (%s)'s info file", bigfileno + 1, bigfile_fname_ptr);
91 log_to_screen(tmp_ptr);
92 paranoid_free(tmp_ptr);
93 return (1);
94 }
95 if (fread((void *) &biggiestruct, 1, sizeof(biggiestruct), fin)) {
96 // FIXME
97 }
98 paranoid_fclose(fin);
99
100 strcpy(checksum_ptr, biggiestruct.checksum);
101 strcpy(bigfile_fname_ptr, biggiestruct.filename);
102
103 log_msg(2, "biggiestruct.filename = %s", biggiestruct.filename);
104 log_msg(2, "biggiestruct.checksum = %s", biggiestruct.checksum);
105
106 if (!g_text_mode) {
107 mr_asprintf(tmp_ptr, "Comparing %s", bigfile_fname_ptr);
108 newtDrawRootText(0, 22, tmp_ptr);
109 paranoid_free(tmp_ptr);
110 newtRefresh();
111 }
112 if (!checksum[0]) {
113 log_msg(2, "Warning - %s has no checksum", bigfile_fname_ptr);
114 }
115 if (!strncmp(bigfile_fname_ptr, "/dev/", 5)) {
116 strcpy(original_cksum_ptr, "IGNORE");
117 } else {
118 sprintf(command_ptr,
119 "md5sum \"%s%s\" > /tmp/md5sum.txt 2> /tmp/errors",
120 MNT_RESTORING, bigfile_fname_ptr);
121 }
122 log_msg(2, command_ptr);
123 mr_asprintf(tmp_ptr, "cat /tmp/errors >> %s 2> /dev/null", MONDO_LOGFILE);
124 paranoid_system(tmp_ptr);
125 paranoid_free(tmp_ptr);
126
127 if (system(command_ptr)) {
128 log_OS_error("Warning - command failed");
129 original_cksum[0] = '\0';
130 return (1);
131 } else {
132 if (!(fin = fopen("/tmp/md5sum.txt", "r"))) {
133 log_msg(2,
134 "Unable to open /tmp/md5sum.txt; can't get live checksum");
135 original_cksum[0] = '\0';
136 return (1);
137 } else {
138 if (fgets(original_cksum_ptr, MAX_STR_LEN - 1, fin)) {
139 // FIXME
140 }
141 paranoid_fclose(fin);
142 for (i = strlen(original_cksum_ptr);
143 i > 0 && original_cksum[i - 1] < 32; i--);
144 original_cksum[i] = '\0';
145 p = (char *) strchr(original_cksum_ptr, ' ');
146 if (p) {
147 *p = '\0';
148 }
149 }
150 }
151 mr_asprintf(tmp_ptr, "bigfile #%ld ('%s') ", bigfileno + 1, bigfile_fname_ptr);
152 if (!strcmp(checksum_ptr, original_cksum_ptr) != 0) {
153 mr_strcat(tmp_ptr, " ... OK");
154 } else {
155 mr_strcat(tmp_ptr, "... changed");
156 retval++;
157 }
158 log_msg(1, tmp_ptr);
159 paranoid_free(tmp_ptr);
160
161 if (retval) {
162 if (!(fout = fopen(MONDO_CACHE"/changed.txt", "a"))) {
163 fatal_error("Cannot openout changed.txt");
164 }
165 fprintf(fout, "%s\n", bigfile_fname_ptr);
166 paranoid_fclose(fout);
167 }
168
169 paranoid_free(original_cksum_ptr);
170 paranoid_free(original_cksum);
171 paranoid_free(bigfile_fname_ptr);
172 paranoid_free(bigfile_fname);
173 paranoid_free(checksum_ptr);
174 paranoid_free(checksum);
175 paranoid_free(command_ptr);
176 paranoid_free(command);
177 paranoid_free(tmp);
178
179 return (retval);
180}
181
182/**************************************************************************
183 *END_COMPARE_A_BIGGIEFILE *
184 **************************************************************************/
185
186
187/**
188 * Compare all biggiefiles in the backup.
189 * @return 0 for success, nonzero for failure.
190 */
191int compare_all_biggiefiles()
192{
193 int retval = 0;
194 int res;
195 long noof_biggiefiles, bigfileno = 0;
196 char tmp[MAX_STR_LEN];
197
198 log_msg(1, "Comparing biggiefiles");
199
200 if (length_of_file(BIGGIELIST) < 6) {
201 log_msg(1,
202 "OK, really teeny-tiny biggielist; not comparing biggiefiles");
203 return (0);
204 }
205 noof_biggiefiles = count_lines_in_file(BIGGIELIST);
206 if (noof_biggiefiles <= 0) {
207 log_msg(1, "OK, no biggiefiles; not comparing biggiefiles");
208 return (0);
209 }
210 mvaddstr_and_log_it(g_currentY, 0,
211 "Comparing large files ");
212 open_progress_form("Comparing large files",
213 "I am now comparing the large files",
214 "against the filesystem. Please wait.", "",
215 noof_biggiefiles);
216 for (bigfileno = 0; bigfileno < noof_biggiefiles; bigfileno++) {
217 sprintf(tmp, "Comparing big file #%ld", bigfileno + 1);
218 log_msg(1, tmp);
219 update_progress_form(tmp);
220 res = compare_a_biggiefile(bigfileno);
221 retval += res;
222 g_current_progress++;
223 }
224 close_progress_form();
225 return (0);
226 if (retval) {
227 mvaddstr_and_log_it(g_currentY++, 74, "Errors.");
228 } else {
229 mvaddstr_and_log_it(g_currentY++, 74, "Done.");
230 }
231 return (retval);
232}
233
234/**************************************************************************
235 *END_COMPARE_ALL_BIGGIEFILES *
236 **************************************************************************/
237
238
239/**
240 * Compare afioball @p tarball_fname against the filesystem.
241 * You must be chdir()ed to the directory where the filesystem is mounted
242 * before you call this function.
243 * @param tarball_fname The filename of the tarball to compare.
244 * @param current_tarball_number The fileset number contained in @p tarball_fname.
245 * @return 0 for success, nonzero for failure.
246 */
247int compare_a_tarball(char *tarball_fname, int current_tarball_number)
248{
249 int retval = 0;
250 int res;
251 long archiver_errors;
252 bool use_star;
253
254 /*** needs malloc *********/
255 char *command, *tmp, *filelist_name, *logfile,
256 *compressor_exe;
257 char *archiver_exe = NULL;
258
259 malloc_string(command);
260 malloc_string(tmp);
261 malloc_string(filelist_name);
262 malloc_string(logfile);
263 malloc_string(compressor_exe);
264
265 use_star = (strstr(tarball_fname, ".star")) ? TRUE : FALSE;
266 assert_string_is_neither_NULL_nor_zerolength(tarball_fname);
267 sprintf(logfile, "/tmp/afio.log.%d", current_tarball_number);
268 sprintf(filelist_name, MNT_CDROM "/archives/filelist.%d",
269 current_tarball_number);
270
271 if (strstr(tarball_fname, ".bz2")) {
272 strcpy(compressor_exe, "bzip2");
273 } else if (strstr(tarball_fname, ".gz")) {
274 strcpy(compressor_exe, "gzip");
275 } else if (strstr(tarball_fname, ".lzo")) {
276 strcpy(compressor_exe, "lzop");
277 } else {
278 compressor_exe[0] = '\0';
279 }
280
281 if (use_star) {
282 mr_asprintf(archiver_exe, "star");
283 } else {
284 mr_asprintf(archiver_exe, "afio");
285 }
286
287 if (compressor_exe[0]) {
288 strcpy(tmp, compressor_exe);
289 if (!find_home_of_exe(tmp)) {
290 fatal_error("(compare_a_tarball) Compression program missing");
291 }
292 if (use_star) // star
293 {
294 if (!strcmp(compressor_exe, "bzip2")) {
295 mr_strcat(archiver_exe, " -bz");
296 } else {
297 fatal_error
298 ("(compare_a_tarball) Please use only bzip2 with star");
299 }
300 } else // afio
301 {
302 sprintf(compressor_exe, "-P %s -Z", tmp);
303 }
304 }
305// star -diff H=star -bz file=....
306
307#ifdef __FreeBSD__
308#define BUFSIZE 512L
309#else
310#define BUFSIZE (1024L*1024L)/TAPE_BLOCK_SIZE
311#endif
312 if (use_star) // doesn't use compressor_exe
313 {
314 sprintf(command,
315 "%s -sparse -diff H=exustar file=%s >> %s 2>> %s",
316 archiver_exe, tarball_fname, logfile, logfile);
317 } else {
318 sprintf(command,
319 "%s -r -b %ld -M 16m -c %ld %s %s >> %s 2>> %s",
320 archiver_exe,
321 TAPE_BLOCK_SIZE,
322 BUFSIZE, compressor_exe, tarball_fname, logfile, logfile);
323 }
324 paranoid_free(archiver_exe);
325
326#undef BUFSIZE
327
328 res = system(command);
329 retval += res;
330 if (res) {
331 log_OS_error(command);
332 sprintf(tmp, "Warning - afio returned error = %d", res);
333 log_msg(2, tmp);
334 }
335 if (length_of_file(logfile) > 5) {
336 sprintf(command,
337 "sed s/': \\\"'/\\|/ %s | sed s/'\\\": '/\\|/ | cut -d'|' -f2 | sort -u | grep -vE \"^dev/.*\" >> "MONDO_CACHE"/changed.txt",
338 logfile);
339 paranoid_system(command);
340 archiver_errors = count_lines_in_file(logfile);
341 } else {
342 archiver_errors = 0;
343 }
344 sprintf(tmp, "%ld difference%c in fileset #%d ",
345 archiver_errors, (archiver_errors != 1) ? 's' : ' ',
346 current_tarball_number);
347 if (archiver_errors) {
348 sprintf(tmp,
349 "Differences found while processing fileset #%d ",
350 current_tarball_number);
351 log_msg(1, tmp);
352 }
353 unlink(logfile);
354 paranoid_free(command);
355 paranoid_free(tmp);
356 paranoid_free(filelist_name);
357 paranoid_free(logfile);
358 paranoid_free(compressor_exe);
359 return (retval);
360}
361
362/**************************************************************************
363 *END_COMPARE_A_TARBALL *
364 **************************************************************************/
365
366
367/**
368 * Compare all afioballs in this backup.
369 * @param bkpinfo The backup media structure. Passed to other functions.
370 * @return 0 for success, nonzero for failure.
371 */
372int compare_all_tarballs()
373{
374 int retval = 0;
375 int current_tarball_number = 0;
376
377 /** needs malloc **********/
378
379 char *tarball_fname, *progress_str, *tmp;
380 char *mds = NULL;
381 long max_val;
382
383 malloc_string(tarball_fname);
384 malloc_string(progress_str);
385 malloc_string(tmp);
386
387 assert(bkpinfo != NULL);
388 mvaddstr_and_log_it(g_currentY, 0, "Comparing archives");
389 read_cfg_var(g_mondo_cfg_file, "last-filelist-number", tmp);
390
391 max_val = atol(tmp);
392 mds = media_descriptor_string(bkpinfo->backup_media_type);
393 sprintf(progress_str, "Comparing with %s #%d ", mds, g_current_media_number);
394
395 open_progress_form("Comparing files",
396 "Comparing tarballs against filesystem.",
397 "Please wait. This may take some time.",
398 progress_str, max_val);
399
400 log_to_screen(progress_str);
401
402 for (;;) {
403 insist_on_this_cd_number(g_current_media_number);
404 update_progress_form(progress_str);
405 sprintf(tarball_fname,
406 MNT_CDROM "/archives/%d.afio.bz2", current_tarball_number);
407
408 if (!does_file_exist(tarball_fname)) {
409 sprintf(tarball_fname, MNT_CDROM "/archives/%d.afio.lzo",
410 current_tarball_number);
411 }
412 if (!does_file_exist(tarball_fname)) {
413 sprintf(tarball_fname, MNT_CDROM "/archives/%d.afio.gz",
414 current_tarball_number);
415 }
416 if (!does_file_exist(tarball_fname)) {
417 sprintf(tarball_fname, MNT_CDROM "/archives/%d.afio.",
418 current_tarball_number);
419 }
420 if (!does_file_exist(tarball_fname)) {
421 sprintf(tarball_fname, MNT_CDROM "/archives/%d.star.bz2",
422 current_tarball_number);
423 }
424 if (!does_file_exist(tarball_fname)) {
425 sprintf(tarball_fname, MNT_CDROM "/archives/%d.star.",
426 current_tarball_number);
427 }
428 if (!does_file_exist(tarball_fname)) {
429 if (!does_file_exist(MNT_CDROM "/archives/NOT-THE-LAST") ||
430 system("find " MNT_CDROM
431 "/archives/slice* > /dev/null 2> /dev/null")
432 == 0) {
433 log_msg(2, "OK, I think I'm done with tarballs...");
434 break;
435 }
436 log_msg(2, "OK, I think it's time for another CD...");
437 g_current_media_number++;
438 sprintf(progress_str, "Comparing with %s #%d ", mds, g_current_media_number);
439 log_to_screen(progress_str);
440 } else {
441 retval += compare_a_tarball(tarball_fname, current_tarball_number);
442
443 g_current_progress++;
444 current_tarball_number++;
445 }
446 }
447 mr_free(mds);
448
449 close_progress_form();
450 if (retval) {
451 mvaddstr_and_log_it(g_currentY++, 74, "Errors.");
452 } else {
453 mvaddstr_and_log_it(g_currentY++, 74, "Done.");
454 }
455 paranoid_free(tarball_fname);
456 paranoid_free(progress_str);
457 paranoid_free(tmp);
458 return (retval);
459}
460
461/**************************************************************************
462 *END_COMPARE_ALL_TARBALLS *
463 **************************************************************************/
464
465/* @} - end LLcompareGroup */
466
467
468/**
469 * @addtogroup compareGroup
470 * @{
471 */
472/**
473 * Compare all data on a CD-R/CD-RW/DVD/ISO/NFS-based backup.
474 * @param bkpinfo The backup information structure. Passed to other functions.
475 * @return 0 for success, nonzero for failure.
476 */
477int compare_to_CD()
478{
479 /** needs malloc *********/
480 char *tmp, *cwd, *new, *command;
481 int resA = 0;
482 int resB = 0;
483 long noof_changed_files;
484
485 malloc_string(tmp);
486 malloc_string(cwd);
487 malloc_string(new);
488 malloc_string(command);
489
490 assert(bkpinfo != NULL);
491
492 if (getcwd(cwd, MAX_STR_LEN - 1)) {
493 // FIXME
494 }
495 if (chdir(bkpinfo->restore_path)) {
496 //FIXME
497 }
498 if (getcwd(new, MAX_STR_LEN - 1)) {
499 // FIXME
500 }
501 insist_on_this_cd_number(g_current_media_number);
502 unlink(MONDO_CACHE"/changed.txt");
503
504 resA = compare_all_tarballs();
505 resB = compare_all_biggiefiles();
506 if (chdir(cwd)) {
507 // FIXME
508 }
509 noof_changed_files = count_lines_in_file(MONDO_CACHE"/changed.txt");
510 if (noof_changed_files) {
511 sprintf(tmp, "%ld files do not match the backup ",
512 noof_changed_files);
513 // mvaddstr_and_log_it( g_currentY++, 0, tmp );
514 log_to_screen(tmp);
515 sprintf(command, "cat "MONDO_CACHE"/changed.txt >> %s", MONDO_LOGFILE);
516 paranoid_system(command);
517 } else {
518 sprintf(tmp, "All files match the backup ");
519 mvaddstr_and_log_it(g_currentY++, 0, tmp);
520 log_to_screen(tmp);
521 }
522
523 paranoid_free(tmp);
524 paranoid_free(cwd);
525 paranoid_free(new);
526 paranoid_free(command);
527
528 return (resA + resB);
529}
530
531/**************************************************************************
532 *END_COMPARE_TO_CD *
533 **************************************************************************/
534
535
536
537
538/**
539 * Compare all data in the user's backup.
540 * This function will mount filesystems, compare afioballs and biggiefiles,
541 * and show the user the differences.
542 * @param bkpinfo The backup information structure. Passed to other functions.
543 * @param mountlist The mountlist containing partitions to mount.
544 * @param raidlist The raidlist containing the user's RAID devices.
545 * @return The number of errors/differences found.
546 */
547int
548compare_mode(struct mountlist_itself *mountlist,
549 struct raidlist_itself *raidlist)
550{
551 int retval = 0;
552 int res = 0;
553 long q;
554 char *tmp;
555 char *new;
556 char *cwd;
557
558 malloc_string(tmp);
559 malloc_string(new);
560 malloc_string(cwd);
561
562 /**************************************************************************
563 * also deletes tmp/filelist.full & tmp/biggielist.txt _and_ tries to *
564 * restore them from start of tape, if available *
565 **************************************************************************/
566 assert(bkpinfo != NULL);
567 assert(mountlist != NULL);
568 assert(raidlist != NULL);
569
570 while (get_cfg_file_from_archive()) {
571 if (!ask_me_yes_or_no
572 ("Failed to find config file/archives. Choose another source?"))
573 {
574 fatal_error("Unable to find config file/archives. Aborting.");
575 }
576 interactively_obtain_media_parameters_from_user(FALSE);
577 }
578
579 read_cfg_file_into_bkpinfo(g_mondo_cfg_file);
580
581 /* edit_mountlist if wanted */
582 log_it("About to edit mountlist");
583 if (g_text_mode) {
584 save_mountlist_to_disk(mountlist, g_mountlist_fname);
585 sprintf(tmp, "%s %s", find_my_editor(), g_mountlist_fname);
586 res = system(tmp);
587 load_mountlist(mountlist, g_mountlist_fname);
588 } else {
589 res = edit_mountlist(g_mountlist_fname, mountlist, raidlist);
590 }
591 log_it("Finished editing mountlist");
592 if (res) {
593 paranoid_MR_finish(1);
594 }
595 save_mountlist_to_disk(mountlist, g_mountlist_fname);
596 save_raidlist_to_raidtab(raidlist, RAIDTAB_FNAME);
597
598 g_current_media_number = 1;
599 mvaddstr_and_log_it(1, 30, "Comparing Automatically");
600 log_it("Pre-MAD");
601 retval = mount_all_devices(mountlist, FALSE);
602 log_it("Post-MAD");
603 if (retval) {
604 unmount_all_devices(mountlist);
605 return (retval);
606 }
607 if (bkpinfo->backup_media_type == tape
608 || bkpinfo->backup_media_type == udev) {
609 retval += compare_to_tape();
610 } else if (bkpinfo->backup_media_type == cdstream) {
611 retval += compare_to_cdstream();
612 } else {
613 retval += compare_to_CD();
614 }
615 if (retval) {
616 mvaddstr_and_log_it(g_currentY++,
617 0,
618 "Warning - differences found during the compare phase");
619 }
620
621 if (count_lines_in_file(MONDO_CACHE"/changed.txt") > 0) {
622 mvaddstr_and_log_it(g_currentY++, 0,
623 "Differences found while files were being compared.");
624 streamline_changes_file(MONDO_CACHE"/changed.files", MONDO_CACHE"/changed.txt");
625 if (count_lines_in_file(MONDO_CACHE"/changed.files") <= 0) {
626 mvaddstr_and_log_it(g_currentY++, 0,
627 "...but they were logfiles and temporary files. Your archives are fine.");
628 log_to_screen
629 ("The differences were logfiles and temporary files. Your archives are fine.");
630 } else {
631 q = count_lines_in_file(MONDO_CACHE"/changed.files");
632 sprintf(tmp, "%ld significant difference%s found.", q,
633 (q != 1) ? "s" : "");
634 mvaddstr_and_log_it(g_currentY++, 0, tmp);
635 log_to_screen(tmp);
636
637 strcpy(tmp,
638 "Type 'less /tmp/changed.files' for a list of non-matching files");
639 mvaddstr_and_log_it(g_currentY++, 0, tmp);
640 log_to_screen(tmp);
641
642 log_msg(2, "calling popup_changelist_from_file()");
643 if (getcwd(cwd, MAX_STR_LEN - 1)) {
644 //FIXME
645 }
646 if (chdir(bkpinfo->restore_path)) {
647 // FIXME
648 }
649 if (getcwd(new, MAX_STR_LEN - 1)) {
650 //FIXME
651 }
652 popup_changelist_from_file(MONDO_CACHE"/changed.files");
653 if (chdir(cwd)) {
654 // FIXME
655 }
656 log_msg(2, "Returning from popup_changelist_from_file()");
657 }
658 } else {
659 log_to_screen
660 ("No significant differences were found. Your backup is perfect.");
661 }
662 retval += unmount_all_devices(mountlist);
663
664 kill_petris();
665 paranoid_free(tmp);
666 paranoid_free(new);
667 paranoid_free(cwd);
668 return (retval);
669}
670
671/**************************************************************************
672 *END_COMPARE_MODE *
673 **************************************************************************/
674
675/**
676 * Compare all data on a cdstream-based backup.
677 * @param bkpinfo The backup information structure. Fields used:
678 * - @c bkpinfo->disaster_recovery
679 * - @c bkpinfo->media_device
680 * - @c bkpinfo->restore_path
681 * @return 0 for success, nonzero for failure.
682 */
683int compare_to_cdstream()
684{
685 int res;
686
687 /** needs malloc **/
688 char *dir, *command;
689
690 assert(bkpinfo != NULL);
691 malloc_string(dir);
692 malloc_string(command);
693 if (getcwd(dir, MAX_STR_LEN)) {
694 // FIXME
695 }
696 if (chdir(bkpinfo->restore_path)) {
697 // FIXME
698 }
699
700 sprintf(command, "cp -f /tmp/LAST-FILELIST-NUMBER %s/tmp",
701 bkpinfo->restore_path);
702 run_program_and_log_output(command, FALSE);
703 mvaddstr_and_log_it(g_currentY,
704 0, "Verifying archives against filesystem");
705
706 if (bkpinfo->disaster_recovery
707 && does_file_exist("/tmp/CDROM-LIVES-HERE")) {
708 strcpy(bkpinfo->media_device,
709 last_line_of_file("/tmp/CDROM-LIVES-HERE"));
710 } else {
711 find_cdrom_device(bkpinfo->media_device, FALSE);
712 }
713 res = verify_tape_backups();
714 if (chdir(dir)) {
715 // FIXME
716 }
717 if (length_of_file(MONDO_CACHE"/changed.txt") > 2
718 && length_of_file(MONDO_CACHE"/changed.files") > 2) {
719 log_msg(0,
720 "Type 'less "MONDO_CACHE"/changed.files' to see which files don't match the archives");
721 log_msg(2, "Calling popup_changelist_from_file()");
722 popup_changelist_from_file(MONDO_CACHE"/changed.files");
723 log_msg(2, "Returned from popup_changelist_from_file()");
724 }
725
726 mvaddstr_and_log_it(g_currentY++, 74, "Done.");
727 paranoid_free(dir);
728 paranoid_free(command);
729 return (res);
730}
731
732/**************************************************************************
733 *END_COMPARE_CD_STREAM *
734 **************************************************************************/
735
736
737/**
738 * Compare all data on a tape-based backup.
739 * @param bkpinfo The backup information structure. Field used: @c bkpinfo->restore_path.
740 * @return 0 for success, nonzero for failure.
741 */
742/**************************************************************************
743 * F@COMPARE_TO_TAPE() *
744 * compare_to_tape() - gots me?? *
745 * *
746 * returns: int *
747 **************************************************************************/
748int compare_to_tape()
749{
750 int res;
751 char *dir, *command;
752
753 assert(bkpinfo != NULL);
754 malloc_string(dir);
755 malloc_string(command);
756
757 if (getcwd(dir, MAX_STR_LEN)) {
758 // FIXME
759 }
760 if (chdir(bkpinfo->restore_path)) {
761 // FIXME
762 }
763 sprintf(command, "cp -f /tmp/LAST-FILELIST-NUMBER %s/tmp",
764 bkpinfo->restore_path);
765 run_program_and_log_output(command, FALSE);
766 mvaddstr_and_log_it(g_currentY,
767 0, "Verifying archives against filesystem");
768 res = verify_tape_backups();
769 if (chdir(dir)) {
770 // FIXME
771 }
772 if (res) {
773 mvaddstr_and_log_it(g_currentY++, 74, "Failed.");
774 } else {
775 mvaddstr_and_log_it(g_currentY++, 74, "Done.");
776 }
777 paranoid_free(dir);
778 paranoid_free(command);
779 return (res);
780}
781
782/**************************************************************************
783 *END_COMPARE_TO_TAPE *
784 **************************************************************************/
785
786/* @} - end compareGroup */
Note: See TracBrowser for help on using the repository browser.