source: MondoRescue/branches/3.2/mondo/src/mondorestore/mondo-rstr-compare.c

Last change on this file was 3613, checked in by Bruno Cornec, 7 years ago

Add function mr_getcwd and use it to allow use o dynamically allocated memory
instead of getcwd

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