Write Bootstrap = "@working_dir@/Client1.bsr"
}
+#Job {
+# Name = "Client2"
+# Client = @hostname@2-fd
+# JobDefs = "DefaultJob"
+# Write Bootstrap = "@working_dir@/Client2.bsr"
+#}
+
# Backup the catalog database (after the nightly save)
Job {
Name = "BackupCatalog"
Priority = 11 # run after main backup
}
+#
# Standard Restore template, to be changed by Console program
+# Only one such job is needed for all Jobs/Clients/Storage ...
+#
Job {
Name = "RestoreFiles"
Type = Restore
AutoPrune = yes # Prune expired Jobs/Files
}
+#
+# Second Client (File Services) to backup
+# You should change Name, Address, and Password before using
+#
+#Client {
+# Name = @hostname@2-fd
+# Address = @hostname@2
+# FDPort = @fd_port@
+# Catalog = MyCatalog
+# Password = "@fd_password@2" # password for FileDaemon 2
+# File Retention = 30 days # 30 days
+# Job Retention = 6 months # six months
+# AutoPrune = yes # Prune expired Jobs/Files
+#}
+
+
# Definiton of file storage device
Storage {
Name = File
#include "dird.h"
/* Commands sent to File daemon */
-static char inc[] = "include\n";
-static char exc[] = "exclude\n";
static char fileset[] = "fileset\n"; /* set full fileset */
static char jobcmd[] = "JobId=%d Job=%s SDid=%u SDtime=%u Authorization=%s\n";
/* Note, mtime_only is not used here -- implemented as file option */
/* Responses received from File daemon */
static char OKinc[] = "2000 OK include\n";
-static char OKexc[] = "2000 OK exclude\n";
static char OKjob[] = "2000 OK Job";
static char OKbootstrap[] = "2000 OK bootstrap\n";
static char OKlevel[] = "2000 OK level\n";
* Send level command to FD.
* Used for backup jobs and estimate command.
*/
-int send_level_command(JCR *jcr)
+bool send_level_command(JCR *jcr)
{
BSOCK *fd = jcr->file_bsock;
/*
return 1;
}
-
-/*
- * Send either an Included or an Excluded list to FD
- */
-static int send_list(JCR *jcr, int list)
-{
- FILESET *fileset;
- BSOCK *fd;
- int num;
-
- fd = jcr->file_bsock;
- fileset = jcr->fileset;
-
- if (list == INC_LIST) {
- num = fileset->num_includes;
- } else {
- num = fileset->num_excludes;
- }
-
- for (int i=0; i<num; i++) {
- BPIPE *bpipe;
- FILE *ffd;
- char buf[2000];
- char *p;
- int optlen, stat;
- INCEXE *ie;
-
-
- if (list == INC_LIST) {
- ie = fileset->include_items[i];
- } else {
- ie = fileset->exclude_items[i];
- }
- for (int j=0; j<ie->name_list.size(); j++) {
- p = (char *)ie->name_list.get(j);
- switch (*p) {
- case '|':
- p++; /* skip over the | */
- fd->msg = edit_job_codes(jcr, fd->msg, p, "");
- bpipe = open_bpipe(fd->msg, 0, "r");
- if (!bpipe) {
- berrno be;
- Jmsg(jcr, M_FATAL, 0, _("Cannot run program: %s. ERR=%s\n"),
- p, be.strerror());
- goto bail_out;
- }
- /* Copy File options */
- if (ie->num_opts) {
- bstrncpy(buf, ie->opts_list[0]->opts, sizeof(buf));
- bstrncat(buf, " ", sizeof(buf));
- } else {
- bstrncpy(buf, "0 ", sizeof(buf));
- }
- Dmsg1(500, "Opts=%s\n", buf);
- optlen = strlen(buf);
- while (fgets(buf+optlen, sizeof(buf)-optlen, bpipe->rfd)) {
- fd->msglen = Mmsg(fd->msg, "%s", buf);
- Dmsg2(500, "Inc/exc len=%d: %s", fd->msglen, fd->msg);
- if (!bnet_send(fd)) {
- Jmsg(jcr, M_FATAL, 0, _(">filed: write error on socket\n"));
- goto bail_out;
- }
- }
- if ((stat=close_bpipe(bpipe)) != 0) {
- berrno be;
- Jmsg(jcr, M_FATAL, 0, _("Error running program %p: ERR=%s\n"),
- p, be.strerror(stat));
- goto bail_out;
- }
- break;
- case '<':
- p++; /* skip over < */
- if ((ffd = fopen(p, "r")) == NULL) {
- Jmsg(jcr, M_FATAL, 0, _("Cannot open %s file: %s. ERR=%s\n"),
- list==INC_LIST?"included":"excluded", p, strerror(errno));
- goto bail_out;
- }
- /* Copy File options */
- if (ie->num_opts) {
- bstrncpy(buf, ie->opts_list[0]->opts, sizeof(buf));
- bstrncat(buf, " ", sizeof(buf));
- } else {
- bstrncpy(buf, "0 ", sizeof(buf));
- }
- Dmsg1(500, "Opts=%s\n", buf);
- optlen = strlen(buf);
- while (fgets(buf+optlen, sizeof(buf)-optlen, ffd)) {
- fd->msglen = Mmsg(fd->msg, "%s", buf);
- if (!bnet_send(fd)) {
- Jmsg(jcr, M_FATAL, 0, _(">filed: write error on socket\n"));
- goto bail_out;
- }
- }
- fclose(ffd);
- break;
- case '\\':
- p++; /* skip over \ */
- /* Note, fall through wanted */
- default:
- if (ie->num_opts) {
- Dmsg2(500, "numopts=%d opts=%s\n", ie->num_opts, NPRT(ie->opts_list[0]->opts));
- pm_strcpy(fd->msg, ie->opts_list[0]->opts);
- pm_strcat(fd->msg, " ");
- } else {
- pm_strcpy(fd->msg, "0 ");
- }
- fd->msglen = pm_strcat(fd->msg, p);
- Dmsg1(500, "Inc/Exc name=%s\n", fd->msg);
- if (!bnet_send(fd)) {
- Jmsg(jcr, M_FATAL, 0, _(">filed: write error on socket\n"));
- goto bail_out;
- }
- break;
- }
- }
- }
- bnet_sig(fd, BNET_EOD); /* end of data */
- if (list == INC_LIST) {
- if (!response(jcr, fd, OKinc, "Include", DISPLAY_ERROR)) {
- goto bail_out;
- }
- } else if (!response(jcr, fd, OKexc, "Exclude", DISPLAY_ERROR)) {
- goto bail_out;
- }
- return 1;
-
-bail_out:
- set_jcr_job_status(jcr, JS_ErrorTerminated);
- return 0;
-
-}
-
-
/*
* Send either an Included or an Excluded list to FD
*/
/*
* Send include list to File daemon
*/
-int send_include_list(JCR *jcr)
+bool send_include_list(JCR *jcr)
{
BSOCK *fd = jcr->file_bsock;
if (jcr->fileset->new_include) {
bnet_fsend(fd, fileset);
return send_fileset(jcr);
- } else {
- bnet_fsend(fd, inc);
}
- return send_list(jcr, INC_LIST);
+ return true;
}
/*
* Send exclude list to File daemon
+ * Under the new scheme, the Exclude list
+ * is part of the FileSet sent with the
+ * "include_list" above.
*/
-int send_exclude_list(JCR *jcr)
+bool send_exclude_list(JCR *jcr)
{
- BSOCK *fd = jcr->file_bsock;
- if (jcr->fileset->new_include) {
- return 1;
- }
- bnet_fsend(fd, exc);
- return send_list(jcr, EXC_LIST);
+ return true;
}
* Send bootstrap file if any to the File daemon.
* This is used for restore and verify VolumeToCatalog
*/
-int send_bootstrap_file(JCR *jcr)
+bool send_bootstrap_file(JCR *jcr)
{
FILE *bs;
char buf[1000];
};
/*
- * Include keywords -- these are keywords that can appear
- * in the options lists of an old include ( Include = compression= ...)
+ * This is the list of options that can be stored by store_opts
+ * Note, now that the old style Include/Exclude code is gone,
+ * the INC_KW code could be put into the "code" field of the
+ * options given above.
*/
static struct s_kw FS_option_kw[] = {
{"compression", INC_KW_COMPRESSION},
*/
void store_inc(LEX *lc, RES_ITEM *item, int index, int pass)
{
- int token, i;
- int options = lc->options;
- int keyword;
- char inc_opts[100];
- int inc_opts_len;
+ int token;
/*
* Decide if we are doing a new Include or an old include. The
store_newinc(lc, item, index, pass);
return;
}
-
- /* What follows is scanning for the OLD style Include/Exclude */
-
- if (token != T_EQUALS) {
- scan_err1(lc, _("Expecting an equals sign, got: %s\n"), lc->str);
- }
- lc->options |= LOPT_NO_IDENT; /* make spaces significant */
- memset(&res_incexe, 0, sizeof(INCEXE));
-
- /* Get include options */
- inc_opts[0] = 0;
- while ((token=lex_get_token(lc, T_SKIP_EOL)) != T_BOB) {
-
- keyword = INC_KW_NONE;
- for (i=0; FS_option_kw[i].name; i++) {
- if (strcasecmp(lc->str, FS_option_kw[i].name) == 0) {
- keyword = FS_option_kw[i].token;
- break;
- }
- }
- if (keyword == INC_KW_NONE) {
- scan_err1(lc, _("Expected a FileSet keyword, got: %s"), lc->str);
- }
- /* Option keyword should be following by = <option> */
- if ((token=lex_get_token(lc, T_SKIP_EOL)) != T_EQUALS) {
- scan_err1(lc, _("expected an = following keyword, got: %s"), lc->str);
- } else {
- /* Scan right hand side of option */
- scan_include_options(lc, keyword, inc_opts, sizeof(inc_opts));
- }
- if (token == T_BOB) {
- break;
- }
- }
-
- if (!inc_opts[0]) {
- bstrncat(inc_opts, "0", sizeof(inc_opts)); /* set no options */
- }
- inc_opts_len = strlen(inc_opts);
-
- if (pass == 1) {
- INCEXE *incexe;
- if (!res_all.res_fs.have_MD5) {
- MD5Init(&res_all.res_fs.md5c);
- res_all.res_fs.have_MD5 = TRUE;
- }
- setup_current_opts();
- bstrncpy(res_incexe.current_opts->opts, inc_opts, MAX_FOPTS);
- Dmsg2(900, "old pass=%d incexe opts=%s\n", pass, res_incexe.current_opts->opts);
-
- /* Create incexe structure */
- Dmsg0(900, "Create INCEXE structure\n");
- incexe = (INCEXE *)malloc(sizeof(INCEXE));
- memcpy(incexe, &res_incexe, sizeof(INCEXE));
- memset(&res_incexe, 0, sizeof(INCEXE));
- if (item->code == 0) { /* include */
- if (res_all.res_fs.num_includes == 0) {
- res_all.res_fs.include_items = (INCEXE **)malloc(sizeof(INCEXE *));
- } else {
- res_all.res_fs.include_items = (INCEXE **)realloc(res_all.res_fs.include_items,
- sizeof(INCEXE *) * (res_all.res_fs.num_includes + 1));
- }
- res_all.res_fs.include_items[res_all.res_fs.num_includes++] = incexe;
- Dmsg1(900, "num_includes=%d\n", res_all.res_fs.num_includes);
- } else { /* exclude */
- if (res_all.res_fs.num_excludes == 0) {
- res_all.res_fs.exclude_items = (INCEXE **)malloc(sizeof(INCEXE *));
- } else {
- res_all.res_fs.exclude_items = (INCEXE **)realloc(res_all.res_fs.exclude_items,
- sizeof(INCEXE *) * (res_all.res_fs.num_excludes + 1));
- }
- res_all.res_fs.exclude_items[res_all.res_fs.num_excludes++] = incexe;
- Dmsg1(900, "num_excludes=%d\n", res_all.res_fs.num_excludes);
- }
-
- /* Pickup include/exclude names. They are stored in INCEXE
- * structures which contains the options and the name.
- */
- while ((token = lex_get_token(lc, T_SKIP_EOL)) != T_EOB) {
- switch (token) {
- case T_COMMA:
- continue;
-
- case T_IDENTIFIER:
- case T_UNQUOTED_STRING:
- case T_QUOTED_STRING:
- if (res_all.res_fs.have_MD5) {
- MD5Update(&res_all.res_fs.md5c, (unsigned char *)lc->str, lc->str_len);
- }
- if (incexe->name_list.size() == 0) {
- incexe->name_list.init(10, true);
- }
- incexe->name_list.append(bstrdup(lc->str));
- Dmsg1(900, "Add to name_list %s\n", lc->str);
- break;
- default:
- scan_err1(lc, "Expected a filename, got: %s", lc->str);
- }
- }
- /* Note, MD5Final is done in backup.c */
- } else { /* pass 2 */
- while (lex_get_token(lc, T_ALL) != T_EOB)
- {}
- }
- scan_to_eol(lc);
- lc->options = options;
- set_bit(index, res_all.hdr.item_present);
+ scan_err0(lc, _("Old style Include/Exclude not supported\n"));
}
/* fd_cmds.c */
extern int connect_to_file_daemon(JCR *jcr, int retry_interval,
int max_retry_time, int verbose);
-extern int send_include_list(JCR *jcr);
-extern int send_exclude_list(JCR *jcr);
-extern int send_bootstrap_file(JCR *jcr);
-extern int send_level_command(JCR *jcr);
+extern bool send_include_list(JCR *jcr);
+extern bool send_exclude_list(JCR *jcr);
+extern bool send_bootstrap_file(JCR *jcr);
+extern bool send_level_command(JCR *jcr);
extern int get_attributes_and_put_in_catalog(JCR *jcr);
extern int get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId);
extern int put_file_into_catalog(JCR *jcr, long file_index, char *fname,
@$(MV) Makefile Makefile.bak
@$(SED) "/^# DO NOT DELETE:/,$$ d" Makefile.bak > Makefile
@$(ECHO) "# DO NOT DELETE: nice dependency list follows" >> Makefile
- @$(CXX) -S -M $(CPPFLAGS) $(XINC) -I$(srcdir) -I$(basedir) $(SQL_INC) *.c >> Makefile
+ @$(CXX) -S -M $(CPPFLAGS) $(XINC) $(PYTHON_INC) -I$(srcdir) -I$(basedir) $(SQL_INC) *.c >> Makefile
@if test -f Makefile ; then \
$(RMF) Makefile.bak; \
else \
static int cancel_cmd(JCR *jcr);
static int setdebug_cmd(JCR *jcr);
static int estimate_cmd(JCR *jcr);
-static int exclude_cmd(JCR *jcr);
static int hello_cmd(JCR *jcr);
static int job_cmd(JCR *jcr);
-static int include_cmd(JCR *jcr);
static int fileset_cmd(JCR *jcr);
static int level_cmd(JCR *jcr);
static int verify_cmd(JCR *jcr);
{"cancel", cancel_cmd, 0},
{"setdebug=", setdebug_cmd, 0},
{"estimate", estimate_cmd, 0},
- {"exclude", exclude_cmd, 0},
{"Hello", hello_cmd, 1},
- {"include", include_cmd, 0},
{"fileset", fileset_cmd, 0},
{"JobId=", job_cmd, 0},
{"level = ", level_cmd, 0},
static char illegal_cmd[] = "2997 Illegal command for a Director with Monitor directive enabled\n";
static char OKinc[] = "2000 OK include\n";
static char OKest[] = "2000 OK estimate files=%u bytes=%s\n";
-static char OKexc[] = "2000 OK exclude\n";
static char OKlevel[] = "2000 OK level\n";
static char OKbackup[] = "2000 OK backup\n";
static char OKbootstrap[] = "2000 OK bootstrap\n";
return true;
}
-
-#define INC_LIST 0
-#define EXC_LIST 1
-
-static void add_fname_to_list(JCR *jcr, char *fname, int list)
-{
- char *p, *q;
- BPIPE *bpipe;
- POOLMEM *fn;
- FILE *ffd;
- char buf[1000];
- int optlen;
- int stat;
-
- /* Skip leading options -- currently ignored */
- for (p=fname; *p && *p != ' '; p++)
- { }
- /* Skip spaces, and q points to first space */
- for (q=NULL; *p && *p == ' '; p++) {
- if (!q) {
- q = p;
- }
- }
-
- switch (*p) {
- case '|':
- p++; /* skip over | */
- fn = get_pool_memory(PM_FNAME);
- fn = edit_job_codes(jcr, fn, p, "");
- bpipe = open_bpipe(fn, 0, "r");
- free_pool_memory(fn);
- if (!bpipe) {
- Jmsg(jcr, M_FATAL, 0, _("Cannot run program: %s. ERR=%s\n"),
- p, strerror(errno));
- return;
- }
- /* Copy File options */
- if (list == INC_LIST) {
- *q = 0; /* terminate options */
- bstrncpy(buf, fname, sizeof(buf));
- bstrncat(buf, " ", sizeof(buf));
- optlen = strlen(buf);
- } else {
- optlen = 0;
- }
- while (fgets(buf+optlen, sizeof(buf)-optlen, bpipe->rfd)) {
- strip_trailing_junk(buf);
- if (list == INC_LIST) {
- add_fname_to_include_list((FF_PKT *)jcr->ff, 1, buf);
- } else {
- add_fname_to_exclude_list((FF_PKT *)jcr->ff, buf);
- }
- }
- if ((stat=close_bpipe(bpipe)) != 0) {
- Jmsg(jcr, M_FATAL, 0, _("Error running program: %s. RtnStat=%d ERR=%s\n"),
- p, stat, strerror(errno));
- return;
- }
- break;
- case '<':
- p++; /* skip over < */
- if ((ffd = fopen(p, "r")) == NULL) {
- berrno be;
- Jmsg(jcr, M_FATAL, 0, _("Cannot open %s file: %s. ERR=%s\n"),
- list==INC_LIST?"included":"excluded", p, be.strerror());
- return;
- }
- /* Copy File options */
- if (list == INC_LIST) {
- *q = 0; /* terminate options */
- bstrncpy(buf, fname, sizeof(buf));
- bstrncat(buf, " ", sizeof(buf));
- optlen = strlen(buf);
- } else {
- optlen = 0;
- }
- while (fgets(buf+optlen, sizeof(buf)-optlen, ffd)) {
- strip_trailing_junk(buf);
- if (list == INC_LIST) {
- add_fname_to_include_list((FF_PKT *)jcr->ff, 1, buf);
- } else {
- add_fname_to_exclude_list((FF_PKT *)jcr->ff, buf);
- }
- }
- fclose(ffd);
- break;
- default:
- if (list == INC_LIST) {
- add_fname_to_include_list((FF_PKT *)jcr->ff, 1, fname);
- } else {
- add_fname_to_exclude_list((FF_PKT *)jcr->ff, p);
- }
- break;
- }
-}
-
-/*
- *
- * Get list of files/directories to include from Director
- *
- */
-static int include_cmd(JCR *jcr)
-{
- BSOCK *dir = jcr->dir_bsock;
-
- while (bnet_recv(dir) >= 0) {
- dir->msg[dir->msglen] = 0;
- strip_trailing_junk(dir->msg);
- Dmsg1(010, "include file: %s\n", dir->msg);
- add_fname_to_list(jcr, dir->msg, INC_LIST);
- }
-
- return bnet_fsend(dir, OKinc);
-}
-
static bool init_fileset(JCR *jcr)
{
FF_PKT *ff;
}
-/*
- * Get list of files to exclude from Director
- *
- */
-static int exclude_cmd(JCR *jcr)
-{
- BSOCK *dir = jcr->dir_bsock;
-
- while (bnet_recv(dir) >= 0) {
- dir->msg[dir->msglen] = 0;
- strip_trailing_junk(dir->msg);
- add_fname_to_list(jcr, dir->msg, EXC_LIST);
- Dmsg1(110, "<dird: exclude file %s\n", dir->msg);
- }
-
- return bnet_fsend(dir, OKexc);
-}
-
-
static int bootstrap_cmd(JCR *jcr)
{
BSOCK *dir = jcr->dir_bsock;
int32_t name_max; /* filename max length */
int32_t path_max; /* path name max length */
-
-/* ****FIXME**** debug until stable */
+#ifdef DEBUG
#undef bmalloc
#define bmalloc(x) sm_malloc(__FILE__, __LINE__, x)
+#endif
static int our_callback(FF_PKT *ff, void *hpkt);
static bool accept_file(FF_PKT *ff);
ff->sys_fname = get_pool_memory(PM_FNAME);
- init_include_exclude_files(ff); /* init lists */
-
/* Get system path and filename maximum lengths */
path_max = pathconf(".", _PC_PATH_MAX);
if (path_max < 1024) {
}
}
}
- } else {
- struct s_included_file *inc = NULL;
-
- /* This is the old deprecated way */
- while (!job_canceled(jcr) && (inc = get_next_included_file(ff, inc))) {
- /* Copy options for this file */
- bstrncat(ff->VerifyOpts, inc->VerifyOpts, sizeof(ff->VerifyOpts));
- Dmsg1(100, "find_files: file=%s\n", inc->fname);
- if (!file_is_excluded(ff, inc->fname)) {
- if (find_one_file(jcr, ff, callback, his_pkt, inc->fname, (dev_t)-1, 1) ==0) {
- return 0; /* error return */
- }
- }
- }
}
return 1;
}
{
int hard_links;
- term_include_exclude_files(ff);
free_pool_memory(ff->sys_fname);
hard_links = term_find_one(ff);
free(ff);
/*
- Copyright (C) 2000-20054 Kern Sibbald
+ Copyright (C) 2000-2005 Kern Sibbald
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
if (ff_pkt->flags & FO_KEEPATIME) {
utime(fname, &restore_times);
}
- Jmsg1(jcr, M_ERROR, 0, _("Top level directory \"%s\" has an unlisted fstype\n"), fname);
- return 1; /* Just ignore this error - or the whole backup is cancelled */
+ Jmsg1(jcr, M_ERROR, 0, _("Top level directory \"%s\" has an unlisted fstype\n"), fname);
+ return 1; /* Just ignore this error - or the whole backup is cancelled */
}
ff_pkt->volhas_attrlist = volume_has_attrlist(fname);
}
*
* Note, this file is used for the old style include and
* excludes, so is deprecated. The new style code is
- * found in find.c
+ * found in find.c.
+ * This code is still used for lists in testls and bextract.
*
* Kern E. Sibbald, December MMI
*
*/
/*
- Copyright (C) 2001-2004 Kern Sibbald
+ Copyright (C) 2001-2005 Kern Sibbald
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
extern const int win32_client;
-/*
- * Initialize structures for filename matching
- */
-void init_include_exclude_files(FF_PKT *ff)
+int
+match_files(JCR *jcr, FF_PKT *ff, int callback(FF_PKT *ff_pkt, void *hpkt), void *his_pkt)
{
+ ff->callback = callback;
+
+ struct s_included_file *inc = NULL;
+
+ /* This is the old deprecated way */
+ while (!job_canceled(jcr) && (inc = get_next_included_file(ff, inc))) {
+ /* Copy options for this file */
+ bstrncat(ff->VerifyOpts, inc->VerifyOpts, sizeof(ff->VerifyOpts));
+ Dmsg1(100, "find_files: file=%s\n", inc->fname);
+ if (!file_is_excluded(ff, inc->fname)) {
+ if (find_one_file(jcr, ff, callback, his_pkt, inc->fname, (dev_t)-1, 1) ==0) {
+ return 0; /* error return */
+ }
+ }
+ }
+ return 1;
}
+
/*
* Done doing filename matching, release all
* resources used.
*/
/* from attribs.c */
-void encode_stat (char *buf, FF_PKT *ff_pkt, int data_stream);
-int decode_stat (char *buf, struct stat *statp, int32_t *LinkFI);
-int32_t decode_LinkFI (char *buf, struct stat *statp);
-int encode_attribsEx (JCR *jcr, char *attribsEx, FF_PKT *ff_pkt);
-bool set_attributes (JCR *jcr, ATTR *attr, BFILE *ofd);
-int select_data_stream(FF_PKT *ff_pkt);
+void encode_stat (char *buf, FF_PKT *ff_pkt, int data_stream);
+int decode_stat (char *buf, struct stat *statp, int32_t *LinkFI);
+int32_t decode_LinkFI (char *buf, struct stat *statp);
+int encode_attribsEx (JCR *jcr, char *attribsEx, FF_PKT *ff_pkt);
+bool set_attributes (JCR *jcr, ATTR *attr, BFILE *ofd);
+int select_data_stream(FF_PKT *ff_pkt);
/* from create_file.c */
-int create_file (JCR *jcr, ATTR *attr, BFILE *ofd, int replace);
+int create_file (JCR *jcr, ATTR *attr, BFILE *ofd, int replace);
/* From find.c */
FF_PKT *init_find_files();
void set_find_options(FF_PKT *ff, int incremental, time_t mtime);
int find_files(JCR *jcr, FF_PKT *ff, int sub(FF_PKT *ff_pkt, void *hpkt), void *pkt);
+int match_files(JCR *jcr, FF_PKT *ff, int sub(FF_PKT *ff_pkt, void *hpkt), void *pkt);
int term_find_files(FF_PKT *ff);
/* From match.c */
int file_is_excluded(FF_PKT *ff, const char *file);
int file_is_included(FF_PKT *ff, const char *file);
struct s_included_file *get_next_included_file(FF_PKT *ff,
- struct s_included_file *inc);
+ struct s_included_file *inc);
/* From find_one.c */
int find_one_file(JCR *jcr, FF_PKT *ff, int handle_file(FF_PKT *ff_pkt, void *hpkt),
- void *pkt, char *p, dev_t parent_device, int top_level);
+ void *pkt, char *p, dev_t parent_device, int top_level);
int term_find_one(FF_PKT *ff);
/* from makepath.c */
int make_path(JCR *jcr, const char *argpath, int mode,
- int parent_mode, uid_t owner, gid_t group,
- int preserve_existing, char *verbose_fmt_string);
+ int parent_mode, uid_t owner, gid_t group,
+ int preserve_existing, char *verbose_fmt_string);
/* from fstype.c */
bool fstype(const char *fname, char *fs, int fslen);
static DCR *dcr;
static BFILE bfd;
static JCR *jcr;
-static FF_PKT my_ff;
-static FF_PKT *ff = &my_ff;
+static FF_PKT *ff;
static BSR *bsr = NULL;
static bool extract = false;
static int non_support_data = 0;
my_name_is(argc, argv, "bextract");
init_msg(NULL, NULL); /* setup message handler */
- memset(ff, 0, sizeof(FF_PKT));
- init_include_exclude_files(ff);
+ ff = init_find_files();
binit(&bfd);
while ((ch = getopt(argc, argv, "b:c:d:e:i:pvV:?")) != -1) {
Pmsg1(000, "%d Win32 data or Win32 gzip data stream records. Ignored.\n",
win32_data_msg);
}
+ term_include_exclude_files(ff);
+ term_find_files(ff);
return 0;
}
bool forge_on = false;
-static FF_PKT ff;
+static FF_PKT *ff;
static BSR *bsr = NULL;
my_name_is(argc, argv, "bls");
init_msg(NULL, NULL); /* initialize message handler */
- memset(&ff, 0, sizeof(ff));
- init_include_exclude_files(&ff);
+ ff = init_find_files();
while ((ch = getopt(argc, argv, "b:c:d:e:i:jkLpvV:?")) != -1) {
switch (ch) {
while (fgets(line, sizeof(line), fd) != NULL) {
strip_trailing_junk(line);
Dmsg1(100, "add_exclude %s\n", line);
- add_fname_to_exclude_list(&ff, line);
+ add_fname_to_exclude_list(ff, line);
}
fclose(fd);
break;
while (fgets(line, sizeof(line), fd) != NULL) {
strip_trailing_junk(line);
Dmsg1(100, "add_include %s\n", line);
- add_fname_to_include_list(&ff, 0, line);
+ add_fname_to_include_list(ff, 0, line);
}
fclose(fd);
break;
parse_config(configfile);
- if (ff.included_files_list == NULL) {
- add_fname_to_include_list(&ff, 0, "/");
+ if (ff->included_files_list == NULL) {
+ add_fname_to_include_list(ff, 0, "/");
}
for (i=0; i < argc; i++) {
if (bsr) {
free_bsr(bsr);
}
+ term_include_exclude_files(ff);
+ term_find_files(ff);
return 0;
}
attr->data_stream = decode_stat(attr->attr, &attr->statp, &attr->LinkFI);
build_attr_output_fnames(jcr, attr);
- if (file_is_included(&ff, attr->fname) && !file_is_excluded(&ff, attr->fname)) {
+ if (file_is_included(ff, attr->fname) && !file_is_excluded(ff, attr->fname)) {
if (verbose) {
Pmsg5(-1, "FileIndex=%d VolSessionId=%d VolSessionTime=%d Stream=%d DataLen=%d\n",
rec->FileIndex, rec->VolSessionId, rec->VolSessionTime, rec->Stream, rec->data_len);
while ((ch = getopt(argc, argv, "ad:e:i:?")) != -1) {
switch (ch) {
- case 'a': /* print extended attributes *debug* */
+ case 'a': /* print extended attributes *debug* */
attrs = 1;
break;
- case 'd': /* set debug level */
+ case 'd': /* set debug level */
debug_level = atoi(optarg);
if (debug_level <= 0) {
debug_level = 1;
}
break;
- case 'e': /* exclude patterns */
+ case 'e': /* exclude patterns */
exc = optarg;
break;
- case 'i': /* include patterns */
+ case 'i': /* include patterns */
inc = optarg;
break;
- case '?':
+ case '?':
default:
usage();
add_fname_to_include_list(ff, 0, "/"); /* default to / */
} else {
for (i=0; i < argc; i++) {
- if (strcmp(argv[i], "-") == 0) {
+ if (strcmp(argv[i], "-") == 0) {
while (fgets(name, sizeof(name)-1, stdin)) {
strip_trailing_junk(name);
add_fname_to_include_list(ff, 0, name);
if (inc) {
fd = fopen(inc, "r");
if (!fd) {
- printf("Could not open include file: %s\n", inc);
+ printf("Could not open include file: %s\n", inc);
exit(1);
}
while (fgets(name, sizeof(name)-1, fd)) {
if (exc) {
fd = fopen(exc, "r");
if (!fd) {
- printf("Could not open exclude file: %s\n", exc);
+ printf("Could not open exclude file: %s\n", exc);
exit(1);
}
while (fgets(name, sizeof(name)-1, fd)) {
}
fclose(fd);
}
- find_files(jcr, ff, print_file, NULL);
+ match_files(jcr, ff, print_file, NULL);
+ term_include_exclude_files(ff);
hard_links = term_find_files(ff);
printf(_(""
switch (ff->type) {
case FT_LNKSAVED:
if (debug_level == 1) {
- printf("%s\n", ff->fname);
+ printf("%s\n", ff->fname);
} else if (debug_level > 1) {
- printf("Lnka: %s -> %s\n", ff->fname, ff->link);
+ printf("Lnka: %s -> %s\n", ff->fname, ff->link);
}
break;
case FT_REGE:
if (debug_level == 1) {
- printf("%s\n", ff->fname);
+ printf("%s\n", ff->fname);
} else if (debug_level > 1) {
- printf("Empty: %s\n", ff->fname);
+ printf("Empty: %s\n", ff->fname);
}
count_files(ff);
break;
case FT_REG:
if (debug_level == 1) {
- printf("%s\n", ff->fname);
+ printf("%s\n", ff->fname);
} else if (debug_level > 1) {
- printf("Reg: %s\n", ff->fname);
+ printf("Reg: %s\n", ff->fname);
}
count_files(ff);
break;
case FT_LNK:
if (debug_level == 1) {
- printf("%s\n", ff->fname);
+ printf("%s\n", ff->fname);
} else if (debug_level > 1) {
- printf("Lnk: %s -> %s\n", ff->fname, ff->link);
+ printf("Lnk: %s -> %s\n", ff->fname, ff->link);
}
count_files(ff);
break;
case FT_INVALIDFS:
case FT_DIREND:
if (debug_level) {
- char errmsg[100] = "";
+ char errmsg[100] = "";
if (ff->type == FT_NORECURSE) {
- bstrncpy(errmsg, "\t[will not descend: recursion turned off]", sizeof(errmsg));
+ bstrncpy(errmsg, "\t[will not descend: recursion turned off]", sizeof(errmsg));
} else if (ff->type == FT_NOFSCHG) {
- bstrncpy(errmsg, "\t[will not descend: file system change not allowed]", sizeof(errmsg));
+ bstrncpy(errmsg, "\t[will not descend: file system change not allowed]", sizeof(errmsg));
} else if (ff->type == FT_INVALIDFS) {
- bstrncpy(errmsg, "\t[will not descend: disallowed file system]", sizeof(errmsg));
+ bstrncpy(errmsg, "\t[will not descend: disallowed file system]", sizeof(errmsg));
}
- printf("%s%s%s\n", (debug_level > 1 ? "Dir: " : ""), ff->fname, errmsg);
+ printf("%s%s%s\n", (debug_level > 1 ? "Dir: " : ""), ff->fname, errmsg);
}
ff->type = FT_DIREND;
count_files(ff);
break;
case FT_SPEC:
if (debug_level == 1) {
- printf("%s\n", ff->fname);
+ printf("%s\n", ff->fname);
} else if (debug_level > 1) {
- printf("Spec: %s\n", ff->fname);
+ printf("Spec: %s\n", ff->fname);
}
count_files(ff);
break;
char attr[200];
encode_attribsEx(NULL, attr, ff);
if (*attr != 0) {
- printf("AttrEx=%s\n", attr);
+ printf("AttrEx=%s\n", attr);
}
// set_attribsEx(NULL, ff->fname, NULL, NULL, ff->type, attr);
}
add_fname_to_include_list(ff, 0, "/"); /* default to / */
} else {
for (i=0; i < argc; i++) {
- if (strcmp(argv[i], "-") == 0) {
+ if (strcmp(argv[i], "-") == 0) {
while (fgets(name, sizeof(name)-1, stdin)) {
strip_trailing_junk(name);
add_fname_to_include_list(ff, 0, name);
if (inc) {
fd = fopen(inc, "r");
if (!fd) {
- printf("Could not open include file: %s\n", inc);
+ printf("Could not open include file: %s\n", inc);
exit(1);
}
while (fgets(name, sizeof(name)-1, fd)) {
if (exc) {
fd = fopen(exc, "r");
if (!fd) {
- printf("Could not open exclude file: %s\n", exc);
+ printf("Could not open exclude file: %s\n", exc);
exit(1);
}
while (fgets(name, sizeof(name)-1, fd)) {
}
fclose(fd);
}
- find_files(jcr, ff, print_file, NULL);
+ match_files(jcr, ff, print_file, NULL);
+ term_include_exclude_files(ff);
hard_links = term_find_files(ff);
free_jcr(jcr);