]> git.sur5r.net Git - bacula/bacula/blob - bacula/patches/testing/fd_checkchanges.patch
ebl fix compilation
[bacula/bacula] / bacula / patches / testing / fd_checkchanges.patch
1 diff -Naur bacula1/src/dird/inc_conf.c bacula2/src/dird/inc_conf.c
2 --- bacula1/src/dird/inc_conf.c 2007-02-19 20:44:13.000000000 +0100
3 +++ bacula2/src/dird/inc_conf.c 2007-02-19 20:44:33.000000000 +0100
4 @@ -120,6 +120,7 @@
5     {"noatime",         store_opts,    {0},     0, 0, 0},
6     {"enhancedwild",    store_opts,    {0},     0, 0, 0},
7     {"drivetype",       store_drivetype, {0},     0, 0, 0},
8 +   {"checkchanges",    store_opts,    {0},     0, 0, 0},
9     {NULL, NULL, {0}, 0, 0, 0}
10  };
11  
12 @@ -145,7 +146,8 @@
13     INC_KW_IGNORECASE,
14     INC_KW_HFSPLUS,
15     INC_KW_NOATIME,
16 -   INC_KW_ENHANCEDWILD
17 +   INC_KW_ENHANCEDWILD,
18 +   INC_KW_CHKCHANGES
19  };
20  
21  /*
22 @@ -174,6 +176,7 @@
23     {"hfsplussupport", INC_KW_HFSPLUS},
24     {"noatime",     INC_KW_NOATIME},
25     {"enhancedwild", INC_KW_ENHANCEDWILD},
26 +   {"checkchanges", INC_KW_CHKCHANGES},
27     {NULL,          0}
28  };
29  
30 @@ -239,6 +242,8 @@
31     {"no",       INC_KW_NOATIME,       "0"},
32     {"yes",      INC_KW_ENHANCEDWILD,  "K"},
33     {"no",       INC_KW_ENHANCEDWILD,  "0"},
34 +   {"yes",      INC_KW_CHKCHANGES,    "c"},
35 +   {"no",       INC_KW_CHKCHANGES,    "0"},
36     {NULL,       0,                      0}
37  };
38  
39 diff -Naur bacula1/src/filed/backup.c bacula2/src/filed/backup.c
40 --- bacula1/src/filed/backup.c  2007-02-19 20:44:13.000000000 +0100
41 +++ bacula2/src/filed/backup.c  2007-02-19 20:47:14.000000000 +0100
42 @@ -453,7 +453,13 @@
43        }
44  
45        stat = send_data(jcr, data_stream, ff_pkt, digest, signing_digest);
46 +
47 +      if (ff_pkt->flags & FO_CHKCHANGES) {
48 +         has_file_changed(jcr, ff_pkt);
49 +      }
50 +
51        bclose(&ff_pkt->bfd);
52 +      
53        if (!stat) {
54           return 0;
55        }
56 diff -Naur bacula1/src/filed/job.c bacula2/src/filed/job.c
57 --- bacula1/src/filed/job.c     2007-02-19 20:44:13.000000000 +0100
58 +++ bacula2/src/filed/job.c     2007-02-19 20:44:33.000000000 +0100
59 @@ -1021,6 +1021,9 @@
60        case 'K':
61           fo->flags |= FO_NOATIME;
62           break;
63 +      case 'c':
64 +         fo->flags |= FO_CHKCHANGES;
65 +         break;
66        default:
67           Emsg1(M_ERROR, 0, _("Unknown include/exclude option: %c\n"), *p);
68           break;
69 diff -Naur bacula1/src/findlib/find.h bacula2/src/findlib/find.h
70 --- bacula1/src/findlib/find.h  2007-02-19 20:44:16.000000000 +0100
71 +++ bacula2/src/findlib/find.h  2007-02-19 20:44:33.000000000 +0100
72 @@ -107,6 +107,7 @@
73  #define FO_ENCRYPT      (1<<21)       /* Encrypt data stream */
74  #define FO_NOATIME      (1<<22)       /* Use O_NOATIME to prevent atime change */
75  #define FO_ENHANCEDWILD (1<<23)       /* Enhanced wild card processing */
76 +#define FO_CHKCHANGES   (1<<24)       /* Check if file have been modified during backup */
77  
78  struct s_included_file {
79     struct s_included_file *next;
80 diff -Naur bacula1/src/findlib/find_one.c bacula2/src/findlib/find_one.c
81 --- bacula1/src/findlib/find_one.c      2007-02-19 20:44:16.000000000 +0100
82 +++ bacula2/src/findlib/find_one.c      2007-02-19 20:44:33.000000000 +0100
83 @@ -271,6 +271,51 @@
84     return false;
85  }
86  
87 +/* check if a file have changed during backup and display an error */
88 +bool has_file_changed(JCR *jcr, FF_PKT *ff_pkt)
89 +{
90 +   struct stat statp;
91 +   Dmsg1(500, "has_file_changed fname=%s\n",ff_pkt->fname);
92 +
93 +   if (ff_pkt->type != FT_REG) { /* not a regular file */
94 +      return false;
95 +   }
96 +
97 +   if (lstat(ff_pkt->fname, &statp) != 0) {
98 +      berrno be;
99 +      Jmsg(jcr, M_WARNING, 0, 
100 +          _("Cannot stat file %s: ERR=%s\n"),ff_pkt->fname,be.strerror());
101 +      return true;
102 +   }
103 +
104 +   if (statp.st_mtime != ff_pkt->statp.st_mtime) {
105 +      /* TODO: add time of changes */
106 +      Jmsg(jcr, M_ERROR, 0, _("%s mtime changed during backup.\n"), ff_pkt->fname);
107 +      return true;
108 +   }
109 +
110 +   if (statp.st_ctime != ff_pkt->statp.st_ctime) {
111 +      /* TODO: add time of changes */
112 +      Jmsg(jcr, M_ERROR, 0, _("%s ctime changed during backup.\n"), ff_pkt->fname);
113 +      return true;
114 +   }
115 +  
116 +   if (statp.st_size != ff_pkt->statp.st_size) {
117 +      /* TODO: add size change */
118 +      Jmsg(jcr, M_ERROR, 0, _("%s size changed during backup.\n"),ff_pkt->fname);
119 +      return true;
120 +   }
121 +
122 +   if ((statp.st_blksize*statp.st_blocks) != 
123 +       (ff_pkt->statp.st_blksize*ff_pkt->statp.st_blocks)) {
124 +      /* TODO: add size change */
125 +      Jmsg(jcr, M_ERROR, 0, _("%s size changed during backup.\n"),ff_pkt->fname);
126 +      return true;
127 +   }
128 +
129 +   return false;
130 +}
131 +
132  /*
133   * Find a single file.
134   * handle_file is the callback for handling the file.
135 diff -Naur bacula1/src/findlib/protos.h bacula2/src/findlib/protos.h
136 --- bacula1/src/findlib/protos.h        2007-02-19 20:44:16.000000000 +0100
137 +++ bacula2/src/findlib/protos.h        2007-02-19 20:44:33.000000000 +0100
138 @@ -65,7 +65,7 @@
139                 int handle_file(FF_PKT *ff_pkt, void *hpkt, bool top_level),
140                 void *pkt, char *p, dev_t parent_device, bool top_level);
141  int   term_find_one(FF_PKT *ff);
142 -
143 +bool  has_file_changed(JCR *jcr, FF_PKT *ff_pkt);
144  
145  /* From get_priv.c */
146  int enable_backup_privileges(JCR *jcr, int ignore_errors);
147 diff -Naur bacula1/src/win32/dll/bacula.def bacula2/src/win32/dll/bacula.def
148 --- bacula1/src/win32/dll/bacula.def    2007-02-28 14:35:43.000000000 +0100
149 +++ bacula2/src/win32/dll/bacula.def    2007-03-01 11:15:50.000000000 +0100
150 @@ -80,6 +80,8 @@
151
152  ; find_one.c:
153  _Z13find_one_fileP3JCRP6FF_PKTPFiS2_PvbES3_Pcjb
154 +_Z17has_file_changedP3JCRP6FF_PKT
155 +
156
157  ; fstype.c:
158  _Z6fstypePKcPci
159
160