From 9fca83b1565414abb247c85bb60430885a6778f9 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Fri, 6 Aug 2004 21:57:03 +0000 Subject: [PATCH] A few changes for Win32 Implement reader in Dir and FD Rework SQL for pruning Add Admin pruner No commas in JobIds printed in restore command git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1514 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/kernstodo | 3 +- bacula/src/dird/dird_conf.c | 12 +++ bacula/src/dird/dird_conf.h | 2 + bacula/src/dird/fd_cmds.c | 6 ++ bacula/src/dird/inc_conf.c | 39 ++++++++ bacula/src/dird/sql_cmds.c | 33 ++++--- bacula/src/dird/ua_prune.c | 9 +- bacula/src/dird/ua_restore.c | 10 ++ bacula/src/filed/backup.c | 3 + bacula/src/filed/filed.c | 22 ++--- bacula/src/filed/job.c | 22 +++++ bacula/src/findlib/bfile.c | 56 ++++++++++- bacula/src/findlib/bfile.h | 7 ++ bacula/src/findlib/find.c | 8 +- bacula/src/findlib/find.h | 108 +++++++++++---------- bacula/src/lib/bnet.c | 2 +- bacula/src/lib/bnet_server.c | 2 +- bacula/src/lib/bpipe.h | 2 +- bacula/src/win32/baculafd/baculafd.mak | 26 +++++ bacula/src/win32/console/console.mak | 11 +++ bacula/src/win32/lib/address_conf.cpp | 1 + bacula/src/win32/wx-console/filelist | 1 + bacula/src/win32/wx-console/wx-console.mak | 25 +++++ 23 files changed, 320 insertions(+), 90 deletions(-) create mode 100755 bacula/src/win32/lib/address_conf.cpp diff --git a/bacula/kernstodo b/bacula/kernstodo index f8e30d4a67..e16b57ea2c 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -1,5 +1,5 @@ Kern's ToDo List - 05 August 2004 + 06 August 2004 Major development: Project Developer @@ -71,6 +71,7 @@ For 1.37 Testing/Documentation: non-existent directories will not be restored properly. Wish list: +- Allow the user to select JobType for manual pruning/purging. - Look at adding Client run command that will use the port opened by the client. - bscan does not put first of two volumes back with all info in diff --git a/bacula/src/dird/dird_conf.c b/bacula/src/dird/dird_conf.c index 36a31ae4d7..4e5e06e5ba 100644 --- a/bacula/src/dird/dird_conf.c +++ b/bacula/src/dird/dird_conf.c @@ -581,6 +581,12 @@ void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fm for (k=0; kbase.size(); k++) { sendit(sock, " B %s\n", fo->base.get(k)); } + if (fo->reader) { + sendit(sock, " D %s\n", fo->reader); + } + if (fo->writer) { + sendit(sock, " T %s\n", fo->writer); + } sendit(sock, " N\n"); } for (j=0; jname_list.size(); j++) { @@ -735,6 +741,12 @@ static void free_incexe(INCEXE *incexe) fopt->regex.destroy(); fopt->wild.destroy(); fopt->base.destroy(); + if (fopt->reader) { + free(fopt->reader); + } + if (fopt->writer) { + free(fopt->writer); + } free(fopt); } if (incexe->opts_list) { diff --git a/bacula/src/dird/dird_conf.h b/bacula/src/dird/dird_conf.h index a91f48b07b..ca70954f35 100644 --- a/bacula/src/dird/dird_conf.h +++ b/bacula/src/dird/dird_conf.h @@ -247,6 +247,8 @@ struct FOPTS { alist regex; /* regex string(s) */ alist wild; /* wild card strings */ alist base; /* list of base names */ + char *reader; /* reader program */ + char *writer; /* writer program */ }; diff --git a/bacula/src/dird/fd_cmds.c b/bacula/src/dird/fd_cmds.c index fdc8617cf4..5d05c051e2 100644 --- a/bacula/src/dird/fd_cmds.c +++ b/bacula/src/dird/fd_cmds.c @@ -391,6 +391,12 @@ static int send_fileset(JCR *jcr) for (k=0; kbase.size(); k++) { bnet_fsend(fd, "B %s\n", fo->base.get(k)); } + if (fo->reader) { + bnet_fsend(fd, "D %s\n", fo->reader); + } + if (fo->writer) { + bnet_fsend(fd, "T %s\n", fo->writer); + } bnet_fsend(fd, "N\n"); } diff --git a/bacula/src/dird/inc_conf.c b/bacula/src/dird/inc_conf.c index d3df0b8fd4..815b824832 100644 --- a/bacula/src/dird/inc_conf.c +++ b/bacula/src/dird/inc_conf.c @@ -43,6 +43,8 @@ static void store_opts(LEX *lc, RES_ITEM *item, int index, int pass); static void store_fname(LEX *lc, RES_ITEM *item, int index, int pass); static void options_res(LEX *lc, RES_ITEM *item, int index, int pass); static void store_base(LEX *lc, RES_ITEM *item, int index, int pass); +static void store_reader(LEX *lc, RES_ITEM *item, int index, int pass); +static void store_writer(LEX *lc, RES_ITEM *item, int index, int pass); static void setup_current_opts(void); @@ -87,6 +89,8 @@ static RES_ITEM options_items[] = { {"wild", store_wild, NULL, 0, 0, 0}, {"exclude", store_opts, NULL, 0, 0, 0}, {"aclsupport", store_opts, NULL, 0, 0, 0}, + {"reader", store_reader, NULL, 0, 0, 0}, + {"writer", store_writer, NULL, 0, 0, 0}, {NULL, NULL, NULL, 0, 0, 0} }; @@ -495,6 +499,41 @@ static void store_base(LEX *lc, RES_ITEM *item, int index, int pass) scan_to_eol(lc); } +/* Store reader info */ +static void store_reader(LEX *lc, RES_ITEM *item, int index, int pass) +{ + int token; + + if (pass == 1) { + /* + * Pickup reader command + */ + token = lex_get_token(lc, T_NAME); + res_incexe.current_opts->reader = bstrdup(lc->str); + } else { /* pass 2 */ + lex_get_token(lc, T_ALL); + } + scan_to_eol(lc); +} + +/* Store writer innfo */ +static void store_writer(LEX *lc, RES_ITEM *item, int index, int pass) +{ + int token; + + if (pass == 1) { + /* + * Pickup writer command + */ + token = lex_get_token(lc, T_NAME); + res_incexe.current_opts->writer = bstrdup(lc->str); + } else { /* pass 2 */ + lex_get_token(lc, T_ALL); + } + scan_to_eol(lc); +} + + /* Store Wild-card info */ static void store_wild(LEX *lc, RES_ITEM *item, int index, int pass) diff --git a/bacula/src/dird/sql_cmds.c b/bacula/src/dird/sql_cmds.c index 8c79737cd5..0058374b50 100644 --- a/bacula/src/dird/sql_cmds.c +++ b/bacula/src/dird/sql_cmds.c @@ -114,45 +114,54 @@ const char *insert_delcand = * (i.e. no files, ...) for deletion. */ const char *select_backup_del = - "SELECT DelCandidates.JobId " + "SELECT DISTINCT DelCandidates.JobId " "FROM Job,DelCandidates " - "WHERE (JobTDate<%s AND ((DelCandidates.JobFiles=0) OR " + "WHERE (Job.JobTDate<%s AND ((DelCandidates.JobFiles=0) OR " "(DelCandidates.JobStatus!='T'))) OR " "(Job.JobTDate>%s " "AND Job.ClientId=%u " "AND Job.Type='B' " "AND Job.Level='F' " "AND Job.JobStatus='T' " - "AND Job.FileSetId=DelCandidates.FileSetId) " - "GROUP BY DelCandidates.JobId"; + "AND Job.FileSetId=DelCandidates.FileSetId)"; /* Select Jobs from the DelCandidates table that have a * more recent InitCatalog -- i.e. are not the only InitCatalog * This is the list of Jobs to delete for a Verify Job. */ const char *select_verify_del = - "SELECT DelCandidates.JobId " + "SELECT DISTINCT DelCandidates.JobId " "FROM Job,DelCandidates " - "WHERE Job.JobTDate>%s " + "WHERE (Job.JobTdate<%s AND DelCandidates.JobStatus!='T') OR " + "(Job.JobTDate>%s " "AND Job.ClientId=%u " "AND Job.Type='V' " "AND Job.Level='V' " "AND Job.JobStatus='T' " - "AND Job.FileSetId=DelCandidates.FileSetId " - "GROUP BY DelCandidates.JobId"; + "AND Job.FileSetId=DelCandidates.FileSetId)"; /* Select Jobs from the DelCandidates table. * This is the list of Jobs to delete for a Restore Job. */ const char *select_restore_del = - "SELECT DelCandidates.JobId " + "SELECT DISTINCT DelCandidates.JobId " "FROM Job,DelCandidates " - "WHERE Job.JobTDate>%s " + "WHERE (Job.JobTdate<%s AND delCandidates.JobStatus!='T') OR " + "(Job.JobTDate>%s " "AND Job.ClientId=%u " - "AND Job.Type='R' " - "GROUP BY DelCandidates.JobId"; + "AND Job.Type='R')"; +/* Select Jobs from the DelCandidates table. + * This is the list of Jobs to delete for an Admin Job. + */ +const char *select_admin_del = + "SELECT DISTINCT DelCandidates.JobId " + "FROM Job,DelCandidates " + "WHERE (Job.JobTdate<%s AND delCandidates.JobStatus!='T') OR " + "(Job.JobTDate>%s " + "AND Job.ClientId=%u " + "AND Job.Type='D')"; /* ======= ua_restore.c */ diff --git a/bacula/src/dird/ua_prune.c b/bacula/src/dird/ua_prune.c index 5e9f93652a..4fb5e4be10 100644 --- a/bacula/src/dird/ua_prune.c +++ b/bacula/src/dird/ua_prune.c @@ -47,6 +47,7 @@ extern char *insert_delcand; extern char *select_backup_del; extern char *select_verify_del; extern char *select_restore_del; +extern char *select_admin_del; extern char *cnt_File; extern char *del_File; extern char *upd_Purged; @@ -413,15 +414,17 @@ int prune_jobs(UAContext *ua, CLIENT *client, int JobType) del.PurgedFiles = (char *)malloc(del.max_ids); switch (JobType) { - case JT_ADMIN: case JT_BACKUP: Mmsg(&query, select_backup_del, ed1, ed1, cr.ClientId); break; case JT_RESTORE: - Mmsg(&query, select_restore_del, ed1, cr.ClientId); + Mmsg(&query, select_restore_del, ed1, ed1, cr.ClientId); break; case JT_VERIFY: - Mmsg(&query, select_verify_del, ed1, cr.ClientId); + Mmsg(&query, select_verify_del, ed1, ed1, cr.ClientId); + break; + case JT_ADMIN: + Mmsg(&query, select_admin_del, ed1, ed1, cr.ClientId); break; } if (!db_sql_query(ua->db, query, job_delete_handler, (void *)&del)) { diff --git a/bacula/src/dird/ua_restore.c b/bacula/src/dird/ua_restore.c index 9c9faec58e..2b1cf9cd0a 100644 --- a/bacula/src/dird/ua_restore.c +++ b/bacula/src/dird/ua_restore.c @@ -415,6 +415,7 @@ static int user_select_jobids_or_files(UAContext *ua, RESTORE_CTX *rx) for ( ; !done; ) { char *fname; int len; + bool gui_save; start_prompt(ua, _("To select the JobIds, you have the following choices:\n")); for (int i=0; list[i]; i++) { @@ -425,7 +426,10 @@ static int user_select_jobids_or_files(UAContext *ua, RESTORE_CTX *rx) case -1: /* error */ return 0; case 0: /* list last 20 Jobs run */ + gui_save = ua->jcr->gui; + ua->jcr->gui = true; db_list_sql_query(ua->jcr, ua->db, uar_list_jobs, prtit, ua, 1, HORZ_LIST); + ua->jcr->gui = gui_save; done = false; break; case 1: /* list where a file is saved */ @@ -437,7 +441,10 @@ static int user_select_jobids_or_files(UAContext *ua, RESTORE_CTX *rx) db_escape_string(fname, ua->cmd, len); Mmsg(&rx->query, uar_file, fname); free(fname); + gui_save = ua->jcr->gui; + ua->jcr->gui = true; db_list_sql_query(ua->jcr, ua->db, rx->query, prtit, ua, 1, HORZ_LIST); + ua->jcr->gui = gui_save; done = false; break; case 2: /* enter a list of JobIds */ @@ -450,7 +457,10 @@ static int user_select_jobids_or_files(UAContext *ua, RESTORE_CTX *rx) if (!get_cmd(ua, _("Enter SQL list command: "))) { return 0; } + gui_save = ua->jcr->gui; + ua->jcr->gui = true; db_list_sql_query(ua->jcr, ua->db, ua->cmd, prtit, ua, 1, HORZ_LIST); + ua->jcr->gui = gui_save; done = false; break; case 4: /* Select the most recent backups */ diff --git a/bacula/src/filed/backup.c b/bacula/src/filed/backup.c index b558480f29..84df57311c 100644 --- a/bacula/src/filed/backup.c +++ b/bacula/src/filed/backup.c @@ -230,6 +230,9 @@ static int save_file(FF_PKT *ff_pkt, void *vjcr) if (ff_pkt->flags & FO_PORTABLE) { set_portable_backup(&ff_pkt->bfd); /* disable Win32 BackupRead() */ } + if (ff_pkt->reader) { + set_prog(&ff_pkt->bfd, ff_pkt->reader, jcr); + } /* * Open any file with data that we intend to save. diff --git a/bacula/src/filed/filed.c b/bacula/src/filed/filed.c index eea48245da..08131cc825 100644 --- a/bacula/src/filed/filed.c +++ b/bacula/src/filed/filed.c @@ -240,25 +240,25 @@ Without that I don't know who I am :-(\n"), configfile); if (inetd_request) { /* Socket is on fd 0 */ struct sockaddr client_addr; - int port = -1; - size_t client_addr_len = sizeof(client_addr); - if (getsockname(0, &client_addr, &client_addr_len) == 0) { - if (client_addr.sa_family == AF_INET) { - port = ((struct sockaddr_in*)&client_addr)->sin_port; - } + int port = -1; + socklen_t client_addr_len = sizeof(client_addr); + if (getsockname(0, &client_addr, &client_addr_len) == 0) { + if (client_addr.sa_family == AF_INET) { + port = ((struct sockaddr_in*)&client_addr)->sin_port; + } #ifdef HAVE_IPV6 - else if (client_addr.sa_family == AF_INET6) { - port = ((struct sockaddr_in6*)&client_addr)->sin6_port; - } + else if (client_addr.sa_family == AF_INET6) { + port = ((struct sockaddr_in6*)&client_addr)->sin6_port; + } #endif - } + } BSOCK *bs = init_bsock(NULL, 0, "client", "unknown client", port, &client_addr); handle_client_request((void *)bs); } else { /* Become server, and handle requests */ IPADDR *p; foreach_dlist(p, me->FDaddrs) { - Dmsg1(10, "filed: listening on port %d\n", ntohs(p->get_port())); + Dmsg1(10, "filed: listening on port %d\n", ntohs(p->get_port())); } bnet_thread_server(me->FDaddrs, me->MaxConcurrentJobs, &dir_workq, handle_client_request); } diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index f75a4c3226..3806a4b13b 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -238,6 +238,12 @@ void *handle_client_request(void *dirp) fo->regex.destroy(); fo->wild.destroy(); fo->base.destroy(); + if (fo->reader) { + free(fo->reader); + } + if (fo->writer) { + free(fo->writer); + } } incexe->opts_list.destroy(); incexe->name_list.destroy(); @@ -747,6 +753,16 @@ static void add_fileset(JCR *jcr, const char *item) set_options(current_opts, item); state = state_options; break; + case 'D': + current_opts = start_options(ff); + current_opts->reader = bstrdup(item); + state = state_options; + break; + case 'T': + current_opts = start_options(ff); + current_opts->writer = bstrdup(item); + state = state_options; + break; default: Jmsg(jcr, M_FATAL, 0, "Invalid FileSet command: %s\n", item); state = state_error; @@ -775,6 +791,12 @@ static bool term_fileset(JCR *jcr) for (k=0; kbase.size(); k++) { Dmsg1(400, "B %s\n", (char *)fo->base.get(k)); } + if (fo->reader) { + Dmsg1(400, "D %s\n", fo->reader); + } + if (fo->writer) { + Dmsg1(400, "T %s\n", fo->writer); + } } for (j=0; jname_list.size(); j++) { Dmsg1(400, "F %s\n", (char *)incexe->name_list.get(j)); diff --git a/bacula/src/findlib/bfile.c b/bacula/src/findlib/bfile.c index 0197bd3c40..c47afde496 100644 --- a/bacula/src/findlib/bfile.c +++ b/bacula/src/findlib/bfile.c @@ -105,10 +105,6 @@ void binit(BFILE *bfd) bfd->fid = -1; bfd->mode = BF_CLOSED; bfd->use_backup_api = have_win32_api(); - bfd->errmsg = NULL; - bfd->lpContext = NULL; - bfd->lerror = 0; - bfd->berrno = 0; } /* @@ -130,6 +126,12 @@ int set_portable_backup(BFILE *bfd) return 1; } +void set_prog(BFILE *bfd, char *prog, JCR *jcr) +{ + bfd->prog = prog; + bfd->jcr = jcr; +} + /* * Return 1 if we are NOT using Win32 BackupWrite() * return 0 if are @@ -462,6 +464,13 @@ int is_portable_backup(BFILE *bfd) return 1; /* portable by definition */ } +void set_prog(BFILE *bfd, char *prog, JCR *jcr) +{ + bfd->prog = prog; + bfd->jcr = jcr; +} + + int is_stream_supported(int stream) { /* No Win32 backup on this machine */ @@ -496,6 +505,34 @@ int is_stream_supported(int stream) int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode) { + /* Open reader/writer program */ + if (bfd->prog) { + POOLMEM *ecmd = get_pool_memory(PM_FNAME); + ecmd = edit_job_codes(bfd->jcr, ecmd, bfd->prog, fname); + char *pmode; + if (flags & O_RDONLY) { + pmode = "r"; + } else { + pmode = "w"; + } + bfd->bpipe = open_bpipe(ecmd, 0, pmode); + if (bfd->bpipe == NULL) { + bfd->berrno = errno; + bfd->fid = -1; + free_pool_memory(ecmd); + return -1; + } + free_pool_memory(ecmd); + if (flags & O_RDONLY) { + bfd->fid = fileno(bfd->bpipe->rfd); + } else { + bfd->fid = fileno(bfd->bpipe->wfd); + } + errno = 0; + return bfd->fid; + } + + /* Normal file open */ bfd->fid = open(fname, flags, mode); bfd->berrno = errno; Dmsg1(400, "Open file %d\n", bfd->fid); @@ -510,10 +547,19 @@ int bclose(BFILE *bfd) if (bfd->fid == -1) { return 0; } + /* Close reader/writer program */ + if (bfd->prog && bfd->bpipe) { + stat = close_bpipe(bfd->bpipe); + bfd->berrno = errno; + bfd->fid = -1; + bfd->bpipe = NULL; + return stat; + } + + /* Close normal file */ stat = close(bfd->fid); bfd->berrno = errno; bfd->fid = -1; - return stat; } diff --git a/bacula/src/findlib/bfile.h b/bacula/src/findlib/bfile.h index d65e5867b5..91beed66a7 100644 --- a/bacula/src/findlib/bfile.h +++ b/bacula/src/findlib/bfile.h @@ -58,6 +58,9 @@ struct BFILE { DWORD rw_bytes; /* Bytes read or written */ DWORD lerror; /* Last error code */ int berrno; /* errno */ + char *prog; /* reader/writer program if any */ + BPIPE *bpipe; /* pipe for reader */ + JCR *jcr; /* jcr for editing job codes */ }; HANDLE bget_handle(BFILE *bfd); @@ -75,6 +78,9 @@ HANDLE bget_handle(BFILE *bfd); struct BFILE { int fid; /* file id on Unix */ int berrno; + char *prog; /* reader/writer program if any */ + BPIPE *bpipe; /* pipe for reader */ + JCR *jcr; /* jcr for editing job codes */ }; #endif @@ -83,6 +89,7 @@ void binit(BFILE *bfd); int is_bopen(BFILE *bfd); int set_win32_backup(BFILE *bfd); int set_portable_backup(BFILE *bfd); +void set_prog(BFILE *bfd, char *prog, JCR *jcr); int have_win32_api(); int is_portable_backup(BFILE *bfd); int is_stream_supported(int stream); diff --git a/bacula/src/findlib/find.c b/bacula/src/findlib/find.c index 5efc669655..d676f96908 100644 --- a/bacula/src/findlib/find.c +++ b/bacula/src/findlib/find.c @@ -159,10 +159,12 @@ static bool accept_file(FF_PKT *ff) for (j=0; jopts_list.size(); j++) { findFOPTS *fo = (findFOPTS *)incexe->opts_list.get(j); + ff->flags = fo->flags; + ff->GZIP_level = fo->GZIP_level; + ff->reader = fo->reader; + ff->writer = fo->writer; for (k=0; kwild.size(); k++) { if (fnmatch((char *)fo->wild.get(k), ff->fname, 0) == 0) { - ff->flags = fo->flags; - ff->GZIP_level = fo->GZIP_level; if (ff->flags & FO_EXCLUDE) { return false; /* reject file */ } @@ -174,8 +176,6 @@ static bool accept_file(FF_PKT *ff) const int nmatch = 30; regmatch_t pmatch[nmatch]; if (regexec((regex_t *)fo->regex.get(k), ff->fname, nmatch, pmatch, 0) == 0) { - ff->flags = fo->flags; - ff->GZIP_level = fo->GZIP_level; if (ff->flags & FO_EXCLUDE) { return false; /* reject file */ } diff --git a/bacula/src/findlib/find.h b/bacula/src/findlib/find.h index 1bf334c125..5ca69c5797 100755 --- a/bacula/src/findlib/find.h +++ b/bacula/src/findlib/find.h @@ -67,38 +67,38 @@ int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result); * Status codes returned by create_file() */ enum { - CF_SKIP = 1, /* skip file (not newer or something) */ - CF_ERROR, /* error creating file */ - CF_EXTRACT, /* file created, data to extract */ - CF_CREATED /* file created, no data to extract */ + CF_SKIP = 1, /* skip file (not newer or something) */ + CF_ERROR, /* error creating file */ + CF_EXTRACT, /* file created, data to extract */ + CF_CREATED /* file created, no data to extract */ }; /* Options saved int "options" of the include/exclude lists. * They are directly jammed ito "flag" of ff packet */ -#define FO_MD5 (1<<1) /* Do MD5 checksum */ -#define FO_GZIP (1<<2) /* Do Zlib compression */ -#define FO_NO_RECURSION (1<<3) /* no recursion in directories */ -#define FO_MULTIFS (1<<4) /* multiple file systems */ -#define FO_SPARSE (1<<5) /* do sparse file checking */ -#define FO_IF_NEWER (1<<6) /* replace if newer */ -#define FO_NOREPLACE (1<<7) /* never replace */ -#define FO_READFIFO (1<<8) /* read data from fifo */ -#define FO_SHA1 (1<<9) /* Do SHA1 checksum */ -#define FO_PORTABLE (1<<10) /* Use portable data format -- no BackupWrite */ -#define FO_MTIMEONLY (1<<11) /* Use mtime rather than mtime & ctime */ -#define FO_KEEPATIME (1<<12) /* Reset access time */ -#define FO_EXCLUDE (1<<13) /* Exclude file */ -#define FO_ACL (1<<14) /* Backup ACLs */ +#define FO_MD5 (1<<1) /* Do MD5 checksum */ +#define FO_GZIP (1<<2) /* Do Zlib compression */ +#define FO_NO_RECURSION (1<<3) /* no recursion in directories */ +#define FO_MULTIFS (1<<4) /* multiple file systems */ +#define FO_SPARSE (1<<5) /* do sparse file checking */ +#define FO_IF_NEWER (1<<6) /* replace if newer */ +#define FO_NOREPLACE (1<<7) /* never replace */ +#define FO_READFIFO (1<<8) /* read data from fifo */ +#define FO_SHA1 (1<<9) /* Do SHA1 checksum */ +#define FO_PORTABLE (1<<10) /* Use portable data format -- no BackupWrite */ +#define FO_MTIMEONLY (1<<11) /* Use mtime rather than mtime & ctime */ +#define FO_KEEPATIME (1<<12) /* Reset access time */ +#define FO_EXCLUDE (1<<13) /* Exclude file */ +#define FO_ACL (1<<14) /* Backup ACLs */ struct s_included_file { struct s_included_file *next; - uint32_t options; /* backup options */ - int level; /* compression level */ - int len; /* length of fname */ - int pattern; /* set if wild card pattern */ - char VerifyOpts[20]; /* Options for verify */ + uint32_t options; /* backup options */ + int level; /* compression level */ + int len; /* length of fname */ + int pattern; /* set if wild card pattern */ + char VerifyOpts[20]; /* Options for verify */ char fname[1]; }; @@ -113,7 +113,7 @@ struct s_excluded_file { * of the structure are passed by the Director to the * File daemon and recompiled back into this structure */ -#undef MAX_FOPTS +#undef MAX_FOPTS #define MAX_FOPTS 30 enum { @@ -125,20 +125,22 @@ enum { /* File options structure */ struct findFOPTS { - uint32_t flags; /* options in bits */ - int GZIP_level; /* GZIP level */ - char VerifyOpts[MAX_FOPTS]; /* verify options */ - alist regex; /* regex string(s) */ - alist wild; /* wild card strings */ - alist base; /* list of base names */ + uint32_t flags; /* options in bits */ + int GZIP_level; /* GZIP level */ + char VerifyOpts[MAX_FOPTS]; /* verify options */ + alist regex; /* regex string(s) */ + alist wild; /* wild card strings */ + alist base; /* list of base names */ + char *reader; /* reader program */ + char *writer; /* writer program */ }; /* This is either an include item or an exclude item */ struct findINCEXE { - findFOPTS *current_opts; /* points to current options structure */ - alist opts_list; /* options list */ - alist name_list; /* filename list -- holds char * */ + findFOPTS *current_opts; /* points to current options structure */ + alist opts_list; /* options list */ + alist name_list; /* filename list -- holds char * */ }; /* @@ -147,7 +149,7 @@ struct findINCEXE { */ struct findFILESET { int state; - findINCEXE *incexe; /* current item */ + findINCEXE *incexe; /* current item */ alist include_list; alist exclude_list; }; @@ -158,22 +160,20 @@ struct findFILESET { * first argument to the find_files callback subroutine. */ struct FF_PKT { - char *fname; /* filename */ - char *link; /* link if file linked */ - POOLMEM *sys_fname; /* system filename */ - struct stat statp; /* stat packet */ - int32_t FileIndex; /* FileIndex of this file */ - int32_t LinkFI; /* FileIndex of main hard linked file */ - struct f_link *linked; /* Set if this file is hard linked */ - int type; /* FT_ type from above */ - uint32_t flags; /* backup options */ - int ff_errno; /* errno */ - BFILE bfd; /* Bacula file descriptor */ - time_t save_time; /* start of incremental time */ - bool dereference; /* follow links (not implemented) */ - bool null_output_device; /* using null output device */ - bool incremental; /* incremental save */ - int GZIP_level; /* compression level */ + char *fname; /* filename */ + char *link; /* link if file linked */ + POOLMEM *sys_fname; /* system filename */ + struct stat statp; /* stat packet */ + int32_t FileIndex; /* FileIndex of this file */ + int32_t LinkFI; /* FileIndex of main hard linked file */ + struct f_link *linked; /* Set if this file is hard linked */ + int type; /* FT_ type from above */ + int ff_errno; /* errno */ + BFILE bfd; /* Bacula file descriptor */ + time_t save_time; /* start of incremental time */ + bool dereference; /* follow links (not implemented) */ + bool null_output_device; /* using null output device */ + bool incremental; /* incremental save */ char VerifyOpts[20]; struct s_included_file *included_files_list; struct s_excluded_file *excluded_files_list; @@ -181,8 +181,14 @@ struct FF_PKT { findFILESET *fileset; int (*callback)(FF_PKT *, void *); /* User's callback */ + /* Values set by accept_file while processing Options */ + uint32_t flags; /* backup options */ + int GZIP_level; /* compression level */ + char *reader; /* reader program */ + char *writer; /* writer program */ + /* List of all hard linked files found */ - struct f_link *linklist; /* hard linked files */ + struct f_link *linklist; /* hard linked files */ }; diff --git a/bacula/src/lib/bnet.c b/bacula/src/lib/bnet.c index 58272bbe6f..ca87ab7bb4 100644 --- a/bacula/src/lib/bnet.c +++ b/bacula/src/lib/bnet.c @@ -671,7 +671,7 @@ static BSOCK *bnet_open(JCR * jcr, const char *name, char *host, char *service, foreach_dlist(ipaddr, addr_list) { ipaddr->set_port(htons(port)); - char allbuf[256 * addr_list->size()]; + char allbuf[256 * 10]; char curbuf[256]; Dmsg2(100, "Current %sAll %s\n", ipaddr->build_address_str(curbuf, sizeof(curbuf)), diff --git a/bacula/src/lib/bnet_server.c b/bacula/src/lib/bnet_server.c index 6f8e38e1b1..aafd216ea7 100644 --- a/bacula/src/lib/bnet_server.c +++ b/bacula/src/lib/bnet_server.c @@ -83,7 +83,7 @@ bnet_thread_server(dlist *addrs, int max_clients, workq_t *client_wq, char buf[128]; dlist sockfds; - char allbuf[256 * addrs->size()]; + char allbuf[256 * 10]; Dmsg1(100, "Addresses %s\n", build_addresses_str(addrs, allbuf, sizeof(allbuf))); foreach_dlist(p, addrs) { diff --git a/bacula/src/lib/bpipe.h b/bacula/src/lib/bpipe.h index 3372792717..de9c98951f 100644 --- a/bacula/src/lib/bpipe.h +++ b/bacula/src/lib/bpipe.h @@ -5,7 +5,7 @@ */ /* - Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker + Copyright (C) 2002-2004 Kern Sibbald and John Walker This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as diff --git a/bacula/src/win32/baculafd/baculafd.mak b/bacula/src/win32/baculafd/baculafd.mak index ee1d3b01d3..ac93adabdc 100644 --- a/bacula/src/win32/baculafd/baculafd.mak +++ b/bacula/src/win32/baculafd/baculafd.mak @@ -40,6 +40,7 @@ ALL : "$(OUTDIR)\bacula-fd.exe" CLEAN : + -@erase "$(INTDIR)\address_conf.obj" -@erase "$(INTDIR)\alist.obj" -@erase "$(INTDIR)\alloc.obj" -@erase "$(INTDIR)\attr.obj" @@ -127,6 +128,7 @@ BSC32_SBRS= \ LINK32=link.exe LINK32_FLAGS=user32.lib advapi32.lib gdi32.lib wsock32.lib shell32.lib pthreadVCE.lib zlib.lib /nologo /subsystem:windows /pdb:none /machine:I386 /nodefaultlib:"MSVCRT.lib" /out:"$(OUTDIR)\bacula-fd.exe" /libpath:"../../../../depkgs-win32/pthreads" /libpath:"../../../../depkgs-win32/zlib" LINK32_OBJS= \ + "$(INTDIR)\address_conf.obj" \ "$(INTDIR)\alist.obj" \ "$(INTDIR)\alloc.obj" \ "$(INTDIR)\attr.obj" \ @@ -217,6 +219,8 @@ ALL : "$(OUTDIR)\bacula-fd.exe" "$(OUTDIR)\baculafd.bsc" CLEAN : + -@erase "$(INTDIR)\address_conf.obj" + -@erase "$(INTDIR)\address_conf.sbr" -@erase "$(INTDIR)\alist.obj" -@erase "$(INTDIR)\alist.sbr" -@erase "$(INTDIR)\alloc.obj" @@ -373,6 +377,7 @@ RSC_PROJ=/l 0x409 /fo"$(INTDIR)\winres.res" /d "_DEBUG" BSC32=bscmake.exe BSC32_FLAGS=/nologo /o"$(OUTDIR)\baculafd.bsc" BSC32_SBRS= \ + "$(INTDIR)\address_conf.sbr" \ "$(INTDIR)\alist.sbr" \ "$(INTDIR)\alloc.sbr" \ "$(INTDIR)\attr.sbr" \ @@ -453,6 +458,7 @@ BSC32_SBRS= \ LINK32=link.exe LINK32_FLAGS=user32.lib advapi32.lib gdi32.lib shell32.lib wsock32.lib pthreadVCE.lib zlib.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /pdb:none /debug /machine:I386 /nodefaultlib:"MSVCRT.lib" /out:"$(OUTDIR)\bacula-fd.exe" /libpath:"../../../../depkgs-win32/pthreads" /libpath:"../../../../depkgs-win32/zlib" LINK32_OBJS= \ + "$(INTDIR)\address_conf.obj" \ "$(INTDIR)\alist.obj" \ "$(INTDIR)\alloc.obj" \ "$(INTDIR)\attr.obj" \ @@ -574,6 +580,25 @@ LINK32_OBJS= \ !IF "$(CFG)" == "baculafd - Win32 Release" || "$(CFG)" == "baculafd - Win32 Debug" + +SOURCE=..\lib\address_conf.cpp + +!IF "$(CFG)" == "baculafd - Win32 Release" + + +"$(INTDIR)\address_conf.obj" : $(SOURCE) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +!ELSEIF "$(CFG)" == "baculafd - Win32 Debug" + + +"$(INTDIR)\address_conf.obj" "$(INTDIR)\address_conf.sbr" : $(SOURCE) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +!ENDIF + SOURCE=..\lib\alist.cpp !IF "$(CFG)" == "baculafd - Win32 Release" @@ -592,6 +617,7 @@ SOURCE=..\lib\alist.cpp !ENDIF + SOURCE=..\lib\alloc.cpp !IF "$(CFG)" == "baculafd - Win32 Release" diff --git a/bacula/src/win32/console/console.mak b/bacula/src/win32/console/console.mak index 5ac8c61c93..d9715ff19b 100644 --- a/bacula/src/win32/console/console.mak +++ b/bacula/src/win32/console/console.mak @@ -40,6 +40,7 @@ ALL : "$(OUTDIR)\bconsole.exe" "$(OUTDIR)\console.pch" CLEAN : + -@erase "$(INTDIR)\address_conf.obj" -@erase "$(INTDIR)\alist.obj" -@erase "$(INTDIR)\authenticate.obj" -@erase "$(INTDIR)\base64.obj" @@ -89,6 +90,7 @@ BSC32_SBRS= \ LINK32=link.exe LINK32_FLAGS=wsock32.lib pthreadVCE.lib /nologo /subsystem:console /pdb:none /machine:I386 /out:"$(OUTDIR)\bconsole.exe" /libpath:"../../../../depkgs-win32/pthreads" LINK32_OBJS= \ + "$(INTDIR)\address_conf.obj" \ "$(INTDIR)\alist.obj" \ "$(INTDIR)\authenticate.obj" \ "$(INTDIR)\base64.obj" \ @@ -141,6 +143,7 @@ ALL : "$(OUTDIR)\bconsole.exe" "$(OUTDIR)\console.pch" CLEAN : + -@erase "$(INTDIR)\address_conf.obj" -@erase "$(INTDIR)\alist.obj" -@erase "$(INTDIR)\authenticate.obj" -@erase "$(INTDIR)\base64.obj" @@ -191,6 +194,7 @@ BSC32_SBRS= \ LINK32=link.exe LINK32_FLAGS=wsock32.lib pthreadVCE.lib /nologo /subsystem:console /pdb:none /debug /machine:I386 /out:"$(OUTDIR)\bconsole.exe" /libpath:"../../../../depkgs-win32/pthreads" LINK32_OBJS= \ + "$(INTDIR)\address_conf.obj" \ "$(INTDIR)\alist.obj" \ "$(INTDIR)\authenticate.obj" \ "$(INTDIR)\base64.obj" \ @@ -274,12 +278,19 @@ LINK32_OBJS= \ !IF "$(CFG)" == "console - Win32 Release" || "$(CFG)" == "console - Win32 Debug" + +SOURCE=..\lib\address_conf.cpp + +"$(INTDIR)\address_conf.obj" : $(SOURCE) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + SOURCE=..\lib\alist.cpp "$(INTDIR)\alist.obj" : $(SOURCE) "$(INTDIR)" $(CPP) $(CPP_PROJ) $(SOURCE) + SOURCE=.\authenticate.cpp "$(INTDIR)\authenticate.obj" : $(SOURCE) "$(INTDIR)" diff --git a/bacula/src/win32/lib/address_conf.cpp b/bacula/src/win32/lib/address_conf.cpp new file mode 100755 index 0000000000..7cc33e14be --- /dev/null +++ b/bacula/src/win32/lib/address_conf.cpp @@ -0,0 +1 @@ +#include "../../lib/address_conf.c" diff --git a/bacula/src/win32/wx-console/filelist b/bacula/src/win32/wx-console/filelist index aa737be66b..82362c37ba 100644 --- a/bacula/src/win32/wx-console/filelist +++ b/bacula/src/win32/wx-console/filelist @@ -1,3 +1,4 @@ +..\lib\address_conf ..\lib\alist ..\lib\alloc ..\lib\attr diff --git a/bacula/src/win32/wx-console/wx-console.mak b/bacula/src/win32/wx-console/wx-console.mak index ec3a9a2cf5..10d867ad13 100644 --- a/bacula/src/win32/wx-console/wx-console.mak +++ b/bacula/src/win32/wx-console/wx-console.mak @@ -40,6 +40,7 @@ ALL : "$(OUTDIR)\wx-console.exe" CLEAN : + -@erase "$(INTDIR)\address_conf.obj" -@erase "$(INTDIR)\alist.obj" -@erase "$(INTDIR)\alloc.obj" -@erase "$(INTDIR)\attr.obj" @@ -113,6 +114,7 @@ LINK32_FLAGS=wxmsw.lib rpcrt4.lib oleaut32.lib ole32.lib uuid.lib winspool.lib w wldap32.lib pthreadVCE.lib zlib.lib /nodefaultlib:libcmt.lib \ /nologo /subsystem:windows /machine:I386 /out:"$(OUTDIR)\wx-console.exe" /libpath:"../../../../depkgs-win32/wx/lib" /libpath:"../../../../depkgs-win32/pthreads" /libpath:"../../../../depkgs-win32/zlib" LINK32_OBJS= \ + "$(INTDIR)\address_conf.obj" \ "$(INTDIR)\alist.obj" \ "$(INTDIR)\alloc.obj" \ "$(INTDIR)\attr.obj" \ @@ -187,6 +189,8 @@ OutDir=.\Debug ALL : "$(OUTDIR)\wx-console.exe" "$(OUTDIR)\wx-console.bsc" CLEAN : + -@erase "$(INTDIR)\address_conf.obj + -@erase "$(INTDIR)\address_conf.sbr" -@erase "$(INTDIR)\alist.obj -@erase "$(INTDIR)\alist.sbr" -@erase "$(INTDIR)\alloc.obj @@ -311,6 +315,7 @@ RSC_PROJ=/l 0x409 /fo"$(INTDIR)\winres.res" /d "_DEBUG" BSC32=bscmake.exe BSC32_FLAGS=/nologo /o"$(OUTDIR)\wx-console.bsc" BSC32_SBRS= \ + "$(INTDIR)\address_conf.sbr" \ "$(INTDIR)\alist.sbr" \ "$(INTDIR)\alloc.sbr" \ "$(INTDIR)\attr.sbr" \ @@ -379,6 +384,7 @@ LINK32_FLAGS=wxmswd.lib rpcrt4.lib oleaut32.lib ole32.lib uuid.lib winspool.lib wldap32.lib pthreadVCE.lib zlib.lib /nodefaultlib:libcmtd.lib \ /nologo /subsystem:windows /pdb:none /debug /machine:I386 /out:"$(OUTDIR)\wx-console.exe" /libpath:"../../../../depkgs-win32/wx/lib" /libpath:"../../../../depkgs-win32/pthreads" /libpath:"../../../../depkgs-win32/zlib" LINK32_OBJS= \ + "$(INTDIR)\address_conf.obj" \ "$(INTDIR)\alist.obj" \ "$(INTDIR)\alloc.obj" \ "$(INTDIR)\attr.obj" \ @@ -488,6 +494,25 @@ SOURCE=..\..\wx-console\wx-console_private.rc "$(INTDIR)\wx-console_private.res" : $(SOURCE) "$(INTDIR)" $(RSC) /l 0x409 /fo"$(INTDIR)\wx-console_private.res" /d "NDEBUG" $(SOURCE) +FILENAME=address_conf +SOURCE=..\lib\address_conf.cpp +!IF "$(CFG)" == "wx-console - Win32 Release" + + +"$(INTDIR)\$(FILENAME).obj" : $(SOURCE) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +!ELSEIF "$(CFG)" == "wx-console - Win32 Debug" + + +"$(INTDIR)\$(FILENAME).obj" "$(INTDIR)\$(FILENAME).sbr" : $(SOURCE) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +!ENDIF + + FILENAME=alist SOURCE=..\lib\alist.cpp !IF "$(CFG)" == "wx-console - Win32 Release" -- 2.39.5