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

Last change on this file was 3193, checked in by Bruno Cornec, 11 years ago
  • Finish with backports from 3.1 for now. Still some work to do, but we will now make that version compile and work again and serve as a base

so the gettext patch can be added

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