1 Index: src/filed/accurate.c
2 ===================================================================
3 --- src/filed/accurate.c (révision 7288)
4 +++ src/filed/accurate.c (copie de travail)
8 typedef struct PrivateCurFile {
13 char *fname; /* not stored with tchdb mode */
20 -static void realfree(void *p); /* used by tokyo code */
22 +static void realfree(void *p); /* used by tokyo/db code */
24 * Update hash element seen=1
26 @@ -190,10 +190,152 @@
30 -#else /* HTABLE mode */
31 +#endif /* USE_TCADB */
35 + * Update hash element seen=1
37 static bool accurate_mark_file_as_seen(JCR *jcr, CurFile *elt)
44 + dbkey.data = elt->fname;
45 + dbkey.size = strlen(elt->fname)+1;
47 + dbdata.size = sizeof(CurFile);
48 + if ((ret = jcr->file_list->put(jcr->file_list, NULL, &dbkey, &dbdata, 0))) {
49 + Jmsg(jcr, M_ERROR, 1, _("Can't update accurate hash disk ERR=%i\n"), ret);
55 +static bool accurate_lookup(JCR *jcr, char *fname, CurFile *elt)
60 + /* Zero out the DBTs before using them. */
61 + memset(&dbkey, 0, sizeof(DBT));
62 + memset(&dbdata, 0, sizeof(DBT));
65 + dbkey.size = strlen(fname)+1;
68 + dbdata.ulen = sizeof(CurFile);
69 + dbdata.flags = DB_DBT_USERMEM;
71 + if (jcr->file_list->get(jcr->file_list, NULL, &dbkey, &dbdata, 0) == 0) {
78 +/* Create tokyo dbm hash file
79 + * If something goes wrong, we cancel accurate mode.
81 +static bool accurate_init(JCR *jcr, int nbfile)
85 + if ((ret = db_create(&jcr->file_list, NULL, 0)) != 0) {
86 + Jmsg(jcr, M_ERROR, 1, _("Can't open accurate hash disk ERR=%i\n"), ret);
90 + jcr->file_list->set_errfile(jcr->file_list, stderr);
91 + jcr->file_list->set_errpfx(jcr->file_list, "hash");
93 + if ((ret = jcr->file_list->set_cachesize(jcr->file_list, 0, 32 * 1024 * 1024, 0)) != 0) {
94 + Jmsg(jcr, M_ERROR, 1, _("Can't setup hash disk cache size ERR=%i\n"), ret);
97 + jcr->hash_name = get_pool_memory(PM_MESSAGE);
98 + make_unique_filename(&jcr->hash_name, jcr->JobId, "accurate");
100 + if ((ret = jcr->file_list->open(jcr->file_list,
101 + NULL, jcr->hash_name, NULL,
102 + DB_BTREE, DB_CREATE | DB_PRIVATE, 0600)) != 0)
104 + jcr->file_list->close(jcr->file_list, DB_NOSYNC);
105 + jcr->file_list=NULL;
106 + free_pool_memory(jcr->hash_name);
107 + jcr->hash_name = NULL;
108 + Jmsg(jcr, M_ERROR, 1, _("Can't setup hash disk cache size ERR=%i\n"), ret);
112 + return jcr->file_list != NULL;
115 +/* This function is called at the end of backup
116 + * We walk over all hash disk element, and we check
119 +bool accurate_send_deleted_list(JCR *jcr)
123 + int stream = STREAM_UNIX_ATTRIBUTES;
126 + /* Zero out the DBTs before using them. */
127 + memset(&dbkey, 0, sizeof(DBT));
128 + memset(&dbdata, 0, sizeof(DBT));
129 + dbdata.data = &elt;
130 + dbdata.ulen = sizeof(CurFile);
131 + dbdata.flags = DB_DBT_USERMEM;
133 + if (!jcr->accurate || jcr->JobLevel == L_FULL) {
137 + if (jcr->file_list == NULL) {
141 + ff_pkt = init_find_files();
142 + ff_pkt->type = FT_DELETED;
144 + /* traverse records */
145 + jcr->file_list->cursor(jcr->file_list, NULL, &cursorp, 0);
147 + while(cursorp->c_get(cursorp, &dbkey, &dbdata, DB_NEXT) == 0) {
148 + if (!elt.seen) { /* already seen */
149 + ff_pkt->fname = (char *) dbkey.data;
150 + ff_pkt->statp.st_mtime = elt.mtime;
151 + ff_pkt->statp.st_ctime = elt.ctime;
152 + encode_and_send_attributes(jcr, ff_pkt, stream);
155 + cursorp->c_close(cursorp);
157 + term_find_files(ff_pkt);
160 + if (jcr->file_list) {
161 + jcr->file_list->close(jcr->file_list, DB_NOSYNC);
162 + if (!bstrcmp(jcr->hash_name, "*")) {
163 + unlink(jcr->hash_name);
165 + free_pool_memory(jcr->hash_name);
166 + jcr->hash_name = NULL;
167 + jcr->file_list = NULL;
175 +static bool accurate_mark_file_as_seen(JCR *jcr, CurFile *elt)
177 CurFile *temp = (CurFile *)jcr->file_list->lookup(elt->fname);
178 temp->seen = 1; /* records are in memory */
181 Jmsg(jcr, M_ERROR, 1, _("Can't update accurate hash disk ERR=%s\n"));
188 + memset(&dbkey, 0, sizeof(DBT));
189 + memset(&dbdata, 0, sizeof(DBT));
190 + dbkey.data = fname;
191 + dbkey.size = strlen(fname)+1;
192 + dbdata.data = &elt;
193 + dbdata.size = sizeof(CurFile);
194 + if ((ret = jcr->file_list->put(jcr->file_list, NULL, &dbkey, &dbdata, 0))) {
195 + Jmsg(jcr, M_ERROR, 1, _("Can't update accurate hash disk ERR=%i\n"), ret);
201 /* we store CurFile, fname and ctime/mtime in the same chunk */
202 item = (CurFile *)jcr->file_list->hash_malloc(sizeof(CurFile)+strlen(fname)+1);
204 jcr->file_list->insert(item->fname, item);
207 -// Dmsg2(dbglvl, "add fname=<%s> lstat=%s\n", fname, lstat);
208 + //Dmsg2(dbglvl, "add fname=<%s> lstat=%s\n", fname, lstat);
212 Index: src/filed/filed.h
213 ===================================================================
214 --- src/filed/filed.h (révision 7288)
215 +++ src/filed/filed.h (copie de travail)
217 #define FILE_DAEMON 1
218 #ifdef USE_TCADB /* hash disk based */
226 # include "lib/htable.h"
228 #include "filed_conf.h"
229 Index: src/baconfig.h
230 ===================================================================
231 --- src/baconfig.h (révision 7288)
232 +++ src/baconfig.h (copie de travail)
235 #endif /* HAVE_WIN32 */
237 +/* Select db backend for accurate mode */
246 Index: src/win32/build-depkgs-mingw32
247 ===================================================================
248 --- src/win32/build-depkgs-mingw32 (révision 7288)
249 +++ src/win32/build-depkgs-mingw32 (copie de travail)
257 for dependency in "$@"
260 ===================================================================
261 --- src/jcr.h (révision 7288)
262 +++ src/jcr.h (copie de travail)
265 TCADB *file_list; /* Previous file list (accurate mode) */
271 + POOLMEM *hash_name;
274 htable *file_list; /* Previous file list (accurate mode) */
276 #endif /* FILE_DAEMON */