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

Last change on this file since 2405 was 2405, checked in by bruno, 10 years ago

Removes some malloc_string static allocation

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