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

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

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

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