2 Bacula(R) - The Network Backup Solution
4 Copyright (C) 2000-2015 Kern Sibbald
5 Copyright (C) 2001-2014 Free Software Foundation Europe e.V.
7 The original author of Bacula is Kern Sibbald, with contributions
8 from many others, a complete list can be found in the file AUTHORS.
10 You may use this file and others of this release according to the
11 license defined in the LICENSE file, which includes the Affero General
12 Public License, v3.0 ("AGPLv3") and some additional permissions and
13 terms pursuant to its AGPLv3 Section 7.
15 This notice must be preserved when any source code is
16 conveyed and/or propagated.
18 Bacula(R) is a registered trademark of Kern Sibbald.
21 * Bacula File Daemon estimate.c
22 * Make and estimate of the number of files and size to be saved.
24 * Kern Sibbald, September MMI
33 static int tally_file(JCR *jcr, FF_PKT *ff_pkt, bool);
36 * Find all the requested files and count them.
38 int make_estimate(JCR *jcr)
42 jcr->setJobStatus(JS_Running);
44 set_find_options((FF_PKT *)jcr->ff, jcr->incremental, jcr->mtime);
45 /* in accurate mode, we overwrite the find_one check function */
47 set_find_changed_function((FF_PKT *)jcr->ff, accurate_check_file);
50 stat = find_files(jcr, (FF_PKT *)jcr->ff, tally_file, plugin_estimate);
56 * Called here by find() for each file included.
59 static int tally_file(JCR *jcr, FF_PKT *ff_pkt, bool top_level)
63 if (job_canceled(jcr)) {
66 switch (ff_pkt->type) {
67 case FT_LNKSAVED: /* Hard linked, file already saved */
94 if (ff_pkt->type != FT_LNKSAVED && S_ISREG(ff_pkt->statp.st_mode)) {
95 if (ff_pkt->statp.st_size > 0) {
96 jcr->JobBytes += ff_pkt->statp.st_size;
99 if (ff_pkt->flags & FO_HFSPLUS) {
100 if (ff_pkt->hfsinfo.rsrclength > 0) {
101 jcr->JobBytes += ff_pkt->hfsinfo.rsrclength;
103 jcr->JobBytes += 32; /* Finder info */
107 jcr->num_files_examined++;
108 jcr->JobFiles++; /* increment number of files seen */
110 memcpy(&attr.statp, &ff_pkt->statp, sizeof(struct stat));
111 attr.type = ff_pkt->type;
112 attr.ofname = (POOLMEM *)ff_pkt->fname;
113 attr.olname = (POOLMEM *)ff_pkt->link;
114 print_ls_output(jcr, &attr);
116 /* TODO: Add loop over jcr->file_list to get Accurate deleted files*/