source: MondoRescue/branches/3.1/mondo/src/mondorestore/mondo-rstr-compare.c@ 3154

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