source: branches/2.2.5/mondo/src/common/libmondo-verify.c @ 1855

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