source: MondoRescue/branches/3.3/mondo/src/common/libmondo-verify.c

Last change on this file was 3892, checked in by Bruno Cornec, 3 months ago

More compiler fixes

  • Fix unused vars
  • Fix FreeBSD #if alone
  • Use MDSTAT_FILE everywhere
  • Fix missing break
  • Fix some strncpy. mr_strncpy used when safe
  • Fix wrong g_isoform_header_str proto !
  • find-cd & find-dvd => find-optical
  • Property svn:keywords set to Id
File size: 35.6 KB
RevLine 
[1]1/***************************************************************************
[2211]2$Id: libmondo-verify.c 3892 2024-03-12 02:10:24Z bruno $
[1]3***************************************************************************/
4
5
6/**
7 * @file
8 * Functions for verifying backups (booted from hard drive, not CD).
9 */
10
11#include "my-stuff.h"
[2211]12#include "mr_mem.h"
[1]13#include "mondostructures.h"
[541]14#include "libmondo-gui-EXT.h"
[1]15#include "libmondo-files-EXT.h"
16#include "libmondo-fork-EXT.h"
17#include "libmondo-stream-EXT.h"
18#include "libmondo-string-EXT.h"
19#include "libmondo-devices-EXT.h"
20#include "libmondo-tools-EXT.h"
[3877]21#include "libmondo-filelist-EXT.h"
[1]22
[3871]23
[1]24/*@unused@*/
[117]25//static char cvsid[] = "$Id: libmondo-verify.c 3892 2024-03-12 02:10:24Z bruno $";
[1]26
27/**
28 * The number of the most recently verified afioball.
29 * @ingroup globalGroup
30 */
31int g_last_afioball_number = -1;
32
[948]33extern char *g_getfacl;
34extern char *g_getfattr;
[1316]35extern char *MONDO_LOGFILE;
[3877]36extern int g_current_media_number;
37extern long g_current_progress;
[1]38
[1645]39/* Reference to global bkpinfo */
40extern struct s_bkpinfo *bkpinfo;
41
[1648]42
[1]43/**
[1648]44 * Generate the filename of a tarball to verify.
45 * @param bkpinfo The backup information structure. @c bkpinfo->zip_suffix is the only field used.
46 * @param mountpoint The directory where the CD/DVD/ISO is mounted.
47 * @param setno The afioball number to get the location of.
48 * @return The absolute path to the afioball.
49 * @note The returned string points to static data that will be overwritten with each call.
50 * @ingroup stringGroup
51 */
52char *vfy_tball_fname(char *mountpoint, int setno)
53{
54 /*@ buffers ******************************************************* */
55 static char output[MAX_STR_LEN];
56
57 assert(bkpinfo != NULL);
58 assert_string_is_neither_NULL_nor_zerolength(mountpoint);
[3191]59 sprintf(output, "%s/archives/%d.star.%s", mountpoint, setno, bkpinfo->zip_suffix);
[1648]60 if (!does_file_exist(output)) {
[3191]61 sprintf(output, "%s/archives/%d.afio.%s", mountpoint, setno, bkpinfo->zip_suffix);
[1648]62 }
63 return (output);
64}
65
66
67/**
[1]68 * Generate a list of the files that have changed, based on @c afio @c -r
69 * messages.
70 * @param changedfiles_fname Filename of the place to put a list of afio's reported changed.
71 * @param ignorefiles_fname Filename of a list of files to ignore (use "" if none).
72 * @param stderr_fname File containing afio's stderr output.
73 * @return The number of differences found (0 for a perfect backup).
74 * @bug This function seems orphaned.
75 * @ingroup utilityGroup
76 */
77long
[128]78generate_list_of_changed_files(char *changedfiles_fname,
79 char *ignorefiles_fname, char *stderr_fname)
[1]80{
[128]81 /*@ buffer ********************************************************** */
[3191]82 char *command = NULL;
83 char *afio_found_changes = NULL;
[1]84
[128]85 /*@ int ************************************************************* */
86 int res = 0;
[1]87
[128]88 /*@ long ************************************************************ */
89 long afio_diffs = 0;
[1]90
[128]91 assert_string_is_neither_NULL_nor_zerolength(changedfiles_fname);
92 assert_string_is_neither_NULL_nor_zerolength(ignorefiles_fname);
93 assert_string_is_neither_NULL_nor_zerolength(stderr_fname);
[1]94
[3191]95 mr_asprintf(afio_found_changes, "%s.afio", ignorefiles_fname);
96 sync();
[128]97
98 log_msg(1, "Now scanning log file for 'afio: ' stuff");
[3191]99 mr_asprintf(command, "grep \"afio: \" %s | sed 's/afio: //' | grep -vE '^/dev/.*$' >> %s", stderr_fname, afio_found_changes);
[128]100 log_msg(2, command);
101 res = system(command);
[3191]102 mr_free(command);
103
[128]104 if (res) {
105 log_msg(2, "Warning - failed to think");
106 }
107
108 log_msg(1, "Now scanning log file for 'star: ' stuff");
[3191]109 mr_asprintf(command, "grep \"star: \" %s | sed 's/star: //' | grep -vE '^/dev/.*$' >> %s", stderr_fname, afio_found_changes);
[128]110 log_msg(2, command);
111 res = system(command);
[3191]112 mr_free(command);
113
[128]114 if (res) {
115 log_msg(2, "Warning - failed to think");
116 }
117 afio_diffs = count_lines_in_file(afio_found_changes);
[3191]118 mr_asprintf(command, "sort %s %s %s | uniq -c | awk '{ if ($1==\"2\") {print $2;};}' | grep -v \"incheckentry xwait()\" > %s", ignorefiles_fname, afio_found_changes, afio_found_changes, changedfiles_fname);
119 mr_free(afio_found_changes);
[128]120 log_msg(2, command);
121 paranoid_system(command);
[3191]122 mr_free(command);
[128]123 return (afio_diffs);
[1]124}
125
126
127
128
129
130/**
131 * Verify one afioball from the CD.
132 * You should be changed to the root directory (/) for this to work.
133 * @param bkpinfo The backup information structure. Fields used:
134 * - @c bkpinfo->use_lzo
135 * - @c bkpinfo->tmpdir
136 * - @c bkpinfo->zip_exe
137 * - @c bkpinfo->zip_suffix
138 * @param tarball_fname The filename of the afioball to verify.
139 * @return 0, always.
140 */
[1645]141int verify_a_tarball(char *tarball_fname)
[1]142{
[128]143 /*@ buffers ********************************************************* */
[3191]144 char *command = NULL;
145 char *outlog = NULL;
146 char *tmp = NULL;
[1]147
[128]148 /*@ pointers ******************************************************* */
149 FILE *pin;
[1]150
[128]151 /*@ long *********************************************************** */
152 long diffs = 0;
[1]153
[128]154 assert(bkpinfo != NULL);
155 assert_string_is_neither_NULL_nor_zerolength(tarball_fname);
[1]156
[128]157 log_it("Verifying fileset '%s'", tarball_fname);
[3191]158 mr_asprintf(outlog, "%s/afio.log", bkpinfo->tmpdir);
159 /* if programmer forgot to say which compression thingy to use then find out */
160 if (strstr(tarball_fname, ".lzo") && strcmp(bkpinfo->zip_suffix, "lzo")) {
[128]161 log_msg(2, "OK, I'm going to start using lzop.");
[3830]162 mr_free(bkpinfo->zip_exe);
163 mr_free(bkpinfo->zip_suffix);
164 mr_asprintf(bkpinfo->zip_exe, "%s", "lzop");
165 mr_asprintf(bkpinfo->zip_suffix, "%s", "lzo");
[128]166 bkpinfo->use_lzo = TRUE;
[998]167 bkpinfo->use_gzip = FALSE;
[3191]168 bkpinfo->use_lzma = FALSE;
[128]169 }
[3191]170 if (strstr(tarball_fname, ".gz") && strcmp(bkpinfo->zip_suffix, "gz")) {
[998]171 log_msg(2, "OK, I'm going to start using gzip.");
[3830]172 mr_free(bkpinfo->zip_exe);
173 mr_free(bkpinfo->zip_suffix);
174 mr_asprintf(bkpinfo->zip_exe, "%s", "gzip");
175 mr_asprintf(bkpinfo->zip_suffix, "%s", "gz");
[998]176 bkpinfo->use_lzo = FALSE;
177 bkpinfo->use_gzip = TRUE;
[3191]178 bkpinfo->use_lzma = FALSE;
[998]179 }
[3191]180 if (strstr(tarball_fname, ".bz2") && strcmp(bkpinfo->zip_suffix, "bz2")) {
[128]181 log_msg(2, "OK, I'm going to start using bzip2.");
[3830]182 mr_free(bkpinfo->zip_exe);
183 mr_free(bkpinfo->zip_suffix);
184 mr_asprintf(bkpinfo->zip_exe, "%s", "bzip2");
185 mr_asprintf(bkpinfo->zip_suffix, "%s", "bz2");
[128]186 bkpinfo->use_lzo = FALSE;
[998]187 bkpinfo->use_gzip = FALSE;
[3191]188 bkpinfo->use_lzma = FALSE;
[128]189 }
[3830]190 if (strstr(tarball_fname, ".xz") && strcmp(bkpinfo->zip_suffix, "xz")) {
[3191]191 log_msg(2, "OK, I'm going to start using lzma.");
[3830]192 mr_free(bkpinfo->zip_exe);
193 mr_free(bkpinfo->zip_suffix);
194 mr_asprintf(bkpinfo->zip_exe, "%s", "xz");
195 mr_asprintf(bkpinfo->zip_suffix, "%s", "xz");
[3191]196 bkpinfo->use_lzo = FALSE;
197 bkpinfo->use_gzip = FALSE;
198 bkpinfo->use_lzma = TRUE;
199 }
[3830]200 // As suffix is used even when no compression make it non-NULL
[3191]201 if (bkpinfo->zip_suffix == NULL) {
[3830]202 mr_asprintf(bkpinfo->zip_suffix, "%s", "");
[3191]203 }
[128]204 unlink(outlog);
205 if (strstr(tarball_fname, ".star")) {
206 bkpinfo->use_star = TRUE;
207 if (strstr(tarball_fname, ".bz2"))
[3191]208 mr_asprintf(command, "star -sparse -diff diffopts=mode,size,data file=%s %s >> %s 2>> %s", tarball_fname, (strstr(tarball_fname, ".bz2")) ? "-bz" : " ", outlog, outlog);
[128]209 } else {
210 bkpinfo->use_star = FALSE;
[3191]211 /* Here we suppose that there is always a compression program called */
212 if (bkpinfo->zip_exe) {
213 mr_asprintf(command, "afio -r -P %s -Z %s >> %s 2>> %s", bkpinfo->zip_exe, tarball_fname, outlog, outlog);
214 } else {
215 mr_asprintf(command, "afio -r -Z %s >> %s 2>> %s", tarball_fname, outlog, outlog);
216 }
[128]217 }
218 log_msg(6, "command=%s", command);
219 paranoid_system(command);
[3191]220 mr_free(command);
221
[128]222 if (length_of_file(outlog) < 10) {
[3191]223 mr_asprintf(command, "cat %s >> %s", outlog, MONDO_LOGFILE);
[128]224 } else {
[3191]225 mr_asprintf(command, "cut -d: -f%d %s | sort -u", (bkpinfo->use_star) ? 1 : 2, outlog);
[128]226 pin = popen(command, "r");
227 if (pin) {
[3191]228 for (mr_getline(tmp, pin); !feof(pin); mr_getline(tmp, pin)) {
[128]229 if (bkpinfo->use_star) {
230 if (!strstr(tmp, "diffopts=")) {
[3191]231 while (strlen(tmp) > 0 && tmp[strlen(tmp) - 1] < 32) {
[128]232 tmp[strlen(tmp) - 1] = '\0';
233 }
234 if (strchr(tmp, '/')) {
235 if (!diffs) {
[3191]236 log_msg(0, "'%s' - differences found", tarball_fname);
[128]237 }
[3191]238 log_msg(0, "star: /%s", strip_afio_output_line(tmp));
[128]239 diffs++;
240 }
241 }
242 } else {
243 if (!diffs) {
[3191]244 log_msg(0, "'%s' - differences found", tarball_fname);
[128]245 }
246 log_msg(0, "afio: /%s", strip_afio_output_line(tmp));
247 diffs++;
248 }
[3191]249 mr_free(tmp);
[1]250 }
[3191]251 mr_free(tmp);
[128]252 paranoid_pclose(pin);
253 } else {
254 log_OS_error(command);
255 }
256 }
[3191]257 mr_free(command);
258 mr_free(outlog);
[128]259 return (0);
[1]260}
261
262
263
264
265
266/**
267 * Verify one afioball from the CD.
268 * Checks for existence (calls fatal_error() if it does not exist) and
269 * then calls verify_an_afioball().
270 * @param bkpinfo The backup information structure. Passed to verify_an_afioball().
271 * @param tarball_fname The filename of the afioball to verify.
272 * @return The return value of verify_an_afioball().
273 * @see verify_an_afioball
274 */
275int
[1645]276verify_an_afioball_from_CD(char *tarball_fname)
[1]277{
278
[128]279 /*@ int ************************************************************* */
280 int res = 0;
[1]281
[128]282 assert_string_is_neither_NULL_nor_zerolength(tarball_fname);
[1]283
[128]284 log_msg(1, "Verifying %s", tarball_fname);
285 if (!does_file_exist(tarball_fname)) {
286 fatal_error("Cannot verify nonexistent afioball");
287 }
[1645]288 res = verify_a_tarball(tarball_fname);
[128]289 return (res);
[1]290}
291
292
293/**
294 * Verify one afioball from the opened tape/CD stream.
295 * Copies the file from tape to tmpdir and then calls verify_an_afioball().
296 * @param bkpinfo The backup information structure. Passed to verify_an_afioball().
297 * @param orig_fname The original filename of the afioball to verify.
298 * @param size The size of the afioball to verify.
299 * @return The return value of verify_an_afioball().
300 * @see verify_an_afioball
301 */
302int
[1645]303verify_an_afioball_from_stream(char *orig_fname, long long size)
[1]304{
305
[128]306 /*@ int ************************************************************** */
307 int retval = 0;
[1]308 int res = 0;
309
[128]310 /*@ buffers ********************************************************** */
[3191]311 char *tmp = NULL;
312 char *tarball_fname = NULL;
[1]313
[128]314 /*@ pointers ********************************************************* */
315 char *p;
[1]316
[128]317 assert(bkpinfo != NULL);
318 assert_string_is_neither_NULL_nor_zerolength(orig_fname);
[1]319
[128]320 p = strrchr(orig_fname, '/');
321 if (!p) {
322 p = orig_fname;
323 } else {
324 p++;
325 }
[3191]326 mr_asprintf(tmp, "mkdir -p %s/tmpfs", bkpinfo->tmpdir);
[128]327 paranoid_system(tmp);
[3191]328 mr_free(tmp);
329
330 mr_asprintf(tarball_fname, "%s/tmpfs/temporary-%s", bkpinfo->tmpdir, p);
[1645]331 read_file_from_stream_to_file(tarball_fname, size);
332 res = verify_a_tarball(tarball_fname);
[128]333 if (res) {
[3191]334 log_msg(0, "Afioball '%s' no longer matches your live filesystem", p);
[128]335 retval++;
336 }
337 unlink(tarball_fname);
[3191]338 mr_free(tarball_fname);
[128]339 return (retval);
[1]340}
341
342
343/**
344 * Verify one biggiefile form the opened tape/CD stream.
345 * @param bkpinfo The backup information structure. @c bkpinfo->tmpdir is the only field used.
346 * @param biggie_fname The filename of the biggiefile to verify.
[3892]347 * @param size The size in bytes of said biggiefile. TODO: Removed as not used. Is it linked to slice_siz ?
[1]348 * @return 0 for success (even if the file doesn't match); nonzero for a tape error.
349 */
350int
[3892]351verify_a_biggiefile_from_stream(char *biggie_fname)
[1]352{
353
[128]354 /*@ int ************************************************************* */
355 int retval = 0;
[1]356 int res = 0;
357 int current_slice_number = 0;
358 int ctrl_chr = '\0';
359
[128]360 /*@ char ************************************************************ */
[3191]361 char *test_file = NULL;
362 char *biggie_cksum = NULL;
363 char *orig_cksum = NULL;
364 char *tmp = NULL;
365 char *slice_fnam = NULL;
[128]366
367 /*@ pointers ******************************************************** */
[1]368 char *p;
369
[128]370 /*@ long long ******************************************************* */
371 long long slice_siz;
[1]372
[128]373 malloc_string(slice_fnam);
374 assert(bkpinfo != NULL);
375 assert_string_is_neither_NULL_nor_zerolength(biggie_fname);
[1]376
[128]377 p = strrchr(biggie_fname, '/');
378 if (!p) {
379 p = biggie_fname;
380 } else {
381 p++;
382 }
[3191]383 mr_asprintf(test_file, "%s/temporary-%s", bkpinfo->tmpdir, p);
[128]384 for (res =
385 read_header_block_from_stream(&slice_siz, slice_fnam, &ctrl_chr);
386 ctrl_chr != BLK_STOP_A_BIGGIE;
387 res =
[3191]388 read_header_block_from_stream(&slice_siz, slice_fnam, &ctrl_chr)) {
[128]389 if (ctrl_chr != BLK_START_AN_AFIO_OR_SLICE) {
390 wrong_marker(BLK_START_AN_AFIO_OR_SLICE, ctrl_chr);
391 }
[1645]392 res = read_file_from_stream_to_file(test_file, slice_siz);
[128]393 unlink(test_file);
394 res =
[3191]395 read_header_block_from_stream(&slice_siz, slice_fnam, &ctrl_chr);
[128]396 if (ctrl_chr != BLK_STOP_AN_AFIO_OR_SLICE) {
397 log_msg(2, "test_file = %s", test_file);
398 wrong_marker(BLK_STOP_AN_AFIO_OR_SLICE, ctrl_chr);
399 }
400 current_slice_number++;
401 retval += res;
[1]402 }
[3191]403 mr_asprintf(biggie_cksum, "%s", slice_fnam);
[128]404 if (biggie_cksum[0] != '\0') {
[3191]405 mr_asprintf(orig_cksum, "%s", calc_checksum_of_file(biggie_fname));
[128]406 if (strcmp(biggie_cksum, orig_cksum)) {
[3191]407 log_msg(2, "orig cksum=%s; curr cksum=%s", biggie_cksum, orig_cksum);
408 log_to_screen("%s has changed on live filesystem", biggie_fname);
409
410 mr_asprintf(tmp, "echo \"%s\" >> %s/biggies.changed", biggie_fname, bkpinfo->tmpdir);
[3060]411 paranoid_system(tmp);
[3191]412 mr_free(tmp);
[128]413 }
[3191]414 mr_free(orig_cksum);
[1]415 }
[3191]416 mr_free(biggie_cksum);
417 mr_free(test_file);
[128]418 paranoid_free(slice_fnam);
419 return (retval);
[1]420}
421
422
423/**
424 * Verify all afioballs from the opened tape/CD stream.
425 * @param bkpinfo The backup information structure. Fields used:
426 * - @c bkpinfo->tmpdir
427 *
428 * @return 0 for success (even if there are differences); nonzero for a tape error.
429 */
[1645]430int verify_afioballs_from_stream()
[1]431{
[128]432 /*@ int ********************************************************** */
433 int retval = 0;
[1]434 int res = 0;
435 long current_afioball_number = 0;
436 int ctrl_chr = 0;
437 int total_afioballs = 0;
438
[128]439 /*@ buffers ***************************************************** */
[3191]440 char *tmp = NULL;
[1]441 char *fname;
[128]442 char *curr_xattr_list_fname;
443 char *curr_acl_list_fname;
[1]444
[128]445 /*@ long long *************************************************** */
446 long long size = 0;
[1]447
[128]448 assert(bkpinfo != NULL);
449 malloc_string(fname);
450 malloc_string(curr_xattr_list_fname);
451 malloc_string(curr_acl_list_fname);
[1]452
[948]453 if (g_getfattr) {
454 sprintf(curr_xattr_list_fname, XATTR_BIGGLST_FNAME_RAW_SZ,
[128]455 bkpinfo->tmpdir);
[948]456 }
457 if (g_getfacl) {
458 sprintf(curr_acl_list_fname, ACL_BIGGLST_FNAME_RAW_SZ,
[128]459 bkpinfo->tmpdir);
[948]460 }
[541]461 log_to_screen("Verifying regular archives on tape");
[1645]462 total_afioballs = get_last_filelist_number() + 1;
[541]463 open_progress_form("Verifying filesystem",
464 "I am verifying archives against your live filesystem now.",
465 "Please wait. This may take a couple of hours.", "",
[128]466 total_afioballs);
467 res = read_header_block_from_stream(&size, fname, &ctrl_chr);
468 if (ctrl_chr != BLK_START_AFIOBALLS) {
[2230]469 log_it("YOU SHOULD NOT GET HERE");
470 log_it("Grabbing the EXAT files");
[128]471 if (ctrl_chr == BLK_START_EXTENDED_ATTRIBUTES) {
[3116]472 res = read_EXAT_files_from_tape(&size, fname, &ctrl_chr,
[128]473 curr_xattr_list_fname,
474 curr_acl_list_fname);
475 }
[1]476 }
[128]477 if (ctrl_chr != BLK_START_AFIOBALLS) {
478 wrong_marker(BLK_START_AFIOBALLS, ctrl_chr);
[1]479 }
[128]480
481 for (res = read_header_block_from_stream(&size, fname, &ctrl_chr);
482 ctrl_chr != BLK_STOP_AFIOBALLS;
483 res = read_header_block_from_stream(&size, fname, &ctrl_chr)) {
[948]484 if (g_getfattr) {
485 sprintf(curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ,
[128]486 bkpinfo->tmpdir, current_afioball_number);
[948]487 }
488 if (g_getfacl) {
489 sprintf(curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ,
[128]490 bkpinfo->tmpdir, current_afioball_number);
[948]491 }
[128]492 if (ctrl_chr == BLK_START_EXTENDED_ATTRIBUTES) {
[2230]493 log_it("Reading EXAT files from tape");
[3116]494 res = read_EXAT_files_from_tape(&size, fname, &ctrl_chr,
[128]495 curr_xattr_list_fname,
496 curr_acl_list_fname);
497 }
498 if (ctrl_chr != BLK_START_AN_AFIO_OR_SLICE) {
499 wrong_marker(BLK_START_AN_AFIO_OR_SLICE, ctrl_chr);
500 }
[3191]501 mr_asprintf(tmp, "Verifying fileset #%ld", current_afioball_number);
[128]502 update_progress_form(tmp);
[3191]503 mr_free(tmp);
504
[1645]505 res = verify_an_afioball_from_stream(fname, size);
[128]506 if (res) {
[3191]507 log_to_screen("Afioball %ld differs from live filesystem", current_afioball_number);
[128]508 }
509 retval += res;
510 current_afioball_number++;
511 g_current_progress++;
512 res = read_header_block_from_stream(&size, fname, &ctrl_chr);
513 if (ctrl_chr != BLK_STOP_AN_AFIO_OR_SLICE) {
514 wrong_marker(BLK_STOP_AN_AFIO_OR_SLICE, ctrl_chr);
515 }
[1]516 }
[128]517 log_msg(1, "All done with afioballs");
518 close_progress_form();
519 paranoid_free(fname);
520 paranoid_free(curr_xattr_list_fname);
521 paranoid_free(curr_acl_list_fname);
522 return (retval);
[1]523}
524
525/**
526 * Verify all biggiefiles on the opened CD/tape stream.
527 * @param bkpinfo The backup information structure. Fields used:
528 * - @c bkpinfo->restore_path
529 * - @c bkpinfo->tmpdir
530 *
531 * @return 0 for success (even if there are differences); nonzero for a tape error.
532 */
[1645]533int verify_biggiefiles_from_stream()
[1]534{
535
[128]536 /*@ int ************************************************************ */
537 int retval = 0;
[1]538 int res = 0;
539 int ctrl_chr = 0;
540
[128]541 /*@ long *********************************************************** */
542 long noof_biggiefiles = 0;
[1]543 long current_biggiefile_number = 0;
544
[128]545 /*@ buffers ******************************************************** */
[3191]546 char *orig_fname;
547 char *logical_fname = NULL;
548 char *comment = NULL;
549 char *curr_xattr_list_fname = NULL;
550 char *curr_acl_list_fname = NULL;
[128]551 /*@ pointers ******************************************************* */
[1]552 char *p;
553
[128]554 /*@ long long size ************************************************* */
555 long long size = 0;
[1]556
[128]557 assert(bkpinfo != NULL);
558 malloc_string(orig_fname);
559 malloc_string(curr_xattr_list_fname);
560 malloc_string(curr_acl_list_fname);
[1]561
[948]562 if (g_getfattr) {
563 sprintf(curr_xattr_list_fname, XATTR_BIGGLST_FNAME_RAW_SZ,
[128]564 bkpinfo->tmpdir);
[948]565 }
566 if (g_getfacl) {
567 sprintf(curr_acl_list_fname, ACL_BIGGLST_FNAME_RAW_SZ,
[128]568 bkpinfo->tmpdir);
[948]569 }
[3191]570 mr_asprintf(comment, "Verifying all bigfiles.");
[128]571 log_to_screen(comment);
572 res = read_header_block_from_stream(&size, orig_fname, &ctrl_chr);
573 if (ctrl_chr != BLK_START_BIGGIEFILES) {
574 if (ctrl_chr == BLK_START_EXTENDED_ATTRIBUTES) {
[2230]575 log_it("Grabbing the EXAT biggiefiles");
[3116]576 res = read_EXAT_files_from_tape(&size, orig_fname,
[128]577 &ctrl_chr, curr_xattr_list_fname,
578 curr_acl_list_fname);
579 }
[1]580 }
[128]581 if (ctrl_chr != BLK_START_BIGGIEFILES) {
582 wrong_marker(BLK_START_BIGGIEFILES, ctrl_chr);
[1]583 }
[128]584 noof_biggiefiles = (long) size;
585 log_msg(1, "noof_biggiefiles = %ld", noof_biggiefiles);
[541]586 open_progress_form("Verifying big files", comment,
587 "Please wait. This may take some time.", "",
[128]588 noof_biggiefiles);
[3191]589 mr_free(comment);
590
[128]591 for (res = read_header_block_from_stream(&size, orig_fname, &ctrl_chr);
592 ctrl_chr != BLK_STOP_BIGGIEFILES;
593 res = read_header_block_from_stream(&size, orig_fname, &ctrl_chr))
[1]594 {
[128]595 if (ctrl_chr != BLK_START_A_NORMBIGGIE
596 && ctrl_chr != BLK_START_A_PIHBIGGIE) {
597 wrong_marker(BLK_START_A_NORMBIGGIE, ctrl_chr);
598 }
599 p = strrchr(orig_fname, '/');
600 if (!p) {
601 p = orig_fname;
602 } else {
603 p++;
604 }
[3191]605 mr_asprintf(comment, "Verifying bigfile #%ld (%ld K)", current_biggiefile_number, (long) size >> 10);
[128]606 update_progress_form(comment);
[3191]607 mr_free(comment);
608
[3828]609 if (bkpinfo->restore_path != NULL) {
[3191]610 mr_asprintf(logical_fname, "%s/%s", bkpinfo->restore_path, orig_fname);
[3892]611 res = verify_a_biggiefile_from_stream(logical_fname);
[3191]612 mr_free(logical_fname);
613 retval += res;
614 } else {
615 log_it("Unable to verify bigfile as restore_path is NULL");
616 }
617
[128]618 current_biggiefile_number++;
619 g_current_progress++;
[1]620 }
[128]621 close_progress_form();
622 paranoid_free(orig_fname);
623 paranoid_free(curr_xattr_list_fname);
624 paranoid_free(curr_acl_list_fname);
625 return (retval);
[1]626}
627
[3878]628
629/**
630 * @addtogroup LLverifyGroup
631 * @{
632 */
633/**
634 * Verify all afioballs stored on the inserted CD (or an ISO image).
635 * @param bkpinfo The backup information structure. @c bkpinfo->backup_media_type
636 * is used in this function, and the structure is also passed to verify_an_afioball_from_CD().
637 * @param mountpoint The location the CD/DVD/ISO is mounted on.
638 * @return The number of sets containing differences (0 for success).
639 */
640int verify_afioballs_on_CD(char *mountpoint)
641{
642
643 /*@ buffers ********************************************************* */
644 char *tmp = NULL;
645 char *mds = NULL;
646
647 /*@ int ************************************************************* */
648 int set_number = 0;
649 int retval = 0;
650 int total_sets = 0;
651 int percentage = 0;
652
653 assert_string_is_neither_NULL_nor_zerolength(mountpoint);
654 assert(bkpinfo != NULL);
655
656 for (set_number = 0;
657 set_number < 9999
658 &&
659 !does_file_exist(vfy_tball_fname(mountpoint, set_number));
660 set_number++);
661 if (!does_file_exist(vfy_tball_fname(mountpoint, set_number))) {
662 return (0);
663 }
664
665 if (g_last_afioball_number != set_number - 1) {
666 if (set_number == 0) {
667 log_msg(1, "Weird error in verify_afioballs_on_CD() but it's really a cosmetic error, nothing more");
668 } else {
669 retval++;
670 log_to_screen("Warning - missing set(s) between %d and %d\n", g_last_afioball_number, set_number - 1);
671 }
672 }
673 mds = media_descriptor_string(bkpinfo->backup_media_type);
674 mr_asprintf(tmp, "Verifying %s #%d's tarballs", mds, g_current_media_number);
675 mr_free(mds);
676
677 open_evalcall_form(tmp);
678 mr_free(tmp);
679
680 for (total_sets = set_number;
681 does_file_exist(vfy_tball_fname(mountpoint, total_sets));
682 total_sets++) {
683 log_msg(1, "total_sets = %d", total_sets);
684 }
685 for (;
686 does_file_exist(vfy_tball_fname(mountpoint, set_number));
687 set_number++) {
688 percentage =
689 (set_number - g_last_afioball_number) * 100 / (total_sets -
690 g_last_afioball_number);
691 update_evalcall_form(percentage);
692 log_msg(1, "set = %d", set_number);
693 retval +=
694 verify_an_afioball_from_CD(vfy_tball_fname(mountpoint, set_number));
695 }
696 g_last_afioball_number = set_number - 1;
697 close_evalcall_form();
698 return (retval);
699}
700
701/**
702 * Verify all slices stored on the inserted CD (or a mounted ISO image).
703 * @param bkpinfo The backup information structure. Fields used:
704 * - @c compression_level
705 * - @c restore_path
706 * - @c use_lzo
707 * - @c zip_exe
708 * - @c zip_suffix
709 * @param mtpt The mountpoint the CD/DVD/ISO is mounted on.
710 * @return The number of differences (0 for perfect biggiefiles).
711 */
712int verify_all_slices_on_CD(char *mtpt)
713{
714
715 /*@ buffer ********************************************************** */
716 char *tmp = NULL;
717 char *mountpoint = NULL;
718 char *command = NULL;
719 char *mds = NULL;
720 char *sz_exe = NULL;
721 static char *bufblkA = NULL;
722 static char *bufblkB = NULL;
723 const long maxbufsize = 65536L;
724 long currsizA = 0;
725 long currsizB = 0;
726 long j;
727
728 /*@ long ************************************************************ */
729 long bigfile_num = 0;
730 long slice_num = -1;
731 int res;
732
733 static FILE *forig = NULL;
734 static struct s_filename_and_lstat_info biggiestruct;
735 static long last_bigfile_num = -1;
736 static long last_slice_num = -1;
737 FILE *pin;
738 FILE *fin;
739 int retval = 0;
740
741 if (!bufblkA) {
742 if (!(bufblkA = malloc(maxbufsize))) {
743 fatal_error("Cannot malloc bufblkA");
744 }
745 }
746 if (!bufblkB) {
747 if (!(bufblkB = malloc(maxbufsize))) {
748 fatal_error("Cannot malloc bufblkB");
749 }
750 }
751
752 assert(bkpinfo != NULL);
753 assert_string_is_neither_NULL_nor_zerolength(mtpt);
754
755 if (bkpinfo->compression_level > 0) {
756 if (bkpinfo->use_lzo) {
757 mr_asprintf(sz_exe, "lzop");
758 } else if (bkpinfo->use_gzip) {
759 mr_asprintf(sz_exe, "gzip");
760 } else if (bkpinfo->use_lzma) {
761 mr_asprintf(sz_exe, "lzma");
762 } else {
763 mr_asprintf(sz_exe, "bzip2");
764 }
765 }
766
767 log_it("before vsbf");
768 mds = media_descriptor_string(bkpinfo->backup_media_type);
769 mr_asprintf(tmp, "Verifying %s#%d's big files", mds, g_current_media_number);
770 mr_free(mds);
771
772 open_evalcall_form(tmp);
773 mr_free(tmp);
774
775 log_it("after vsbf");
776 mr_asprintf(mountpoint, "%s/archives", mtpt);
777 if (last_bigfile_num == -1) {
778 bigfile_num = 0;
779 slice_num = 0;
780 } else if (slice_num == 0) {
781 bigfile_num = last_bigfile_num + 1;
782 slice_num = 0;
783 } else {
784 bigfile_num = last_bigfile_num;
785 slice_num = last_slice_num + 1;
786 }
787 while (does_file_exist(slice_fname(bigfile_num, slice_num, mountpoint, bkpinfo->zip_suffix))) {
788 // handle slices until end of CD
789 if (slice_num == 0) {
790 log_msg(2, "ISO=%d bigfile=%ld --START--", g_current_media_number, bigfile_num);
791 if (! (fin = fopen(slice_fname(bigfile_num, slice_num, mountpoint, ""), "r"))) {
792 log_msg(2, "Cannot open bigfile's info file");
793 } else {
794 if (fread ((void *) &biggiestruct, 1, sizeof(biggiestruct), fin) < sizeof(biggiestruct)) {
795 log_msg(2, "Unable to get biggiestruct");
796 }
797 paranoid_fclose(fin);
798 }
799 if (bkpinfo->restore_path != NULL) {
800 mr_asprintf(tmp, "%s/%s", bkpinfo->restore_path, biggiestruct.filename);
801 log_msg(2, "Opening biggiefile #%ld - '%s'", bigfile_num, tmp);
802 forig = fopen(tmp, "r");
803 mr_free(tmp);
804
805 if (!forig) {
806 log_msg(2, "Failed to open bigfile. Darn.");
807 log_to_screen("%s/%s not found on live filesystem", bkpinfo->restore_path, biggiestruct.filename);
808 mr_asprintf(tmp, "echo \"%s/%s not found\" >> %s/biggies.changed", bkpinfo->restore_path, biggiestruct.filename, bkpinfo->tmpdir);
809 paranoid_system(tmp);
810 mr_free(tmp);
811
812 bigfile_num++;
813 slice_num = 0;
814 retval++;
815 } else {
816 slice_num++;
817 }
818 } else {
819 log_it("Unable to open bigfile as restore_path is NULL");
820 }
821 } else if (does_file_exist(slice_fname(bigfile_num, slice_num, mountpoint, "")) &&
822 (length_of_file(slice_fname(bigfile_num, slice_num, mountpoint, "")) == 0)) {
823 log_msg(2, "ISO=%d bigfile=%ld ---END---", g_current_media_number, bigfile_num);
824 bigfile_num++;
825 paranoid_fclose(forig);
826 slice_num = 0;
827 } else {
828 log_msg(2, "ISO=%d bigfile=%ld slice=%ld", g_current_media_number, bigfile_num, slice_num);
829 if ((!does_file_exist(slice_fname(bigfile_num, slice_num, mountpoint, ""))) && (sz_exe != NULL)) {
830 mr_asprintf(command, "%s -dc %s 2>> %s", sz_exe, slice_fname(bigfile_num, slice_num, mountpoint, bkpinfo->zip_suffix), MONDO_LOGFILE);
831 } else {
832 mr_asprintf(command, "cat %s 2>> %s", slice_fname(bigfile_num, slice_num, mountpoint, ""), MONDO_LOGFILE);
833 }
834 pin = popen(command, "r");
835 mr_free(command);
836 if (pin) {
837 res = 0;
838 while (!feof(pin)) {
839 currsizA = fread(bufblkA, 1, maxbufsize, pin);
840 if (currsizA <= 0) {
841 break;
842 }
843 currsizB = fread(bufblkB, 1, currsizA, forig);
844 if (currsizA != currsizB) {
845 res++;
846 } else {
847 for (j = 0;
848 j < currsizA && bufblkA[j] == bufblkB[j];
849 j++);
850 if (j < currsizA) {
851 res++;
852 }
853 }
854 }
855 paranoid_pclose(pin);
856 if (res && !strncmp(biggiestruct.filename, "/dev/", 5)) {
857 log_msg(3,
858 "Ignoring differences between %s and live filesystem because it's a device and therefore the archives are stored via ntfsclone, not dd.",
859 biggiestruct.filename);
860 log_msg(3,
861 "If you really want verification for %s, please contact the devteam and offer an incentive.",
862 biggiestruct.filename);
863 res = 0;
864 }
865 if (res) {
866 log_msg(0,
867 "afio: \"%s\": Corrupt biggie file, says libmondo-archive.c",
868 biggiestruct.filename);
869 retval++;
870 }
871 }
872 slice_num++;
873 }
874 }
875 mr_free(mountpoint);
876 mr_free(sz_exe);
877
878 last_bigfile_num = bigfile_num;
879 last_slice_num = slice_num - 1;
880 if (last_slice_num < 0) {
881 last_bigfile_num--;
882 }
883 close_evalcall_form();
884 if (bufblkA) {
885 paranoid_free(bufblkA);
886 }
887 if (bufblkB) {
888 paranoid_free(bufblkB);
889 }
890 return (0);
891}
892
893
894
[1]895/* @} - end of LLverifyGroup */
896
897
898/**
[1709]899 * Verify the USB device
900 * @param bkpinfo The backup information structure. Fields used:
901 * - @c bkpinfo->media_device
902 * - @c bkpinfo->tmpdir
903 * - @c bkpinfo->verify_data
904 *
905 * @return 0 for success (even if differences are found), nonzero for failure.
906 * @ingroup verifyGroup
907 */
908int verify_usb_image()
909{
910
911 /*@ int ************************************************************ */
912 int retval = 0;
913
914 /*@ buffers ******************************************************** */
915 char *mountpoint = NULL;
916 char *tmp = NULL;
917 char *tmp1 = NULL;
918 char *fname = NULL;
[1711]919 int ret = 0;
[1709]920#ifdef __FreeBSD__
921 char mdd[32];
922 char *mddevice = mdd;
923 int vndev = 2;
924#else
925//skip
926#endif
927
928 assert(bkpinfo != NULL);
929
[3191]930 if (bkpinfo->media_device == NULL) {
931 return(1);
932 }
933
[3185]934 mr_asprintf(fname, "%s1", bkpinfo->media_device);
[1709]935 if (is_this_device_mounted(fname)) {
936 log_msg(1, "USB device mounted. Remounting it at the right place");
[3185]937 mr_asprintf(tmp, "umount %s", fname);
[1709]938 run_program_and_log_output(tmp, FALSE);
939 paranoid_free(tmp);
940 }
941 paranoid_free(fname);
942
943 log_msg(1, "Mounting USB device.");
[3185]944 mr_asprintf(mountpoint, "%s/usb", bkpinfo->tmpdir);
945 mr_asprintf(tmp, "mkdir -p %s", mountpoint);
[1709]946 run_program_and_log_output(tmp, FALSE);
947 paranoid_free(tmp);
948 /* Mindi always create one single parition on the USB dev */
[3185]949 mr_asprintf(tmp, "mount %s1 %s", bkpinfo->media_device, mountpoint);
[1709]950 ret = run_program_and_log_output(tmp, FALSE);
951 paranoid_free(tmp);
952 if (ret) {
953 paranoid_free(mountpoint);
954 return(ret);
955 }
956
957 sync();
[3380]958 log_msg(2, "OK, I've mounted the USB Disk/Key");
[3185]959 mr_asprintf(tmp, "%s/archives/NOT-THE-LAST", mountpoint);
[1709]960 if (!does_file_exist(tmp)) {
961 log_msg
962 (2,
963 "This is the last USB device. I am therefore setting bkpinfo->verify_data to FALSE.");
964 bkpinfo->verify_data = FALSE;
965/*
966 (a) It's an easy way to tell the calling subroutine that we've finished &
967 there are no more device to be verified; (b) It stops the post-backup verifier
968 from running after the per-device verifier has run too.
969*/
970 }
971 paranoid_free(tmp);
972 verify_afioballs_on_CD(mountpoint);
[2230]973 log_it("before verify_all_slices");
[1709]974 verify_all_slices_on_CD(mountpoint);
975
[3185]976 mr_asprintf(tmp1, "umount -d %s", mountpoint);
[1709]977#ifdef __FreeBSD__
978 ret += system(tmp1);
979 ret += kick_vn(mddevice);
980 if (ret)
981#else
982 if (system(tmp1))
983#endif
984 {
[3191]985 log_to_screen("%s failed; unable to unmount USB device\n", tmp1);
[1709]986 retval++;
987 } else {
[3380]988 log_msg(2, "OK, I've unmounted the USB device");
[1709]989 }
[3191]990 mr_free(tmp1);
991 mr_free(mountpoint);
[1709]992 return (retval);
993}
994
995
996/**
[1]997 * Verify the CD indicated by @c g_current_media_number.
998 * @param bkpinfo The backup information structure. Fields used:
999 * - @c bkpinfo->isodir
[20]1000 * - @c bkpinfo->prefix
[1]1001 * - @c bkpinfo->manual_cd_tray
1002 * - @c bkpinfo->media_device
[2380]1003 * - @c bkpinfo->netfs_remote_dir
[1]1004 * - @c bkpinfo->tmpdir
1005 * - @c bkpinfo->verify_data
1006 *
1007 * @return 0 for success (even if differences are found), nonzero for failure.
1008 * @ingroup verifyGroup
1009 */
[1645]1010int verify_cd_image()
[1]1011{
1012
[128]1013 /*@ int ************************************************************ */
1014 int retval = 0;
[1]1015
[128]1016 /*@ buffers ******************************************************** */
[3191]1017 char *mountpoint = NULL;
1018 char *command = NULL;
1019 char *tmp = NULL;
1020 char *fname = NULL;
[1]1021#ifdef __FreeBSD__
[128]1022 char mdd[32];
[1]1023 char *mddevice = mdd;
[128]1024 int ret = 0;
1025 int vndev = 2;
[1]1026#else
1027//skip
1028#endif
1029
[128]1030 assert(bkpinfo != NULL);
[1]1031
[3191]1032 if (bkpinfo->media_device == NULL) {
1033 return(1);
1034 }
[128]1035
[3191]1036 mr_asprintf(mountpoint, "%s/cdrom", bkpinfo->tmpdir);
1037 if (((bkpinfo->isodir == NULL) && (bkpinfo->netfs_remote_dir == NULL)) || (bkpinfo->prefix == NULL)) {
1038 fatal_error("No iso filename preparation possible");
1039 }
[3207]1040 if (bkpinfo->netfs_remote_dir != NULL) {
[3191]1041 // NETFS
1042 mr_asprintf(fname, "%s/%s/%s-%d.iso", bkpinfo->isodir, bkpinfo->netfs_remote_dir, bkpinfo->prefix, g_current_media_number);
1043 } else {
1044 // ISO
1045 mr_asprintf(fname, "%s/%s-%d.iso", bkpinfo->isodir, bkpinfo->prefix, g_current_media_number);
1046 }
1047
[128]1048 mkdir(mountpoint, 1777);
1049 sync();
1050 if (!does_file_exist(fname)) {
[3191]1051 log_msg(2, "%s not found; assuming you backed up to CD; verifying CD...", fname);
[128]1052 if (bkpinfo->manual_cd_tray) {
[541]1053 popup_and_OK("Please push CD tray closed.");
[128]1054 }
[1645]1055 if (find_and_mount_actual_cd(mountpoint)) {
[541]1056 log_to_screen("failed to mount actual CD");
[3191]1057 mr_free(mountpoint);
1058 mr_free(fname);
[128]1059 return (1);
1060 }
1061 } else {
[3191]1062 log_msg(2, "%s found; verifying ISO...", fname);
[1]1063#ifdef __FreeBSD__
[128]1064 ret = 0;
1065 vndev = 2;
1066 mddevice = make_vn(fname);
1067 if (ret) {
[3191]1068 log_to_screen("make_vn of %s failed; unable to verify ISO\n", fname);
1069 mr_free(mountpoint);
1070 mr_free(fname);
[128]1071 return (1);
1072 }
[3191]1073 mr_asprintf(command, "mount_cd9660 %s %s", mddevice, mountpoint);
[1]1074#else
[3191]1075 mr_asprintf(command, "mount -o loop,ro -t iso9660 %s %s", fname, mountpoint);
[1]1076#endif
[128]1077 if (run_program_and_log_output(command, FALSE)) {
[3191]1078 log_to_screen("%s failed; unable to mount ISO image\n", command);
1079 mr_free(mountpoint);
1080 mr_free(command);
1081 mr_free(fname);
[128]1082 return (1);
1083 }
[3191]1084 mr_free(command);
[1]1085 }
[3380]1086 log_msg(2, "OK, I've mounted the ISO/CD");
[3191]1087 mr_asprintf(tmp, "%s/archives/NOT-THE-LAST", mountpoint);
[128]1088 if (!does_file_exist(tmp)) {
1089 log_msg
1090 (2,
1091 "This is the last CD. I am therefore setting bkpinfo->verify_data to FALSE.");
1092 bkpinfo->verify_data = FALSE;
[1]1093/*
1094 (a) It's an easy way to tell the calling subroutine that we've finished &
1095 there are no more CD's to be verified; (b) It stops the post-backup verifier
1096 from running after the per-CD verifier has run too.
1097*/
[128]1098 }
[3191]1099 mr_free(tmp);
1100
[1645]1101 verify_afioballs_on_CD(mountpoint);
[2230]1102 log_it("before verify_all_slices");
[1645]1103 verify_all_slices_on_CD(mountpoint);
[1]1104
1105#ifdef __FreeBSD__
[128]1106 ret = 0;
[3191]1107 mr_asprintf(command, "umount -d %s", mountpoint);
[128]1108 ret += system(command);
1109 ret += kick_vn(mddevice);
[3191]1110 if (ret) {
[1]1111#else
[3191]1112 mr_asprintf(command, "umount -d %s", mountpoint);
1113 if (system(command)) {
[1]1114#endif
[3191]1115 log_to_screen("%s failed; unable to unmount ISO image\n", command);
1116
[128]1117 retval++;
1118 } else {
[3380]1119 log_msg(2, "OK, I've unmounted the ISO file");
[1]1120 }
[3191]1121 mr_free(mountpoint);
1122 mr_free(command);
1123
[128]1124 if (!does_file_exist(fname)) {
[3191]1125 mr_asprintf(command, "umount -d %s", bkpinfo->media_device);
[128]1126 run_program_and_log_output(command, 2);
[3191]1127 mr_free(command);
1128
1129 if (!bkpinfo->please_dont_eject && eject_device(bkpinfo->media_device)) {
[128]1130 log_msg(2, "Failed to eject CD-ROM drive");
1131 }
1132 }
[3191]1133 mr_free(fname);
[128]1134 return (retval);
[1]1135}
1136
1137/**
1138 * Verify all backups on tape.
1139 * This should be done after the backup process has already closed the tape.
1140 * @param bkpinfo The backup information structure. Passed to various helper functions.
1141 * @return 0 for success (even if thee were differences), nonzero for failure.
1142 * @ingroup verifyGroup
1143 */
[1645]1144int verify_tape_backups()
[1]1145{
1146
[128]1147 /*@ int ************************************************************ */
1148 int retval = 0;
[1]1149
[128]1150 /*@ buffers ******************************************************** */
[3191]1151 char *tmp = NULL;
1152 char *changed_files_fname = NULL;
[1]1153
[128]1154 /*@ long *********************************************************** */
1155 long diffs = 0;
[1]1156
[128]1157 assert(bkpinfo != NULL);
[1]1158
[128]1159 log_msg(3, "verify_tape_backups --- starting");
[541]1160 log_to_screen("Verifying backups");
[1645]1161 openin_tape();
[1]1162/* verify archives themselves */
[1645]1163 retval += verify_afioballs_from_stream();
1164 retval += verify_biggiefiles_from_stream();
[1]1165/* find the final blocks */
[3191]1166 sync();
[128]1167 sleep(2);
[1645]1168 closein_tape();
[1]1169/* close tape; exit */
1170// fclose(g_tape_stream); <-- not needed; is handled by closein_tape()
[3191]1171 mr_asprintf(tmp, "rm -f %s/biggies.changed %s/changed.files 2> /dev/null", bkpinfo->tmpdir, bkpinfo->tmpdir);
[1644]1172 paranoid_system(tmp);
[3191]1173 mr_free(tmp);
1174
1175 mr_asprintf(changed_files_fname, "%s/changed.files", bkpinfo->tmpdir);
1176 mr_asprintf(tmp, "grep -E '^%s:.*$' %s | cut -d'\"' -f2 | sort -u | awk '{print \"/\"$0;};' | tr -s '/' '/' | grep -v \"(total of\" | grep -v \"incheckentry.*xwait\" | grep -vE '^/afio:.*$' | grep -vE '^dev/.*$' > %s", (bkpinfo->use_star) ? "star" : "afio", MONDO_LOGFILE, changed_files_fname);
[128]1177 log_msg(2, "Running command to derive list of changed files");
1178 log_msg(2, tmp);
1179 if (system(tmp)) {
[3191]1180 if (does_file_exist(changed_files_fname) && length_of_file(changed_files_fname) > 2) {
1181 log_to_screen("Warning - unable to check logfile to derive list of changed files");
[128]1182 } else {
[3191]1183 log_to_screen("No differences found. Therefore, no 'changed.files' text file.");
[128]1184 }
1185 }
[3191]1186 mr_free(tmp);
1187
1188 mr_asprintf(tmp, "cat %s/biggies.changed >> %s", bkpinfo->tmpdir, changed_files_fname);
[128]1189 paranoid_system(tmp);
[3191]1190 mr_free(tmp);
[1]1191
[128]1192 diffs = count_lines_in_file(changed_files_fname);
1193 if (diffs > 0) {
[3191]1194 mr_asprintf(tmp, "cp -f %s %s/changed.files", changed_files_fname, MONDO_CACHE);
[128]1195 run_program_and_log_output(tmp, FALSE);
[3191]1196 mr_free(tmp);
1197
1198 log_msg(0, "%ld files differed from live filesystem; type less %s or less %s/changed.files to see", diffs, changed_files_fname, MONDO_CACHE);
[1747]1199 log_to_screen("See "MONDO_CACHE"/changed.files for a list of nonmatching files.");
[1644]1200 log_to_screen("The files probably changed on filesystem, not on backup media.");
[128]1201 }
[3191]1202 mr_free(changed_files_fname);
[128]1203 return (retval);
[1]1204}
1205
1206
1207
Note: See TracBrowser for help on using the repository browser.