2 * Bacula File Daemon estimate.c
3 * Make and estimate of the number of files and size to be saved.
5 * Kern Sibbald, September MMI
11 Copyright (C) 2000-2003 Kern Sibbald and John Walker
13 This program is free software; you can redistribute it and/or
14 modify it under the terms of the GNU General Public License as
15 published by the Free Software Foundation; either version 2 of
16 the License, or (at your option) any later version.
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 General Public License for more details.
23 You should have received a copy of the GNU General Public
24 License along with this program; if not, write to the Free
25 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
33 static int tally_file(FF_PKT *ff_pkt, void *pkt);
36 * Find all the requested files and count them.
38 int make_estimate(JCR *jcr)
42 jcr->JobStatus = JS_Running;
44 set_find_options((FF_PKT *)jcr->ff, jcr->incremental, jcr->mtime);
45 stat = find_files(jcr, (FF_PKT *)jcr->ff, tally_file, (void *)jcr);
51 * Called here by find() for each file included.
54 static int tally_file(FF_PKT *ff_pkt, void *ijcr)
56 JCR *jcr = (JCR *)ijcr;
59 if (job_canceled(jcr)) {
62 switch (ff_pkt->type) {
63 case FT_LNKSAVED: /* Hard linked, file already saved */
85 if (ff_pkt->type != FT_LNKSAVED && S_ISREG(ff_pkt->statp.st_mode) &&
86 ff_pkt->statp.st_size > 0) {
87 jcr->JobBytes += ff_pkt->statp.st_size;
89 jcr->num_files_examined++;
90 jcr->JobFiles++; /* increment number of files seen */
92 memcpy(&attr.statp, &ff_pkt->statp, sizeof(struct stat));
93 attr.type = ff_pkt->type;
94 attr.ofname = (POOLMEM *)ff_pkt->fname;
95 attr.olname = (POOLMEM *)ff_pkt->link;
96 print_ls_output(jcr, &attr);