source: MondoRescue/trunk/mondo/mondo/mondorestore/mondo-rstr-compare.c@ 729

Last change on this file since 729 was 689, checked in by bcornec, 18 years ago

Still other memory management improvements ( I hope :-)

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