source: MondoRescue/branches/3.2/mondo/src/common/libmondo-verify.c@ 3373

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