From 66696d1cadedbb362c392dadce9a8ce275dd5d80 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Tue, 21 Dec 2004 16:19:00 +0000 Subject: [PATCH] Apply Preben 'Peppe' Guldberg three patches that clean up white space: ws.patch.02.strings: Breaks strings that span lines into concatenated strings. I am not sure if you like this one. Other code works with concatenated strings, though. ws.patch.03.trailing: This removes trailing whitespace. No changes resulted from this for my setup. ws.patch.04.leading: This replaces space runs at the start of line with tabs. No changes again. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1769 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/patches/1.36.1-store.patch | 802 ++++++++++++++++++++++++++++ bacula/patches/patches-1.36.1 | 6 + bacula/src/baconfig.h | 32 +- bacula/src/bacula.h | 4 +- bacula/src/bc_types.h | 16 +- bacula/src/cats/bdb.c | 54 +- bacula/src/cats/bdb_create.c | 18 +- bacula/src/cats/bdb_delete.c | 14 +- bacula/src/cats/bdb_find.c | 44 +- bacula/src/cats/bdb_get.c | 52 +- bacula/src/cats/bdb_list.c | 48 +- bacula/src/cats/bdb_update.c | 26 +- bacula/src/cats/cats.h | 34 +- bacula/src/cats/mysql.c | 58 +- bacula/src/cats/postgresql.c | 58 +- bacula/src/cats/protos.h | 8 +- bacula/src/cats/sql.c | 74 +-- bacula/src/cats/sql_create.c | 144 ++--- bacula/src/cats/sql_delete.c | 26 +- bacula/src/cats/sql_find.c | 70 +-- bacula/src/cats/sql_get.c | 234 ++++---- bacula/src/cats/sql_list.c | 168 +++--- bacula/src/cats/sql_update.c | 100 ++-- bacula/src/cats/sqlite.c | 36 +- bacula/src/console/authenticate.c | 10 +- bacula/src/console/conio.c | 62 +-- bacula/src/console/console.c | 86 +-- bacula/src/console/console_conf.c | 38 +- bacula/src/console/console_conf.h | 2 +- bacula/src/dird/admin.c | 24 +- bacula/src/dird/authenticate.c | 46 +- bacula/src/dird/autoprune.c | 22 +- bacula/src/dird/backup.c | 138 ++--- bacula/src/dird/bsr.c | 70 +-- bacula/src/dird/bsr.h | 8 +- bacula/src/dird/catreq.c | 100 ++-- bacula/src/dird/dird.c | 98 ++-- bacula/src/dird/dird_conf.c | 272 +++++----- bacula/src/dird/dird_conf.h | 28 +- bacula/src/dird/expand.c | 62 +-- bacula/src/dird/fd_cmds.c | 204 +++---- bacula/src/dird/getmsg.c | 52 +- bacula/src/dird/inc_conf.c | 73 +-- bacula/src/dird/job.c | 51 +- bacula/src/dird/jobq.c | 112 ++-- bacula/src/dird/jobq.h | 8 +- bacula/src/dird/mac.c | 126 ++--- bacula/src/dird/msgchan.c | 46 +- bacula/src/dird/newvol.c | 16 +- bacula/src/dird/next_vol.c | 100 ++-- bacula/src/dird/protos.h | 8 +- bacula/src/dird/python.c | 12 +- bacula/src/dird/recycle.c | 14 +- bacula/src/dird/restore.c | 76 +-- bacula/src/dird/run_conf.c | 112 ++-- bacula/src/dird/scheduler.c | 56 +- bacula/src/dird/sql_cmds.c | 44 +- bacula/src/dird/ua.h | 2 +- bacula/src/dird/ua_acl.c | 8 +- bacula/src/dird/ua_cmds.c | 310 +++++------ bacula/src/dird/ua_dotcmds.c | 30 +- bacula/src/dird/ua_input.c | 10 +- bacula/src/dird/ua_label.c | 162 +++--- bacula/src/dird/ua_output.c | 116 ++-- bacula/src/dird/ua_prune.c | 76 +-- bacula/src/dird/ua_purge.c | 80 +-- bacula/src/dird/ua_query.c | 66 +-- bacula/src/dird/ua_restore.c | 182 +++---- bacula/src/dird/ua_run.c | 262 ++++----- bacula/src/dird/ua_select.c | 134 ++--- bacula/src/dird/ua_server.c | 14 +- bacula/src/dird/ua_status.c | 140 ++--- bacula/src/dird/ua_tree.c | 94 ++-- bacula/src/dird/verify.c | 234 ++++---- bacula/src/filed/authenticate.c | 36 +- bacula/src/filed/backup.c | 154 +++--- bacula/src/filed/chksum.c | 2 +- bacula/src/filed/estimate.c | 18 +- bacula/src/filed/filed.c | 26 +- bacula/src/filed/filed.h | 2 +- bacula/src/filed/filed_conf.c | 58 +- bacula/src/filed/filed_conf.h | 2 +- bacula/src/filed/heartbeat.c | 12 +- bacula/src/filed/job.c | 234 ++++---- bacula/src/filed/restore.c | 200 +++---- bacula/src/filed/status.c | 98 ++-- bacula/src/filed/verify.c | 40 +- bacula/src/filed/verify_vol.c | 78 +-- bacula/src/filed/win32/popup.c | 8 +- bacula/src/filed/win32/winabout.h | 2 +- bacula/src/filed/win32/winservice.h | 4 +- bacula/src/filed/win32/winstat.h | 2 +- bacula/src/filed/win32/wintray.h | 2 +- bacula/src/findlib/attribs.c | 62 +-- bacula/src/findlib/bfile.c | 44 +- bacula/src/findlib/bfile.h | 8 +- bacula/src/findlib/create_file.c | 74 +-- bacula/src/findlib/enable_priv.c | 20 +- bacula/src/findlib/find.c | 32 +- bacula/src/findlib/find.h | 12 +- bacula/src/findlib/find_one.c | 56 +- bacula/src/findlib/fstype.c | 24 +- bacula/src/findlib/makepath.c | 68 +-- bacula/src/findlib/match.c | 74 +-- bacula/src/findlib/protos.h | 4 +- bacula/src/findlib/save-cwd.c | 14 +- bacula/src/findlib/save-cwd.h | 2 +- bacula/src/findlib/winapi.c | 2 +- bacula/src/findlib/winapi.h | 4 +- bacula/src/jcr.h | 16 +- bacula/src/lib/address_conf.c | 96 ++-- bacula/src/lib/address_conf.h | 2 +- bacula/src/lib/alist.c | 18 +- bacula/src/lib/alist.h | 14 +- bacula/src/lib/alloc.c | 8 +- bacula/src/lib/attr.c | 30 +- bacula/src/lib/attr.h | 6 +- bacula/src/lib/base64.c | 36 +- bacula/src/lib/berrno.c | 10 +- bacula/src/lib/berrno.h | 8 +- bacula/src/lib/bget_msg.c | 22 +- bacula/src/lib/bits.h | 4 +- bacula/src/lib/bnet.c | 76 +-- bacula/src/lib/bnet_pkt.c | 12 +- bacula/src/lib/bnet_server.c | 54 +- bacula/src/lib/bpipe.c | 48 +- bacula/src/lib/bpipe.h | 2 +- bacula/src/lib/bsd_queue.h | 440 +++++++-------- bacula/src/lib/bshm.c | 14 +- bacula/src/lib/bsock.h | 6 +- bacula/src/lib/bsys.c | 60 +-- bacula/src/lib/btime.c | 30 +- bacula/src/lib/btime.h | 2 +- bacula/src/lib/btimers.c | 12 +- bacula/src/lib/btimers.h | 2 +- bacula/src/lib/cram-md5.c | 6 +- bacula/src/lib/crc32.c | 4 +- bacula/src/lib/daemon.c | 10 +- bacula/src/lib/dlist.c | 34 +- bacula/src/lib/dlist.h | 18 +- bacula/src/lib/edit.c | 46 +- bacula/src/lib/events.c | 26 +- bacula/src/lib/fnmatch.c | 76 +-- bacula/src/lib/getopt.h | 6 +- bacula/src/lib/hmac.c | 4 +- bacula/src/lib/htable.c | 28 +- bacula/src/lib/htable.h | 8 +- bacula/src/lib/jcr.c | 66 +-- bacula/src/lib/lex.c | 447 ++++++++-------- bacula/src/lib/lex.h | 11 +- bacula/src/lib/lib.h | 2 +- bacula/src/lib/md5.c | 4 +- bacula/src/lib/mem_pool.c | 20 +- bacula/src/lib/mem_pool.h | 10 +- bacula/src/lib/message.c | 242 ++++----- bacula/src/lib/message.h | 4 +- bacula/src/lib/parse_conf.c | 130 ++--- bacula/src/lib/parse_conf.h | 10 +- bacula/src/lib/protos.h | 22 +- bacula/src/lib/python.c | 16 +- bacula/src/lib/queue.c | 12 +- bacula/src/lib/rwlock.c | 70 +-- bacula/src/lib/rwlock.h | 6 +- bacula/src/lib/scan.c | 68 +-- bacula/src/lib/semlock.c | 60 +-- bacula/src/lib/semlock.h | 6 +- bacula/src/lib/serial.c | 4 +- bacula/src/lib/serial.h | 6 +- bacula/src/lib/sha1.c | 20 +- bacula/src/lib/sha1.h | 8 +- bacula/src/lib/signal.c | 84 +-- bacula/src/lib/smartall.c | 66 +-- bacula/src/lib/smartall.h | 32 +- bacula/src/lib/tcpd.h | 12 +- bacula/src/lib/tree.c | 50 +- bacula/src/lib/tree.h | 8 +- bacula/src/lib/util.c | 102 ++-- bacula/src/lib/var.c | 400 +++++++------- bacula/src/lib/var.h | 2 +- bacula/src/lib/waitq.h | 6 +- bacula/src/lib/watchdog.c | 28 +- bacula/src/lib/watchdog.h | 22 +- bacula/src/lib/workq.c | 52 +- bacula/src/lib/workq.h | 14 +- bacula/src/stored/acquire.c | 94 ++-- bacula/src/stored/append.c | 68 +-- bacula/src/stored/askdir.c | 134 ++--- bacula/src/stored/authenticate.c | 28 +- bacula/src/stored/autochanger.c | 92 ++-- bacula/src/stored/bcopy.c | 44 +- bacula/src/stored/bextract.c | 72 +-- bacula/src/stored/block.c | 122 ++--- bacula/src/stored/block.h | 2 +- bacula/src/stored/bls.c | 58 +- bacula/src/stored/bscan.c | 182 +++---- bacula/src/stored/bsr.h | 22 +- bacula/src/stored/btape.c | 546 +++++++++---------- bacula/src/stored/butil.c | 34 +- bacula/src/stored/dev.c | 220 ++++---- bacula/src/stored/dev.h | 18 +- bacula/src/stored/device.c | 58 +- bacula/src/stored/dircmd.c | 212 ++++---- bacula/src/stored/fd_cmds.c | 28 +- bacula/src/stored/job.c | 56 +- bacula/src/stored/label.c | 204 +++---- bacula/src/stored/match_bsr.c | 24 +- bacula/src/stored/mount.c | 98 ++-- bacula/src/stored/parse_bsr.c | 74 +-- bacula/src/stored/protos.h | 10 +- bacula/src/stored/read.c | 12 +- bacula/src/stored/read_record.c | 66 +-- bacula/src/stored/record.c | 82 +-- bacula/src/stored/record.h | 14 +- bacula/src/stored/spool.c | 70 +-- bacula/src/stored/status.c | 78 +-- bacula/src/stored/stored.c | 44 +- bacula/src/stored/stored_conf.c | 80 +-- bacula/src/stored/stored_conf.h | 2 +- bacula/src/tools/bsmtp.c | 64 +-- bacula/src/tools/dbcheck.c | 308 +++++------ bacula/src/tools/fstype.c | 18 +- bacula/src/tools/testfind.c | 78 +-- bacula/src/tools/testls.c | 24 +- bacula/src/version.h | 4 +- 224 files changed, 7690 insertions(+), 6870 deletions(-) create mode 100644 bacula/patches/1.36.1-store.patch diff --git a/bacula/patches/1.36.1-store.patch b/bacula/patches/1.36.1-store.patch new file mode 100644 index 0000000000..8b0a926a16 --- /dev/null +++ b/bacula/patches/1.36.1-store.patch @@ -0,0 +1,802 @@ + This patch fixes a problem with overriding storage daemon + specifications. Previously they were not always honored. + This implements more uniform handling. It also eliminates + an orphaned buffer situation using JobDefs. + Apply to version 1.36.1 with: + + cd + patch -p0 <1.36.1-store.patch + make + make install + ... + +Index: src/dird/job.c +=================================================================== +RCS file: /cvsroot/bacula/bacula/src/dird/job.c,v +retrieving revision 1.92 +diff -u -r1.92 job.c +--- src/dird/job.c 21 Nov 2004 13:10:15 -0000 1.92 ++++ src/dird/job.c 21 Dec 2004 13:04:08 -0000 +@@ -4,10 +4,10 @@ + * + * Kern Sibbald, October MM + * +- * Version $Id$ ++ * Version $Id$ + */ + /* +- Copyright (C) 2000-2004 Kern Sibbald and John Walker ++ Copyright (C) 2000-2004 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 +@@ -344,7 +344,7 @@ + if (!ua->jcr->storage[0]) { + copy_storage(ua->jcr, jcr); + } else { +- ua->jcr->store = jcr->store; ++ set_storage(ua->jcr, jcr->store); + } + if (!connect_to_storage_daemon(ua->jcr, 10, SDConnectTimeout, 1)) { + bsendmsg(ua, _("Failed to connect to Storage daemon.\n")); +@@ -724,6 +724,12 @@ + if (jcr->term_wait_inited) { + pthread_cond_destroy(&jcr->term_wait); + } ++ /* Delete lists setup to hold storage pointers */ ++ for (int i=0; istorage[i]) { ++ delete jcr->storage[i]; ++ } ++ } + jcr->job_end_push.destroy(); + Dmsg0(200, "End dird free_jcr\n"); + } +@@ -749,10 +755,17 @@ + break; + } + jcr->JobPriority = job->Priority; ++ /* Copy storage definitions -- deleted in dir_free_jcr above */ + for (int i=0; istorage[i] = job->storage[i]; ++ STORE *st; ++ if (job->storage[i]) { ++ jcr->storage[i] = New(alist(10, not_owned_by_alist)); ++ foreach_alist(st, job->storage[i]) { ++ jcr->storage[i]->append(st); ++ } ++ } + } +- if (!jcr->store && jcr->storage[0]) { ++ if (jcr->storage[0]) { + jcr->store = (STORE *)jcr->storage[0]->first(); + } + jcr->client = job->client; +@@ -805,6 +818,9 @@ + for (int i=0; i < MAX_STORE; i++) { + if (old_jcr->storage[i]) { + STORE *st; ++ if (old_jcr->storage[i]) { ++ delete old_jcr->storage[i]; ++ } + new_jcr->storage[i] = New(alist(10, not_owned_by_alist)); + foreach_alist(st, old_jcr->storage[i]) { + new_jcr->storage[i]->append(st); +@@ -817,3 +833,10 @@ + } + } + } ++ ++/* Set storage override */ ++void set_storage(JCR *jcr, STORE *store) ++{ ++ jcr->store = store; ++ jcr->storage[0]->prepend(store); ++} +Index: src/dird/msgchan.c +=================================================================== +RCS file: /cvsroot/bacula/bacula/src/dird/msgchan.c,v +retrieving revision 1.32 +diff -u -r1.32 msgchan.c +--- src/dird/msgchan.c 29 Sep 2004 19:58:17 -0000 1.32 ++++ src/dird/msgchan.c 21 Dec 2004 13:04:08 -0000 +@@ -13,10 +13,10 @@ + * Create a thread to interact with the Storage daemon + * who returns a job status and requests Catalog services, etc. + * +- * Version $Id$ ++ * Version $Id$ + */ + /* +- Copyright (C) 2000-2004 Kern Sibbald and John Walker ++ Copyright (C) 2000-2004 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 +@@ -64,10 +64,9 @@ + int max_retry_time, int verbose) + { + BSOCK *sd; +- STORE *store = jcr->store; +- if (!store) { +- jcr->store = store = (STORE *)jcr->storage[0]->first(); +- } ++ STORE *store; ++ ++ store = (STORE *)jcr->storage[0]->first(); + + /* + * Open message channel with the Storage daemon +@@ -94,13 +93,13 @@ + */ + int start_storage_daemon_job(JCR *jcr) + { +- int status; ++ int status = 0; + STORE *storage; + BSOCK *sd; + char auth_key[100]; + POOL_MEM device_name, pool_name, pool_type, media_type; ++ int i; + +- storage = jcr->store; + sd = jcr->store_bsock; + /* + * Now send JobId and permissions, and get back the authorization key. +@@ -139,23 +138,29 @@ + /* + * Send use device = xxx media = yyy pool = zzz + */ +- pm_strcpy(device_name, storage->dev_name); +- pm_strcpy(media_type, storage->media_type); +- pm_strcpy(pool_type, jcr->pool->pool_type); +- pm_strcpy(pool_name, jcr->pool->hdr.name); +- bash_spaces(device_name); +- bash_spaces(media_type); +- bash_spaces(pool_type); +- bash_spaces(pool_name); +- bnet_fsend(sd, use_device, device_name.c_str(), +- media_type.c_str(), pool_name.c_str(), pool_type.c_str()); +- Dmsg1(110, ">stored: %s", sd->msg); +- status = response(jcr, sd, OK_device, "Use Device", NO_DISPLAY); +- if (!status) { +- pm_strcpy(pool_type, sd->msg); /* save message */ +- Jmsg(jcr, M_FATAL, 0, _("\n" +- " Storage daemon didn't accept Device \"%s\" because:\n %s"), +- device_name.c_str(), pool_type.c_str()/* sd->msg */); ++ ++ for (i=0; i < MAX_STORE; i++) { ++ if (jcr->storage[i]) { ++ storage = (STORE *)jcr->storage[i]->first(); ++ pm_strcpy(device_name, storage->dev_name); ++ pm_strcpy(media_type, storage->media_type); ++ pm_strcpy(pool_type, jcr->pool->pool_type); ++ pm_strcpy(pool_name, jcr->pool->hdr.name); ++ bash_spaces(device_name); ++ bash_spaces(media_type); ++ bash_spaces(pool_type); ++ bash_spaces(pool_name); ++ bnet_fsend(sd, use_device, device_name.c_str(), ++ media_type.c_str(), pool_name.c_str(), pool_type.c_str()); ++ Dmsg1(110, ">stored: %s", sd->msg); ++ status = response(jcr, sd, OK_device, "Use Device", NO_DISPLAY); ++ if (!status) { ++ pm_strcpy(pool_type, sd->msg); /* save message */ ++ Jmsg(jcr, M_FATAL, 0, _("\n" ++ " Storage daemon didn't accept Device \"%s\" because:\n %s"), ++ device_name.c_str(), pool_type.c_str()/* sd->msg */); ++ } ++ } + } + return status; + } +Index: src/dird/protos.h +=================================================================== +RCS file: /cvsroot/bacula/bacula/src/dird/protos.h,v +retrieving revision 1.56 +diff -u -r1.56 protos.h +--- src/dird/protos.h 17 Nov 2004 22:48:22 -0000 1.56 ++++ src/dird/protos.h 21 Dec 2004 13:04:08 -0000 +@@ -1,7 +1,7 @@ + /* + * Director external function prototypes + * +- * Version $Id$ ++ * Version $Id$ + */ + /* + Copyright (C) 2000-2004 Kern Sibbald and John Walker +@@ -62,7 +62,7 @@ + + /* fd_cmds.c */ + extern int connect_to_file_daemon(JCR *jcr, int retry_interval, +- int max_retry_time, int verbose); ++ 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); +@@ -70,7 +70,7 @@ + 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, +- char *link, char *attr, int stream); ++ char *link, char *attr, int stream); + extern void get_level_since_time(JCR *jcr, char *since, int since_len); + extern int send_run_before_and_after_commands(JCR *jcr); + +@@ -91,13 +91,14 @@ + extern int cancel_job(UAContext *ua, JCR *jcr); + extern void init_jcr_job_record(JCR *jcr); + extern void copy_storage(JCR *new_jcr, JCR *old_jcr); ++extern void set_storage(JCR *jcr, STORE *store); + + /* mountreq.c */ + extern void mount_request(JCR *jcr, BSOCK *bs, char *buf); + + /* msgchan.c */ + extern bool connect_to_storage_daemon(JCR *jcr, int retry_interval, +- int max_retry_time, int verbose); ++ int max_retry_time, int verbose); + extern int start_storage_daemon_job(JCR *jcr); + extern int start_storage_daemon_message_thread(JCR *jcr); + extern int bget_dirmsg(BSOCK *bs); +@@ -149,28 +150,28 @@ + void free_ua_context(UAContext *ua); + + /* ua_select.c */ +-STORE *select_storage_resource(UAContext *ua); +-JOB *select_job_resource(UAContext *ua); +-JOB *select_restore_job_resource(UAContext *ua); +-CLIENT *select_client_resource(UAContext *ua); ++STORE *select_storage_resource(UAContext *ua); ++JOB *select_job_resource(UAContext *ua); ++JOB *select_restore_job_resource(UAContext *ua); ++CLIENT *select_client_resource(UAContext *ua); + FILESET *select_fileset_resource(UAContext *ua); +-int select_pool_and_media_dbr(UAContext *ua, POOL_DBR *pr, MEDIA_DBR *mr); +-int select_media_dbr(UAContext *ua, MEDIA_DBR *mr); +-bool select_pool_dbr(UAContext *ua, POOL_DBR *pr); +-int select_client_dbr(UAContext *ua, CLIENT_DBR *cr); +- +-void start_prompt(UAContext *ua, const char *msg); +-void add_prompt(UAContext *ua, const char *prompt); +-int do_prompt(UAContext *ua, const char *automsg, const char *msg, char *prompt, int max_prompt); +-CAT *get_catalog_resource(UAContext *ua); ++int select_pool_and_media_dbr(UAContext *ua, POOL_DBR *pr, MEDIA_DBR *mr); ++int select_media_dbr(UAContext *ua, MEDIA_DBR *mr); ++bool select_pool_dbr(UAContext *ua, POOL_DBR *pr); ++int select_client_dbr(UAContext *ua, CLIENT_DBR *cr); ++ ++void start_prompt(UAContext *ua, const char *msg); ++void add_prompt(UAContext *ua, const char *prompt); ++int do_prompt(UAContext *ua, const char *automsg, const char *msg, char *prompt, int max_prompt); ++CAT *get_catalog_resource(UAContext *ua); + STORE *get_storage_resource(UAContext *ua, int use_default); +-int get_media_type(UAContext *ua, char *MediaType, int max_media); +-bool get_pool_dbr(UAContext *ua, POOL_DBR *pr); +-int get_client_dbr(UAContext *ua, CLIENT_DBR *cr); ++int get_media_type(UAContext *ua, char *MediaType, int max_media); ++bool get_pool_dbr(UAContext *ua, POOL_DBR *pr); ++int get_client_dbr(UAContext *ua, CLIENT_DBR *cr); + POOL *get_pool_resource(UAContext *ua); + POOL *select_pool_resource(UAContext *ua); + CLIENT *get_client_resource(UAContext *ua); +-int get_job_dbr(UAContext *ua, JOB_DBR *jr); ++int get_job_dbr(UAContext *ua, JOB_DBR *jr); + + int find_arg_keyword(UAContext *ua, const char **list); + int find_arg(UAContext *ua, const char *keyword); +@@ -190,3 +191,6 @@ + + /* ua_purge.c */ + int purge_jobs_from_volume(UAContext *ua, MEDIA_DBR *mr); ++ ++/* ua_run.c */ ++extern int run_cmd(UAContext *ua, const char *cmd); +Index: src/dird/scheduler.c +=================================================================== +RCS file: /cvsroot/bacula/bacula/src/dird/scheduler.c,v +retrieving revision 1.27 +diff -u -r1.27 scheduler.c +--- src/dird/scheduler.c 3 Oct 2004 19:47:34 -0000 1.27 ++++ src/dird/scheduler.c 21 Dec 2004 13:04:08 -0000 +@@ -10,7 +10,7 @@ + * Version $Id$ + */ + /* +- Copyright (C) 2000-2004 Kern Sibbald and John Walker ++ Copyright (C) 2000-2004 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 +@@ -157,7 +157,7 @@ + jcr->dif_pool = run->dif_pool; /* override dif pool */ + } + if (run->storage) { +- jcr->store = run->storage; /* override storage */ ++ set_storage(jcr, run->storage); /* override storage */ + } + if (run->msgs) { + jcr->messages = run->msgs; /* override messages */ +Index: src/dird/ua.h +=================================================================== +RCS file: /cvsroot/bacula/bacula/src/dird/ua.h,v +retrieving revision 1.23 +diff -u -r1.23 ua.h +--- src/dird/ua.h 18 Jun 2004 10:07:41 -0000 1.23 ++++ src/dird/ua.h 21 Dec 2004 13:04:08 -0000 +@@ -3,7 +3,7 @@ + * + * Kern Sibbald, August MMI + * +- * Version $Id$ ++ * Version $Id$ + */ + /* + Copyright (C) 2000-2004 Kern Sibbald and John Walker +@@ -48,6 +48,7 @@ + bool automount; /* if set, mount after label */ + bool quit; /* if set, quit */ + bool verbose; /* set for normal UA verbosity */ ++ bool batch; /* set for non-interactive mode */ + uint32_t pint32_val; /* positive integer */ + int32_t int32_val; /* positive/negative */ + }; +Index: src/dird/ua_cmds.c +=================================================================== +RCS file: /cvsroot/bacula/bacula/src/dird/ua_cmds.c,v +retrieving revision 1.127 +diff -u -r1.127 ua_cmds.c +--- src/dird/ua_cmds.c 4 Oct 2004 20:34:01 -0000 1.127 ++++ src/dird/ua_cmds.c 21 Dec 2004 13:04:10 -0000 +@@ -4,7 +4,7 @@ + * + * Kern Sibbald, September MM + * +- * Version $Id$ ++ * Version $Id$ + */ + + /* +@@ -52,7 +52,6 @@ + extern int gui_cmd(UAContext *ua, const char *cmd); + extern int sqlquerycmd(UAContext *ua, const char *cmd); + extern int querycmd(UAContext *ua, const char *cmd); +-extern int run_cmd(UAContext *ua, const char *cmd); + extern int retentioncmd(UAContext *ua, const char *cmd); + extern int prunecmd(UAContext *ua, const char *cmd); + extern int purgecmd(UAContext *ua, const char *cmd); +@@ -1195,7 +1194,7 @@ + BSOCK *sd; + JCR *jcr = ua->jcr; + +- jcr->store = store; ++ set_storage(jcr, store); + /* Try connecting for up to 15 seconds */ + bsendmsg(ua, _("Connecting to Storage daemon %s at %s:%d\n"), + store->hdr.name, store->address, store->SDport); +@@ -1254,8 +1253,10 @@ + /* Count Storage items */ + LockRes(); + store = NULL; +- for (i=0; (store = (STORE *)GetNextRes(R_STORAGE, (RES *)store)); i++) +- { } ++ i = 0; ++ foreach_res(store, R_STORAGE) { ++ i++; ++ } + unique_store = (STORE **) malloc(i * sizeof(STORE)); + /* Find Unique Storage address/port */ + store = (STORE *)GetNextRes(R_STORAGE, NULL); +@@ -1286,8 +1287,10 @@ + /* Count Client items */ + LockRes(); + client = NULL; +- for (i=0; (client = (CLIENT *)GetNextRes(R_CLIENT, (RES *)client)); i++) +- { } ++ i = 0; ++ foreach_res(client, R_CLIENT) { ++ i++; ++ } + unique_client = (CLIENT **) malloc(i * sizeof(CLIENT)); + /* Find Unique Client address/port */ + client = (CLIENT *)GetNextRes(R_CLIENT, NULL); +@@ -1841,7 +1844,7 @@ + Dmsg2(120, "Found storage, MediaType=%s DevName=%s\n", + store->media_type, store->dev_name); + +- jcr->store = store; ++ set_storage(jcr, store); + if (!connect_to_storage_daemon(jcr, 10, SDConnectTimeout, 1)) { + bsendmsg(ua, _("Failed to connect to Storage daemon.\n")); + return; +Index: src/dird/ua_label.c +=================================================================== +RCS file: /cvsroot/bacula/bacula/src/dird/ua_label.c,v +retrieving revision 1.38 +diff -u -r1.38 ua_label.c +--- src/dird/ua_label.c 17 Aug 2004 14:40:09 -0000 1.38 ++++ src/dird/ua_label.c 21 Dec 2004 13:04:10 -0000 +@@ -8,7 +8,7 @@ + */ + + /* +- Copyright (C) 2000-2004 Kern Sibbald and John Walker ++ Copyright (C) 2000-2004 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 +@@ -170,7 +170,7 @@ + if (!store) { + return 1; + } +- ua->jcr->store = store; ++ set_storage(ua->jcr, store); + + scan = find_arg(ua, _("scan")) >= 0; + +@@ -296,7 +296,7 @@ + if (!store) { + return 1; + } +- ua->jcr->store = store; ++ set_storage(ua->jcr, store); + + if (!relabel && find_arg_keyword(ua, barcode_keyword) >= 0) { + label_from_barcodes(ua); +Index: src/dird/ua_run.c +=================================================================== +RCS file: /cvsroot/bacula/bacula/src/dird/ua_run.c,v +retrieving revision 1.58 +diff -u -r1.58 ua_run.c +--- src/dird/ua_run.c 8 Nov 2004 21:12:12 -0000 1.58 ++++ src/dird/ua_run.c 21 Dec 2004 13:04:11 -0000 +@@ -4,11 +4,11 @@ + * + * Kern Sibbald, December MMI + * +- * Version $Id$ ++ * Version $Id$ + */ + + /* +- Copyright (C) 2001-2004 Kern Sibbald and John Walker ++ Copyright (C) 2001-2004 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 +@@ -42,6 +42,9 @@ + * For Restore Jobs + * run jobid=nn + * ++ * Returns: 0 on error ++ * JobId if OK ++ * + */ + int run_cmd(UAContext *ua, const char *cmd) + { +@@ -101,7 +104,7 @@ + catalog_name = NULL; + + for (i=1; iargc; i++) { +- Dmsg2(200, "Doing arg %d = %s\n", i, ua->argk[i]); ++ Dmsg2(800, "Doing arg %d = %s\n", i, ua->argk[i]); + kw_ok = false; + /* Keep looking until we find a good keyword */ + for (j=0; !kw_ok && kw[j]; j++) { +@@ -111,12 +114,12 @@ + bsendmsg(ua, _("Value missing for keyword %s\n"), ua->argk[i]); + return 1; + } +- Dmsg1(200, "Got keyword=%s\n", kw[j]); ++ Dmsg1(800, "Got keyword=%s\n", kw[j]); + switch (j) { + case 0: /* job */ + if (job_name) { + bsendmsg(ua, _("Job name specified twice.\n")); +- return 1; ++ return 0; + } + job_name = ua->argv[i]; + kw_ok = true; +@@ -124,7 +127,7 @@ + case 1: /* JobId */ + if (jid) { + bsendmsg(ua, _("JobId specified twice.\n")); +- return 1; ++ return 0; + } + jid = ua->argv[i]; + kw_ok = true; +@@ -133,7 +136,7 @@ + case 3: /* fd */ + if (client_name) { + bsendmsg(ua, _("Client specified twice.\n")); +- return 1; ++ return 0; + } + client_name = ua->argv[i]; + kw_ok = true; +@@ -141,7 +144,7 @@ + case 4: /* fileset */ + if (fileset_name) { + bsendmsg(ua, _("FileSet specified twice.\n")); +- return 1; ++ return 0; + } + fileset_name = ua->argv[i]; + kw_ok = true; +@@ -149,7 +152,7 @@ + case 5: /* level */ + if (level_name) { + bsendmsg(ua, _("Level specified twice.\n")); +- return 1; ++ return 0; + } + level_name = ua->argv[i]; + kw_ok = true; +@@ -158,7 +161,7 @@ + case 7: /* sd */ + if (store_name) { + bsendmsg(ua, _("Storage specified twice.\n")); +- return 1; ++ return 0; + } + store_name = ua->argv[i]; + kw_ok = true; +@@ -166,7 +169,7 @@ + case 8: /* pool */ + if (pool_name) { + bsendmsg(ua, _("Pool specified twice.\n")); +- return 1; ++ return 0; + } + pool_name = ua->argv[i]; + kw_ok = true; +@@ -174,7 +177,7 @@ + case 9: /* where */ + if (where) { + bsendmsg(ua, _("Where specified twice.\n")); +- return 1; ++ return 0; + } + where = ua->argv[i]; + kw_ok = true; +@@ -182,7 +185,7 @@ + case 10: /* bootstrap */ + if (bootstrap) { + bsendmsg(ua, _("Bootstrap specified twice.\n")); +- return 1; ++ return 0; + } + bootstrap = ua->argv[i]; + kw_ok = true; +@@ -190,7 +193,7 @@ + case 11: /* replace */ + if (replace) { + bsendmsg(ua, _("Replace specified twice.\n")); +- return 1; ++ return 0; + } + replace = ua->argv[i]; + kw_ok = true; +@@ -198,7 +201,7 @@ + case 12: /* When */ + if (when) { + bsendmsg(ua, _("When specified twice.\n")); +- return 1; ++ return 0; + } + when = ua->argv[i]; + kw_ok = true; +@@ -206,7 +209,7 @@ + case 13: /* Priority */ + if (Priority) { + bsendmsg(ua, _("Priority specified twice.\n")); +- return 1; ++ return 0; + } + Priority = atoi(ua->argv[i]); + if (Priority <= 0) { +@@ -221,7 +224,7 @@ + case 15: /* Verify Job */ + if (verify_job_name) { + bsendmsg(ua, _("Verify Job specified twice.\n")); +- return 1; ++ return 0; + } + verify_job_name = ua->argv[i]; + kw_ok = true; +@@ -255,21 +258,22 @@ + Dmsg1(200, "Set jobname=%s\n", job_name); + } else { + bsendmsg(ua, _("Invalid keyword: %s\n"), ua->argk[i]); +- return 1; ++ return 0; + } + } + } /* end argc loop */ + +- Dmsg0(200, "Done scan.\n"); ++ Dmsg0(800, "Done scan.\n"); + + CAT *catalog = NULL; + if (catalog_name != NULL) { + catalog = (CAT *)GetResWithName(R_CATALOG, catalog_name); + if (catalog == NULL) { + bsendmsg(ua, _("Catalog \"%s\" not found\n"), catalog_name); +- return 1; ++ return 0; + } + } ++ Dmsg1(200, "Using catalog=%s\n", catalog_name); + + if (job_name) { + /* Find Job */ +@@ -287,11 +291,11 @@ + job = select_job_resource(ua); + } + if (!job) { +- return 1; ++ return 0; + } else if (!acl_access_ok(ua, Job_ACL, job->hdr.name)) { + bsendmsg(ua, _("No authorization. Job \"%s\".\n"), + job->hdr.name); +- return 1; ++ return 0; + } + + if (store_name) { +@@ -310,8 +314,9 @@ + } else if (!acl_access_ok(ua, Storage_ACL, store->hdr.name)) { + bsendmsg(ua, _("No authorization. Storage \"%s\".\n"), + store->hdr.name); +- return 1; ++ return 0; + } ++ Dmsg1(200, "Using storage=%s\n", store->hdr.name); + + if (pool_name) { + pool = (POOL *)GetResWithName(R_POOL, pool_name); +@@ -325,12 +330,13 @@ + pool = job->pool; /* use default */ + } + if (!pool) { +- return 1; ++ return 0; + } else if (!acl_access_ok(ua, Pool_ACL, store->hdr.name)) { + bsendmsg(ua, _("No authorization. Pool \"%s\".\n"), + pool->hdr.name); +- return 1; ++ return 0; + } ++ Dmsg1(200, "Using pool\n", pool->hdr.name); + + if (client_name) { + client = (CLIENT *)GetResWithName(R_CLIENT, client_name); +@@ -344,12 +350,13 @@ + client = job->client; /* use default */ + } + if (!client) { +- return 1; ++ return 0; + } else if (!acl_access_ok(ua, Client_ACL, store->hdr.name)) { + bsendmsg(ua, _("No authorization. Client \"%s\".\n"), + client->hdr.name); +- return 1; ++ return 0; + } ++ Dmsg1(200, "Using client=%s\n", client->hdr.name); + + if (fileset_name) { + fileset = (FILESET *)GetResWithName(R_FILESET, fileset_name); +@@ -361,11 +368,11 @@ + fileset = job->fileset; /* use default */ + } + if (!fileset) { +- return 1; ++ return 0; + } else if (!acl_access_ok(ua, FileSet_ACL, store->hdr.name)) { + bsendmsg(ua, _("No authorization. FileSet \"%s\".\n"), + fileset->hdr.name); +- return 1; ++ return 0; + } + + if (verify_job_name) { +@@ -386,7 +393,7 @@ + set_jcr_defaults(jcr, job); + + jcr->verify_job = verify_job; +- jcr->store = store; ++ set_storage(jcr, store); + jcr->client = client; + jcr->fileset = fileset; + jcr->pool = pool; +@@ -460,7 +467,7 @@ + } + + /* Run without prompting? */ +- if (find_arg(ua, _("yes")) > 0) { ++ if (ua->batch || find_arg(ua, _("yes")) > 0) { + goto start_job; + } + +@@ -701,7 +708,7 @@ + /* Storage */ + store = select_storage_resource(ua); + if (store) { +- jcr->store = store; ++ set_storage(jcr, store); + goto try_again; + } + break; +@@ -847,7 +854,7 @@ + } else { + bsendmsg(ua, _("Job started. JobId=%u\n"), JobId); + } +- return 1; ++ return JobId; + } + + bail_out: +Index: src/dird/ua_server.c +=================================================================== +RCS file: /cvsroot/bacula/bacula/src/dird/ua_server.c,v +retrieving revision 1.35 +diff -u -r1.35 ua_server.c +--- src/dird/ua_server.c 19 Sep 2004 18:56:24 -0000 1.35 ++++ src/dird/ua_server.c 21 Dec 2004 13:04:11 -0000 +@@ -99,6 +99,15 @@ + { + JCR *jcr; + jcr = new_jcr(sizeof(JCR), dird_free_jcr); ++ /* ++ * The job and defaults are not really used, but ++ * we set them up to ensure that everything is correctly ++ * initialized. ++ */ ++ LockRes(); ++ jcr->job = (JOB *)GetNextRes(R_JOB, NULL); ++ set_jcr_defaults(jcr, jcr->job); ++ UnlockRes(); + jcr->sd_auth_key = bstrdup("dummy"); /* dummy Storage daemon key */ + create_unique_job_name(jcr, base_name); + jcr->sched_time = jcr->start_time; +@@ -106,20 +115,6 @@ + jcr->JobLevel = L_NONE; + jcr->JobStatus = JS_Running; + jcr->JobId = 0; +- /* +- * None of these are really defined for control JCRs, so we +- * simply take the first of each one. This ensures that there +- * will be no null pointer references. +- */ +- LockRes(); +- jcr->job = (JOB *)GetNextRes(R_JOB, NULL); +- jcr->messages = (MSGS *)GetNextRes(R_MSGS, NULL); +- jcr->client = (CLIENT *)GetNextRes(R_CLIENT, NULL); +- jcr->pool = (POOL *)GetNextRes(R_POOL, NULL); +- jcr->catalog = (CAT *)GetNextRes(R_CATALOG, NULL); +- jcr->store = (STORE *)GetNextRes(R_STORAGE, NULL); +- jcr->fileset = (FILESET *)GetNextRes(R_FILESET, NULL); +- UnlockRes(); + return jcr; + } + +Index: src/dird/ua_status.c +=================================================================== +RCS file: /cvsroot/bacula/bacula/src/dird/ua_status.c,v +retrieving revision 1.61 +diff -u -r1.61 ua_status.c +--- src/dird/ua_status.c 19 Sep 2004 18:56:25 -0000 1.61 ++++ src/dird/ua_status.c 21 Dec 2004 13:04:12 -0000 +@@ -282,7 +282,7 @@ + { + BSOCK *sd; + +- ua->jcr->store = store; ++ set_storage(ua->jcr, store); + /* Try connecting for up to 15 seconds */ + bsendmsg(ua, _("Connecting to Storage daemon %s at %s:%d\n"), + store->hdr.name, store->address, store->SDport); diff --git a/bacula/patches/patches-1.36.1 b/bacula/patches/patches-1.36.1 index cf12c35f1c..0480335f72 100644 --- a/bacula/patches/patches-1.36.1 +++ b/bacula/patches/patches-1.36.1 @@ -12,3 +12,9 @@ This patch fixes the despooling size printed in the Job report. Previously, it reported the total size for the device. This patch makes it report the size for the job. + +21Dec04 + This patch fixes a problem with overriding storage daemon + specifications. Previously they were not always honored. + This implements more uniform handling. It also eliminates + an orphaned buffer situation using JobDefs. diff --git a/bacula/src/baconfig.h b/bacula/src/baconfig.h index a5fc2a1333..4771264511 100644 --- a/bacula/src/baconfig.h +++ b/bacula/src/baconfig.h @@ -55,7 +55,7 @@ #endif /* Allow printing of NULL pointers */ -#define NPRT(x) (x)?(x):"*None*" +#define NPRT(x) (x)?(x):"*None*" #ifdef ENABLE_NLS #include @@ -76,7 +76,7 @@ #define MAXSTRING 500 /* Maximum length to edit time/date */ -#define MAX_TIME_LENGTH 50 +#define MAX_TIME_LENGTH 50 /* Maximum Name length including EOS */ #define MAX_NAME_LENGTH 128 @@ -141,8 +141,8 @@ /*** FIXME ***/ -/* - * File type (Bacula defined). +/* + * File type (Bacula defined). * NOTE!!! These are saved in the Attributes record on the tape, so * do not change them. If need be, add to them. * @@ -151,7 +151,7 @@ * additional optional fields in the attribute record. */ #define FT_MASK 0xFFFF /* Bits used by FT (type) */ -#define FT_LNKSAVED 1 /* hard link to file already saved */ +#define FT_LNKSAVED 1 /* hard link to file already saved */ #define FT_REGE 2 /* Regular file but empty */ #define FT_REG 3 /* Regular file */ #define FT_LNK 4 /* Soft Link */ @@ -260,13 +260,13 @@ extern void _v(char *file, int line, pthread_mutex_t *m); #define P(x) \ do { int errstat; if ((errstat=pthread_mutex_lock(&(x)))) \ e_msg(__FILE__, __LINE__, M_ABORT, 0, "Mutex lock failure. ERR=%s\n",\ - strerror(errstat)); \ + strerror(errstat)); \ } while(0) #define V(x) \ do { int errstat; if ((errstat=pthread_mutex_unlock(&(x)))) \ - e_msg(__FILE__, __LINE__, M_ABORT, 0, "Mutex unlock failure. ERR=%s\n",\ - strerror(errstat)); \ + e_msg(__FILE__, __LINE__, M_ABORT, 0, "Mutex unlock failure. ERR=%s\n",\ + strerror(errstat)); \ } while(0) #endif /* DEBUG_MUTEX */ @@ -275,13 +275,13 @@ extern void _v(char *file, int line, pthread_mutex_t *m); #define Pw(x) \ do { int errstat; if ((errstat=rwl_writelock(&(x)))) \ e_msg(__FILE__, __LINE__, M_ABORT, 0, "Write lock lock failure. ERR=%s\n",\ - strerror(errstat)); \ + strerror(errstat)); \ } while(0) #define Vw(x) \ do { int errstat; if ((errstat=rwl_writeunlock(&(x)))) \ - e_msg(__FILE__, __LINE__, M_ABORT, 0, "Write lock unlock failure. ERR=%s\n",\ - strerror(errstat)); \ + e_msg(__FILE__, __LINE__, M_ABORT, 0, "Write lock unlock failure. ERR=%s\n",\ + strerror(errstat)); \ } while(0) #define LockRes() b_LockRes(__FILE__, __LINE__) @@ -378,7 +378,7 @@ void b_memset(const char *file, int line, void *mem, int val, size_t num); #define Pmsg13(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13) p_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13) #define Pmsg14(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14) p_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14) - + /* Daemon Error Messages that are delivered according to the message resource */ #define Emsg0(typ, lvl, msg) e_msg(__FILE__, __LINE__, typ, lvl, msg) #define Emsg1(typ, lvl, msg, a1) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1) @@ -463,7 +463,7 @@ int m_msg(const char *file, int line, POOLMEM *&pool_buf, const char *fmt, ...) #endif #ifdef HAVE_SUN_OS - /* + /* * On Solaris 2.5, threads are not timesliced by default, so we need to * explictly increase the conncurrency level. */ @@ -504,7 +504,7 @@ extern "C" int getdomainname(char *name, int len); extern "C" int fchdir(int filedes); extern "C" long gethostid(void); #endif - + /* This probably should be done on a machine by machine basic, but it works */ #define ALIGN_SIZE (sizeof(double)) #define BALIGN(x) (((x) + ALIGN_SIZE - 1) & ~(ALIGN_SIZE -1)) @@ -517,7 +517,7 @@ extern "C" long gethostid(void); /* * Replace codes needed in both file routines and non-file routines - * Job replace codes -- in "replace" + * Job replace codes -- in "replace" */ #define REPLACE_ALWAYS 'a' #define REPLACE_IFNEWER 'w' @@ -532,7 +532,7 @@ extern "C" long gethostid(void); #endif #ifdef HAVE_NL_LANGINFO #include -#else +#else #define nl_langinfo(x) ("ANSI_X3.4-1968") #endif diff --git a/bacula/src/bacula.h b/bacula/src/bacula.h index 6e2bf2769b..d40cdfb328 100644 --- a/bacula/src/bacula.h +++ b/bacula/src/bacula.h @@ -72,7 +72,7 @@ #else #include "lib/getopt.h" #endif -#endif +#endif #include #include @@ -110,7 +110,7 @@ #include /* Local Bacula includes. Be sure to put all the system - * includes before these. + * includes before these. */ #include "version.h" #include "bc_types.h" diff --git a/bacula/src/bc_types.h b/bacula/src/bc_types.h index 1f5738c37c..3229b35d0e 100644 --- a/bacula/src/bc_types.h +++ b/bacula/src/bc_types.h @@ -38,7 +38,7 @@ #ifndef __bc_types_INCLUDED #define __bc_types_INCLUDED -typedef char POOLMEM; +typedef char POOLMEM; /* Types */ @@ -139,14 +139,14 @@ typedef u_int64_t u_intmax_t; /* Limits for the above types. */ -#undef INT8_MIN -#undef INT8_MAX -#undef UINT8_MAX -#undef INT16_MIN -#undef INT16_MAX +#undef INT8_MIN +#undef INT8_MAX +#undef UINT8_MAX +#undef INT16_MIN +#undef INT16_MAX #undef UINT16_MAX -#undef INT32_MIN -#undef INT32_MAX +#undef INT32_MIN +#undef INT32_MAX #undef UINT32_MAX #define INT8_MIN (-127-1) diff --git a/bacula/src/cats/bdb.c b/bacula/src/cats/bdb.c index 1cf8c3a05b..ae12c1c22d 100644 --- a/bacula/src/cats/bdb.c +++ b/bacula/src/cats/bdb.c @@ -5,8 +5,8 @@ * The purpose of these routines is to ensure that Bacula * can limp along if no real database is loaded on the * system. - * - * Kern Sibbald, January MMI + * + * Kern Sibbald, January MMI * * Version $Id$ * @@ -79,7 +79,7 @@ static POOLMEM *make_filename(B_DB *mdb, char *name) if (working_directory[strlen(working_directory)-1] == '/') { sep = 0; } else { - sep = '/'; + sep = '/'; } Mmsg(dbf, "%s%c%s-%s", working_directory, sep, mdb->db_name, name); return dbf; @@ -103,7 +103,7 @@ int bdb_write_control_file(B_DB *mdb) */ B_DB * db_init_database(JCR *jcr, char const *db_name, char const *db_user, char const *db_password, - char const *db_address, int db_port, char const *db_socket, + char const *db_address, int db_port, char const *db_socket, int mult_db_connections) { B_DB *mdb; @@ -111,7 +111,7 @@ db_init_database(JCR *jcr, char const *db_name, char const *db_user, char const /* Look to see if DB already open */ for (mdb=NULL; (mdb=(B_DB *)qnext(&db_list, &mdb->bq)); ) { if (strcmp(mdb->db_name, db_name) == 0) { - Dmsg2(200, "DB REopen %d %s\n", mdb->ref_count, db_name); + Dmsg2(200, "DB REopen %d %s\n", mdb->ref_count, db_name); mdb->ref_count++; V(mutex); return mdb; /* already open */ @@ -163,10 +163,10 @@ db_open_database(JCR *jcr, B_DB *mdb) Dmsg0(200, "make_filename\n"); dbf = make_filename(mdb, DB_CONTROL_FILENAME); - mdb->cfd = open(dbf, O_CREAT|O_RDWR, 0600); + mdb->cfd = open(dbf, O_CREAT|O_RDWR, 0600); free_memory(dbf); if (mdb->cfd < 0) { - Mmsg2(&mdb->errmsg, _("Unable to open Catalog DB control file %s: ERR=%s\n"), + Mmsg2(&mdb->errmsg, _("Unable to open Catalog DB control file %s: ERR=%s\n"), dbf, strerror(errno)); V(mutex); return 0; @@ -224,9 +224,9 @@ db_open_database(JCR *jcr, B_DB *mdb) Mmsg1(&mdb->errmsg, _("Error reading catalog DB control file. ERR=%s\n"), strerror(errno)); badctl = 1; } else if (mdb->control.bdb_version != BDB_VERSION) { - Mmsg2(&mdb->errmsg, _("Error, catalog DB control file wrong version. \ -Wanted %d, got %d\n\ -Please reinitialize the working directory.\n"), + Mmsg2(&mdb->errmsg, _("Error, catalog DB control file wrong version. " +"Wanted %d, got %d\n" +"Please reinitialize the working directory.\n"), BDB_VERSION, mdb->control.bdb_version); badctl = 1; } @@ -239,7 +239,7 @@ Please reinitialize the working directory.\n"), return 1; } -void db_close_database(JCR *jcr, B_DB *mdb) +void db_close_database(JCR *jcr, B_DB *mdb) { P(mutex); mdb->ref_count--; @@ -268,7 +268,7 @@ void db_close_database(JCR *jcr, B_DB *mdb) if (mdb->filesetfd) { fclose(mdb->filesetfd); } - rwl_destroy(&mdb->lock); + rwl_destroy(&mdb->lock); free_pool_memory(mdb->errmsg); free_pool_memory(mdb->cmd); free_pool_memory(mdb->cached_path); @@ -301,11 +301,11 @@ int bdb_open_jobs_file(B_DB *mdb) { char *dbf; - if (!mdb->jobfd) { + if (!mdb->jobfd) { dbf = make_filename(mdb, DB_JOBS_FILENAME); mdb->jobfd = fopen(dbf, "r+"); if (!mdb->jobfd) { - Mmsg2(&mdb->errmsg, "Error opening DB Jobs file %s: ERR=%s\n", + Mmsg2(&mdb->errmsg, "Error opening DB Jobs file %s: ERR=%s\n", dbf, strerror(errno)); Emsg0(M_FATAL, 0, mdb->errmsg); free_memory(dbf); @@ -323,11 +323,11 @@ int bdb_open_jobmedia_file(B_DB *mdb) { char *dbf; - if (!mdb->jobmediafd) { + if (!mdb->jobmediafd) { dbf = make_filename(mdb, DB_JOBMEDIA_FILENAME); mdb->jobmediafd = fopen(dbf, "r+"); if (!mdb->jobmediafd) { - Mmsg2(&mdb->errmsg, "Error opening DB JobMedia file %s: ERR=%s\n", + Mmsg2(&mdb->errmsg, "Error opening DB JobMedia file %s: ERR=%s\n", dbf, strerror(errno)); Emsg0(M_FATAL, 0, mdb->errmsg); free_memory(dbf); @@ -346,11 +346,11 @@ int bdb_open_pools_file(B_DB *mdb) { char *dbf; - if (!mdb->poolfd) { + if (!mdb->poolfd) { dbf = make_filename(mdb, DB_POOLS_FILENAME); mdb->poolfd = fopen(dbf, "r+"); if (!mdb->poolfd) { - Mmsg2(&mdb->errmsg, "Error opening DB Pools file %s: ERR=%s\n", + Mmsg2(&mdb->errmsg, "Error opening DB Pools file %s: ERR=%s\n", dbf, strerror(errno)); Emsg0(M_FATAL, 0, mdb->errmsg); free_memory(dbf); @@ -369,11 +369,11 @@ int bdb_open_client_file(B_DB *mdb) { char *dbf; - if (!mdb->clientfd) { + if (!mdb->clientfd) { dbf = make_filename(mdb, DB_CLIENT_FILENAME); mdb->clientfd = fopen(dbf, "r+"); if (!mdb->clientfd) { - Mmsg2(&mdb->errmsg, "Error opening DB Clients file %s: ERR=%s\n", + Mmsg2(&mdb->errmsg, "Error opening DB Clients file %s: ERR=%s\n", dbf, strerror(errno)); Emsg0(M_FATAL, 0, mdb->errmsg); free_memory(dbf); @@ -391,11 +391,11 @@ int bdb_open_fileset_file(B_DB *mdb) { char *dbf; - if (!mdb->filesetfd) { + if (!mdb->filesetfd) { dbf = make_filename(mdb, DB_CLIENT_FILENAME); mdb->filesetfd = fopen(dbf, "r+"); if (!mdb->filesetfd) { - Mmsg2(&mdb->errmsg, "Error opening DB FileSet file %s: ERR=%s\n", + Mmsg2(&mdb->errmsg, "Error opening DB FileSet file %s: ERR=%s\n", dbf, strerror(errno)); Emsg0(M_FATAL, 0, mdb->errmsg); free_memory(dbf); @@ -415,11 +415,11 @@ int bdb_open_media_file(B_DB *mdb) { char *dbf; - if (!mdb->mediafd) { + if (!mdb->mediafd) { dbf = make_filename(mdb, DB_MEDIA_FILENAME); mdb->mediafd = fopen(dbf, "r+"); if (!mdb->mediafd) { - Mmsg2(&mdb->errmsg, "Error opening DB Media file %s: ERR=%s\n", + Mmsg2(&mdb->errmsg, "Error opening DB Media file %s: ERR=%s\n", dbf, strerror(errno)); free_memory(dbf); return 0; @@ -437,7 +437,7 @@ void _db_lock(const char *file, int line, B_DB *mdb) e_msg(file, line, M_ABORT, 0, "rwl_writelock failure. ERR=%s\n", strerror(errstat)); } -} +} void _db_unlock(const char *file, int line, B_DB *mdb) { @@ -446,11 +446,11 @@ void _db_unlock(const char *file, int line, B_DB *mdb) e_msg(file, line, M_ABORT, 0, "rwl_writeunlock failure. ERR=%s\n", strerror(errstat)); } -} +} /* * Start a transaction. This groups inserts and makes things - * much more efficient. Usually started when inserting + * much more efficient. Usually started when inserting * file attributes. */ void db_start_transaction(JCR *jcr, B_DB *mdb) diff --git a/bacula/src/cats/bdb_create.c b/bacula/src/cats/bdb_create.c index a42c4a422a..1654041240 100644 --- a/bacula/src/cats/bdb_create.c +++ b/bacula/src/cats/bdb_create.c @@ -7,8 +7,8 @@ * The purpose of these routines is to ensure that Bacula * can limp along if no real database is loaded on the * system. - * - * Kern Sibbald, January MMI + * + * Kern Sibbald, January MMI * * Version $Id$ */ @@ -62,14 +62,14 @@ int db_create_file_attributes_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar) } int db_create_file_item(JCR *jcr, B_DB *mdb, ATTR_DBR *ar) -{ +{ /****FIXME***** not implemented */ return 1; } -/* - * Create a new record for the Job +/* + * Create a new record for the Job * This record is created at the start of the Job, * it is updated in bdb_update.c when the Job terminates. * @@ -101,7 +101,7 @@ int db_create_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr) return 1; } -/* Create a JobMedia record for Volume used this job +/* Create a JobMedia record for Volume used this job * Returns: 0 on failure * record-id on success */ @@ -172,14 +172,14 @@ int db_create_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr) } -/* +/* * Create Unique Media record. This record * contains all the data pertaining to a specific * Volume. * * Returns: 0 on failure * 1 on success - */ + */ int db_create_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) { int len; @@ -254,7 +254,7 @@ int db_create_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cr) /* * Create a unique FileSet record or return existing record * - * Note, here we write the FILESET_DBR structure + * Note, here we write the FILESET_DBR structure * * Returns: 0 on failure * 1 on success diff --git a/bacula/src/cats/bdb_delete.c b/bacula/src/cats/bdb_delete.c index b2c5ad10c5..3e3915a8d3 100644 --- a/bacula/src/cats/bdb_delete.c +++ b/bacula/src/cats/bdb_delete.c @@ -7,8 +7,8 @@ * The purpose of these routines is to ensure that Bacula * can limp along if no real database is loaded on the * system. - * - * Kern Sibbald, January MMI + * + * Kern Sibbald, January MMI * * Version $Id$ */ @@ -59,7 +59,7 @@ * Delete a Pool record given the Name * * Returns: 0 on error - * the number of records deleted on success + * the number of records deleted on success */ int db_delete_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr) { @@ -77,11 +77,11 @@ int db_delete_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr) memset(&opr, 0, sizeof(opr)); stat = fwrite(&opr, sizeof(opr), 1, mdb->poolfd); db_unlock(mdb); - return stat; + return stat; } -int db_delete_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) -{ +int db_delete_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) +{ int stat; MEDIA_DBR omr; @@ -95,7 +95,7 @@ int db_delete_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) memset(&omr, 0, sizeof(omr)); stat = fwrite(&omr, sizeof(omr), 1, mdb->mediafd); db_unlock(mdb); - return stat; + return stat; } #endif /* HAVE_BACULA_DB */ diff --git a/bacula/src/cats/bdb_find.c b/bacula/src/cats/bdb_find.c index 38e8a57c46..b234f69b69 100644 --- a/bacula/src/cats/bdb_find.c +++ b/bacula/src/cats/bdb_find.c @@ -11,8 +11,8 @@ * The purpose of these routines is to ensure that Bacula * can limp along if no real database is loaded on the * system. - * - * Kern Sibbald, January MMI + * + * Kern Sibbald, January MMI * * Version $Id$ */ @@ -58,7 +58,7 @@ */ -/* +/* * Find job start time. Used to find last full save that terminated normally * so we can do Incremental and Differential saves. * @@ -86,8 +86,8 @@ int db_find_job_start_time(JCR *jcr, B_DB *mdb, JOB_DBR *jr, POOLMEM **stime) */ while (fgets(cmd, sizeof(cmd), mdb->jobfd)) { - if (sscanf(cmd, "JobStart JobId=%d Name=%127s Type=%1s Level=%1s \ -StartTime=%100s", &JobId, Name, cType, cLevel, StartTime) == 5) { + if (sscanf(cmd, "JobStart JobId=%d Name=%127s Type=%1s Level=%1s " +"StartTime=%100s", &JobId, Name, cType, cLevel, StartTime) == 5) { if (JobId < jr->JobId) { continue; /* older not a candidate */ } @@ -95,15 +95,15 @@ StartTime=%100s", &JobId, Name, cType, cLevel, StartTime) == 5) { Level = cLevel[0]; unbash_spaces(Name); unbash_spaces(StartTime); - Dmsg4(200, "Got Type=%c Level=%c Name=%s StartTime=%s\n", + Dmsg4(200, "Got Type=%c Level=%c Name=%s StartTime=%s\n", Type, Level, Name, StartTime); - Dmsg3(200, "Want Type=%c Level=%c Name=%s\n", jr->JobType, jr->JobLevel, + Dmsg3(200, "Want Type=%c Level=%c Name=%s\n", jr->JobType, jr->JobLevel, jr->Name); /* Differential is since last Full backup */ /* Incremental is since last FULL or Incremental or Differential */ - if (((jr->JobLevel == L_DIFFERENTIAL) && (Type == jr->JobType && + if (((jr->JobLevel == L_DIFFERENTIAL) && (Type == jr->JobType && Level == L_FULL && strcmp(Name, jr->Name) == 0)) || - ((jr->JobLevel == L_INCREMENTAL) && (Type == jr->JobType && + ((jr->JobLevel == L_INCREMENTAL) && (Type == jr->JobType && (Level == L_FULL || Level == L_INCREMENTAL || Level == L_DIFFERENTIAL) && strcmp(Name, jr->Name) == 0))) { addr = ftell(mdb->jobfd); /* save current location */ @@ -111,10 +111,10 @@ StartTime=%100s", &JobId, Name, cType, cLevel, StartTime) == 5) { found = 0; /* Search for matching JobEnd record */ while (!found && fgets(cmd, sizeof(cmd), mdb->jobfd)) { - if (sscanf(cmd, "JobEnd JobId=%d JobStatus=%1s ClientId=%d", + if (sscanf(cmd, "JobEnd JobId=%d JobStatus=%1s ClientId=%d", &EndId, JobStatus, &ClientId) == 3) { - if (EndId == JobId && *JobStatus == 'T' && ClientId == jr->ClientId) { - Dmsg0(200, "====found EndJob matching Job\n"); + if (EndId == JobId && *JobStatus == 'T' && ClientId == jr->ClientId) { + Dmsg0(200, "====found EndJob matching Job\n"); found = 1; break; } @@ -125,7 +125,7 @@ StartTime=%100s", &JobId, Name, cType, cLevel, StartTime) == 5) { if (found) { pm_strcpy(stime, StartTime); stat = 1; /* Got a candidate */ - Dmsg5(200, "Got candidate JobId=%d Type=%c Level=%c Name=%s StartTime=%s\n", + Dmsg5(200, "Got candidate JobId=%d Type=%c Level=%c Name=%s StartTime=%s\n", JobId, Type, Level, Name, StartTime); } } @@ -136,18 +136,18 @@ StartTime=%100s", &JobId, Name, cType, cLevel, StartTime) == 5) { } -/* +/* * Find Available Media (Volume) for Pool * * Find a Volume for a given PoolId, MediaType, and VolStatus * - * Note! this does not correctly implement InChanger. + * Note! this does not correctly implement InChanger. * * Returns: 0 on failure * numrows on success - */ + */ int -db_find_next_volume(JCR *jcr, B_DB *mdb, int item, bool InChanger, MEDIA_DBR *mr) +db_find_next_volume(JCR *jcr, B_DB *mdb, int item, bool InChanger, MEDIA_DBR *mr) { MEDIA_DBR omr; int stat = 0; @@ -164,19 +164,19 @@ db_find_next_volume(JCR *jcr, B_DB *mdb, int item, bool InChanger, MEDIA_DBR *mr while (fread(&omr, len, 1, mdb->mediafd) > 0) { if (mr->PoolId == omr.PoolId && strcmp(mr->VolStatus, omr.VolStatus) == 0 && strcmp(mr->MediaType, omr.MediaType) == 0) { - if (!(++index == item)) { /* looking for item'th entry */ - Dmsg0(200, "Media record matches, but not index\n"); + if (!(++index == item)) { /* looking for item'th entry */ + Dmsg0(200, "Media record matches, but not index\n"); continue; } - Dmsg0(200, "Media record matches\n"); + Dmsg0(200, "Media record matches\n"); memcpy(mr, &omr, len); - Dmsg1(200, "Findnextvol MediaId=%d\n", mr->MediaId); + Dmsg1(200, "Findnextvol MediaId=%d\n", mr->MediaId); stat = 1; break; /* found it */ } } db_unlock(mdb); - return stat; + return stat; } int diff --git a/bacula/src/cats/bdb_get.c b/bacula/src/cats/bdb_get.c index cbabc7a3aa..4bc4447d52 100644 --- a/bacula/src/cats/bdb_get.c +++ b/bacula/src/cats/bdb_get.c @@ -2,7 +2,7 @@ * Bacula Catalog Database Get record interface routines * Note, these routines generally get a record by id or * by name. If more logic is involved, the routine - * should be in find.c + * should be in find.c * * Bacula Catalog Database routines written specifically * for Bacula. Note, these routines are VERY dumb and @@ -10,8 +10,8 @@ * The purpose of these routines is to ensure that Bacula * can limp along if no real database is loaded on the * system. - * - * Kern Sibbald, January MMI + * + * Kern Sibbald, January MMI * * Version $Id$ */ @@ -59,14 +59,14 @@ */ -/* +/* * Get Job record for given JobId * Returns: 0 on failure * 1 on success */ int db_get_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr) -{ +{ JOB_DBR ojr; faddr_t rec_addr; int found = 0; @@ -98,7 +98,7 @@ int db_get_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr) /* Search by Job */ } else if (strcmp(jr->Job, ojr.Job) == 0) { found = 1; - Dmsg1(200, "Found Job: %s\n", ojr.Job); + Dmsg1(200, "Found Job: %s\n", ojr.Job); } if (!found) { rec_addr = ftell(mdb->jobfd); /* save start next record */ @@ -121,7 +121,7 @@ int db_get_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr) } -/* +/* * Get the number of pool records * * Returns: -1 on failure @@ -172,13 +172,13 @@ int db_get_pool_ids(JCR *jcr, B_DB *mdb, int *num_ids, uint32_t *ids[]) } -/* - * Get Pool Record +/* + * Get Pool Record * If the PoolId is non-zero, we get its record, * otherwise, we search on the PoolName * * Returns: 0 on failure - * id on success + * id on success */ int db_get_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr) { @@ -208,7 +208,7 @@ int db_get_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr) /* Search by Name */ } else if (strcmp(pr->Name, opr.Name) == 0) { found = 1; - Dmsg1(200, "Found pool: %s\n", opr.Name); + Dmsg1(200, "Found pool: %s\n", opr.Name); } if (!found) { rec_addr = ftell(mdb->poolfd); /* save start next record */ @@ -230,7 +230,7 @@ int db_get_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr) return stat; } -/* +/* * Get the number of Media records * * Returns: -1 on failure @@ -247,7 +247,7 @@ int db_get_num_media_records(JCR *jcr, B_DB *mdb) } /* - * This function returns a list of all the Media record ids + * This function returns a list of all the Media record ids * for a specified PoolId * The caller must free ids if non-NULL. * @@ -287,13 +287,13 @@ int db_get_media_ids(JCR *jcr, B_DB *mdb, uint32_t PoolId, int *num_ids, uint32_ return 1; } -/* - * Get Media Record +/* + * Get Media Record * If the MediaId is non-zero, we get its record, * otherwise, we search on the MediaName * * Returns: 0 on failure - * id on success + * id on success */ int db_get_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) { @@ -320,7 +320,7 @@ int db_get_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) Dmsg1(200, "VolName=%s\n", omr.VolumeName); /* If id not zero, search by Id */ if (mr->MediaId != 0) { - Dmsg1(200, "MediaId=%d\n", mr->MediaId); + Dmsg1(200, "MediaId=%d\n", mr->MediaId); if (mr->MediaId == omr.MediaId) { found = 1; } @@ -381,7 +381,7 @@ int db_get_job_volume_names(JCR *jcr, B_DB *mdb, uint32_t JobId, POOLMEM **Volum while (fread(&mr, mrlen, 1, mdb->mediafd) > 0) { if (jm.MediaId == mr.MediaId) { if (*VolumeNames[0] != 0) { /* if not first name, */ - pm_strcat(VolumeNames, "|"); /* add separator */ + pm_strcat(VolumeNames, "|"); /* add separator */ } pm_strcat(VolumeNames, mr.VolumeName); /* add Volume Name */ found++; @@ -393,16 +393,16 @@ int db_get_job_volume_names(JCR *jcr, B_DB *mdb, uint32_t JobId, POOLMEM **Volum strcpy(mdb->errmsg, "No Volumes found.\n"); } db_unlock(mdb); - return found; + return found; } -/* - * Get Client Record +/* + * Get Client Record * If the ClientId is non-zero, we get its record, * otherwise, we search on the Name * * Returns: 0 on failure - * id on success + * id on success */ int db_get_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cr) { @@ -432,7 +432,7 @@ int db_get_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cr) } memcpy(cr, &lcr, len); stat = lcr.ClientId; - Dmsg2(200, "Found Client record: ClientId=%d Name=%s\n", + Dmsg2(200, "Found Client record: ClientId=%d Name=%s\n", lcr.ClientId, lcr.Name); break; } @@ -443,13 +443,13 @@ int db_get_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cr) return stat; } -/* +/* * Get FileSet Record (We read the FILESET_DBR structure) * If the FileSetId is non-zero, we get its record, * otherwise, we search on the FileSet (its name). * * Returns: 0 on failure - * id on success + * id on success */ int db_get_fileset_record(JCR *jcr, B_DB *mdb, FILESET_DBR *fsr) { @@ -479,7 +479,7 @@ int db_get_fileset_record(JCR *jcr, B_DB *mdb, FILESET_DBR *fsr) /* Found desired record, now return it */ memcpy(fsr, &lfsr, sizeof(lfsr)); stat = fsr->FileSetId; - Dmsg2(200, "Found FileSet record: FileSetId=%d FileSet=%s\n", + Dmsg2(200, "Found FileSet record: FileSetId=%d FileSet=%s\n", lfsr.FileSetId, lfsr.FileSet); break; } diff --git a/bacula/src/cats/bdb_list.c b/bacula/src/cats/bdb_list.c index 49fa0f39b7..82238c77da 100644 --- a/bacula/src/cats/bdb_list.c +++ b/bacula/src/cats/bdb_list.c @@ -7,8 +7,8 @@ * The purpose of these routines is to ensure that Bacula * can limp along if no real database is loaded on the * system. - * - * Kern Sibbald, January MMI + * + * Kern Sibbald, January MMI * * Version $Id$ */ @@ -54,10 +54,10 @@ * ----------------------------------------------------------------------- */ -/* +/* * Submit general SQL query */ -int db_list_sql_query(JCR *jcr, B_DB *mdb, char *query, DB_LIST_HANDLER *sendit, +int db_list_sql_query(JCR *jcr, B_DB *mdb, char *query, DB_LIST_HANDLER *sendit, void *ctx, int verbose) { sendit(ctx, "SQL Queries not implemented with internal database.\n"); @@ -84,7 +84,7 @@ void db_list_pool_records(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ct fseek(mdb->poolfd, 0L, SEEK_SET); /* rewind file */ len = sizeof(pr); while (fread(&pr, len, 1, mdb->poolfd) > 0) { - Mmsg(mdb->cmd, " %7d %6d %6d %-10s %s\n", + Mmsg(mdb->cmd, " %7d %6d %6d %-10s %s\n", pr.PoolId, pr.NumVols, pr.MaxVols, pr.PoolType, pr.Name); sendit(ctx, mdb->cmd); } @@ -98,7 +98,7 @@ void db_list_pool_records(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ct /* * List Media records */ -void db_list_media_records(JCR *jcr, B_DB *mdb, MEDIA_DBR *mdbr, +void db_list_media_records(JCR *jcr, B_DB *mdb, MEDIA_DBR *mdbr, DB_LIST_HANDLER *sendit, void *ctx) { char ewc[30]; @@ -115,7 +115,7 @@ void db_list_media_records(JCR *jcr, B_DB *mdb, MEDIA_DBR *mdbr, fseek(mdb->mediafd, 0L, SEEK_SET); /* rewind file */ len = sizeof(mr); while (fread(&mr, len, 1, mdb->mediafd) > 0) { - Mmsg(mdb->cmd, " %-10s %17s %-15s %s\n", + Mmsg(mdb->cmd, " %-10s %17s %-15s %s\n", mr.VolStatus, edit_uint64_with_commas(mr.VolBytes, ewc), mr.MediaType, mr.VolumeName); sendit(ctx, mdb->cmd); @@ -125,7 +125,7 @@ void db_list_media_records(JCR *jcr, B_DB *mdb, MEDIA_DBR *mdbr, return; } -void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, uint32_t JobId, +void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, uint32_t JobId, DB_LIST_HANDLER *sendit, void *ctx) { JOBMEDIA_DBR jm; @@ -154,7 +154,7 @@ void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, uint32_t JobId, fseek(mdb->mediafd, 0L, SEEK_SET); while (fread(&mr, mrlen, 1, mdb->mediafd) > 0) { if (mr.MediaId == jm.MediaId) { - Mmsg(mdb->cmd, " %7d %-10s %10d %10d\n", + Mmsg(mdb->cmd, " %7d %-10s %10d %10d\n", jm.JobId, mr.VolumeName, jm.FirstIndex, jm.LastIndex); sendit(ctx, mdb->cmd); break; @@ -166,7 +166,7 @@ void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, uint32_t JobId, fseek(mdb->mediafd, 0L, SEEK_SET); while (fread(&mr, mrlen, 1, mdb->mediafd) > 0) { if (mr.MediaId == jm.MediaId) { - Mmsg(mdb->cmd, " %7d %-10s %10d %10d\n", + Mmsg(mdb->cmd, " %7d %-10s %10d %10d\n", jm.JobId, mr.VolumeName, jm.FirstIndex, jm.LastIndex); sendit(ctx, mdb->cmd); break; @@ -184,7 +184,7 @@ void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, uint32_t JobId, /* * List Job records */ -void db_list_job_records(JCR *jcr, B_DB *mdb, JOB_DBR *jr, +void db_list_job_records(JCR *jcr, B_DB *mdb, JOB_DBR *jr, DB_LIST_HANDLER *sendit, void *ctx) { int jrlen; @@ -200,7 +200,7 @@ void db_list_job_records(JCR *jcr, B_DB *mdb, JOB_DBR *jr, return; } fseek(mdb->jobfd, 0L, SEEK_SET); /* rewind file */ - /* + /* * Linear search through Job records */ sendit(ctx, " JobId StartTime Type Level Bytes Files Stat JobName\n"); @@ -216,9 +216,9 @@ void db_list_job_records(JCR *jcr, B_DB *mdb, JOB_DBR *jr, } localtime_r(&ojr.StartTime, &tm); strftime(dt, sizeof(dt), "%m-%d %H:%M", &tm); - Mmsg(mdb->cmd, " %7d %-10s %c %c %14s %10s %c %s\n", - ojr.JobId, dt, (char)ojr.JobType, (char)ojr.JobLevel, - edit_uint64_with_commas(ojr.JobBytes, ewc1), + Mmsg(mdb->cmd, " %7d %-10s %c %c %14s %10s %c %s\n", + ojr.JobId, dt, (char)ojr.JobType, (char)ojr.JobLevel, + edit_uint64_with_commas(ojr.JobBytes, ewc1), edit_uint64_with_commas(ojr.JobFiles, ewc2), (char)ojr.JobStatus, ojr.Name); sendit(ctx, mdb->cmd); @@ -232,7 +232,7 @@ void db_list_job_records(JCR *jcr, B_DB *mdb, JOB_DBR *jr, /* * List Job Totals */ -void db_list_job_totals(JCR *jcr, B_DB *mdb, JOB_DBR *jr, +void db_list_job_totals(JCR *jcr, B_DB *mdb, JOB_DBR *jr, DB_LIST_HANDLER *sendit, void *ctx) { char ewc1[30], ewc2[30], ewc3[30]; @@ -248,7 +248,7 @@ void db_list_job_totals(JCR *jcr, B_DB *mdb, JOB_DBR *jr, return; } fseek(mdb->jobfd, 0L, SEEK_SET); /* rewind file */ - /* + /* * Linear search through JobStart records */ sendit(ctx, " NumJobs NumFiles NumBytes\n"); @@ -259,9 +259,9 @@ void db_list_job_totals(JCR *jcr, B_DB *mdb, JOB_DBR *jr, total_bytes += ojr.JobBytes; total_jobs++; } - Mmsg(mdb->cmd, " %7s %10s %15s\n", + Mmsg(mdb->cmd, " %7s %10s %15s\n", edit_uint64_with_commas(total_jobs, ewc1), - edit_uint64_with_commas(total_files, ewc2), + edit_uint64_with_commas(total_files, ewc2), edit_uint64_with_commas(total_bytes, ewc3)); sendit(ctx, mdb->cmd); sendit(ctx, "=======================================\n"); @@ -277,27 +277,27 @@ void db_list_files_for_job(JCR *jcr, B_DB *mdb, uint32_t jobid, DB_LIST_HANDLER void db_list_client_records(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ctx) { } -int db_list_sql_query(JCR *jcr, B_DB *mdb, char *query, DB_LIST_HANDLER *sendit, +int db_list_sql_query(JCR *jcr, B_DB *mdb, char *query, DB_LIST_HANDLER *sendit, void *ctx, int verbose, e_list_type type) { return 0; } void -db_list_pool_records(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ctx, e_list_type type) +db_list_pool_records(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ctx, e_list_type type) { } void -db_list_media_records(JCR *jcr, B_DB *mdb, MEDIA_DBR *mdbr, +db_list_media_records(JCR *jcr, B_DB *mdb, MEDIA_DBR *mdbr, DB_LIST_HANDLER *sendit, void *ctx, e_list_type type) { } -void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, uint32_t JobId, +void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, uint32_t JobId, DB_LIST_HANDLER *sendit, void *ctx, e_list_type type) { } void -db_list_job_records(JCR *jcr, B_DB *mdb, JOB_DBR *jr, DB_LIST_HANDLER *sendit, +db_list_job_records(JCR *jcr, B_DB *mdb, JOB_DBR *jr, DB_LIST_HANDLER *sendit, void *ctx, e_list_type type) { } diff --git a/bacula/src/cats/bdb_update.c b/bacula/src/cats/bdb_update.c index 3728613543..bea9cc8bec 100755 --- a/bacula/src/cats/bdb_update.c +++ b/bacula/src/cats/bdb_update.c @@ -7,8 +7,8 @@ * The purpose of these routines is to ensure that Bacula * can limp along if no real database is loaded on the * system. - * - * Kern Sibbald, January MMI + * + * Kern Sibbald, January MMI * * * Version $Id$ @@ -61,7 +61,7 @@ * most current start fields to the job record. * It is assumed that you did a db_create_job_record() already. */ -bool db_update_job_start_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr) +bool db_update_job_start_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr) { int len, stat = 1; JOB_DBR ojr; @@ -93,7 +93,7 @@ bool db_update_job_start_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr) * This is called at Job termination time to add all the * other fields to the job record. */ -int db_update_job_end_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr) +int db_update_job_end_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr) { int len, stat = 1; JOB_DBR ojr; @@ -121,12 +121,12 @@ int db_update_job_end_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr) } -int db_update_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) -{ +int db_update_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) +{ int stat = 1; MEDIA_DBR omr; int len; - + db_lock(mdb); Dmsg0(200, "In db_update_media_record\n"); mr->MediaId = 0; @@ -159,12 +159,12 @@ int db_update_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) return stat; } -int db_update_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr) -{ +int db_update_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr) +{ int stat = 1; POOL_DBR opr; int len; - + db_lock(mdb); Dmsg0(200, "In db_update_pool_record\n"); len = sizeof(opr); @@ -178,7 +178,7 @@ int db_update_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr) /* Update specific fields */ opr.NumVols = pr->NumVols; - opr.MaxVols = pr->MaxVols; + opr.MaxVols = pr->MaxVols; opr.UseOnce = pr->UseOnce; opr.UseCatalog = pr->UseCatalog; opr.AcceptAnyVolume = pr->AcceptAnyVolume; @@ -203,7 +203,7 @@ int db_add_SIG_to_file_record(JCR *jcr, B_DB *mdb, FileId_t FileId, char *SIG, i } int db_mark_file_record(JCR *jcr, B_DB *mdb, FileId_t FileId, JobId_t JobId) -{ +{ return 1; } @@ -217,7 +217,7 @@ int db_update_counter_record(JCR *jcr, B_DB *mdb, COUNTER_DBR *cr) return 0; } -int db_update_media_defaults(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) +int db_update_media_defaults(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) { return 1; } diff --git a/bacula/src/cats/cats.h b/bacula/src/cats/cats.h index 62125549c7..4b98d9094b 100644 --- a/bacula/src/cats/cats.h +++ b/bacula/src/cats/cats.h @@ -113,8 +113,8 @@ typedef struct s_db { } B_DB; -/* - * "Generic" names for easier conversion +/* + * "Generic" names for easier conversion * * S Q L I T E */ @@ -122,7 +122,7 @@ typedef struct s_db { #define sql_free_result(x) my_sqlite_free_table(x) #define sql_fetch_row(x) my_sqlite_fetch_row(x) #define sql_query(x, y) my_sqlite_query((x), (y)) -#define sql_close(x) sqlite_close((x)->db) +#define sql_close(x) sqlite_close((x)->db) #define sql_strerror(x) (x)->sqlite_errmsg?(x)->sqlite_errmsg:"unknown" #define sql_num_rows(x) (x)->nrow #define sql_data_seek(x, i) (x)->row = (i) @@ -131,7 +131,7 @@ typedef struct s_db { #define sql_field_seek(x, y) my_sqlite_field_seek((x), (y)) #define sql_fetch_field(x) my_sqlite_fetch_field(x) #define sql_num_fields(x) ((x)->ncolumn) -#define SQL_ROW char** +#define SQL_ROW char** @@ -195,7 +195,7 @@ typedef struct s_db { #define sql_free_result(x) mysql_free_result((x)->result) #define sql_fetch_row(x) mysql_fetch_row((x)->result) #define sql_query(x, y) mysql_query((x)->db, (y)) -#define sql_close(x) mysql_close((x)->db) +#define sql_close(x) mysql_close((x)->db) #define sql_strerror(x) mysql_error((x)->db) #define sql_num_rows(x) mysql_num_rows((x)->result) #define sql_data_seek(x, i) mysql_data_seek((x)->result, (i)) @@ -221,10 +221,10 @@ typedef struct s_db { typedef char **POSTGRESQL_ROW; typedef struct pg_field { - char *name; - int max_length; - unsigned int type; - unsigned int flags; // 1 == not null + char *name; + int max_length; + unsigned int type; + unsigned int flags; // 1 == not null } POSTGRESQL_FIELD; @@ -285,7 +285,7 @@ POSTGRESQL_FIELD * my_postgresql_fetch_field(B_DB *mdb); #define sql_free_result(x) my_postgresql_free_result(x) #define sql_fetch_row(x) my_postgresql_fetch_row(x) #define sql_query(x, y) my_postgresql_query((x), (y)) -#define sql_close(x) PQfinish((x)->db) +#define sql_close(x) PQfinish((x)->db) #define sql_strerror(x) PQresultErrorMessage((x)->result) #define sql_num_rows(x) ((unsigned) PQntuples((x)->result)) #define sql_data_seek(x, i) my_postgresql_data_seek((x), (i)) @@ -357,9 +357,9 @@ typedef struct s_db { /* This is a "dummy" definition for use outside of sql.c */ -typedef struct s_db { +typedef struct s_db { int dummy; /* for SunOS compiler */ -} B_DB; +} B_DB; #endif /* __SQL_C */ @@ -371,7 +371,7 @@ extern uint32_t bacula_db_version; typedef uint32_t FileId_t; typedef uint32_t DBId_t; /* general DB id type */ typedef uint32_t JobId_t; - + #define faddr_t long @@ -439,7 +439,7 @@ struct JOBMEDIA_DBR { /* Volume Parameter structure */ struct VOL_PARAMS { char VolumeName[MAX_NAME_LENGTH]; /* Volume name */ - uint32_t VolIndex; /* Volume seqence no. */ + uint32_t VolIndex; /* Volume seqence no. */ uint32_t FirstIndex; /* First index this Volume */ uint32_t LastIndex; /* Last index this Volume */ uint32_t StartFile; /* File for start of data */ @@ -497,7 +497,7 @@ struct POOL_DBR { uint32_t MaxVolJobs; /* Max Jobs on Volume */ uint32_t MaxVolFiles; /* Max files on Volume */ uint64_t MaxVolBytes; /* Max bytes on Volume */ - char PoolType[MAX_NAME_LENGTH]; + char PoolType[MAX_NAME_LENGTH]; char LabelFormat[MAX_NAME_LENGTH]; /* Extra stuff not in DB */ faddr_t rec_addr; @@ -584,7 +584,7 @@ struct FILESET_DBR { #include "jcr.h" /* - * Some functions exported by sql.c for use withing the + * Some functions exported by sql.c for use withing the * cats directory. */ void list_result(B_DB *mdb, DB_LIST_HANDLER *send, void *ctx, e_list_type type); @@ -593,5 +593,5 @@ int get_sql_record_max(JCR *jcr, B_DB *mdb); int check_tables_version(JCR *jcr, B_DB *mdb); void _db_unlock(const char *file, int line, B_DB *mdb); void _db_lock(const char *file, int line, B_DB *mdb); - + #endif /* __SQL_H_ */ diff --git a/bacula/src/cats/mysql.c b/bacula/src/cats/mysql.c index 1fc4d8aba2..a8cd052bbd 100644 --- a/bacula/src/cats/mysql.c +++ b/bacula/src/cats/mysql.c @@ -56,13 +56,13 @@ static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; * never have errors, or it is really fatal. */ B_DB * -db_init_database(JCR *jcr, const char *db_name, const char *db_user, const char *db_password, +db_init_database(JCR *jcr, const char *db_name, const char *db_user, const char *db_password, const char *db_address, int db_port, const char *db_socket, int mult_db_connections) { B_DB *mdb; - if (!db_user) { + if (!db_user) { Jmsg(jcr, M_FATAL, 0, _("A user name for MySQL must be supplied.\n")); return NULL; } @@ -71,7 +71,7 @@ db_init_database(JCR *jcr, const char *db_name, const char *db_user, const char if (!mult_db_connections) { for (mdb=NULL; (mdb=(B_DB *)qnext(&db_list, &mdb->bq)); ) { if (strcmp(mdb->db_name, db_name) == 0) { - Dmsg2(100, "DB REopen %d %s\n", mdb->ref_count, db_name); + Dmsg2(100, "DB REopen %d %s\n", mdb->ref_count, db_name); mdb->ref_count++; V(mutex); return mdb; /* already open */ @@ -127,7 +127,7 @@ db_open_database(JCR *jcr, B_DB *mdb) mdb->connected = FALSE; if ((errstat=rwl_init(&mdb->lock)) != 0) { - Mmsg1(&mdb->errmsg, _("Unable to initialize DB lock. ERR=%s\n"), + Mmsg1(&mdb->errmsg, _("Unable to initialize DB lock. ERR=%s\n"), strerror(errstat)); V(mutex); return 0; @@ -157,15 +157,15 @@ db_open_database(JCR *jcr, B_DB *mdb) } bmicrosleep(5,0); } - + Dmsg0(50, "mysql_real_connect done\n"); - Dmsg3(50, "db_user=%s db_name=%s db_password=%s\n", mdb->db_user, mdb->db_name, - mdb->db_password==NULL?"(NULL)":mdb->db_password); - + Dmsg3(50, "db_user=%s db_name=%s db_password=%s\n", mdb->db_user, mdb->db_name, + mdb->db_password==NULL?"(NULL)":mdb->db_password); + if (mdb->db == NULL) { - Mmsg2(&mdb->errmsg, _("Unable to connect to MySQL server. \n\ -Database=%s User=%s\n\ -It is probably not running or your password is incorrect.\n"), + Mmsg2(&mdb->errmsg, _("Unable to connect to MySQL server. \n" +"Database=%s User=%s\n" +"It is probably not running or your password is incorrect.\n"), mdb->db_name, mdb->db_user); V(mutex); return 0; @@ -204,7 +204,7 @@ db_close_database(JCR *jcr, B_DB *mdb) mysql_server_end(); #endif } - rwl_destroy(&mdb->lock); + rwl_destroy(&mdb->lock); free_pool_memory(mdb->errmsg); free_pool_memory(mdb->cmd); free_pool_memory(mdb->cached_path); @@ -234,7 +234,7 @@ db_close_database(JCR *jcr, B_DB *mdb) /* * Return the next unique index (auto-increment) for * the given table. Return NULL on error. - * + * * For MySQL, NULL causes the auto-increment value * to be updated. */ @@ -242,7 +242,7 @@ int db_next_index(JCR *jcr, B_DB *mdb, char *table, char *index) { strcpy(index, "NULL"); return 1; -} +} /* @@ -269,38 +269,38 @@ unsigned long mysql_real_escape_string(MYSQL *mysql, char *to, const char *from, while (len--) { switch (*o) { case 0: - *n++= '\\'; - *n++= '0'; + *n++= '\\'; + *n++= '0'; o++; break; case '\n': - *n++= '\\'; - *n++= 'n'; + *n++= '\\'; + *n++= 'n'; o++; break; case '\r': - *n++= '\\'; - *n++= 'r'; + *n++= '\\'; + *n++= 'r'; o++; break; case '\\': - *n++= '\\'; - *n++= '\\'; + *n++= '\\'; + *n++= '\\'; o++; break; case '\'': - *n++= '\\'; - *n++= '\''; + *n++= '\\'; + *n++= '\''; o++; break; case '"': - *n++= '\\'; - *n++= '"'; + *n++= '\\'; + *n++= '"'; o++; break; case '\032': - *n++= '\\'; - *n++= 'Z'; + *n++= '\\'; + *n++= 'Z'; o++; break; default: @@ -318,7 +318,7 @@ unsigned long mysql_real_escape_string(MYSQL *mysql, char *to, const char *from, int db_sql_query(B_DB *mdb, const char *query, DB_RESULT_HANDLER *result_handler, void *ctx) { SQL_ROW row; - + db_lock(mdb); if (sql_query(mdb, query) != 0) { Mmsg(mdb->errmsg, _("Query failed: %s: ERR=%s\n"), query, sql_strerror(mdb)); diff --git a/bacula/src/cats/postgresql.c b/bacula/src/cats/postgresql.c index 270d1b14eb..19d730a33a 100644 --- a/bacula/src/cats/postgresql.c +++ b/bacula/src/cats/postgresql.c @@ -58,13 +58,13 @@ static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; * never have errors, or it is really fatal. */ B_DB * -db_init_database(JCR *jcr, const char *db_name, const char *db_user, const char *db_password, - const char *db_address, int db_port, const char *db_socket, +db_init_database(JCR *jcr, const char *db_name, const char *db_user, const char *db_password, + const char *db_address, int db_port, const char *db_socket, int mult_db_connections) { B_DB *mdb; - if (!db_user) { + if (!db_user) { Jmsg(jcr, M_FATAL, 0, _("A user name for PostgreSQL must be supplied.\n")); return NULL; } @@ -73,7 +73,7 @@ db_init_database(JCR *jcr, const char *db_name, const char *db_user, const char /* Look to see if DB already open */ for (mdb=NULL; (mdb=(B_DB *)qnext(&db_list, &mdb->bq)); ) { if (strcmp(mdb->db_name, db_name) == 0) { - Dmsg2(100, "DB REopen %d %s\n", mdb->ref_count, db_name); + Dmsg2(100, "DB REopen %d %s\n", mdb->ref_count, db_name); mdb->ref_count++; V(mutex); return mdb; /* already open */ @@ -131,7 +131,7 @@ db_open_database(JCR *jcr, B_DB *mdb) mdb->connected = false; if ((errstat=rwl_init(&mdb->lock)) != 0) { - Mmsg1(&mdb->errmsg, _("Unable to initialize DB lock. ERR=%s\n"), + Mmsg1(&mdb->errmsg, _("Unable to initialize DB lock. ERR=%s\n"), strerror(errstat)); V(mutex); return 0; @@ -158,19 +158,19 @@ db_open_database(JCR *jcr, B_DB *mdb) /* If no connect, try once more in case it is a timing problem */ if (PQstatus(mdb->db) == CONNECTION_OK) { - break; + break; } bmicrosleep(5, 0); } Dmsg0(50, "pg_real_connect done\n"); - Dmsg3(50, "db_user=%s db_name=%s db_password=%s\n", mdb->db_user, mdb->db_name, - mdb->db_password==NULL?"(NULL)":mdb->db_password); - + Dmsg3(50, "db_user=%s db_name=%s db_password=%s\n", mdb->db_user, mdb->db_name, + mdb->db_password==NULL?"(NULL)":mdb->db_password); + if (PQstatus(mdb->db) != CONNECTION_OK) { Mmsg2(&mdb->errmsg, _("Unable to connect to PostgreSQL server.\n" - "Database=%s User=%s\n" - "It is probably not running or your password is incorrect.\n"), + "Database=%s User=%s\n" + "It is probably not running or your password is incorrect.\n"), mdb->db_name, mdb->db_user); V(mutex); return 0; @@ -199,7 +199,7 @@ db_close_database(JCR *jcr, B_DB *mdb) if (mdb->connected && mdb->db) { sql_close(mdb); } - rwl_destroy(&mdb->lock); + rwl_destroy(&mdb->lock); free_pool_memory(mdb->errmsg); free_pool_memory(mdb->cmd); free_pool_memory(mdb->cached_path); @@ -221,7 +221,7 @@ db_close_database(JCR *jcr, B_DB *mdb) if (mdb->db_socket) { free(mdb->db_socket); } - my_postgresql_free_result(mdb); + my_postgresql_free_result(mdb); free(mdb); } V(mutex); @@ -230,7 +230,7 @@ db_close_database(JCR *jcr, B_DB *mdb) /* * Return the next unique index (auto-increment) for * the given table. Return NULL on error. - * + * * For PostgreSQL, NULL causes the auto-increment value * to be updated. */ @@ -238,7 +238,7 @@ int db_next_index(JCR *jcr, B_DB *mdb, char *table, char *index) { strcpy(index, "NULL"); return 1; -} +} /* @@ -263,7 +263,7 @@ int db_sql_query(B_DB *mdb, const char *query, DB_RESULT_HANDLER *result_handler SQL_ROW row; Dmsg0(500, "db_sql_query started\n"); - + db_lock(mdb); if (sql_query(mdb, query) != 0) { Mmsg(mdb->errmsg, _("Query failed: %s: ERR=%s\n"), query, sql_strerror(mdb)); @@ -278,10 +278,10 @@ int db_sql_query(B_DB *mdb, const char *query, DB_RESULT_HANDLER *result_handler if ((mdb->result = sql_store_result(mdb)) != NULL) { int num_fields = sql_num_fields(mdb); - Dmsg0(500, "db_sql_query sql_store_result suceeded\n"); + Dmsg0(500, "db_sql_query sql_store_result suceeded\n"); while ((row = sql_fetch_row(mdb)) != NULL) { - Dmsg0(500, "db_sql_query sql_fetch_row worked\n"); + Dmsg0(500, "db_sql_query sql_fetch_row worked\n"); if (result_handler(ctx, num_fields, row)) break; } @@ -298,7 +298,7 @@ int db_sql_query(B_DB *mdb, const char *query, DB_RESULT_HANDLER *result_handler -POSTGRESQL_ROW my_postgresql_fetch_row(B_DB *mdb) +POSTGRESQL_ROW my_postgresql_fetch_row(B_DB *mdb) { int j; POSTGRESQL_ROW row = NULL; // by default, return NULL @@ -309,7 +309,7 @@ POSTGRESQL_ROW my_postgresql_fetch_row(B_DB *mdb) Dmsg1(500, "we have need space of %d bytes\n", sizeof(char *) * mdb->num_fields); if (mdb->row != NULL) { - Dmsg0(500, "my_postgresql_fetch_row freeing space\n"); + Dmsg0(500, "my_postgresql_fetch_row freeing space\n"); free(mdb->row); mdb->row = NULL; } @@ -326,7 +326,7 @@ POSTGRESQL_ROW my_postgresql_fetch_row(B_DB *mdb) // get each value from this row for (j = 0; j < mdb->num_fields; j++) { mdb->row[j] = PQgetvalue(mdb->result, mdb->row_number, j); - Dmsg2(500, "my_postgresql_fetch_row field '%d' has value '%s'\n", j, mdb->row[j]); + Dmsg2(500, "my_postgresql_fetch_row field '%d' has value '%s'\n", j, mdb->row[j]); } // increment the row number for the next call mdb->row_number++; @@ -352,11 +352,11 @@ int my_postgresql_max_length(B_DB *mdb, int field_num) { max_length = 0; for (i = 0; i < mdb->num_rows; i++) { if (PQgetisnull(mdb->result, i, field_num)) { - this_length = 4; // "NULL" + this_length = 4; // "NULL" } else { this_length = strlen(PQgetvalue(mdb->result, i, field_num)); } - + if (max_length < this_length) { max_length = this_length; } @@ -365,7 +365,7 @@ int my_postgresql_max_length(B_DB *mdb, int field_num) { return max_length; } -POSTGRESQL_FIELD * my_postgresql_fetch_field(B_DB *mdb) +POSTGRESQL_FIELD * my_postgresql_fetch_field(B_DB *mdb) { int i; @@ -375,13 +375,13 @@ POSTGRESQL_FIELD * my_postgresql_fetch_field(B_DB *mdb) mdb->fields = (POSTGRESQL_FIELD *)malloc(sizeof(POSTGRESQL_FIELD) * mdb->num_fields); for (i = 0; i < mdb->num_fields; i++) { - Dmsg1(500, "filling field %d\n", i); + Dmsg1(500, "filling field %d\n", i); mdb->fields[i].name = PQfname(mdb->result, i); mdb->fields[i].max_length = my_postgresql_max_length(mdb, i); mdb->fields[i].type = PQftype(mdb->result, i); mdb->fields[i].flags = 0; - Dmsg4(500, "my_postgresql_fetch_field finds field '%s' has length='%d' type='%d' and IsNull=%d\n", + Dmsg4(500, "my_postgresql_fetch_field finds field '%s' has length='%d' type='%d' and IsNull=%d\n", mdb->fields[i].name, mdb->fields[i].max_length, mdb->fields[i].type, mdb->fields[i].flags); } // end for @@ -393,7 +393,7 @@ POSTGRESQL_FIELD * my_postgresql_fetch_field(B_DB *mdb) return &mdb->fields[mdb->field_number++]; } -void my_postgresql_data_seek(B_DB *mdb, int row) +void my_postgresql_data_seek(B_DB *mdb, int row) { // set the row number to be returned on the next call // to my_postgresql_fetch_row @@ -444,7 +444,7 @@ int my_postgresql_query(B_DB *mdb, const char *query) { return mdb->status; } -void my_postgresql_free_result (B_DB *mdb) +void my_postgresql_free_result (B_DB *mdb) { if (mdb->result) { PQclear(mdb->result); @@ -462,7 +462,7 @@ void my_postgresql_free_result (B_DB *mdb) } } -int my_postgresql_currval(B_DB *mdb, char *table_name) +int my_postgresql_currval(B_DB *mdb, char *table_name) { // Obtain the current value of the sequence that // provides the serial value for primary key of the table. diff --git a/bacula/src/cats/protos.h b/bacula/src/cats/protos.h index 6fe707657a..4c049ce99f 100644 --- a/bacula/src/cats/protos.h +++ b/bacula/src/cats/protos.h @@ -33,8 +33,8 @@ /* Database prototypes */ /* sql.c */ -B_DB *db_init_database(JCR *jcr, const char *db_name, const char *db_user, const char *db_password, - const char *db_address, int db_port, const char *db_socket, +B_DB *db_init_database(JCR *jcr, const char *db_name, const char *db_user, const char *db_password, + const char *db_address, int db_port, const char *db_socket, int mult_db_connections); int db_open_database(JCR *jcr, B_DB *db); void db_close_database(JCR *jcr, B_DB *db); @@ -52,7 +52,7 @@ int db_create_job_record(JCR *jcr, B_DB *db, JOB_DBR *jr); int db_create_media_record(JCR *jcr, B_DB *db, MEDIA_DBR *media_dbr); int db_create_client_record(JCR *jcr, B_DB *db, CLIENT_DBR *cr); int db_create_fileset_record(JCR *jcr, B_DB *db, FILESET_DBR *fsr); -int db_create_pool_record(JCR *jcr, B_DB *db, POOL_DBR *pool_dbr); +int db_create_pool_record(JCR *jcr, B_DB *db, POOL_DBR *pool_dbr); bool db_create_jobmedia_record(JCR *jcr, B_DB *mdb, JOBMEDIA_DBR *jr); int db_create_counter_record(JCR *jcr, B_DB *mdb, COUNTER_DBR *cr); @@ -106,7 +106,7 @@ int db_update_pool_record(JCR *jcr, B_DB *db, POOL_DBR *pr); int db_update_media_record(JCR *jcr, B_DB *db, MEDIA_DBR *mr); int db_update_media_defaults(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr); int db_update_counter_record(JCR *jcr, B_DB *mdb, COUNTER_DBR *cr); -int db_add_SIG_to_file_record(JCR *jcr, B_DB *mdb, FileId_t FileId, char *SIG, int type); +int db_add_SIG_to_file_record(JCR *jcr, B_DB *mdb, FileId_t FileId, char *SIG, int type); int db_mark_file_record(JCR *jcr, B_DB *mdb, FileId_t FileId, JobId_t JobId); void db_make_inchanger_unique(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr); diff --git a/bacula/src/cats/sql.c b/bacula/src/cats/sql.c index 75b8e94333..a4c1872a70 100644 --- a/bacula/src/cats/sql.c +++ b/bacula/src/cats/sql.c @@ -1,6 +1,6 @@ /* * Bacula Catalog Database interface routines - * + * * Almost generic set of SQL database interface routines * (with a little more work) * @@ -64,7 +64,7 @@ static int int_handler(void *ctx, int num_fields, char **row) Dmsg0(800, "int_handler finishes\n"); return 0; } - + /* NOTE!!! The following routines expect that the @@ -75,7 +75,7 @@ static int int_handler(void *ctx, int num_fields, char **row) int check_tables_version(JCR *jcr, B_DB *mdb) { const char *query = "SELECT VersionId FROM Version"; - + bacula_db_version = 0; db_sql_query(mdb, query, int_handler, (void *)&bacula_db_version); if (bacula_db_version != BDB_VERSION) { @@ -96,7 +96,7 @@ QueryDB(const char *file, int line, JCR *jcr, B_DB *mdb, char *cmd) m_msg(file, line, &mdb->errmsg, _("query %s failed:\n%s\n"), cmd, sql_strerror(mdb)); j_msg(file, line, jcr, M_FATAL, 0, "%s", mdb->errmsg); if (verbose) { - j_msg(file, line, jcr, M_INFO, 0, "%s\n", cmd); + j_msg(file, line, jcr, M_INFO, 0, "%s\n", cmd); } return 0; } @@ -106,9 +106,9 @@ QueryDB(const char *file, int line, JCR *jcr, B_DB *mdb, char *cmd) return mdb->result != NULL; } -/* - * Utility routine to do inserts - * Returns: 0 on failure +/* + * Utility routine to do inserts + * Returns: 0 on failure * 1 on success */ int @@ -118,7 +118,7 @@ InsertDB(const char *file, int line, JCR *jcr, B_DB *mdb, char *cmd) m_msg(file, line, &mdb->errmsg, _("insert %s failed:\n%s\n"), cmd, sql_strerror(mdb)); j_msg(file, line, jcr, M_FATAL, 0, "%s", mdb->errmsg); if (verbose) { - j_msg(file, line, jcr, M_INFO, 0, "%s\n", cmd); + j_msg(file, line, jcr, M_INFO, 0, "%s\n", cmd); } return 0; } @@ -129,10 +129,10 @@ InsertDB(const char *file, int line, JCR *jcr, B_DB *mdb, char *cmd) } if (mdb->num_rows != 1) { char ed1[30]; - m_msg(file, line, &mdb->errmsg, _("Insertion problem: affected_rows=%s\n"), + m_msg(file, line, &mdb->errmsg, _("Insertion problem: affected_rows=%s\n"), edit_uint64(mdb->num_rows, ed1)); if (verbose) { - j_msg(file, line, jcr, M_INFO, 0, "%s\n", cmd); + j_msg(file, line, jcr, M_INFO, 0, "%s\n", cmd); } return 0; } @@ -142,7 +142,7 @@ InsertDB(const char *file, int line, JCR *jcr, B_DB *mdb, char *cmd) /* Utility routine for updates. * Returns: 0 on failure - * 1 on success + * 1 on success */ int UpdateDB(const char *file, int line, JCR *jcr, B_DB *mdb, char *cmd) @@ -152,14 +152,14 @@ UpdateDB(const char *file, int line, JCR *jcr, B_DB *mdb, char *cmd) m_msg(file, line, &mdb->errmsg, _("update %s failed:\n%s\n"), cmd, sql_strerror(mdb)); j_msg(file, line, jcr, M_ERROR, 0, "%s", mdb->errmsg); if (verbose) { - j_msg(file, line, jcr, M_INFO, 0, "%s\n", cmd); + j_msg(file, line, jcr, M_INFO, 0, "%s\n", cmd); } return 0; } mdb->num_rows = sql_affected_rows(mdb); if (mdb->num_rows < 1) { char ed1[30]; - m_msg(file, line, &mdb->errmsg, _("Update problem: affected_rows=%s\n"), + m_msg(file, line, &mdb->errmsg, _("Update problem: affected_rows=%s\n"), edit_uint64(mdb->num_rows, ed1)); if (verbose) { // j_msg(file, line, jcr, M_INFO, 0, "%s\n", cmd); @@ -170,7 +170,7 @@ UpdateDB(const char *file, int line, JCR *jcr, B_DB *mdb, char *cmd) return 1; } -/* Utility routine for deletes +/* Utility routine for deletes * * Returns: -1 on error * n number of rows affected @@ -183,7 +183,7 @@ DeleteDB(const char *file, int line, JCR *jcr, B_DB *mdb, char *cmd) m_msg(file, line, &mdb->errmsg, _("delete %s failed:\n%s\n"), cmd, sql_strerror(mdb)); j_msg(file, line, jcr, M_ERROR, 0, "%s", mdb->errmsg); if (verbose) { - j_msg(file, line, jcr, M_INFO, 0, "%s\n", cmd); + j_msg(file, line, jcr, M_INFO, 0, "%s\n", cmd); } return -1; } @@ -206,7 +206,7 @@ int get_sql_record_max(JCR *jcr, B_DB *mdb) if (QUERY_DB(jcr, mdb, mdb->cmd)) { if ((row = sql_fetch_row(mdb)) == NULL) { - Mmsg1(&mdb->errmsg, _("error fetching row: %s\n"), sql_strerror(mdb)); + Mmsg1(&mdb->errmsg, _("error fetching row: %s\n"), sql_strerror(mdb)); stat = -1; } else { stat = atoi(row[0]); @@ -240,7 +240,7 @@ void _db_lock(const char *file, int line, B_DB *mdb) e_msg(file, line, M_ABORT, 0, "rwl_writelock failure. ERR=%s\n", be.strerror(errstat)); } -} +} /* * Unlock the database. This can be called multiple times by the @@ -255,11 +255,11 @@ void _db_unlock(const char *file, int line, B_DB *mdb) e_msg(file, line, M_ABORT, 0, "rwl_writeunlock failure. ERR=%s\n", be.strerror(errstat)); } -} +} /* * Start a transaction. This groups inserts and makes things - * much more efficient. Usually started when inserting + * much more efficient. Usually started when inserting * file attributes. */ void db_start_transaction(JCR *jcr, B_DB *mdb) @@ -273,7 +273,7 @@ void db_start_transaction(JCR *jcr, B_DB *mdb) if (mdb->transaction && mdb->changes > 10000) { db_end_transaction(jcr, mdb); } - if (!mdb->transaction) { + if (!mdb->transaction) { my_sqlite_query(mdb, "BEGIN"); /* begin transaction */ Dmsg0(400, "Start SQLite transaction\n"); mdb->transaction = 1; @@ -283,7 +283,7 @@ void db_start_transaction(JCR *jcr, B_DB *mdb) /* * This is turned off because transactions break - * if multiple simultaneous jobs are run. + * if multiple simultaneous jobs are run. */ #ifdef HAVE_POSTGRESQL if (!mdb->allow_transactions) { @@ -294,7 +294,7 @@ void db_start_transaction(JCR *jcr, B_DB *mdb) if (mdb->transaction && mdb->changes > 25000) { db_end_transaction(jcr, mdb); } - if (!mdb->transaction) { + if (!mdb->transaction) { db_sql_query(mdb, "BEGIN", NULL, NULL); /* begin transaction */ Dmsg0(400, "Start PosgreSQL transaction\n"); mdb->transaction = 1; @@ -306,7 +306,7 @@ void db_start_transaction(JCR *jcr, B_DB *mdb) void db_end_transaction(JCR *jcr, B_DB *mdb) { /* - * This can be called during thread cleanup and + * This can be called during thread cleanup and * the db may already be closed. So simply return. */ if (!mdb) { @@ -350,7 +350,7 @@ void split_path_and_file(JCR *jcr, B_DB *mdb, const char *fname) { const char *p, *f; - /* Find path without the filename. + /* Find path without the filename. * I.e. everything after the last / is a "filename". * OK, maybe it is a directory name, but we treat it like * a filename. If we don't find a / then the whole name @@ -368,7 +368,7 @@ void split_path_and_file(JCR *jcr, B_DB *mdb, const char *fname) } /* If filename doesn't exist (i.e. root directory), we - * simply create a blank name consisting of a single + * simply create a blank name consisting of a single * space. This makes handling zero length filenames * easier. */ @@ -382,7 +382,7 @@ void split_path_and_file(JCR *jcr, B_DB *mdb, const char *fname) mdb->fnl = 0; } - mdb->pnl = f - fname; + mdb->pnl = f - fname; if (mdb->pnl > 0) { mdb->path = check_pool_memory_size(mdb->path, mdb->pnl+1); memcpy(mdb->path, fname, mdb->pnl); @@ -411,7 +411,7 @@ list_dashes(B_DB *mdb, DB_LIST_HANDLER *send, void *ctx) for (i = 0; i < sql_num_fields(mdb); i++) { field = sql_fetch_field(mdb); for (j = 0; j < (int)field->max_length + 2; j++) { - send(ctx, "-"); + send(ctx, "-"); } send(ctx, "+"); } @@ -419,8 +419,8 @@ list_dashes(B_DB *mdb, DB_LIST_HANDLER *send, void *ctx) } /* - * If full_list is set, we list vertically, otherwise, we - * list on one line horizontally. + * If full_list is set, we list vertically, otherwise, we + * list on one line horizontally. */ void list_result(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *send, void *ctx, e_list_type type) @@ -455,7 +455,7 @@ list_result(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *send, void *ctx, e_list_type t col_len = field->max_length; } if (col_len < 4 && !IS_NOT_NULL(field->flags)) { - col_len = 4; /* 4 = length of the word "NULL" */ + col_len = 4; /* 4 = length of the word "NULL" */ } field->max_length = col_len; /* reset column info */ } @@ -486,12 +486,12 @@ list_result(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *send, void *ctx, e_list_type t for (i = 0; i < sql_num_fields(mdb); i++) { field = sql_fetch_field(mdb); if (row[i] == NULL) { - bsnprintf(buf, sizeof(buf), " %-*s |", (int)field->max_length, "NULL"); + bsnprintf(buf, sizeof(buf), " %-*s |", (int)field->max_length, "NULL"); } else if (IS_NUM(field->type) && !jcr->gui && is_an_integer(row[i])) { - bsnprintf(buf, sizeof(buf), " %*s |", (int)field->max_length, + bsnprintf(buf, sizeof(buf), " %*s |", (int)field->max_length, add_commas(row[i], ewc)); } else { - bsnprintf(buf, sizeof(buf), " %-*s |", (int)field->max_length, row[i]); + bsnprintf(buf, sizeof(buf), " %-*s |", (int)field->max_length, row[i]); } send(ctx, buf); } @@ -501,19 +501,19 @@ list_result(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *send, void *ctx, e_list_type t return; vertical_list: - + Dmsg1(800, "list_result starts vertical list at %d fields\n", sql_num_fields(mdb)); while ((row = sql_fetch_row(mdb)) != NULL) { sql_field_seek(mdb, 0); for (i = 0; i < sql_num_fields(mdb); i++) { field = sql_fetch_field(mdb); if (row[i] == NULL) { - bsnprintf(buf, sizeof(buf), " %*s: %s\n", max_len, field->name, "NULL"); + bsnprintf(buf, sizeof(buf), " %*s: %s\n", max_len, field->name, "NULL"); } else if (IS_NUM(field->type) && !jcr->gui && is_an_integer(row[i])) { - bsnprintf(buf, sizeof(buf), " %*s: %s\n", max_len, field->name, + bsnprintf(buf, sizeof(buf), " %*s: %s\n", max_len, field->name, add_commas(row[i], ewc)); } else { - bsnprintf(buf, sizeof(buf), " %*s: %s\n", max_len, field->name, row[i]); + bsnprintf(buf, sizeof(buf), " %*s: %s\n", max_len, field->name, row[i]); } send(ctx, buf); } diff --git a/bacula/src/cats/sql_create.c b/bacula/src/cats/sql_create.c index 03c7d9f81a..147538484a 100644 --- a/bacula/src/cats/sql_create.c +++ b/bacula/src/cats/sql_create.c @@ -1,6 +1,6 @@ /* * Bacula Catalog Database Create record interface routines - * + * * Kern Sibbald, March 2000 * * Version $Id$ @@ -77,19 +77,19 @@ db_create_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr) stime = jr->SchedTime; ASSERT(stime != 0); - localtime_r(&stime, &tm); + localtime_r(&stime, &tm); strftime(dt, sizeof(dt), "%Y-%m-%d %T", &tm); JobTDate = (utime_t)stime; /* Must create it */ Mmsg(mdb->cmd, -"INSERT INTO Job (Job,Name,Type,Level,JobStatus,SchedTime,JobTDate) VALUES \ -('%s','%s','%c','%c','%c','%s',%s)", - jr->Job, jr->Name, (char)(jr->JobType), (char)(jr->JobLevel), +"INSERT INTO Job (Job,Name,Type,Level,JobStatus,SchedTime,JobTDate) VALUES " +"('%s','%s','%c','%c','%c','%s',%s)", + jr->Job, jr->Name, (char)(jr->JobType), (char)(jr->JobLevel), (char)(jr->JobStatus), dt, edit_uint64(JobTDate, ed1)); if (!INSERT_DB(jcr, mdb, mdb->cmd)) { - Mmsg2(&mdb->errmsg, _("Create DB Job record %s failed. ERR=%s\n"), + Mmsg2(&mdb->errmsg, _("Create DB Job record %s failed. ERR=%s\n"), mdb->cmd, sql_strerror(mdb)); jr->JobId = 0; stat = 0; @@ -101,7 +101,7 @@ db_create_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr) return stat; } -/* Create a JobMedia record for medium used this job +/* Create a JobMedia record for medium used this job * Returns: false on failure * true on success */ @@ -121,25 +121,25 @@ db_create_jobmedia_record(JCR *jcr, B_DB *mdb, JOBMEDIA_DBR *jm) } count++; - Mmsg(mdb->cmd, - "INSERT INTO JobMedia (JobId,MediaId,FirstIndex,LastIndex," - "StartFile,EndFile,StartBlock,EndBlock,VolIndex) " - "VALUES (%u,%u,%u,%u,%u,%u,%u,%u,%u)", + Mmsg(mdb->cmd, + "INSERT INTO JobMedia (JobId,MediaId,FirstIndex,LastIndex," + "StartFile,EndFile,StartBlock,EndBlock,VolIndex) " + "VALUES (%u,%u,%u,%u,%u,%u,%u,%u,%u)", jm->JobId, jm->MediaId, jm->FirstIndex, jm->LastIndex, jm->StartFile, jm->EndFile, jm->StartBlock, jm->EndBlock,count); Dmsg0(300, mdb->cmd); if (!INSERT_DB(jcr, mdb, mdb->cmd)) { - Mmsg2(&mdb->errmsg, _("Create JobMedia record %s failed: ERR=%s\n"), mdb->cmd, + Mmsg2(&mdb->errmsg, _("Create JobMedia record %s failed: ERR=%s\n"), mdb->cmd, sql_strerror(mdb)); ok = false; } else { /* Worked, now update the Media record with the EndFile and EndBlock */ - Mmsg(mdb->cmd, - "UPDATE Media SET EndFile=%u, EndBlock=%u WHERE MediaId=%u", + Mmsg(mdb->cmd, + "UPDATE Media SET EndFile=%u, EndBlock=%u WHERE MediaId=%u", jm->EndFile, jm->EndBlock, jm->MediaId); if (!UPDATE_DB(jcr, mdb, mdb->cmd)) { - Mmsg2(&mdb->errmsg, _("Update Media record %s failed: ERR=%s\n"), mdb->cmd, + Mmsg2(&mdb->errmsg, _("Update Media record %s failed: ERR=%s\n"), mdb->cmd, sql_strerror(mdb)); ok = false; } @@ -169,7 +169,7 @@ db_create_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr) if (QUERY_DB(jcr, mdb, mdb->cmd)) { mdb->num_rows = sql_num_rows(mdb); if (mdb->num_rows > 0) { - Mmsg1(&mdb->errmsg, _("pool record %s already exists\n"), pr->Name); + Mmsg1(&mdb->errmsg, _("pool record %s already exists\n"), pr->Name); sql_free_result(mdb); db_unlock(mdb); return 0; @@ -178,11 +178,11 @@ db_create_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr) } /* Must create it */ - Mmsg(mdb->cmd, -"INSERT INTO Pool (Name,NumVols,MaxVols,UseOnce,UseCatalog,\ -AcceptAnyVolume,AutoPrune,Recycle,VolRetention,VolUseDuration,\ -MaxVolJobs,MaxVolFiles,MaxVolBytes,PoolType,LabelFormat) \ -VALUES ('%s',%u,%u,%d,%d,%d,%d,%d,%s,%s,%u,%u,%s,'%s','%s')", + Mmsg(mdb->cmd, +"INSERT INTO Pool (Name,NumVols,MaxVols,UseOnce,UseCatalog," +"AcceptAnyVolume,AutoPrune,Recycle,VolRetention,VolUseDuration," +"MaxVolJobs,MaxVolFiles,MaxVolBytes,PoolType,LabelFormat) " +"VALUES ('%s',%u,%u,%d,%d,%d,%d,%d,%s,%s,%u,%u,%s,'%s','%s')", pr->Name, pr->NumVols, pr->MaxVols, pr->UseOnce, pr->UseCatalog, @@ -195,7 +195,7 @@ VALUES ('%s',%u,%u,%d,%d,%d,%d,%d,%s,%s,%u,%u,%s,'%s','%s')", pr->PoolType, pr->LabelFormat); Dmsg1(200, "Create Pool: %s\n", mdb->cmd); if (!INSERT_DB(jcr, mdb, mdb->cmd)) { - Mmsg2(&mdb->errmsg, _("Create db Pool record %s failed: ERR=%s\n"), + Mmsg2(&mdb->errmsg, _("Create db Pool record %s failed: ERR=%s\n"), mdb->cmd, sql_strerror(mdb)); pr->PoolId = 0; stat = 0; @@ -204,17 +204,17 @@ VALUES ('%s',%u,%u,%d,%d,%d,%d,%d,%s,%s,%u,%u,%s,'%s','%s')", stat = 1; } db_unlock(mdb); - + return stat; } -/* +/* * Create Media record. VolumeName and non-zero Slot must be unique * * Returns: 0 on failure * 1 on success - */ + */ int db_create_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) { @@ -223,14 +223,14 @@ db_create_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) struct tm tm; db_lock(mdb); - Mmsg(mdb->cmd, "SELECT MediaId FROM Media WHERE VolumeName='%s'", + Mmsg(mdb->cmd, "SELECT MediaId FROM Media WHERE VolumeName='%s'", mr->VolumeName); Dmsg1(300, "selectpool: %s\n", mdb->cmd); if (QUERY_DB(jcr, mdb, mdb->cmd)) { mdb->num_rows = sql_num_rows(mdb); if (mdb->num_rows > 0) { - Mmsg1(&mdb->errmsg, _("Volume \"%s\" already exists.\n"), mr->VolumeName); + Mmsg1(&mdb->errmsg, _("Volume \"%s\" already exists.\n"), mr->VolumeName); sql_free_result(mdb); db_unlock(mdb); return 0; @@ -239,14 +239,14 @@ db_create_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) } /* Must create it */ - Mmsg(mdb->cmd, -"INSERT INTO Media (VolumeName,MediaType,PoolId,MaxVolBytes,VolCapacityBytes," + Mmsg(mdb->cmd, +"INSERT INTO Media (VolumeName,MediaType,PoolId,MaxVolBytes,VolCapacityBytes," "Recycle,VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles," -"VolStatus,Slot,VolBytes,InChanger,VolReadTime,VolWriteTime," +"VolStatus,Slot,VolBytes,InChanger,VolReadTime,VolWriteTime," "EndFile,EndBlock) " -"VALUES ('%s','%s',%u,%s,%s,%d,%s,%s,%u,%u,'%s',%d,%s,%d,%s,%s,0,0)", +"VALUES ('%s','%s',%u,%s,%s,%d,%s,%s,%u,%u,'%s',%d,%s,%d,%s,%s,0,0)", mr->VolumeName, - mr->MediaType, mr->PoolId, + mr->MediaType, mr->PoolId, edit_uint64(mr->MaxVolBytes,ed1), edit_uint64(mr->VolCapacityBytes, ed2), mr->Recycle, @@ -273,9 +273,9 @@ db_create_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) if (mr->LabelDate) { char dt[MAX_TIME_LENGTH]; localtime_r(&mr->LabelDate, &tm); - strftime(dt, sizeof(dt), "%Y-%m-%d %T", &tm); - Mmsg(mdb->cmd, "UPDATE Media SET LabelDate='%s' " - "WHERE MediaId=%d", dt, mr->MediaId); + strftime(dt, sizeof(dt), "%Y-%m-%d %T", &tm); + Mmsg(mdb->cmd, "UPDATE Media SET LabelDate='%s' " + "WHERE MediaId=%d", dt, mr->MediaId); stat = UPDATE_DB(jcr, mdb, mdb->cmd); } } @@ -292,8 +292,8 @@ db_create_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) -/* - * Create a Unique record for the client -- no duplicates +/* + * Create a Unique record for the client -- no duplicates * Returns: 0 on failure * 1 on success with id in cr->ClientId */ @@ -311,13 +311,13 @@ int db_create_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cr) mdb->num_rows = sql_num_rows(mdb); /* If more than one, report error, but return first row */ if (mdb->num_rows > 1) { - Mmsg1(&mdb->errmsg, _("More than one Client!: %d\n"), (int)(mdb->num_rows)); - Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg); + Mmsg1(&mdb->errmsg, _("More than one Client!: %d\n"), (int)(mdb->num_rows)); + Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg); } if (mdb->num_rows >= 1) { if ((row = sql_fetch_row(mdb)) == NULL) { - Mmsg1(&mdb->errmsg, _("error fetching Client row: %s\n"), sql_strerror(mdb)); - Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg); + Mmsg1(&mdb->errmsg, _("error fetching Client row: %s\n"), sql_strerror(mdb)); + Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg); sql_free_result(mdb); db_unlock(mdb); return 0; @@ -336,9 +336,9 @@ int db_create_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cr) } /* Must create it */ - Mmsg(mdb->cmd, "INSERT INTO Client (Name, Uname, AutoPrune, \ -FileRetention, JobRetention) VALUES \ -('%s', '%s', %d, %s, %s)", cr->Name, cr->Uname, cr->AutoPrune, + Mmsg(mdb->cmd, "INSERT INTO Client (Name, Uname, AutoPrune, " +"FileRetention, JobRetention) VALUES " +"('%s', '%s', %d, %s, %s)", cr->Name, cr->Uname, cr->AutoPrune, edit_uint64(cr->FileRetention, ed1), edit_uint64(cr->JobRetention, ed2)); @@ -357,8 +357,8 @@ FileRetention, JobRetention) VALUES \ } -/* - * Create a Unique record for the counter -- no duplicates +/* + * Create a Unique record for the counter -- no duplicates * Returns: 0 on failure * 1 on success with counter filled in */ @@ -395,7 +395,7 @@ int db_create_counter_record(JCR *jcr, B_DB *mdb, COUNTER_DBR *cr) } -/* +/* * Create a FileSet record. This record is unique in the * name and the MD5 signature of the include/exclude sets. * Returns: 0 on failure @@ -416,13 +416,13 @@ int db_create_fileset_record(JCR *jcr, B_DB *mdb, FILESET_DBR *fsr) if (QUERY_DB(jcr, mdb, mdb->cmd)) { mdb->num_rows = sql_num_rows(mdb); if (mdb->num_rows > 1) { - Mmsg1(&mdb->errmsg, _("More than one FileSet!: %d\n"), (int)(mdb->num_rows)); - Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg); + Mmsg1(&mdb->errmsg, _("More than one FileSet!: %d\n"), (int)(mdb->num_rows)); + Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg); } if (mdb->num_rows >= 1) { if ((row = sql_fetch_row(mdb)) == NULL) { - Mmsg1(&mdb->errmsg, _("error fetching FileSet row: ERR=%s\n"), sql_strerror(mdb)); - Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg); + Mmsg1(&mdb->errmsg, _("error fetching FileSet row: ERR=%s\n"), sql_strerror(mdb)); + Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg); sql_free_result(mdb); db_unlock(mdb); return 0; @@ -482,17 +482,17 @@ int db_create_fileset_record(JCR *jcr, B_DB *mdb, FILESET_DBR *fsr) * unsigned long st_blocks; * number of blocks allocated * * time_t st_atime; * time of last access * * time_t st_mtime; * time of last modification * - * time_t st_ctime; * time of last inode change * + * time_t st_ctime; * time of last inode change * * }; */ -/* - * Create File record in B_DB +/* + * Create File record in B_DB * * In order to reduce database size, we store the File attributes, - * the FileName, and the Path separately. In principle, there + * the FileName, and the Path separately. In principle, there * is a single FileName record and a single Path record, no matter * how many times it occurs. This is this subroutine, we separate * the file and the path and create three database records. @@ -506,7 +506,7 @@ int db_create_file_attributes_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar) /* * Make sure we have an acceptable attributes record. */ - if (!(ar->Stream == STREAM_UNIX_ATTRIBUTES || + if (!(ar->Stream == STREAM_UNIX_ATTRIBUTES || ar->Stream == STREAM_UNIX_ATTRIBUTES_EX)) { Mmsg0(&mdb->errmsg, _("Attempt to put non-attributes into catalog\n")); Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg); @@ -556,13 +556,13 @@ static int db_create_file_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar) /* Must create it */ Mmsg(mdb->cmd, - "INSERT INTO File (FileIndex,JobId,PathId,FilenameId," - "LStat,MD5) VALUES (%u,%u,%u,%u,'%s','0')", - ar->FileIndex, ar->JobId, ar->PathId, ar->FilenameId, + "INSERT INTO File (FileIndex,JobId,PathId,FilenameId," + "LStat,MD5) VALUES (%u,%u,%u,%u,'%s','0')", + ar->FileIndex, ar->JobId, ar->PathId, ar->FilenameId, ar->attr); if (!INSERT_DB(jcr, mdb, mdb->cmd)) { - Mmsg2(&mdb->errmsg, _("Create db File record %s failed. ERR=%s"), + Mmsg2(&mdb->errmsg, _("Create db File record %s failed. ERR=%s"), mdb->cmd, sql_strerror(mdb)); Jmsg(jcr, M_FATAL, 0, "%s", mdb->errmsg); ar->FileId = 0; @@ -587,7 +587,7 @@ static int db_create_path_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar) strcmp(mdb->cached_path, mdb->path) == 0) { ar->PathId = mdb->cached_path_id; return 1; - } + } Mmsg(mdb->cmd, "SELECT PathId FROM Path WHERE Path='%s'", mdb->esc_name); @@ -595,15 +595,15 @@ static int db_create_path_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar) mdb->num_rows = sql_num_rows(mdb); if (mdb->num_rows > 1) { char ed1[30]; - Mmsg2(&mdb->errmsg, _("More than one Path!: %s for path: %s\n"), + Mmsg2(&mdb->errmsg, _("More than one Path!: %s for path: %s\n"), edit_uint64(mdb->num_rows, ed1), mdb->path); - Jmsg(jcr, M_WARNING, 0, "%s", mdb->errmsg); + Jmsg(jcr, M_WARNING, 0, "%s", mdb->errmsg); } /* Even if there are multiple paths, take the first one */ if (mdb->num_rows >= 1) { if ((row = sql_fetch_row(mdb)) == NULL) { - Mmsg1(&mdb->errmsg, _("error fetching row: %s\n"), sql_strerror(mdb)); - Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg); + Mmsg1(&mdb->errmsg, _("error fetching row: %s\n"), sql_strerror(mdb)); + Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg); sql_free_result(mdb); ar->PathId = 0; ASSERT(ar->PathId); @@ -626,7 +626,7 @@ static int db_create_path_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar) Mmsg(mdb->cmd, "INSERT INTO Path (Path) VALUES ('%s')", mdb->esc_name); if (!INSERT_DB(jcr, mdb, mdb->cmd)) { - Mmsg2(&mdb->errmsg, _("Create db Path record %s failed. ERR=%s\n"), + Mmsg2(&mdb->errmsg, _("Create db Path record %s failed. ERR=%s\n"), mdb->cmd, sql_strerror(mdb)); Jmsg(jcr, M_FATAL, 0, "%s", mdb->errmsg); ar->PathId = 0; @@ -646,7 +646,7 @@ static int db_create_path_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar) } /* Create a Unique record for the filename -- no duplicates */ -static int db_create_filename_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar) +static int db_create_filename_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar) { SQL_ROW row; @@ -659,15 +659,15 @@ static int db_create_filename_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar) mdb->num_rows = sql_num_rows(mdb); if (mdb->num_rows > 1) { char ed1[30]; - Mmsg2(&mdb->errmsg, _("More than one Filename! %s for file: %s\n"), + Mmsg2(&mdb->errmsg, _("More than one Filename! %s for file: %s\n"), edit_uint64(mdb->num_rows, ed1), mdb->fname); - Jmsg(jcr, M_WARNING, 0, "%s", mdb->errmsg); + Jmsg(jcr, M_WARNING, 0, "%s", mdb->errmsg); } if (mdb->num_rows >= 1) { if ((row = sql_fetch_row(mdb)) == NULL) { - Mmsg2(&mdb->errmsg, _("Error fetching row for file=%s: ERR=%s\n"), + Mmsg2(&mdb->errmsg, _("Error fetching row for file=%s: ERR=%s\n"), mdb->fname, sql_strerror(mdb)); - Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg); + Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg); ar->FilenameId = 0; } else { ar->FilenameId = atoi(row[0]); @@ -681,7 +681,7 @@ static int db_create_filename_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar) Mmsg(mdb->cmd, "INSERT INTO Filename (Name) VALUES ('%s')", mdb->esc_name); if (!INSERT_DB(jcr, mdb, mdb->cmd)) { - Mmsg2(&mdb->errmsg, _("Create db Filename record %s failed. ERR=%s\n"), + Mmsg2(&mdb->errmsg, _("Create db Filename record %s failed. ERR=%s\n"), mdb->cmd, sql_strerror(mdb)); Jmsg(jcr, M_FATAL, 0, "%s", mdb->errmsg); ar->FilenameId = 0; diff --git a/bacula/src/cats/sql_delete.c b/bacula/src/cats/sql_delete.c index fd07956607..a35b64e900 100644 --- a/bacula/src/cats/sql_delete.c +++ b/bacula/src/cats/sql_delete.c @@ -1,6 +1,6 @@ /* * Bacula Catalog Database Delete record interface routines - * + * * Kern Sibbald, December 2000 * * Version $Id$ @@ -50,7 +50,7 @@ extern void print_dashes(B_DB *mdb); extern void print_result(B_DB *mdb); extern int QueryDB(const char *file, int line, JCR *jcr, B_DB *db, char *select_cmd); extern int DeleteDB(const char *file, int line, JCR *jcr, B_DB *db, char *delete_cmd); - + /* * Delete Pool record, must also delete all associated * Media records. @@ -74,20 +74,20 @@ db_delete_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr) if (QUERY_DB(jcr, mdb, mdb->cmd)) { mdb->num_rows = sql_num_rows(mdb); - + if (mdb->num_rows == 0) { - Mmsg(mdb->errmsg, _("No pool record %s exists\n"), pr->Name); + Mmsg(mdb->errmsg, _("No pool record %s exists\n"), pr->Name); sql_free_result(mdb); db_unlock(mdb); return 0; } else if (mdb->num_rows != 1) { - Mmsg(mdb->errmsg, _("Expecting one pool record, got %d\n"), mdb->num_rows); + Mmsg(mdb->errmsg, _("Expecting one pool record, got %d\n"), mdb->num_rows); sql_free_result(mdb); db_unlock(mdb); return 0; } if ((row = sql_fetch_row(mdb)) == NULL) { - Mmsg1(&mdb->errmsg, _("Error fetching row %s\n"), sql_strerror(mdb)); + Mmsg1(&mdb->errmsg, _("Error fetching row %s\n"), sql_strerror(mdb)); db_unlock(mdb); return 0; } @@ -115,7 +115,7 @@ db_delete_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr) #define MAX_DEL_LIST_LEN 1000000 struct s_del_ctx { - JobId_t *JobId; + JobId_t *JobId; int num_ids; /* ids stored */ int max_ids; /* size of array */ int num_del; /* number deleted */ @@ -133,7 +133,7 @@ static int delete_handler(void *ctx, int num_fields, char **row) { struct s_del_ctx *del = (struct s_del_ctx *)ctx; - if (del->num_ids == MAX_DEL_LIST_LEN) { + if (del->num_ids == MAX_DEL_LIST_LEN) { return 1; } if (del->num_ids == del->max_ids) { @@ -146,8 +146,8 @@ static int delete_handler(void *ctx, int num_fields, char **row) } -/* - * This routine will purge (delete) all records +/* + * This routine will purge (delete) all records * associated with a particular Volume. It will * not delete the media record itself. */ @@ -194,7 +194,7 @@ int db_delete_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) if (mr->MediaId == 0 && !db_get_media_record(jcr, mdb, mr)) { db_unlock(mdb); return 0; - } + } /* Do purge if not already purged */ if (strcmp(mr->VolStatus, "Purged") != 0) { /* Delete associated records */ @@ -208,7 +208,7 @@ int db_delete_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) } /* - * Purge all records associated with a + * Purge all records associated with a * media record. This does not delete the * media record itself. But the media status * is changed to "Purged". @@ -219,7 +219,7 @@ int db_purge_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) if (mr->MediaId == 0 && !db_get_media_record(jcr, mdb, mr)) { db_unlock(mdb); return 0; - } + } /* Delete associated records */ do_media_purge(mdb, mr); /* Note, always purge */ diff --git a/bacula/src/cats/sql_find.c b/bacula/src/cats/sql_find.c index b09d69189d..dd10220aa1 100644 --- a/bacula/src/cats/sql_find.c +++ b/bacula/src/cats/sql_find.c @@ -4,7 +4,7 @@ * Note, generally, these routines are more complicated * that a simple search by name or id. Such simple * request are in get.c - * + * * Kern Sibbald, December 2000 * * Version $Id$ @@ -57,7 +57,7 @@ extern int QueryDB(const char *file, int line, JCR *jcr, B_DB *db, char *select_ * find last full save for Incremental and Differential saves. * * StartTime is returned in stime - * + * * Returns: 0 on failure * 1 on success, jr is unchanged, but stime is set */ @@ -72,7 +72,7 @@ db_find_job_start_time(JCR *jcr, B_DB *mdb, JOB_DBR *jr, POOLMEM **stime) /* If no Id given, we must find corresponding job */ if (jr->JobId == 0) { /* Differential is since last Full backup */ - Mmsg(mdb->cmd, + Mmsg(mdb->cmd, "SELECT StartTime FROM Job WHERE JobStatus='T' AND Type='%c' AND " "Level='%c' AND Name='%s' AND ClientId=%u AND FileSetId=%u " "ORDER BY StartTime DESC LIMIT 1", @@ -83,34 +83,34 @@ db_find_job_start_time(JCR *jcr, B_DB *mdb, JOB_DBR *jr, POOLMEM **stime) /* Incremental is since last Full, Incremental, or Differential */ } else if (jr->JobLevel == L_INCREMENTAL) { - /* + /* * For an Incremental job, we must first ensure * that a Full backup was done (cmd edited above) * then we do a second look to find the most recent * backup */ if (!QUERY_DB(jcr, mdb, mdb->cmd)) { - Mmsg2(&mdb->errmsg, _("Query error for start time request: ERR=%s\nCMD=%s\n"), + Mmsg2(&mdb->errmsg, _("Query error for start time request: ERR=%s\nCMD=%s\n"), sql_strerror(mdb), mdb->cmd); db_unlock(mdb); return 0; } if ((row = sql_fetch_row(mdb)) == NULL) { sql_free_result(mdb); - Mmsg(mdb->errmsg, _("No prior Full backup Job record found.\n")); + Mmsg(mdb->errmsg, _("No prior Full backup Job record found.\n")); db_unlock(mdb); return 0; } sql_free_result(mdb); /* Now edit SQL command for Incremental Job */ - Mmsg(mdb->cmd, + Mmsg(mdb->cmd, "SELECT StartTime FROM Job WHERE JobStatus='T' AND Type='%c' AND " "Level IN ('%c','%c','%c') AND Name='%s' AND ClientId=%u " "AND FileSetId=%u ORDER BY StartTime DESC LIMIT 1", jr->JobType, L_INCREMENTAL, L_DIFFERENTIAL, L_FULL, jr->Name, jr->ClientId, jr->FileSetId); } else { - Mmsg1(&mdb->errmsg, _("Unknown level=%d\n"), jr->JobLevel); + Mmsg1(&mdb->errmsg, _("Unknown level=%d\n"), jr->JobLevel); db_unlock(mdb); return 0; } @@ -144,7 +144,7 @@ db_find_job_start_time(JCR *jcr, B_DB *mdb, JOB_DBR *jr, POOLMEM **stime) } /* - * Find last failed job since given start-time + * Find last failed job since given start-time * it must be either Full or Diff. * * Returns: false on failure @@ -158,7 +158,7 @@ db_find_failed_job_since(JCR *jcr, B_DB *mdb, JOB_DBR *jr, POOLMEM *stime, int & db_lock(mdb); /* Differential is since last Full backup */ - Mmsg(mdb->cmd, + Mmsg(mdb->cmd, "SELECT Level FROM Job WHERE JobStatus!='T' AND Type='%c' AND " "Level IN ('%c','%c') AND Name='%s' AND ClientId=%u " "AND FileSetId=%u AND StartTime>'%s' " @@ -184,7 +184,7 @@ db_find_failed_job_since(JCR *jcr, B_DB *mdb, JOB_DBR *jr, POOLMEM *stime, int & } -/* +/* * Find JobId of last job that ran. E.g. for * VERIFY_CATALOG we want the JobId of the last INIT. * For VERIFY_VOLUME_TO_CATALOG, we want the JobId of the last Job. @@ -200,7 +200,7 @@ db_find_last_jobid(JCR *jcr, B_DB *mdb, const char *Name, JOB_DBR *jr) /* Find last full */ db_lock(mdb); if (jr->JobLevel == L_VERIFY_CATALOG) { - Mmsg(mdb->cmd, + Mmsg(mdb->cmd, "SELECT JobId FROM Job WHERE Type='V' AND Level='%c' AND " " JobStatus='T' AND Name='%s' AND " "ClientId=%u ORDER BY StartTime DESC LIMIT 1", @@ -212,7 +212,7 @@ db_find_last_jobid(JCR *jcr, B_DB *mdb, const char *Name, JOB_DBR *jr) "SELECT JobId FROM Job WHERE Type='B' AND JobStatus='T' AND " "Name='%s' ORDER BY StartTime DESC LIMIT 1", Name); } else { - Mmsg(mdb->cmd, + Mmsg(mdb->cmd, "SELECT JobId FROM Job WHERE Type='B' AND JobStatus='T' AND " "ClientId=%u ORDER BY StartTime DESC LIMIT 1", jr->ClientId); } @@ -247,7 +247,7 @@ db_find_last_jobid(JCR *jcr, B_DB *mdb, const char *Name, JOB_DBR *jr) return 1; } -/* +/* * Find Available Media (Volume) for Pool * * Find a Volume for a given PoolId, MediaType, and Status. @@ -256,7 +256,7 @@ db_find_last_jobid(JCR *jcr, B_DB *mdb, const char *Name, JOB_DBR *jr) * numrows on success */ int -db_find_next_volume(JCR *jcr, B_DB *mdb, int item, bool InChanger, MEDIA_DBR *mr) +db_find_next_volume(JCR *jcr, B_DB *mdb, int item, bool InChanger, MEDIA_DBR *mr) { SQL_ROW row; int numrows; @@ -266,33 +266,33 @@ db_find_next_volume(JCR *jcr, B_DB *mdb, int item, bool InChanger, MEDIA_DBR *mr if (item == -1) { /* find oldest volume */ /* Find oldest volume */ Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,VolJobs,VolFiles,VolBlocks," - "VolBytes,VolMounts,VolErrors,VolWrites,MaxVolBytes,VolCapacityBytes," - "VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles,Recycle,Slot," - "FirstWritten,LastWritten,VolStatus,InChanger " - "FROM Media WHERE PoolId=%u AND MediaType='%s' AND VolStatus IN ('Full'," - "'Recycle','Purged','Used','Append') " - "ORDER BY LastWritten LIMIT 1", mr->PoolId, mr->MediaType); + "VolBytes,VolMounts,VolErrors,VolWrites,MaxVolBytes,VolCapacityBytes," + "VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles,Recycle,Slot," + "FirstWritten,LastWritten,VolStatus,InChanger " + "FROM Media WHERE PoolId=%u AND MediaType='%s' AND VolStatus IN ('Full'," + "'Recycle','Purged','Used','Append') " + "ORDER BY LastWritten LIMIT 1", mr->PoolId, mr->MediaType); item = 1; } else { /* Find next available volume */ if (InChanger) { - changer = "AND InChanger=1"; + changer = "AND InChanger=1"; } else { - changer = ""; + changer = ""; } if (strcmp(mr->VolStatus, "Recycled") == 0 || - strcmp(mr->VolStatus, "Purged") == 0) { - order = "ORDER BY LastWritten ASC,MediaId"; /* take oldest */ + strcmp(mr->VolStatus, "Purged") == 0) { + order = "ORDER BY LastWritten ASC,MediaId"; /* take oldest */ } else { - order = "ORDER BY LastWritten IS NULL,LastWritten DESC,MediaId"; /* take most recently written */ - } + order = "ORDER BY LastWritten IS NULL,LastWritten DESC,MediaId"; /* take most recently written */ + } Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,VolJobs,VolFiles,VolBlocks," - "VolBytes,VolMounts,VolErrors,VolWrites,MaxVolBytes,VolCapacityBytes," - "VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles,Recycle,Slot," - "FirstWritten,LastWritten,VolStatus,InChanger " - "FROM Media WHERE PoolId=%u AND MediaType='%s' AND VolStatus='%s' " - "%s " - "%s LIMIT %d", + "VolBytes,VolMounts,VolErrors,VolWrites,MaxVolBytes,VolCapacityBytes," + "VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles,Recycle,Slot," + "FirstWritten,LastWritten,VolStatus,InChanger " + "FROM Media WHERE PoolId=%u AND MediaType='%s' AND VolStatus='%s' " + "%s " + "%s LIMIT %d", mr->PoolId, mr->MediaType, mr->VolStatus, changer, order, item); } if (!QUERY_DB(jcr, mdb, mdb->cmd)) { @@ -307,8 +307,8 @@ db_find_next_volume(JCR *jcr, B_DB *mdb, int item, bool InChanger, MEDIA_DBR *mr db_unlock(mdb); return 0; } - - /* Seek to desired item + + /* Seek to desired item * Note, we use base 1; SQL uses base 0 */ sql_data_seek(mdb, item-1); diff --git a/bacula/src/cats/sql_get.c b/bacula/src/cats/sql_get.c index 6b27b17ad5..e53ecfa4db 100644 --- a/bacula/src/cats/sql_get.c +++ b/bacula/src/cats/sql_get.c @@ -2,7 +2,7 @@ * Bacula Catalog Database Get record interface routines * Note, these routines generally get a record by id or * by name. If more logic is involved, the routine - * should be in find.c + * should be in find.c * * Kern Sibbald, March 2000 * @@ -86,9 +86,9 @@ int db_get_file_attributes_record(JCR *jcr, B_DB *mdb, char *fname, JOB_DBR *jr, return stat; } - + /* - * Get a File record + * Get a File record * Returns: 0 on failure * 1 on success * @@ -105,32 +105,32 @@ int db_get_file_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr, FILE_DBR *fdbr) int stat = 0; if (jcr->JobLevel == L_VERIFY_DISK_TO_CATALOG) { - Mmsg(mdb->cmd, + Mmsg(mdb->cmd, "SELECT FileId, LStat, MD5 FROM File,Job WHERE " "File.JobId=Job.JobId AND File.PathId=%u AND " "File.FilenameId=%u AND Job.Type='B' AND Job.JobSTATUS='T' AND " "ClientId=%u ORDER BY StartTime DESC LIMIT 1", fdbr->PathId, fdbr->FilenameId, jr->ClientId); } else { - Mmsg(mdb->cmd, + Mmsg(mdb->cmd, "SELECT FileId, LStat, MD5 FROM File WHERE File.JobId=%u AND File.PathId=%u AND " "File.FilenameId=%u", fdbr->JobId, fdbr->PathId, fdbr->FilenameId); } Dmsg3(050, "Get_file_record JobId=%u FilenameId=%u PathId=%u\n", fdbr->JobId, fdbr->FilenameId, fdbr->PathId); - + Dmsg1(100, "Query=%s\n", mdb->cmd); if (QUERY_DB(jcr, mdb, mdb->cmd)) { mdb->num_rows = sql_num_rows(mdb); Dmsg1(050, "get_file_record num_rows=%d\n", (int)mdb->num_rows); if (mdb->num_rows > 1) { - Mmsg1(&mdb->errmsg, _("get_file_record want 1 got rows=%d\n"), + Mmsg1(&mdb->errmsg, _("get_file_record want 1 got rows=%d\n"), mdb->num_rows); } if (mdb->num_rows >= 1) { if ((row = sql_fetch_row(mdb)) == NULL) { - Mmsg1(&mdb->errmsg, _("Error fetching row: %s\n"), sql_strerror(mdb)); + Mmsg1(&mdb->errmsg, _("Error fetching row: %s\n"), sql_strerror(mdb)); } else { fdbr->FileId = (FileId_t)str_to_int64(row[0]); bstrncpy(fdbr->LStat, row[1], sizeof(fdbr->LStat)); @@ -138,7 +138,7 @@ int db_get_file_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr, FILE_DBR *fdbr) stat = 1; } } else { - Mmsg2(&mdb->errmsg, _("File record for PathId=%u FilenameId=%u not found.\n"), + Mmsg2(&mdb->errmsg, _("File record for PathId=%u FilenameId=%u not found.\n"), fdbr->PathId, fdbr->FilenameId); } sql_free_result(mdb); @@ -149,7 +149,7 @@ int db_get_file_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr, FILE_DBR *fdbr) } -/* Get Filename record +/* Get Filename record * Returns: 0 on failure * FilenameId on success * @@ -162,29 +162,29 @@ static int db_get_filename_record(JCR *jcr, B_DB *mdb) mdb->esc_name = check_pool_memory_size(mdb->esc_name, 2*mdb->fnl+2); db_escape_string(mdb->esc_name, mdb->fname, mdb->fnl); - + Mmsg(mdb->cmd, "SELECT FilenameId FROM Filename WHERE Name='%s'", mdb->esc_name); if (QUERY_DB(jcr, mdb, mdb->cmd)) { char ed1[30]; mdb->num_rows = sql_num_rows(mdb); if (mdb->num_rows > 1) { - Mmsg2(&mdb->errmsg, _("More than one Filename!: %s for file: %s\n"), + Mmsg2(&mdb->errmsg, _("More than one Filename!: %s for file: %s\n"), edit_uint64(mdb->num_rows, ed1), mdb->fname); - Jmsg(jcr, M_WARNING, 0, "%s", mdb->errmsg); - } + Jmsg(jcr, M_WARNING, 0, "%s", mdb->errmsg); + } if (mdb->num_rows >= 1) { if ((row = sql_fetch_row(mdb)) == NULL) { - Mmsg1(&mdb->errmsg, _("error fetching row: %s\n"), sql_strerror(mdb)); + Mmsg1(&mdb->errmsg, _("error fetching row: %s\n"), sql_strerror(mdb)); } else { FilenameId = atoi(row[0]); if (FilenameId <= 0) { - Mmsg2(&mdb->errmsg, _("Get DB Filename record %s found bad record: %d\n"), - mdb->cmd, FilenameId); + Mmsg2(&mdb->errmsg, _("Get DB Filename record %s found bad record: %d\n"), + mdb->cmd, FilenameId); FilenameId = 0; } } } else { - Mmsg1(&mdb->errmsg, _("Filename record: %s not found.\n"), mdb->fname); + Mmsg1(&mdb->errmsg, _("Filename record: %s not found.\n"), mdb->fname); } sql_free_result(mdb); } else { @@ -193,7 +193,7 @@ static int db_get_filename_record(JCR *jcr, B_DB *mdb) return FilenameId; } -/* Get path record +/* Get path record * Returns: 0 on failure * PathId on success * @@ -210,7 +210,7 @@ static int db_get_path_record(JCR *jcr, B_DB *mdb) if (mdb->cached_path_id != 0 && mdb->cached_path_len == mdb->pnl && strcmp(mdb->cached_path, mdb->path) == 0) { return mdb->cached_path_id; - } + } Mmsg(mdb->cmd, "SELECT PathId FROM Path WHERE Path='%s'", mdb->esc_name); @@ -218,19 +218,19 @@ static int db_get_path_record(JCR *jcr, B_DB *mdb) char ed1[30]; mdb->num_rows = sql_num_rows(mdb); if (mdb->num_rows > 1) { - Mmsg2(&mdb->errmsg, _("More than one Path!: %s for path: %s\n"), + Mmsg2(&mdb->errmsg, _("More than one Path!: %s for path: %s\n"), edit_uint64(mdb->num_rows, ed1), mdb->path); - Jmsg(jcr, M_WARNING, 0, "%s", mdb->errmsg); - } + Jmsg(jcr, M_WARNING, 0, "%s", mdb->errmsg); + } /* Even if there are multiple paths, take the first one */ if (mdb->num_rows >= 1) { if ((row = sql_fetch_row(mdb)) == NULL) { - Mmsg1(&mdb->errmsg, _("error fetching row: %s\n"), sql_strerror(mdb)); + Mmsg1(&mdb->errmsg, _("error fetching row: %s\n"), sql_strerror(mdb)); } else { PathId = atoi(row[0]); if (PathId <= 0) { - Mmsg2(&mdb->errmsg, _("Get DB path record %s found bad record: %u\n"), - mdb->cmd, PathId); + Mmsg2(&mdb->errmsg, _("Get DB path record %s found bad record: %u\n"), + mdb->cmd, PathId); PathId = 0; } else { /* Cache path */ @@ -241,8 +241,8 @@ static int db_get_path_record(JCR *jcr, B_DB *mdb) } } } - } else { - Mmsg1(&mdb->errmsg, _("Path record: %s not found.\n"), mdb->path); + } else { + Mmsg1(&mdb->errmsg, _("Path record: %s not found.\n"), mdb->path); } sql_free_result(mdb); } else { @@ -252,7 +252,7 @@ static int db_get_path_record(JCR *jcr, B_DB *mdb) } -/* +/* * Get Job record for given JobId or Job name * Returns: 0 on failure * 1 on success @@ -322,11 +322,11 @@ int db_get_job_volume_names(JCR *jcr, B_DB *mdb, uint32_t JobId, POOLMEM **Volum db_lock(mdb); /* Get one entry per VolumeName, but "sort" by VolIndex */ - Mmsg(mdb->cmd, - "SELECT VolumeName,MAX(VolIndex) FROM JobMedia,Media WHERE " - "JobMedia.JobId=%u AND JobMedia.MediaId=Media.MediaId " - "GROUP BY VolumeName " - "ORDER BY 2 ASC", JobId); + Mmsg(mdb->cmd, + "SELECT VolumeName,MAX(VolIndex) FROM JobMedia,Media WHERE " + "JobMedia.JobId=%u AND JobMedia.MediaId=Media.MediaId " + "GROUP BY VolumeName " + "ORDER BY 2 ASC", JobId); Dmsg1(130, "VolNam=%s\n", mdb->cmd); *VolumeNames[0] = 0; @@ -334,19 +334,19 @@ int db_get_job_volume_names(JCR *jcr, B_DB *mdb, uint32_t JobId, POOLMEM **Volum mdb->num_rows = sql_num_rows(mdb); Dmsg1(130, "Num rows=%d\n", mdb->num_rows); if (mdb->num_rows <= 0) { - Mmsg1(&mdb->errmsg, _("No volumes found for JobId=%d\n"), JobId); + Mmsg1(&mdb->errmsg, _("No volumes found for JobId=%d\n"), JobId); stat = 0; } else { stat = mdb->num_rows; for (i=0; i < stat; i++) { if ((row = sql_fetch_row(mdb)) == NULL) { - Mmsg2(&mdb->errmsg, _("Error fetching row %d: ERR=%s\n"), i, sql_strerror(mdb)); - Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg); + Mmsg2(&mdb->errmsg, _("Error fetching row %d: ERR=%s\n"), i, sql_strerror(mdb)); + Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg); stat = 0; break; } else { if (*VolumeNames[0] != 0) { - pm_strcat(VolumeNames, "|"); + pm_strcat(VolumeNames, "|"); } pm_strcat(VolumeNames, row[0]); } @@ -376,7 +376,7 @@ int db_get_job_volume_parameters(JCR *jcr, B_DB *mdb, uint32_t JobId, VOL_PARAMS VOL_PARAMS *Vols = NULL; db_lock(mdb); - Mmsg(mdb->cmd, + Mmsg(mdb->cmd, "SELECT VolumeName,FirstIndex,LastIndex,StartFile,JobMedia.EndFile," "StartBlock,JobMedia.EndBlock" " FROM JobMedia,Media WHERE JobMedia.JobId=%u" @@ -387,7 +387,7 @@ int db_get_job_volume_parameters(JCR *jcr, B_DB *mdb, uint32_t JobId, VOL_PARAMS mdb->num_rows = sql_num_rows(mdb); Dmsg1(130, "Num rows=%d\n", mdb->num_rows); if (mdb->num_rows <= 0) { - Mmsg1(&mdb->errmsg, _("No volumes found for JobId=%d\n"), JobId); + Mmsg1(&mdb->errmsg, _("No volumes found for JobId=%d\n"), JobId); stat = 0; } else { stat = mdb->num_rows; @@ -396,8 +396,8 @@ int db_get_job_volume_parameters(JCR *jcr, B_DB *mdb, uint32_t JobId, VOL_PARAMS } for (i=0; i < stat; i++) { if ((row = sql_fetch_row(mdb)) == NULL) { - Mmsg2(&mdb->errmsg, _("Error fetching row %d: ERR=%s\n"), i, sql_strerror(mdb)); - Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg); + Mmsg2(&mdb->errmsg, _("Error fetching row %d: ERR=%s\n"), i, sql_strerror(mdb)); + Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg); stat = 0; break; } else { @@ -419,7 +419,7 @@ int db_get_job_volume_parameters(JCR *jcr, B_DB *mdb, uint32_t JobId, VOL_PARAMS -/* +/* * Get the number of pool records * * Returns: -1 on failure @@ -512,12 +512,12 @@ int db_get_client_ids(JCR *jcr, B_DB *mdb, int *num_ids, uint32_t *ids[]) -/* Get Pool Record +/* Get Pool Record * If the PoolId is non-zero, we get its record, * otherwise, we search on the PoolName * * Returns: 0 on failure - * id on success + * id on success */ int db_get_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pdbr) { @@ -526,31 +526,31 @@ int db_get_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pdbr) db_lock(mdb); if (pdbr->PoolId != 0) { /* find by id */ - Mmsg(mdb->cmd, -"SELECT PoolId,Name,NumVols,MaxVols,UseOnce,UseCatalog,AcceptAnyVolume,\ -AutoPrune,Recycle,VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles,\ -MaxVolBytes,PoolType,LabelFormat FROM Pool WHERE Pool.PoolId=%u", pdbr->PoolId); + Mmsg(mdb->cmd, +"SELECT PoolId,Name,NumVols,MaxVols,UseOnce,UseCatalog,AcceptAnyVolume," +"AutoPrune,Recycle,VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles," +"MaxVolBytes,PoolType,LabelFormat FROM Pool WHERE Pool.PoolId=%u", pdbr->PoolId); } else { /* find by name */ - Mmsg(mdb->cmd, -"SELECT PoolId,Name,NumVols,MaxVols,UseOnce,UseCatalog,AcceptAnyVolume,\ -AutoPrune,Recycle,VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles,\ -MaxVolBytes,PoolType,LabelFormat FROM Pool WHERE Pool.Name='%s'", pdbr->Name); - } + Mmsg(mdb->cmd, +"SELECT PoolId,Name,NumVols,MaxVols,UseOnce,UseCatalog,AcceptAnyVolume," +"AutoPrune,Recycle,VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles," +"MaxVolBytes,PoolType,LabelFormat FROM Pool WHERE Pool.Name='%s'", pdbr->Name); + } if (QUERY_DB(jcr, mdb, mdb->cmd)) { mdb->num_rows = sql_num_rows(mdb); if (mdb->num_rows > 1) { char ed1[30]; - Mmsg1(&mdb->errmsg, _("More than one Pool!: %s\n"), + Mmsg1(&mdb->errmsg, _("More than one Pool!: %s\n"), edit_uint64(mdb->num_rows, ed1)); - Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg); + Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg); } else if (mdb->num_rows == 1) { if ((row = sql_fetch_row(mdb)) == NULL) { - Mmsg1(&mdb->errmsg, _("error fetching row: %s\n"), sql_strerror(mdb)); - Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg); + Mmsg1(&mdb->errmsg, _("error fetching row: %s\n"), sql_strerror(mdb)); + Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg); } else { pdbr->PoolId = str_to_int64(row[0]); - bstrncpy(pdbr->Name, row[1]!=NULL?row[1]:"", sizeof(pdbr->Name)); + bstrncpy(pdbr->Name, row[1]!=NULL?row[1]:"", sizeof(pdbr->Name)); pdbr->NumVols = str_to_int64(row[2]); pdbr->MaxVols = str_to_int64(row[3]); pdbr->UseOnce = str_to_int64(row[4]); @@ -563,12 +563,12 @@ MaxVolBytes,PoolType,LabelFormat FROM Pool WHERE Pool.Name='%s'", pdbr->Name); pdbr->MaxVolJobs = str_to_int64(row[11]); pdbr->MaxVolFiles = str_to_int64(row[12]); pdbr->MaxVolBytes = str_to_uint64(row[13]); - bstrncpy(pdbr->PoolType, row[13]!=NULL?row[14]:"", sizeof(pdbr->PoolType)); - bstrncpy(pdbr->LabelFormat, row[14]!=NULL?row[15]:"", sizeof(pdbr->LabelFormat)); + bstrncpy(pdbr->PoolType, row[13]!=NULL?row[14]:"", sizeof(pdbr->PoolType)); + bstrncpy(pdbr->LabelFormat, row[14]!=NULL?row[15]:"", sizeof(pdbr->LabelFormat)); stat = pdbr->PoolId; } } else { - Mmsg(mdb->errmsg, _("Pool record not found in Catalog.\n")); + Mmsg(mdb->errmsg, _("Pool record not found in Catalog.\n")); } sql_free_result(mdb); } else { @@ -578,12 +578,12 @@ MaxVolBytes,PoolType,LabelFormat FROM Pool WHERE Pool.Name='%s'", pdbr->Name); return stat; } -/* Get Client Record +/* Get Client Record * If the ClientId is non-zero, we get its record, * otherwise, we search on the Client Name * * Returns: 0 on failure - * 1 on success + * 1 on success */ int db_get_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cdbr) { @@ -592,37 +592,37 @@ int db_get_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cdbr) db_lock(mdb); if (cdbr->ClientId != 0) { /* find by id */ - Mmsg(mdb->cmd, + Mmsg(mdb->cmd, "SELECT ClientId,Name,Uname,AutoPrune,FileRetention,JobRetention " "FROM Client WHERE Client.ClientId=%u", cdbr->ClientId); } else { /* find by name */ - Mmsg(mdb->cmd, + Mmsg(mdb->cmd, "SELECT ClientId,Name,Uname,AutoPrune,FileRetention,JobRetention " "FROM Client WHERE Client.Name='%s'", cdbr->Name); - } + } if (QUERY_DB(jcr, mdb, mdb->cmd)) { mdb->num_rows = sql_num_rows(mdb); if (mdb->num_rows > 1) { char ed1[30]; - Mmsg1(&mdb->errmsg, _("More than one Client!: %s\n"), + Mmsg1(&mdb->errmsg, _("More than one Client!: %s\n"), edit_uint64(mdb->num_rows, ed1)); - Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg); + Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg); } else if (mdb->num_rows == 1) { if ((row = sql_fetch_row(mdb)) == NULL) { - Mmsg1(&mdb->errmsg, _("error fetching row: %s\n"), sql_strerror(mdb)); - Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg); + Mmsg1(&mdb->errmsg, _("error fetching row: %s\n"), sql_strerror(mdb)); + Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg); } else { cdbr->ClientId = str_to_int64(row[0]); - bstrncpy(cdbr->Name, row[1]!=NULL?row[1]:"", sizeof(cdbr->Name)); - bstrncpy(cdbr->Uname, row[2]!=NULL?row[1]:"", sizeof(cdbr->Uname)); + bstrncpy(cdbr->Name, row[1]!=NULL?row[1]:"", sizeof(cdbr->Name)); + bstrncpy(cdbr->Uname, row[2]!=NULL?row[1]:"", sizeof(cdbr->Uname)); cdbr->AutoPrune = str_to_int64(row[3]); cdbr->FileRetention = str_to_int64(row[4]); cdbr->JobRetention = str_to_int64(row[5]); stat = 1; } } else { - Mmsg(mdb->errmsg, _("Client record not found in Catalog.\n")); + Mmsg(mdb->errmsg, _("Client record not found in Catalog.\n")); } sql_free_result(mdb); } else { @@ -648,16 +648,16 @@ int db_get_counter_record(JCR *jcr, B_DB *mdb, COUNTER_DBR *cr) if (QUERY_DB(jcr, mdb, mdb->cmd)) { mdb->num_rows = sql_num_rows(mdb); - + /* If more than one, report error, but return first row */ if (mdb->num_rows > 1) { - Mmsg1(&mdb->errmsg, _("More than one Counter!: %d\n"), (int)(mdb->num_rows)); - Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg); + Mmsg1(&mdb->errmsg, _("More than one Counter!: %d\n"), (int)(mdb->num_rows)); + Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg); } if (mdb->num_rows >= 1) { if ((row = sql_fetch_row(mdb)) == NULL) { - Mmsg1(&mdb->errmsg, _("error fetching Counter row: %s\n"), sql_strerror(mdb)); - Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg); + Mmsg1(&mdb->errmsg, _("error fetching Counter row: %s\n"), sql_strerror(mdb)); + Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg); sql_free_result(mdb); db_unlock(mdb); return 0; @@ -677,18 +677,18 @@ int db_get_counter_record(JCR *jcr, B_DB *mdb, COUNTER_DBR *cr) sql_free_result(mdb); } else { Mmsg(mdb->errmsg, _("Counter record: %s not found in Catalog.\n"), cr->Counter); - } + } db_unlock(mdb); return 0; } -/* Get FileSet Record +/* Get FileSet Record * If the FileSetId is non-zero, we get its record, * otherwise, we search on the name * * Returns: 0 on failure - * id on success + * id on success */ int db_get_fileset_record(JCR *jcr, B_DB *mdb, FILESET_DBR *fsr) { @@ -697,30 +697,30 @@ int db_get_fileset_record(JCR *jcr, B_DB *mdb, FILESET_DBR *fsr) db_lock(mdb); if (fsr->FileSetId != 0) { /* find by id */ - Mmsg(mdb->cmd, - "SELECT FileSetId,FileSet,MD5,CreateTime FROM FileSet " - "WHERE FileSetId=%u", fsr->FileSetId); + Mmsg(mdb->cmd, + "SELECT FileSetId,FileSet,MD5,CreateTime FROM FileSet " + "WHERE FileSetId=%u", fsr->FileSetId); } else { /* find by name */ - Mmsg(mdb->cmd, - "SELECT FileSetId,FileSet,CreateTime,MD5 FROM FileSet " - "WHERE FileSet='%s' ORDER BY CreateTime DESC LIMIT 1", fsr->FileSet); - } + Mmsg(mdb->cmd, + "SELECT FileSetId,FileSet,CreateTime,MD5 FROM FileSet " + "WHERE FileSet='%s' ORDER BY CreateTime DESC LIMIT 1", fsr->FileSet); + } if (QUERY_DB(jcr, mdb, mdb->cmd)) { mdb->num_rows = sql_num_rows(mdb); if (mdb->num_rows > 1) { char ed1[30]; - Mmsg1(&mdb->errmsg, _("Error got %s FileSets but expected only one!\n"), + Mmsg1(&mdb->errmsg, _("Error got %s FileSets but expected only one!\n"), edit_uint64(mdb->num_rows, ed1)); sql_data_seek(mdb, mdb->num_rows-1); } if ((row = sql_fetch_row(mdb)) == NULL) { - Mmsg1(&mdb->errmsg, _("FileSet record \"%s\" not found.\n"), fsr->FileSet); + Mmsg1(&mdb->errmsg, _("FileSet record \"%s\" not found.\n"), fsr->FileSet); } else { fsr->FileSetId = atoi(row[0]); - bstrncpy(fsr->FileSet, row[1]!=NULL?row[1]:"", sizeof(fsr->FileSet)); - bstrncpy(fsr->MD5, row[2]!=NULL?row[2]:"", sizeof(fsr->MD5)); - bstrncpy(fsr->cCreateTime, row[3]!=NULL?row[3]:"", sizeof(fsr->cCreateTime)); + bstrncpy(fsr->FileSet, row[1]!=NULL?row[1]:"", sizeof(fsr->FileSet)); + bstrncpy(fsr->MD5, row[2]!=NULL?row[2]:"", sizeof(fsr->MD5)); + bstrncpy(fsr->cCreateTime, row[3]!=NULL?row[3]:"", sizeof(fsr->cCreateTime)); stat = fsr->FileSetId; } sql_free_result(mdb); @@ -732,7 +732,7 @@ int db_get_fileset_record(JCR *jcr, B_DB *mdb, FILESET_DBR *fsr) } -/* +/* * Get the number of Media records * * Returns: -1 on failure @@ -789,10 +789,10 @@ int db_get_media_ids(JCR *jcr, B_DB *mdb, uint32_t PoolId, int *num_ids, uint32_ } -/* Get Media Record +/* Get Media Record * * Returns: 0 on failure - * id on success + * id on success */ int db_get_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) { @@ -808,33 +808,33 @@ int db_get_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) } if (mr->MediaId != 0) { /* find by id */ Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,VolJobs,VolFiles,VolBlocks," - "VolBytes,VolMounts,VolErrors,VolWrites,MaxVolBytes,VolCapacityBytes," - "MediaType,VolStatus,PoolId,VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles," - "Recycle,Slot,FirstWritten,LastWritten,InChanger,EndFile,EndBlock " - "FROM Media WHERE MediaId=%d", mr->MediaId); + "VolBytes,VolMounts,VolErrors,VolWrites,MaxVolBytes,VolCapacityBytes," + "MediaType,VolStatus,PoolId,VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles," + "Recycle,Slot,FirstWritten,LastWritten,InChanger,EndFile,EndBlock " + "FROM Media WHERE MediaId=%d", mr->MediaId); } else { /* find by name */ Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,VolJobs,VolFiles,VolBlocks," - "VolBytes,VolMounts,VolErrors,VolWrites,MaxVolBytes,VolCapacityBytes," - "MediaType,VolStatus,PoolId,VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles," - "Recycle,Slot,FirstWritten,LastWritten,InChanger,EndFile,EndBlock " - "FROM Media WHERE VolumeName='%s'", mr->VolumeName); - } + "VolBytes,VolMounts,VolErrors,VolWrites,MaxVolBytes,VolCapacityBytes," + "MediaType,VolStatus,PoolId,VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles," + "Recycle,Slot,FirstWritten,LastWritten,InChanger,EndFile,EndBlock " + "FROM Media WHERE VolumeName='%s'", mr->VolumeName); + } if (QUERY_DB(jcr, mdb, mdb->cmd)) { mdb->num_rows = sql_num_rows(mdb); if (mdb->num_rows > 1) { char ed1[30]; - Mmsg1(&mdb->errmsg, _("More than one Volume!: %s\n"), + Mmsg1(&mdb->errmsg, _("More than one Volume!: %s\n"), edit_uint64(mdb->num_rows, ed1)); - Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg); + Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg); } else if (mdb->num_rows == 1) { if ((row = sql_fetch_row(mdb)) == NULL) { - Mmsg1(&mdb->errmsg, _("error fetching row: %s\n"), sql_strerror(mdb)); - Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg); + Mmsg1(&mdb->errmsg, _("error fetching row: %s\n"), sql_strerror(mdb)); + Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg); } else { /* return values */ mr->MediaId = str_to_int64(row[0]); - bstrncpy(mr->VolumeName, row[1]!=NULL?row[1]:"", sizeof(mr->VolumeName)); + bstrncpy(mr->VolumeName, row[1]!=NULL?row[1]:"", sizeof(mr->VolumeName)); mr->VolJobs = str_to_int64(row[2]); mr->VolFiles = str_to_int64(row[3]); mr->VolBlocks = str_to_int64(row[4]); @@ -844,8 +844,8 @@ int db_get_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) mr->VolWrites = str_to_int64(row[8]); mr->MaxVolBytes = str_to_uint64(row[9]); mr->VolCapacityBytes = str_to_uint64(row[10]); - bstrncpy(mr->MediaType, row[11]!=NULL?row[11]:"", sizeof(mr->MediaType)); - bstrncpy(mr->VolStatus, row[12]!=NULL?row[12]:"", sizeof(mr->VolStatus)); + bstrncpy(mr->MediaType, row[11]!=NULL?row[11]:"", sizeof(mr->MediaType)); + bstrncpy(mr->VolStatus, row[12]!=NULL?row[12]:"", sizeof(mr->VolStatus)); mr->PoolId = str_to_int64(row[13]); mr->VolRetention = str_to_uint64(row[14]); mr->VolUseDuration = str_to_uint64(row[15]); @@ -853,9 +853,9 @@ int db_get_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) mr->MaxVolFiles = str_to_int64(row[17]); mr->Recycle = str_to_int64(row[18]); mr->Slot = str_to_int64(row[19]); - bstrncpy(mr->cFirstWritten, row[20]!=NULL?row[20]:"", sizeof(mr->cFirstWritten)); + bstrncpy(mr->cFirstWritten, row[20]!=NULL?row[20]:"", sizeof(mr->cFirstWritten)); mr->FirstWritten = (time_t)str_to_utime(mr->cFirstWritten); - bstrncpy(mr->cLastWritten, row[21]!=NULL?row[21]:"", sizeof(mr->cLastWritten)); + bstrncpy(mr->cLastWritten, row[21]!=NULL?row[21]:"", sizeof(mr->cLastWritten)); mr->LastWritten = (time_t)str_to_utime(mr->cLastWritten); mr->InChanger = str_to_uint64(row[22]); mr->EndFile = str_to_uint64(row[23]); @@ -864,9 +864,9 @@ int db_get_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) } } else { if (mr->MediaId != 0) { - Mmsg1(&mdb->errmsg, _("Media record MediaId=%u not found.\n"), mr->MediaId); + Mmsg1(&mdb->errmsg, _("Media record MediaId=%u not found.\n"), mr->MediaId); } else { - Mmsg1(&mdb->errmsg, _("Media record for Volume \"%s\" not found.\n"), + Mmsg1(&mdb->errmsg, _("Media record for Volume \"%s\" not found.\n"), mr->VolumeName); } } diff --git a/bacula/src/cats/sql_list.c b/bacula/src/cats/sql_list.c index c539bcb6c0..fa18ad9fac 100644 --- a/bacula/src/cats/sql_list.c +++ b/bacula/src/cats/sql_list.c @@ -1,6 +1,6 @@ /* * Bacula Catalog Database List records interface routines - * + * * Kern Sibbald, March 2000 * * Version $Id$ @@ -48,10 +48,10 @@ extern void list_result(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ctx, extern int QueryDB(const char *file, int line, JCR *jcr, B_DB *db, char *select_cmd); -/* +/* * Submit general SQL query */ -int db_list_sql_query(JCR *jcr, B_DB *mdb, char *query, DB_LIST_HANDLER *sendit, +int db_list_sql_query(JCR *jcr, B_DB *mdb, char *query, DB_LIST_HANDLER *sendit, void *ctx, int verbose, e_list_type type) { db_lock(mdb); @@ -75,18 +75,18 @@ int db_list_sql_query(JCR *jcr, B_DB *mdb, char *query, DB_LIST_HANDLER *sendit, } void -db_list_pool_records(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ctx, e_list_type type) +db_list_pool_records(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ctx, e_list_type type) { db_lock(mdb); if (type == VERT_LIST) { Mmsg(mdb->cmd, "SELECT PoolId,Name,NumVols,MaxVols,UseOnce,UseCatalog," - "AcceptAnyVolume,VolRetention,VolUseDuration,MaxVolJobs,MaxVolBytes," - "AutoPrune,Recycle,PoolType,LabelFormat,Enabled,ScratchPoolId," - "RecyclePoolId " - "FROM Pool ORDER BY PoolId"); + "AcceptAnyVolume,VolRetention,VolUseDuration,MaxVolJobs,MaxVolBytes," + "AutoPrune,Recycle,PoolType,LabelFormat,Enabled,ScratchPoolId," + "RecyclePoolId " + "FROM Pool ORDER BY PoolId"); } else { Mmsg(mdb->cmd, "SELECT PoolId,Name,NumVols,MaxVols,PoolType,LabelFormat " - "FROM Pool ORDER BY PoolId"); + "FROM Pool ORDER BY PoolId"); } if (!QUERY_DB(jcr, mdb, mdb->cmd)) { @@ -95,7 +95,7 @@ db_list_pool_records(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ctx, e_ } list_result(jcr, mdb, sendit, ctx, type); - + sql_free_result(mdb); db_unlock(mdb); } @@ -106,11 +106,11 @@ db_list_client_records(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ctx, db_lock(mdb); if (type == VERT_LIST) { Mmsg(mdb->cmd, "SELECT ClientId,Name,Uname,AutoPrune,FileRetention," - "FileRetention,JobRetention " - "FROM Client ORDER BY ClientId"); + "FileRetention,JobRetention " + "FROM Client ORDER BY ClientId"); } else { Mmsg(mdb->cmd, "SELECT ClientId,Name,FileRetention,JobRetention " - "FROM Client ORDER BY ClientId"); + "FROM Client ORDER BY ClientId"); } if (!QUERY_DB(jcr, mdb, mdb->cmd)) { @@ -119,7 +119,7 @@ db_list_client_records(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ctx, } list_result(jcr, mdb, sendit, ctx, type); - + sql_free_result(mdb); db_unlock(mdb); } @@ -130,37 +130,37 @@ db_list_client_records(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ctx, * otherwise, list the Volumes in the Pool specified by PoolId */ void -db_list_media_records(JCR *jcr, B_DB *mdb, MEDIA_DBR *mdbr, +db_list_media_records(JCR *jcr, B_DB *mdb, MEDIA_DBR *mdbr, DB_LIST_HANDLER *sendit, void *ctx, e_list_type type) { db_lock(mdb); if (type == VERT_LIST) { if (mdbr->VolumeName[0] != 0) { - Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,Slot,PoolId," - "MediaType,FirstWritten,LastWritten,LabelDate,VolJobs," - "VolFiles,VolBlocks,VolMounts,VolBytes,VolErrors,VolWrites," - "VolCapacityBytes,VolStatus,Recycle,VolRetention," - "VolUseDuration,MaxVolJobs,MaxVolFiles,MaxVolBytes,InChanger," - "EndFile,EndBlock " - "FROM Media WHERE Media.VolumeName='%s'", mdbr->VolumeName); + Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,Slot,PoolId," + "MediaType,FirstWritten,LastWritten,LabelDate,VolJobs," + "VolFiles,VolBlocks,VolMounts,VolBytes,VolErrors,VolWrites," + "VolCapacityBytes,VolStatus,Recycle,VolRetention," + "VolUseDuration,MaxVolJobs,MaxVolFiles,MaxVolBytes,InChanger," + "EndFile,EndBlock " + "FROM Media WHERE Media.VolumeName='%s'", mdbr->VolumeName); } else { - Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,Slot,PoolId," - "MediaType,FirstWritten,LastWritten,LabelDate,VolJobs," - "VolFiles,VolBlocks,VolMounts,VolBytes,VolErrors,VolWrites," - "VolCapacityBytes,VolStatus,Recycle,VolRetention," - "VolUseDuration,MaxVolJobs,MaxVolFiles,MaxVolBytes,InChanger," - "EndFile,EndBlock " - "FROM Media WHERE Media.PoolId=%u ORDER BY MediaId", mdbr->PoolId); + Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,Slot,PoolId," + "MediaType,FirstWritten,LastWritten,LabelDate,VolJobs," + "VolFiles,VolBlocks,VolMounts,VolBytes,VolErrors,VolWrites," + "VolCapacityBytes,VolStatus,Recycle,VolRetention," + "VolUseDuration,MaxVolJobs,MaxVolFiles,MaxVolBytes,InChanger," + "EndFile,EndBlock " + "FROM Media WHERE Media.PoolId=%u ORDER BY MediaId", mdbr->PoolId); } } else { if (mdbr->VolumeName[0] != 0) { - Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,VolStatus," - "VolBytes,VolFiles,VolRetention,Recycle,Slot,InChanger,MediaType,LastWritten " - "FROM Media WHERE Media.VolumeName='%s'", mdbr->VolumeName); + Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,VolStatus," + "VolBytes,VolFiles,VolRetention,Recycle,Slot,InChanger,MediaType,LastWritten " + "FROM Media WHERE Media.VolumeName='%s'", mdbr->VolumeName); } else { - Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,VolStatus," - "VolBytes,VolFiles,VolRetention,Recycle,Slot,InChanger,MediaType,LastWritten " - "FROM Media WHERE Media.PoolId=%u ORDER BY MediaId", mdbr->PoolId); + Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,VolStatus," + "VolBytes,VolFiles,VolRetention,Recycle,Slot,InChanger,MediaType,LastWritten " + "FROM Media WHERE Media.PoolId=%u ORDER BY MediaId", mdbr->PoolId); } } @@ -170,37 +170,37 @@ db_list_media_records(JCR *jcr, B_DB *mdb, MEDIA_DBR *mdbr, } list_result(jcr, mdb, sendit, ctx, type); - + sql_free_result(mdb); db_unlock(mdb); } -void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, uint32_t JobId, +void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, uint32_t JobId, DB_LIST_HANDLER *sendit, void *ctx, e_list_type type) { db_lock(mdb); if (type == VERT_LIST) { if (JobId > 0) { /* do by JobId */ - Mmsg(mdb->cmd, "SELECT JobMediaId,JobId,MediaId,Media.VolumeName," - "FirstIndex,LastIndex,StartFile,JobMedia.EndFile,StartBlock," - "JobMedia.EndBlock " - "FROM JobMedia,Media WHERE Media.MediaId=JobMedia.MediaId " - "AND JobMedia.JobId=%u", JobId); + Mmsg(mdb->cmd, "SELECT JobMediaId,JobId,MediaId,Media.VolumeName," + "FirstIndex,LastIndex,StartFile,JobMedia.EndFile,StartBlock," + "JobMedia.EndBlock " + "FROM JobMedia,Media WHERE Media.MediaId=JobMedia.MediaId " + "AND JobMedia.JobId=%u", JobId); } else { - Mmsg(mdb->cmd, "SELECT JobMediaId,JobId,MediaId,Media.VolumeName," - "FirstIndex,LastIndex,StartFile,JobMedia.EndFile,StartBlock," - "JobMedia.EndBlock " - "FROM JobMedia,Media WHERE Media.MediaId=JobMedia.MediaId"); + Mmsg(mdb->cmd, "SELECT JobMediaId,JobId,MediaId,Media.VolumeName," + "FirstIndex,LastIndex,StartFile,JobMedia.EndFile,StartBlock," + "JobMedia.EndBlock " + "FROM JobMedia,Media WHERE Media.MediaId=JobMedia.MediaId"); } } else { if (JobId > 0) { /* do by JobId */ - Mmsg(mdb->cmd, "SELECT JobId,Media.VolumeName,FirstIndex,LastIndex " - "FROM JobMedia,Media WHERE Media.MediaId=JobMedia.MediaId " - "AND JobMedia.JobId=%u", JobId); + Mmsg(mdb->cmd, "SELECT JobId,Media.VolumeName,FirstIndex,LastIndex " + "FROM JobMedia,Media WHERE Media.MediaId=JobMedia.MediaId " + "AND JobMedia.JobId=%u", JobId); } else { - Mmsg(mdb->cmd, "SELECT JobId,Media.VolumeName,FirstIndex,LastIndex " - "FROM JobMedia,Media WHERE Media.MediaId=JobMedia.MediaId"); + Mmsg(mdb->cmd, "SELECT JobId,Media.VolumeName,FirstIndex,LastIndex " + "FROM JobMedia,Media WHERE Media.MediaId=JobMedia.MediaId"); } } if (!QUERY_DB(jcr, mdb, mdb->cmd)) { @@ -209,7 +209,7 @@ void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, uint32_t JobId, } list_result(jcr, mdb, sendit, ctx, type); - + sql_free_result(mdb); db_unlock(mdb); } @@ -223,40 +223,40 @@ void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, uint32_t JobId, * only the job with the specified id. */ void -db_list_job_records(JCR *jcr, B_DB *mdb, JOB_DBR *jr, DB_LIST_HANDLER *sendit, +db_list_job_records(JCR *jcr, B_DB *mdb, JOB_DBR *jr, DB_LIST_HANDLER *sendit, void *ctx, e_list_type type) { db_lock(mdb); if (type == VERT_LIST) { if (jr->JobId == 0 && jr->Job[0] == 0) { - Mmsg(mdb->cmd, - "SELECT JobId,Job,Job.Name,PurgedFiles,Type,Level," - "Job.ClientId,Client.Name,JobStatus,SchedTime," - "StartTime,EndTime,JobTDate," - "VolSessionId,VolSessionTime,JobFiles,JobErrors," - "JobMissingFiles,Job.PoolId,Pool.Name,Job.FileSetId,FileSet.FileSet " - "FROM Job,Client,Pool,FileSet WHERE " - "Client.ClientId=Job.ClientId AND Pool.PoolId=Job.PoolId " - "AND FileSet.FileSetId=Job.FileSetId ORDER BY StartTime"); + Mmsg(mdb->cmd, + "SELECT JobId,Job,Job.Name,PurgedFiles,Type,Level," + "Job.ClientId,Client.Name,JobStatus,SchedTime," + "StartTime,EndTime,JobTDate," + "VolSessionId,VolSessionTime,JobFiles,JobErrors," + "JobMissingFiles,Job.PoolId,Pool.Name,Job.FileSetId,FileSet.FileSet " + "FROM Job,Client,Pool,FileSet WHERE " + "Client.ClientId=Job.ClientId AND Pool.PoolId=Job.PoolId " + "AND FileSet.FileSetId=Job.FileSetId ORDER BY StartTime"); } else { /* single record */ - Mmsg(mdb->cmd, - "SELECT JobId,Job,Job.Name,PurgedFiles,Type,Level," - "Job.ClientId,Client.Name,JobStatus,SchedTime," - "StartTime,EndTime,JobTDate," - "VolSessionId,VolSessionTime,JobFiles,JobErrors," - "JobMissingFiles,Job.PoolId,Pool.Name,Job.FileSetId,FileSet.FileSet " - "FROM Job,Client,Pool,FileSet WHERE Job.JobId=%u AND " - "Client.ClientId=Job.ClientId AND Pool.PoolId=Job.PoolId " - "AND FileSet.FileSetId=Job.FileSetId", jr->JobId); + Mmsg(mdb->cmd, + "SELECT JobId,Job,Job.Name,PurgedFiles,Type,Level," + "Job.ClientId,Client.Name,JobStatus,SchedTime," + "StartTime,EndTime,JobTDate," + "VolSessionId,VolSessionTime,JobFiles,JobErrors," + "JobMissingFiles,Job.PoolId,Pool.Name,Job.FileSetId,FileSet.FileSet " + "FROM Job,Client,Pool,FileSet WHERE Job.JobId=%u AND " + "Client.ClientId=Job.ClientId AND Pool.PoolId=Job.PoolId " + "AND FileSet.FileSetId=Job.FileSetId", jr->JobId); } } else { if (jr->JobId == 0 && jr->Job[0] == 0) { - Mmsg(mdb->cmd, - "SELECT JobId,Name,StartTime,Type,Level,JobFiles,JobBytes,JobStatus " - "FROM Job ORDER BY StartTime"); + Mmsg(mdb->cmd, + "SELECT JobId,Name,StartTime,Type,Level,JobFiles,JobBytes,JobStatus " + "FROM Job ORDER BY StartTime"); } else { /* single record */ - Mmsg(mdb->cmd, "SELECT JobId,Name,StartTime,Type,Level," - "JobFiles,JobBytes,JobStatus FROM Job WHERE JobId=%u", jr->JobId); + Mmsg(mdb->cmd, "SELECT JobId,Name,StartTime,Type,Level," + "JobFiles,JobBytes,JobStatus FROM Job WHERE JobId=%u", jr->JobId); } } if (!QUERY_DB(jcr, mdb, mdb->cmd)) { @@ -264,7 +264,7 @@ db_list_job_records(JCR *jcr, B_DB *mdb, JOB_DBR *jr, DB_LIST_HANDLER *sendit, return; } list_result(jcr, mdb, sendit, ctx, type); - + sql_free_result(mdb); db_unlock(mdb); } @@ -288,12 +288,12 @@ db_list_job_totals(JCR *jcr, B_DB *mdb, JOB_DBR *jr, DB_LIST_HANDLER *sendit, vo } list_result(jcr, mdb, sendit, ctx, HORZ_LIST); - + sql_free_result(mdb); /* Do Grand Total */ - Mmsg(mdb->cmd, "SELECT count(*) AS Jobs,sum(JobFiles) \ -AS Files,sum(JobBytes) As Bytes FROM Job"); + Mmsg(mdb->cmd, "SELECT count(*) AS Jobs,sum(JobFiles) " +"AS Files,sum(JobBytes) As Bytes FROM Job"); if (!QUERY_DB(jcr, mdb, mdb->cmd)) { db_unlock(mdb); @@ -301,13 +301,13 @@ AS Files,sum(JobBytes) As Bytes FROM Job"); } list_result(jcr, mdb, sendit, ctx, HORZ_LIST); - + sql_free_result(mdb); db_unlock(mdb); } -/* - * Stupid MySQL is NON-STANDARD ! +/* + * Stupid MySQL is NON-STANDARD ! */ #ifdef HAVE_MYSQL #define FN "CONCAT(Path.Path,Filename.Name)" @@ -331,7 +331,7 @@ db_list_files_for_job(JCR *jcr, B_DB *mdb, uint32_t jobid, DB_LIST_HANDLER *send } list_result(jcr, mdb, sendit, ctx, HORZ_LIST); - + sql_free_result(mdb); db_unlock(mdb); } diff --git a/bacula/src/cats/sql_update.c b/bacula/src/cats/sql_update.c index d2d73c998d..86f65d6c39 100644 --- a/bacula/src/cats/sql_update.c +++ b/bacula/src/cats/sql_update.c @@ -1,6 +1,6 @@ /* * Bacula Catalog Database Update record interface routines - * + * * Kern Sibbald, March 2000 * * Version $Id$ @@ -70,7 +70,7 @@ db_add_SIG_to_file_record(JCR *jcr, B_DB *mdb, FileId_t FileId, char *SIG, /* Mark the file record as being visited during database * verify compare. Stuff JobId into MarkedId field */ -int db_mark_file_record(JCR *jcr, B_DB *mdb, FileId_t FileId, JobId_t JobId) +int db_mark_file_record(JCR *jcr, B_DB *mdb, FileId_t FileId, JobId_t JobId) { int stat; @@ -96,7 +96,7 @@ db_update_job_start_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr) btime_t JobTDate; int stat; char ed1[30]; - + stime = jr->StartTime; localtime_r(&stime, &tm); strftime(dt, sizeof(dt), "%Y-%m-%d %T", &tm); @@ -105,7 +105,7 @@ db_update_job_start_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr) db_lock(mdb); Mmsg(mdb->cmd, "UPDATE Job SET JobStatus='%c',Level='%c',StartTime='%s'," "ClientId=%u,JobTDate=%s WHERE JobId=%u", - (char)(jcr->JobStatus), + (char)(jcr->JobStatus), (char)(jr->JobLevel), dt, jr->ClientId, edit_uint64(JobTDate, ed1), jr->JobId); stat = UPDATE_DB(jcr, mdb, mdb->cmd); @@ -120,7 +120,7 @@ db_update_job_start_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr) * */ void edit_num_or_null(char *s, size_t n, uint32_t id) { - bsnprintf(s, n, id ? "%u" : "NULL", id); + bsnprintf(s, n, id ? "%u" : "NULL", id); } @@ -148,7 +148,7 @@ db_update_job_end_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr) edit_num_or_null(PoolId, sizeof(PoolId), jr->PoolId); edit_num_or_null(FileSetId, sizeof(FileSetId), jr->FileSetId); edit_num_or_null(ClientId, sizeof(ClientId), jr->ClientId); - + ttime = jr->EndTime; localtime_r(&ttime, &tm); strftime(dt, sizeof(dt), "%Y-%m-%d %T", &tm); @@ -156,11 +156,11 @@ db_update_job_end_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr) db_lock(mdb); Mmsg(mdb->cmd, - "UPDATE Job SET JobStatus='%c', EndTime='%s', \ -ClientId=%s, JobBytes=%s, JobFiles=%u, JobErrors=%u, VolSessionId=%u, \ -VolSessionTime=%u, PoolId=%s, FileSetId=%s, JobTDate=%s WHERE JobId=%u", - (char)(jr->JobStatus), dt, ClientId, edit_uint64(jr->JobBytes, ed1), - jr->JobFiles, jr->JobErrors, jr->VolSessionId, jr->VolSessionTime, + "UPDATE Job SET JobStatus='%c', EndTime='%s', " +"ClientId=%s, JobBytes=%s, JobFiles=%u, JobErrors=%u, VolSessionId=%u, " +"VolSessionTime=%u, PoolId=%s, FileSetId=%s, JobTDate=%s WHERE JobId=%u", + (char)(jr->JobStatus), dt, ClientId, edit_uint64(jr->JobBytes, ed1), + jr->JobFiles, jr->JobErrors, jr->VolSessionId, jr->VolSessionTime, PoolId, FileSetId, edit_uint64(JobTDate, ed2), jr->JobId); stat = UPDATE_DB(jcr, mdb, mdb->cmd); @@ -170,7 +170,7 @@ VolSessionTime=%u, PoolId=%s, FileSetId=%s, JobTDate=%s WHERE JobId=%u", /* - * Update Client record + * Update Client record * Returns: 0 on failure * 1 on success */ @@ -189,7 +189,7 @@ db_update_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cr) } Mmsg(mdb->cmd, -"UPDATE Client SET AutoPrune=%d,FileRetention=%s,JobRetention=%s," +"UPDATE Client SET AutoPrune=%d,FileRetention=%s,JobRetention=%s," "Uname='%s' WHERE Name='%s'", cr->AutoPrune, edit_uint64(cr->FileRetention, ed1), @@ -212,7 +212,7 @@ int db_update_counter_record(JCR *jcr, B_DB *mdb, COUNTER_DBR *cr) db_lock(mdb); Mmsg(mdb->cmd, -"UPDATE Counters SET MinValue=%d,MaxValue=%d,CurrentValue=%d," +"UPDATE Counters SET MinValue=%d,MaxValue=%d,CurrentValue=%d," "WrapCounter='%s' WHERE Counter='%s'", cr->MinValue, cr->MaxValue, cr->CurrentValue, cr->WrapCounter, cr->Counter); @@ -231,7 +231,7 @@ db_update_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr) db_lock(mdb); Mmsg(mdb->cmd, -"UPDATE Pool SET NumVols=%u,MaxVols=%u,UseOnce=%d,UseCatalog=%d," +"UPDATE Pool SET NumVols=%u,MaxVols=%u,UseOnce=%d,UseCatalog=%d," "AcceptAnyVolume=%d,VolRetention='%s',VolUseDuration='%s'," "MaxVolJobs=%u,MaxVolFiles=%u,MaxVolBytes=%s,Recycle=%d," "AutoPrune=%d,LabelFormat='%s' WHERE PoolId=%u", @@ -248,21 +248,21 @@ db_update_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr) return stat; } -/* +/* * Update the Media Record at end of Session * * Returns: 0 on failure * numrows on success */ int -db_update_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) +db_update_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) { char dt[MAX_TIME_LENGTH]; time_t ttime; struct tm tm; int stat; char ed1[30], ed2[30], ed3[30], ed4[30]; - + Dmsg1(100, "update_media: FirstWritten=%d\n", mr->FirstWritten); db_lock(mdb); @@ -271,8 +271,8 @@ db_update_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) ttime = mr->FirstWritten; localtime_r(&ttime, &tm); strftime(dt, sizeof(dt), "%Y-%m-%d %T", &tm); - Mmsg(mdb->cmd, "UPDATE Media SET FirstWritten='%s'\ - WHERE VolumeName='%s'", dt, mr->VolumeName); + Mmsg(mdb->cmd, "UPDATE Media SET FirstWritten='%s'" +" WHERE VolumeName='%s'", dt, mr->VolumeName); stat = UPDATE_DB(jcr, mdb, mdb->cmd); Dmsg1(400, "Firstwritten stat=%d\n", stat); } @@ -286,37 +286,37 @@ db_update_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) localtime_r(&ttime, &tm); strftime(dt, sizeof(dt), "%Y-%m-%d %T", &tm); Mmsg(mdb->cmd, "UPDATE Media SET LabelDate='%s' " - "WHERE VolumeName='%s'", dt, mr->VolumeName); + "WHERE VolumeName='%s'", dt, mr->VolumeName); stat = UPDATE_DB(jcr, mdb, mdb->cmd); } - + if (mr->LastWritten != 0) { ttime = mr->LastWritten; localtime_r(&ttime, &tm); strftime(dt, sizeof(dt), "%Y-%m-%d %T", &tm); Mmsg(mdb->cmd, "UPDATE Media SET VolJobs=%u," - "VolFiles=%u,VolBlocks=%u,VolBytes=%s,VolMounts=%u,VolErrors=%u," - "VolWrites=%u,MaxVolBytes=%s,LastWritten='%s',VolStatus='%s'," - "Slot=%d,InChanger=%d,VolReadTime=%s,VolWriteTime=%s " - " WHERE VolumeName='%s'", + "VolFiles=%u,VolBlocks=%u,VolBytes=%s,VolMounts=%u,VolErrors=%u," + "VolWrites=%u,MaxVolBytes=%s,LastWritten='%s',VolStatus='%s'," + "Slot=%d,InChanger=%d,VolReadTime=%s,VolWriteTime=%s " + " WHERE VolumeName='%s'", mr->VolJobs, mr->VolFiles, mr->VolBlocks, edit_uint64(mr->VolBytes, ed1), - mr->VolMounts, mr->VolErrors, mr->VolWrites, - edit_uint64(mr->MaxVolBytes, ed2), dt, - mr->VolStatus, mr->Slot, mr->InChanger, + mr->VolMounts, mr->VolErrors, mr->VolWrites, + edit_uint64(mr->MaxVolBytes, ed2), dt, + mr->VolStatus, mr->Slot, mr->InChanger, edit_uint64(mr->VolReadTime, ed3), edit_uint64(mr->VolWriteTime, ed4), mr->VolumeName); } else { Mmsg(mdb->cmd, "UPDATE Media SET VolJobs=%u," - "VolFiles=%u,VolBlocks=%u,VolBytes=%s,VolMounts=%u,VolErrors=%u," - "VolWrites=%u,MaxVolBytes=%s,VolStatus='%s'," - "Slot=%d,InChanger=%d,VolReadTime=%s,VolWriteTime=%s " - " WHERE VolumeName='%s'", + "VolFiles=%u,VolBlocks=%u,VolBytes=%s,VolMounts=%u,VolErrors=%u," + "VolWrites=%u,MaxVolBytes=%s,VolStatus='%s'," + "Slot=%d,InChanger=%d,VolReadTime=%s,VolWriteTime=%s " + " WHERE VolumeName='%s'", mr->VolJobs, mr->VolFiles, mr->VolBlocks, edit_uint64(mr->VolBytes, ed1), - mr->VolMounts, mr->VolErrors, mr->VolWrites, - edit_uint64(mr->MaxVolBytes, ed2), - mr->VolStatus, mr->Slot, mr->InChanger, + mr->VolMounts, mr->VolErrors, mr->VolWrites, + edit_uint64(mr->MaxVolBytes, ed2), + mr->VolStatus, mr->Slot, mr->InChanger, edit_uint64(mr->VolReadTime, ed3), edit_uint64(mr->VolWriteTime, ed4), mr->VolumeName); @@ -333,36 +333,36 @@ db_update_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) return stat; } -/* +/* * Update the Media Record Default values from Pool * * Returns: 0 on failure * numrows on success */ int -db_update_media_defaults(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) +db_update_media_defaults(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) { int stat; char ed1[30], ed2[30], ed3[30]; - + db_lock(mdb); if (mr->VolumeName[0]) { Mmsg(mdb->cmd, "UPDATE Media SET " - "Recycle=%d,VolRetention=%s,VolUseDuration=%s," - "MaxVolJobs=%u,MaxVolFiles=%u,MaxVolBytes=%s" - " WHERE VolumeName='%s'", - mr->Recycle,edit_uint64(mr->VolRetention, ed1), + "Recycle=%d,VolRetention=%s,VolUseDuration=%s," + "MaxVolJobs=%u,MaxVolFiles=%u,MaxVolBytes=%s" + " WHERE VolumeName='%s'", + mr->Recycle,edit_uint64(mr->VolRetention, ed1), edit_uint64(mr->VolUseDuration, ed2), mr->MaxVolJobs, mr->MaxVolFiles, edit_uint64(mr->VolBytes, ed3), mr->VolumeName); } else { Mmsg(mdb->cmd, "UPDATE Media SET " - "Recycle=%d,VolRetention=%s,VolUseDuration=%s," - "MaxVolJobs=%u,MaxVolFiles=%u,MaxVolBytes=%s" - " WHERE PoolId=%u", - mr->Recycle,edit_uint64(mr->VolRetention, ed1), + "Recycle=%d,VolRetention=%s,VolUseDuration=%s," + "MaxVolJobs=%u,MaxVolFiles=%u,MaxVolBytes=%s" + " WHERE PoolId=%u", + mr->Recycle,edit_uint64(mr->VolRetention, ed1), edit_uint64(mr->VolUseDuration, ed2), mr->MaxVolJobs, mr->MaxVolFiles, edit_uint64(mr->VolBytes, ed3), @@ -378,18 +378,18 @@ db_update_media_defaults(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) } -/* +/* * If we have a non-zero InChanger, ensure that no other Media * record has InChanger set on the same Slot. * * This routine assumes the database is already locked. */ void -db_make_inchanger_unique(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) +db_make_inchanger_unique(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) { if (mr->InChanger != 0 && mr->Slot != 0) { Mmsg(mdb->cmd, "UPDATE Media SET InChanger=0 WHERE " - "Slot=%d AND PoolId=%u AND MediaId!=%u", + "Slot=%d AND PoolId=%u AND MediaId!=%u", mr->Slot, mr->PoolId, mr->MediaId); Dmsg1(400, "%s\n", mdb->cmd); UPDATE_DB(jcr, mdb, mdb->cmd); diff --git a/bacula/src/cats/sqlite.c b/bacula/src/cats/sqlite.c index f65414bf4a..c0398f9aa8 100644 --- a/bacula/src/cats/sqlite.c +++ b/bacula/src/cats/sqlite.c @@ -60,7 +60,7 @@ int QueryDB(const char *file, int line, JCR *jcr, B_DB *db, char *select_cmd); */ B_DB * db_init_database(JCR *jcr, const char *db_name, const char *db_user, const char *db_password, - const char *db_address, int db_port, const char *db_socket, + const char *db_address, int db_port, const char *db_socket, int mult_db_connections) { B_DB *mdb; @@ -70,7 +70,7 @@ db_init_database(JCR *jcr, const char *db_name, const char *db_user, const char if (!mult_db_connections) { for (mdb=NULL; (mdb=(B_DB *)qnext(&db_list, &mdb->bq)); ) { if (strcmp(mdb->db_name, db_name) == 0) { - Dmsg2(300, "DB REopen %d %s\n", mdb->ref_count, db_name); + Dmsg2(300, "DB REopen %d %s\n", mdb->ref_count, db_name); mdb->ref_count++; V(mutex); return mdb; /* already open */ @@ -81,7 +81,7 @@ db_init_database(JCR *jcr, const char *db_name, const char *db_user, const char mdb = (B_DB *) malloc(sizeof(B_DB)); memset(mdb, 0, sizeof(B_DB)); mdb->db_name = bstrdup(db_name); - mdb->have_insert_id = TRUE; + mdb->have_insert_id = TRUE; mdb->errmsg = get_pool_memory(PM_EMSG); /* get error message buffer */ *mdb->errmsg = 0; mdb->cmd = get_pool_memory(PM_EMSG); /* get command buffer */ @@ -119,21 +119,21 @@ db_open_database(JCR *jcr, B_DB *mdb) mdb->connected = FALSE; if ((errstat=rwl_init(&mdb->lock)) != 0) { - Mmsg1(&mdb->errmsg, _("Unable to initialize DB lock. ERR=%s\n"), + Mmsg1(&mdb->errmsg, _("Unable to initialize DB lock. ERR=%s\n"), strerror(errstat)); V(mutex); return 0; } /* open the database */ - len = strlen(working_directory) + strlen(mdb->db_name) + 5; + len = strlen(working_directory) + strlen(mdb->db_name) + 5; db_name = (char *)malloc(len); strcpy(db_name, working_directory); strcat(db_name, "/"); strcat(db_name, mdb->db_name); strcat(db_name, ".db"); if (stat(db_name, &statbuf) != 0) { - Mmsg1(&mdb->errmsg, _("Database %s does not exist, please create it.\n"), + Mmsg1(&mdb->errmsg, _("Database %s does not exist, please create it.\n"), db_name); free(db_name); V(mutex); @@ -145,10 +145,10 @@ db_open_database(JCR *jcr, B_DB *mdb) &mdb->sqlite_errmsg); /* error message */ Dmsg0(300, "sqlite_open\n"); - + if (mdb->db == NULL) { Mmsg2(&mdb->errmsg, _("Unable to open Database=%s. ERR=%s\n"), - db_name, mdb->sqlite_errmsg ? mdb->sqlite_errmsg : _("unknown")); + db_name, mdb->sqlite_errmsg ? mdb->sqlite_errmsg : _("unknown")); free(db_name); V(mutex); return 0; @@ -177,7 +177,7 @@ db_close_database(JCR *jcr, B_DB *mdb) if (mdb->connected && mdb->db) { sqlite_close(mdb->db); } - rwl_destroy(&mdb->lock); + rwl_destroy(&mdb->lock); free_pool_memory(mdb->errmsg); free_pool_memory(mdb->cmd); free_pool_memory(mdb->cached_path); @@ -228,7 +228,7 @@ int db_next_index(JCR *jcr, B_DB *mdb, char *table, char *index) db_unlock(mdb); return 1; -} +} /* @@ -248,12 +248,12 @@ db_escape_string(char *snew, char *old, int len) while (len--) { switch (*o) { case '\'': - *n++ = '\''; - *n++ = '\''; + *n++ = '\''; + *n++ = '\''; o++; break; case 0: - *n++ = '\\'; + *n++ = '\\'; *n++ = 0; o++; break; @@ -270,12 +270,12 @@ struct rh_data { void *ctx; }; -/* - * Convert SQLite's callback into Bacula DB callback +/* + * Convert SQLite's callback into Bacula DB callback */ static int sqlite_result(void *arh_data, int num_fields, char **rows, char **col_names) { - struct rh_data *rh_data = (struct rh_data *)arh_data; + struct rh_data *rh_data = (struct rh_data *)arh_data; if (rh_data->result_handler) { (*(rh_data->result_handler))(rh_data->ctx, num_fields, rows); @@ -312,7 +312,7 @@ int db_sql_query(B_DB *mdb, const char *query, DB_RESULT_HANDLER *result_handler /* * Submit a sqlite query and retrieve all the data */ -int my_sqlite_query(B_DB *mdb, char *cmd) +int my_sqlite_query(B_DB *mdb, char *cmd) { int stat; @@ -348,7 +348,7 @@ void my_sqlite_free_table(B_DB *mdb) mdb->fields_defined = false; } sqlite_free_table(mdb->result); - mdb->nrow = mdb->ncolumn = 0; + mdb->nrow = mdb->ncolumn = 0; } void my_sqlite_field_seek(B_DB *mdb, int field) diff --git a/bacula/src/console/authenticate.c b/bacula/src/console/authenticate.c index fe242c256b..7cedabb5c1 100644 --- a/bacula/src/console/authenticate.c +++ b/bacula/src/console/authenticate.c @@ -25,7 +25,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free - Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, + Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ @@ -35,7 +35,7 @@ void senditf(const char *fmt, ...); -void sendit(const char *buf); +void sendit(const char *buf); /* Commands sent to Director */ static char hello[] = "Hello %s calling\n"; @@ -55,7 +55,7 @@ int authenticate_director(JCR *jcr, DIRRES *director, CONRES *cons) char bashed_name[MAX_NAME_LENGTH]; char *password; - /* + /* * Send my name to the Director then do authentication */ if (cons) { @@ -70,11 +70,11 @@ int authenticate_director(JCR *jcr, DIRRES *director, CONRES *cons) btimer_t *tid = start_bsock_timer(dir, 60 * 5); bnet_fsend(dir, hello, bashed_name); - if (!cram_md5_get_auth(dir, password, ssl_need) || + if (!cram_md5_get_auth(dir, password, ssl_need) || !cram_md5_auth(dir, password, ssl_need)) { stop_bsock_timer(tid); sendit( _("Director authorization problem.\n" - "Most likely the passwords do not agree.\n" + "Most likely the passwords do not agree.\n" "Please see http://www.bacula.org/html-manual/faq.html#AuthorizationErrors for help.\n")); return 0; } diff --git a/bacula/src/console/conio.c b/bacula/src/console/conio.c index 889400b0a9..19f10bde3f 100755 --- a/bacula/src/console/conio.c +++ b/bacula/src/console/conio.c @@ -1,12 +1,12 @@ -/* - Generalized console input/output handler +/* + Generalized console input/output handler A maintanable replacement for readline() Updated for Bacula, Kern Sibbald, December MMIII This code is in part derived from code that I wrote in 1981, so some of it is a bit old and could use a cleanup. - + */ /* Copyright (C) 1981-2004 Kern Sibbald and John Walker @@ -29,7 +29,7 @@ */ -/* +/* * UTF-8 * If the top bit of a UTF-8 string is 0 (8 bits), then it * is a normal ASCII character. @@ -45,7 +45,7 @@ #include #include #include -#include +#include #else /* We are in Bacula */ @@ -243,10 +243,10 @@ void con_term(); void trapctlc(); int usrbrk(); void clrbrk(); - + void con_init(FILE *input) { - atexit(con_term); + atexit(con_term); rawmode(input); trapctlc(); } @@ -313,7 +313,7 @@ char *bstrncpy(char *dest, const char *src, int maxlen) static unsigned do_smap(unsigned c) { char str[MAX_STAB]; - int len = 0; + int len = 0; stab_t *tstab; int i, found; unsigned cm; @@ -362,7 +362,7 @@ static void dump_stab() for (j=0; jlen; j++) { c = tstab->str[j]; if (c < 0x20 || c > 0x7F) { - sprintf(buf, " 0x%x ", c); + sprintf(buf, " 0x%x ", c); t_send(buf); } else { buf[0] = c; @@ -370,7 +370,7 @@ static void dump_stab() t_sendl(buf, 1); } } - sprintf(buf, " func=%d len=%d\n\r", tstab->func, tstab->len); + sprintf(buf, " func=%d len=%d\n\r", tstab->func, tstab->len); t_send(buf); } } @@ -384,7 +384,7 @@ static void add_smap(char *str, int func) { stab_t *tstab; int len; - + if (!str) { return; } @@ -405,7 +405,7 @@ static void add_smap(char *str, int func) } tstab->next = stab[tstab->len-1]; stab[tstab->len-1] = tstab; -/* printf("Add_smap tstab=%x len=%d func=%d tstab->next=%x\n\r", tstab, len, +/* printf("Add_smap tstab=%x len=%d func=%d tstab->next=%x\n\r", tstab, len, func, tstab->next); */ } @@ -460,7 +460,7 @@ input_line(char *string, int length) } switch (c=input_char()) { case F_RETURN: /* CR */ - t_sendl("\r\n", 2); /* yes, print it and */ + t_sendl("\r\n", 2); /* yes, print it and */ goto done; /* get out */ case F_CLRSCRN: /* clear screen */ asclrs(); @@ -496,7 +496,7 @@ input_line(char *string, int length) backup(curline); delchr(1, curline, sizeof(curline)); if (cp == 0) { - t_char(' '); + t_char(' '); t_char(0x8); } break; @@ -534,7 +534,7 @@ input_line(char *string, int length) t_clrline(0, t_width); /* erase line */ cp = 0; cl = 0; /* reset cursor counter */ - t_char(' '); + t_char(' '); t_char(0x8); break; case F_SOL: @@ -582,7 +582,7 @@ input_line(char *string, int length) curline[cp++] = c; /* store character in line being built */ t_char(c); /* echo character to terminal */ while (more--) { - c= input_char(); + c= input_char(); insert_hole(curline, sizeof(curline)); curline[cp++] = c; /* store character in line being built */ t_char(c); /* echo character to terminal */ @@ -670,7 +670,7 @@ forward(char *str, int str_len) } /* How many characters under the cursor */ -static int +static int char_count(int cptr, char *str) { int cnt = 1; @@ -689,7 +689,7 @@ char_count(int cptr, char *str) /* Backup cursor keeping characters under it */ static void -backup(char *str) +backup(char *str) { if (cp == 0) { return; @@ -703,7 +703,7 @@ backup(char *str) /* Delete the character under the cursor */ static void -delchr(int del, char *curline, int line_len) +delchr(int del, char *curline, int line_len) { int i, cnt; @@ -873,7 +873,7 @@ dump(struct lstr *ptr, char *msg) printf("%s buf=%x nextl=%x prevl=%x len=%d used=%d\n", msg,ptr,ptr->nextl,ptr->prevl,ptr->len,ptr->used); if (ptr->used) - printf("line=%s\n",&ptr->line); + printf("line=%s\n",&ptr->line); } #endif /* DEBUGOUT */ @@ -906,7 +906,7 @@ t_clrline(int pos, int width) asclrl(pos, width); /* clear to end of line */ } -/* Helper function to add string preceded by +/* Helper function to add string preceded by * ESC to smap table */ static void add_esc_smap(const char *str, int func) { @@ -936,11 +936,11 @@ static void rawmode(FILE *input) exit(1); } old_term_params_set = true; - t = old_term_params; + t = old_term_params; t.c_cc[VMIN] = 1; /* satisfy read after 1 char */ t.c_cc[VTIME] = 0; - t.c_iflag &= ~(BRKINT | IGNPAR | PARMRK | INPCK | - ISTRIP | ICRNL | IXON | IXOFF | INLCR | IGNCR); + t.c_iflag &= ~(BRKINT | IGNPAR | PARMRK | INPCK | + ISTRIP | ICRNL | IXON | IXOFF | INLCR | IGNCR); t.c_iflag |= IGNBRK; t.c_oflag |= ONLCR; t.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHONL | ICANON | @@ -955,7 +955,7 @@ static void rawmode(FILE *input) signal(SIGHUP, SIG_IGN); // signal(SIGSTOP, SIG_IGN); signal(SIGINT, sigintcatcher); - signal(SIGWINCH, SIG_IGN); + signal(SIGWINCH, SIG_IGN); signal(SIGQUIT, SIG_IGN); signal(SIGCHLD, SIG_IGN); // signal(SIGTSTP, SIG_IGN); @@ -1054,9 +1054,9 @@ static unsigned t_getch(void) if (read(0, &c, 1) != 1) { c = 0; } - return (unsigned)c; + return (unsigned)c; } - + /* Send message to terminal - primitive routine */ void t_sendl(const char *msg, int len) @@ -1116,7 +1116,7 @@ void trapctlc() /* ASCLRL() -- Clear to end of line from current position */ -static void asclrl(int pos, int width) +static void asclrl(int pos, int width) { int i; @@ -1134,7 +1134,7 @@ static void asclrl(int pos, int width) for (i=1; i<=width-pos+1; i++) /* backspace to original position */ t_char(0x8); return; - + } @@ -1143,10 +1143,10 @@ static void ascurs(int y, int x) { t_send((char *)tgoto(t_cm, x, y)); } - + /* ASCLRS -- Clear whole screen */ -static void asclrs() +static void asclrs() { ascurs(0,0); t_send(t_cs); diff --git a/bacula/src/console/console.c b/bacula/src/console/console.c index 73989938d3..5db974b480 100644 --- a/bacula/src/console/console.c +++ b/bacula/src/console/console.c @@ -34,12 +34,12 @@ #ifdef HAVE_CONIO #include "conio.h" #else -#define con_init(x) +#define con_init(x) #define con_term() #define con_set_zed_keys(); #define trapctlc() #define clrbrk() -#define usrbrk() 0 +#define usrbrk() 0 #endif #ifdef HAVE_WIN32 @@ -47,7 +47,7 @@ #define isatty(fd) (fd==0) DWORD g_platform_id = VER_PLATFORM_WIN32_WINDOWS; #endif - + /* Exported variables */ #ifdef HAVE_CYGWIN @@ -77,7 +77,7 @@ extern "C" void got_sigtin(int sig); /* Static variables */ static char *configfile = NULL; static BSOCK *UA_sock = NULL; -static DIRRES *dir; +static DIRRES *dir; static FILE *output = stdout; static bool tee = false; /* output to output and stdout */ static bool stop = false; @@ -109,32 +109,32 @@ static void usage() " -dnn set debug level to nn\n" " -s no signals\n" " -t test - read configuration and exit\n" -" -? print this message.\n" +" -? print this message.\n" "\n"), HOST_OS, DISTNAME, DISTVER); } -extern "C" +extern "C" void got_sigstop(int sig) { stop = true; } -extern "C" +extern "C" void got_sigcontinue(int sig) { stop = false; } -extern "C" -void got_sigtout(int sig) +extern "C" +void got_sigtout(int sig) { // printf("Got tout\n"); } -extern "C" +extern "C" void got_sigtin(int sig) -{ +{ // printf("Got tin\n"); } @@ -148,7 +148,7 @@ static int zed_keyscmd(FILE *input, BSOCK *UA_sock) /* * These are the @command */ -struct cmdstruct { const char *key; int (*func)(FILE *input, BSOCK *UA_sock); const char *help; }; +struct cmdstruct { const char *key; int (*func)(FILE *input, BSOCK *UA_sock); const char *help; }; static struct cmdstruct commands[] = { { N_("input"), inputcmd, _("input from file")}, { N_("output"), outputcmd, _("output to file")}, @@ -199,18 +199,18 @@ static int do_a_command(FILE *input, BSOCK *UA_sock) } -static void read_and_process_input(FILE *input, BSOCK *UA_sock) +static void read_and_process_input(FILE *input, BSOCK *UA_sock) { const char *prompt = "*"; bool at_prompt = false; int tty_input = isatty(fileno(input)); int stat; - for ( ;; ) { + for ( ;; ) { if (at_prompt) { /* don't prompt multiple times */ - prompt = ""; + prompt = ""; } else { - prompt = "*"; + prompt = "*"; at_prompt = true; } if (tty_input) { @@ -239,15 +239,15 @@ static void read_and_process_input(FILE *input, BSOCK *UA_sock) if (stat < 0) { break; /* error or interrupt */ } else if (stat == 0) { /* timeout */ - if (strcmp(prompt, "*") == 0) { - bnet_fsend(UA_sock, ".messages"); + if (strcmp(prompt, "*") == 0) { + bnet_fsend(UA_sock, ".messages"); } else { continue; } } else { at_prompt = FALSE; /* @ => internal command for us */ - if (UA_sock->msg[0] == '@') { + if (UA_sock->msg[0] == '@') { parse_args(UA_sock->msg, &args, &argc, argk, argv, MAX_CMD_ARGS); if (!do_a_command(input, UA_sock)) { break; @@ -264,7 +264,7 @@ static void read_and_process_input(FILE *input, BSOCK *UA_sock) while ((stat = bnet_recv(UA_sock)) >= 0) { if (at_prompt) { if (!stop) { - sendit("\n"); + sendit("\n"); } at_prompt = false; } @@ -287,7 +287,7 @@ static void read_and_process_input(FILE *input, BSOCK *UA_sock) if (UA_sock->msglen == BNET_PROMPT) { at_prompt = true; } - Dmsg1(100, "Got poll %s\n", bnet_sig_to_ascii(UA_sock)); + Dmsg1(100, "Got poll %s\n", bnet_sig_to_ascii(UA_sock)); } } } @@ -342,7 +342,7 @@ int main(int argc, char *argv[]) usage(); con_term(); exit(1); - } + } } argc -= optind; argv += optind; @@ -382,8 +382,8 @@ int main(int argc, char *argv[]) UnlockRes(); if (ndir == 0) { con_term(); - Emsg1(M_ERROR_TERM, 0, _("No Director resource defined in %s\n\ -Without that I don't how to speak to the Director :-(\n"), configfile); + Emsg1(M_ERROR_TERM, 0, _("No Director resource defined in %s\n" +"Without that I don't how to speak to the Director :-(\n"), configfile); } if (test_config) { @@ -404,7 +404,7 @@ try_again: LockRes(); ndir = 0; foreach_res(dir, R_DIRECTOR) { - senditf( _("%d %s at %s:%d\n"), 1+ndir++, dir->hdr.name, dir->address, + senditf( _("%d %s at %s:%d\n"), 1+ndir++, dir->hdr.name, dir->address, dir->DIRport); } UnlockRes(); @@ -414,7 +414,7 @@ try_again: } item = atoi(UA_sock->msg); if (item < 0 || item > ndir) { - senditf(_("You must enter a number between 1 and %d\n"), ndir); + senditf(_("You must enter a number between 1 and %d\n"), ndir); goto try_again; } LockRes(); @@ -429,9 +429,9 @@ try_again: dir = (DIRRES *)GetNextRes(R_DIRECTOR, NULL); UnlockRes(); } - + senditf(_("Connecting to Director %s:%d\n"), dir->address,dir->DIRport); - UA_sock = bnet_connect(NULL, 5, 15, "Director daemon", dir->address, + UA_sock = bnet_connect(NULL, 5, 15, "Director daemon", dir->address, NULL, dir->DIRport, 0); if (UA_sock == NULL) { terminate_console(0); @@ -504,7 +504,7 @@ static void terminate_console(int sig) #include "history.h" -int +int get_cmd(FILE *input, const char *prompt, BSOCK *sock, int sec) { char *line; @@ -559,17 +559,17 @@ wait_for_data(int fd, int sec) } } -/* - * Get next input command from terminal. +/* + * Get next input command from terminal. * * Returns: 1 if got input * 0 if timeout * -1 if EOF or error */ -int +int get_cmd(FILE *input, const char *prompt, BSOCK *sock, int sec) { - int len; + int len; if (!stop) { if (output == stdout || tee) { sendit(prompt); @@ -579,7 +579,7 @@ again: switch (wait_for_data(fileno(input), sec)) { case 0: return 0; /* timeout */ - case -1: + case -1: return -1; /* error */ default: len = sizeof_pool_memory(sock->msg) - 1; @@ -629,9 +629,9 @@ static int inputcmd(FILE *input, BSOCK *UA_sock) } fd = fopen(argk[1], "r"); if (!fd) { - senditf(_("Cannot open file %s for input. ERR=%s\n"), + senditf(_("Cannot open file %s for input. ERR=%s\n"), argk[1], strerror(errno)); - return 1; + return 1; } read_and_process_input(fd, UA_sock); fclose(fd); @@ -675,9 +675,9 @@ static int do_outputcmd(FILE *input, BSOCK *UA_sock) } fd = fopen(argk[1], mode); if (!fd) { - senditf(_("Cannot open file %s for output. ERR=%s\n"), + senditf(_("Cannot open file %s for output. ERR=%s\n"), argk[1], strerror(errno)); - return 1; + return 1; } output = fd; return 1; @@ -726,18 +726,18 @@ void sendit(const char *buf) { #ifdef xHAVE_CONIO if (output == stdout || tee) { - char *p, *q; + char *p, *q; /* - * Here, we convert every \n into \r\n because the - * terminal is in raw mode when we are using + * Here, we convert every \n into \r\n because the + * terminal is in raw mode when we are using * conio. */ for (p=q=buf; (p=strchr(q, '\n')); ) { if (p-q > 0) { t_sendl(q, p-q); } - t_sendl("\r\n", 2); - q = ++p; /* point after \n */ + t_sendl("\r\n", 2); + q = ++p; /* point after \n */ } if (*q) { t_send(q); diff --git a/bacula/src/console/console_conf.c b/bacula/src/console/console_conf.c index 83d0f22791..54b179c94b 100644 --- a/bacula/src/console/console_conf.c +++ b/bacula/src/console/console_conf.c @@ -7,7 +7,7 @@ * * 1. The generic lexical scanner in lib/lex.c and lib/lex.h * - * 2. The generic config scanner in lib/parse_config.c and + * 2. The generic config scanner in lib/parse_config.c and * lib/parse_config.h. * These files contain the parser code, some utility * routines, and the common store routines (name, int, @@ -69,9 +69,9 @@ int res_all_size = sizeof(res_all); #endif /* Definition of records permitted within each - * resource with the routine to process the record + * resource with the routine to process the record * information. - */ + */ /* Console "globals" */ static RES_ITEM cons_items[] = { @@ -81,7 +81,7 @@ static RES_ITEM cons_items[] = { {"historyfile", store_dir, ITEM(res_cons.hist_file), 0, 0, 0}, {"requiressl", store_yesno, ITEM(res_cons.require_ssl), 1, ITEM_DEFAULT, 0}, {"password", store_password, ITEM(res_cons.password), 0, ITEM_REQUIRED, 0}, - {NULL, NULL, NULL, 0, 0, 0} + {NULL, NULL, NULL, 0, 0, 0} }; @@ -93,15 +93,15 @@ static RES_ITEM dir_items[] = { {"address", store_str, ITEM(res_dir.address), 0, 0, 0}, {"password", store_password, ITEM(res_dir.password), 0, ITEM_REQUIRED, 0}, {"enablessl", store_yesno, ITEM(res_dir.enable_ssl), 1, ITEM_DEFAULT, 0}, - {NULL, NULL, NULL, 0, 0, 0} + {NULL, NULL, NULL, 0, 0, 0} }; -/* - * This is the master resource definition. +/* + * This is the master resource definition. * It must have one item for each of the resources. */ RES_TABLE resources[] = { - {"console", cons_items, R_CONSOLE}, + {"console", cons_items, R_CONSOLE}, {"director", dir_items, R_DIRECTOR}, {NULL, NULL, 0} }; @@ -127,7 +127,7 @@ void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fm res->res_cons.rc_file, res->res_cons.hist_file); break; case R_DIRECTOR: - printf("Director: name=%s address=%s DIRport=%d\n", reshdr->name, + printf("Director: name=%s address=%s DIRport=%d\n", reshdr->name, res->res_dir.address, res->res_dir.DIRport); break; default: @@ -138,10 +138,10 @@ void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fm } } -/* - * Free memory of resource. +/* + * Free memory of resource. * NB, we don't need to worry about freeing any references - * to other resources as they will be freed when that + * to other resources as they will be freed when that * resource chain is traversed. Mainly we worry about freeing * allocated strings (names). */ @@ -192,16 +192,16 @@ void save_resource(int type, RES_ITEM *items, int pass) { URES *res; int rindex = type - r_first; - int i, size; + int i, size; int error = 0; - /* + /* * Ensure that all required items are present */ for (i=0; items[i].name; i++) { if (items[i].flags & ITEM_REQUIRED) { - if (!bit_is_set(i, res_all.res_dir.hdr.item_present)) { - Emsg2(M_ABORT, 0, "%s item is required in %s resource, but not found.\n", + if (!bit_is_set(i, res_all.res_dir.hdr.item_present)) { + Emsg2(M_ABORT, 0, "%s item is required in %s resource, but not found.\n", items[i].name, resources[rindex]); } } @@ -220,7 +220,7 @@ void save_resource(int type, RES_ITEM *items, int pass) break; default: - Emsg1(M_ERROR, 0, "Unknown resource type %d\n", type); + Emsg1(M_ERROR, 0, "Unknown resource type %d\n", type); error = 1; break; } @@ -263,12 +263,12 @@ void save_resource(int type, RES_ITEM *items, int pass) for (next=res_head[rindex]; next->next; next=next->next) { if (strcmp(next->name, res->res_dir.hdr.name) == 0) { Emsg2(M_ERROR_TERM, 0, - _("Attempt to define second %s resource named \"%s\" is not permitted.\n"), + _("Attempt to define second %s resource named \"%s\" is not permitted.\n"), resources[rindex].name, res->res_dir.hdr.name); } } next->next = (RES *)res; - Dmsg2(90, "Inserting %s res: %s\n", res_to_str(type), + Dmsg2(90, "Inserting %s res: %s\n", res_to_str(type), res->res_dir.hdr.name); } } diff --git a/bacula/src/console/console_conf.h b/bacula/src/console/console_conf.h index 55e5c87c58..f0b7f7a59c 100644 --- a/bacula/src/console/console_conf.h +++ b/bacula/src/console/console_conf.h @@ -7,7 +7,7 @@ */ /* - * Resource codes -- they must be sequential for indexing + * Resource codes -- they must be sequential for indexing */ enum { diff --git a/bacula/src/dird/admin.c b/bacula/src/dird/admin.c index b26ae18c94..f85636ef4a 100644 --- a/bacula/src/dird/admin.c +++ b/bacula/src/dird/admin.c @@ -40,11 +40,11 @@ static void admin_cleanup(JCR *jcr, int TermCode); /* External functions */ -/* +/* * Returns: 0 on failure * 1 on success */ -int do_admin(JCR *jcr) +int do_admin(JCR *jcr) { jcr->jr.JobId = jcr->JobId; @@ -76,9 +76,9 @@ static void admin_cleanup(JCR *jcr, int TermCode) set_jcr_job_status(jcr, TermCode); update_job_end_record(jcr); /* update database */ - + if (!db_get_job_record(jcr, jcr->db, &jcr->jr)) { - Jmsg(jcr, M_WARNING, 0, _("Error getting job record for stats: %s"), + Jmsg(jcr, M_WARNING, 0, _("Error getting job record for stats: %s"), db_strerror(jcr->db)); set_jcr_job_status(jcr, JS_ErrorTerminated); } @@ -90,7 +90,7 @@ static void admin_cleanup(JCR *jcr, int TermCode) break; case JS_FatalError: case JS_ErrorTerminated: - term_msg = _("*** Admin Error ***"); + term_msg = _("*** Admin Error ***"); msg_type = M_ERROR; /* Generate error message */ break; case JS_Canceled: @@ -104,12 +104,12 @@ static void admin_cleanup(JCR *jcr, int TermCode) bstrftime(sdt, sizeof(sdt), jcr->jr.StartTime); bstrftime(edt, sizeof(edt), jcr->jr.EndTime); - Jmsg(jcr, msg_type, 0, _("Bacula " VERSION " (" LSMDATE "): %s\n\ - JobId: %d\n\ - Job: %s\n\ - Start time: %s\n\ - End time: %s\n\ - Termination: %s\n\n"), + Jmsg(jcr, msg_type, 0, _("Bacula " VERSION " (" LSMDATE "): %s\n" +" JobId: %d\n" +" Job: %s\n" +" Start time: %s\n" +" End time: %s\n" +" Termination: %s\n\n"), edt, jcr->jr.JobId, jcr->jr.Job, @@ -118,4 +118,4 @@ static void admin_cleanup(JCR *jcr, int TermCode) term_msg); Dmsg0(100, "Leave admin_cleanup()\n"); -} +} diff --git a/bacula/src/dird/authenticate.c b/bacula/src/dird/authenticate.c index 4ad863a3ea..4ec64b41bd 100644 --- a/bacula/src/dird/authenticate.c +++ b/bacula/src/dird/authenticate.c @@ -52,14 +52,14 @@ static char Dir_sorry[] = "1999 You are not authorized.\n"; /* * Authenticate Storage daemon connection */ -bool authenticate_storage_daemon(JCR *jcr, STORE *store) +bool authenticate_storage_daemon(JCR *jcr, STORE *store) { BSOCK *sd = jcr->store_bsock; char dirname[MAX_NAME_LENGTH]; int ssl_need = BNET_SSL_NONE; bool get_auth, auth = false; - /* + /* * Send my name to the Storage daemon then do authentication */ bstrncpy(dirname, director->hdr.name, sizeof(dirname)); @@ -72,11 +72,11 @@ bool authenticate_storage_daemon(JCR *jcr, STORE *store) Jmsg(jcr, M_FATAL, 0, _("Error sending Hello to Storage daemon. ERR=%s\n"), bnet_strerror(sd)); return 0; } - get_auth = cram_md5_get_auth(sd, store->password, ssl_need); + get_auth = cram_md5_get_auth(sd, store->password, ssl_need); if (get_auth) { - auth = cram_md5_auth(sd, store->password, ssl_need); + auth = cram_md5_auth(sd, store->password, ssl_need); if (!auth) { - Dmsg1(50, "cram_auth failed for %s\n", sd->who); + Dmsg1(50, "cram_auth failed for %s\n", sd->who); } } else { Dmsg1(50, "cram_get_auth failed for %s\n", sd->who); @@ -85,11 +85,11 @@ bool authenticate_storage_daemon(JCR *jcr, STORE *store) stop_bsock_timer(tid); Dmsg0(50, _("Director and Storage daemon passwords or names not the same.\n")); Jmsg0(jcr, M_FATAL, 0, - _("Unable to authenticate with Storage daemon. Possible causes:\n" - "Passwords or names not the same or\n" - "Maximum Concurrent Jobs exceeded on the SD or\n" - "SD networking messed up (restart daemon).\n" - "Please see http://www.bacula.org/html-manual/faq.html#AuthorizationErrors for help.\n")); + _("Unable to authenticate with Storage daemon. Possible causes:\n" + "Passwords or names not the same or\n" + "Maximum Concurrent Jobs exceeded on the SD or\n" + "SD networking messed up (restart daemon).\n" + "Please see http://www.bacula.org/html-manual/faq.html#AuthorizationErrors for help.\n")); return 0; } Dmsg1(116, ">stored: %s", sd->msg); @@ -119,7 +119,7 @@ int authenticate_file_daemon(JCR *jcr) int ssl_need = BNET_SSL_NONE; bool get_auth, auth = false; - /* + /* * Send my name to the File daemon then do authentication */ bstrncpy(dirname, director->hdr.name, sizeof(dirname)); @@ -131,11 +131,11 @@ int authenticate_file_daemon(JCR *jcr) Jmsg(jcr, M_FATAL, 0, _("Error sending Hello to File daemon. ERR=%s\n"), bnet_strerror(fd)); return 0; } - get_auth = cram_md5_get_auth(fd, jcr->client->password, ssl_need); + get_auth = cram_md5_get_auth(fd, jcr->client->password, ssl_need); if (get_auth) { - auth = cram_md5_auth(fd, jcr->client->password, ssl_need); + auth = cram_md5_auth(fd, jcr->client->password, ssl_need); if (!auth) { - Dmsg1(50, "cram_auth failed for %s\n", fd->who); + Dmsg1(50, "cram_auth failed for %s\n", fd->who); } } else { Dmsg1(50, "cram_get_auth failed for %s\n", fd->who); @@ -144,11 +144,11 @@ int authenticate_file_daemon(JCR *jcr) stop_bsock_timer(tid); Dmsg0(50, _("Director and File daemon passwords or names not the same.\n")); Jmsg(jcr, M_FATAL, 0, - _("Unable to authenticate with File daemon. Possible causes:\n" - "Passwords or names not the same or\n" - "Maximum Concurrent Jobs exceeded on the FD or\n" - "FD networking messed up (restart daemon).\n" - "Please see http://www.bacula.org/html-manual/faq.html#AuthorizationErrors for help.\n")); + _("Unable to authenticate with File daemon. Possible causes:\n" + "Passwords or names not the same or\n" + "Maximum Concurrent Jobs exceeded on the FD or\n" + "FD networking messed up (restart daemon).\n" + "Please see http://www.bacula.org/html-manual/faq.html#AuthorizationErrors for help.\n")); return 0; } Dmsg1(116, ">filed: %s", fd->msg); @@ -170,14 +170,14 @@ int authenticate_file_daemon(JCR *jcr) return 1; } -/********************************************************************* +/********************************************************************* * */ -int authenticate_user_agent(UAContext *uac) +int authenticate_user_agent(UAContext *uac) { char name[MAX_NAME_LENGTH]; int ssl_need = BNET_SSL_NONE; - bool ok; + bool ok; BSOCK *ua = uac->UA_sock; // Emsg4(M_INFO, 0, _("UA Hello from %s:%s:%d is invalid. Len=%d\n"), ua->who, @@ -199,7 +199,7 @@ int authenticate_user_agent(UAContext *uac) ok = cram_md5_auth(ua, director->password, ssl_need) && cram_md5_get_auth(ua, director->password, ssl_need); } else { - unbash_spaces(name); + unbash_spaces(name); CONRES *cons = (CONRES *)GetResWithName(R_CONSOLE, name); if (cons) { ok = cram_md5_auth(ua, cons->password, ssl_need) && diff --git a/bacula/src/dird/autoprune.c b/bacula/src/dird/autoprune.c index 663ed00c98..0b7c2a863a 100644 --- a/bacula/src/dird/autoprune.c +++ b/bacula/src/dird/autoprune.c @@ -1,6 +1,6 @@ /* * - * Bacula Director -- Automatic Pruning + * Bacula Director -- Automatic Pruning * Applies retention periods * * Kern Sibbald, May MMII @@ -60,7 +60,7 @@ int do_autoprune(JCR *jcr) } else { pruned = false; } - + if (jcr->job->PruneFiles || jcr->client->AutoPrune) { Jmsg(jcr, M_INFO, 0, _("Begin pruning Files.\n")); prune_files(ua, client); @@ -71,7 +71,7 @@ int do_autoprune(JCR *jcr) } free_ua_context(ua); - return 1; + return 1; } /* @@ -110,7 +110,7 @@ int prune_volumes(JCR *jcr) for (i=0; idb, &mr)) { - Jmsg(jcr, M_ERROR, 0, "%s", db_strerror(jcr->db)); + Jmsg(jcr, M_ERROR, 0, "%s", db_strerror(jcr->db)); continue; } /* Prune only Volumes from current Pool */ @@ -118,14 +118,14 @@ int prune_volumes(JCR *jcr) continue; } /* Prune only Volumes with status "Full", "Used", or "Append" */ - if (strcmp(mr.VolStatus, "Full") == 0 || - strcmp(mr.VolStatus, "Append") == 0 || - strcmp(mr.VolStatus, "Used") == 0) { - Dmsg1(200, "Prune Volume %s\n", mr.VolumeName); - stat += prune_volume(ua, &mr); - Dmsg1(200, "Num pruned = %d\n", stat); + if (strcmp(mr.VolStatus, "Full") == 0 || + strcmp(mr.VolStatus, "Append") == 0 || + strcmp(mr.VolStatus, "Used") == 0) { + Dmsg1(200, "Prune Volume %s\n", mr.VolumeName); + stat += prune_volume(ua, &mr); + Dmsg1(200, "Num pruned = %d\n", stat); } - } + } bail_out: db_unlock(jcr->db); diff --git a/bacula/src/dird/backup.c b/bacula/src/dird/backup.c index 5ef4d3a572..e3f744bec6 100644 --- a/bacula/src/dird/backup.c +++ b/bacula/src/dird/backup.c @@ -46,7 +46,7 @@ static char storaddr[] = "storage address=%s port=%d ssl=%d\n"; static char OKbackup[] = "2000 OK backup\n"; static char OKstore[] = "2000 OK storage\n"; static char EndJob[] = "2800 End Job TermCode=%d JobFiles=%u " - "ReadBytes=%" lld " JobBytes=%" lld " Errors=%u\n"; + "ReadBytes=%" lld " JobBytes=%" lld " Errors=%u\n"; /* Forward referenced functions */ @@ -54,13 +54,13 @@ static void backup_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr /* External functions */ -/* +/* * Do a backup of the specified FileSet - * + * * Returns: 0 on failure * 1 on success */ -int do_backup(JCR *jcr) +int do_backup(JCR *jcr) { char since[MAXSTRING]; int stat; @@ -83,23 +83,23 @@ int do_backup(JCR *jcr) jcr->fname = get_pool_memory(PM_FNAME); - /* - * Get the Pool record -- first apply any level defined pools + /* + * Get the Pool record -- first apply any level defined pools */ switch (jcr->JobLevel) { case L_FULL: if (jcr->full_pool) { - jcr->pool = jcr->full_pool; + jcr->pool = jcr->full_pool; } break; case L_INCREMENTAL: if (jcr->inc_pool) { - jcr->pool = jcr->inc_pool; + jcr->pool = jcr->inc_pool; } break; case L_DIFFERENTIAL: if (jcr->dif_pool) { - jcr->pool = jcr->dif_pool; + jcr->pool = jcr->dif_pool; } break; } @@ -109,11 +109,11 @@ int do_backup(JCR *jcr) while (!db_get_pool_record(jcr, jcr->db, &pr)) { /* get by Name */ /* Try to create the pool */ if (create_pool(jcr, jcr->db, jcr->pool, POOL_OP_CREATE) < 0) { - Jmsg(jcr, M_FATAL, 0, _("Pool %s not in database. %s"), pr.Name, + Jmsg(jcr, M_FATAL, 0, _("Pool %s not in database. %s"), pr.Name, db_strerror(jcr->db)); goto bail_out; } else { - Jmsg(jcr, M_INFO, 0, _("Pool %s created in database.\n"), pr.Name); + Jmsg(jcr, M_INFO, 0, _("Pool %s created in database.\n"), pr.Name); } } jcr->PoolId = pr.PoolId; /****FIXME**** this can go away */ @@ -140,7 +140,7 @@ int do_backup(JCR *jcr) Dmsg0(110, "Open connection with storage daemon\n"); set_jcr_job_status(jcr, JS_WaitSD); /* - * Start conversation with Storage daemon + * Start conversation with Storage daemon */ if (!connect_to_storage_daemon(jcr, 10, SDConnectTimeout, 1)) { goto bail_out; @@ -179,7 +179,7 @@ int do_backup(JCR *jcr) goto bail_out; } - /* + /* * send Storage daemon address to the File daemon */ store = jcr->store; @@ -203,7 +203,7 @@ int do_backup(JCR *jcr) goto bail_out; } - /* Pickup Job termination data */ + /* Pickup Job termination data */ stat = wait_for_job_termination(jcr); backup_cleanup(jcr, stat, since, &fsr); return 1; @@ -217,7 +217,7 @@ bail_out: * Here we wait for the File daemon to signal termination, * then we wait for the Storage daemon. When both * are done, we return the job status. - * Also used by restore.c + * Also used by restore.c */ int wait_for_job_termination(JCR *jcr) { @@ -234,9 +234,9 @@ int wait_for_job_termination(JCR *jcr) &ReadBytes, &JobBytes, &Errors) == 5) { fd_ok = true; set_jcr_job_status(jcr, jcr->FDJobStatus); - Dmsg1(100, "FDStatus=%c\n", (char)jcr->JobStatus); + Dmsg1(100, "FDStatus=%c\n", (char)jcr->JobStatus); } else { - Jmsg(jcr, M_WARNING, 0, _("Unexpected Client Job message: %s\n"), + Jmsg(jcr, M_WARNING, 0, _("Unexpected Client Job message: %s\n"), fd->msg); } if (job_canceled(jcr)) { @@ -267,7 +267,7 @@ int wait_for_job_termination(JCR *jcr) // jcr->JobStatus, jcr->SDJobStatus); /* Return the first error status we find Dir, FD, or SD */ - if (!fd_ok || is_bnet_error(fd)) { + if (!fd_ok || is_bnet_error(fd)) { jcr->FDJobStatus = JS_ErrorTerminated; } if (jcr->JobStatus != JS_Terminated) { @@ -282,7 +282,7 @@ int wait_for_job_termination(JCR *jcr) /* * Release resources allocated during backup. */ -static void backup_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr) +static void backup_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr) { char sdt[50], edt[50]; char ec1[30], ec2[30], ec3[30], ec4[30], ec5[30], compress[50]; @@ -299,22 +299,22 @@ static void backup_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr set_jcr_job_status(jcr, TermCode); update_job_end_record(jcr); /* update database */ - + if (!db_get_job_record(jcr, jcr->db, &jcr->jr)) { - Jmsg(jcr, M_WARNING, 0, _("Error getting job record for stats: %s"), + Jmsg(jcr, M_WARNING, 0, _("Error getting job record for stats: %s"), db_strerror(jcr->db)); set_jcr_job_status(jcr, JS_ErrorTerminated); } bstrncpy(mr.VolumeName, jcr->VolumeName, sizeof(mr.VolumeName)); if (!db_get_media_record(jcr, jcr->db, &mr)) { - Jmsg(jcr, M_WARNING, 0, _("Error getting Media record for Volume \"%s\": ERR=%s"), + Jmsg(jcr, M_WARNING, 0, _("Error getting Media record for Volume \"%s\": ERR=%s"), mr.VolumeName, db_strerror(jcr->db)); set_jcr_job_status(jcr, JS_ErrorTerminated); } /* Now update the bootstrap file if any */ - if (jcr->JobStatus == JS_Terminated && jcr->jr.JobBytes && + if (jcr->JobStatus == JS_Terminated && jcr->jr.JobBytes && jcr->job->WriteBootstrap) { FILE *fd; BPIPE *bpipe = NULL; @@ -326,18 +326,18 @@ static void backup_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr if (*fname == '|') { fname++; got_pipe = 1; - bpipe = open_bpipe(fname, 0, "w"); + bpipe = open_bpipe(fname, 0, "w"); fd = bpipe ? bpipe->wfd : NULL; } else { /* ***FIXME*** handle BASE */ - fd = fopen(fname, jcr->JobLevel==L_FULL?"w+":"a+"); + fd = fopen(fname, jcr->JobLevel==L_FULL?"w+":"a+"); } if (fd) { VolCount = db_get_job_volume_parameters(jcr, jcr->db, jcr->JobId, &VolParams); if (VolCount == 0) { - Jmsg(jcr, M_ERROR, 0, _("Could not get Job Volume Parameters to " - "update Bootstrap file. ERR=%s\n"), db_strerror(jcr->db)); + Jmsg(jcr, M_ERROR, 0, _("Could not get Job Volume Parameters to " + "update Bootstrap file. ERR=%s\n"), db_strerror(jcr->db)); if (jcr->SDJobFiles != 0) { set_jcr_job_status(jcr, JS_ErrorTerminated); } @@ -345,14 +345,14 @@ static void backup_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr } for (int i=0; i < VolCount; i++) { /* Write the record */ - fprintf(fd, "Volume=\"%s\"\n", VolParams[i].VolumeName); - fprintf(fd, "VolSessionId=%u\n", jcr->VolSessionId); - fprintf(fd, "VolSessionTime=%u\n", jcr->VolSessionTime); - fprintf(fd, "VolFile=%u-%u\n", VolParams[i].StartFile, + fprintf(fd, "Volume=\"%s\"\n", VolParams[i].VolumeName); + fprintf(fd, "VolSessionId=%u\n", jcr->VolSessionId); + fprintf(fd, "VolSessionTime=%u\n", jcr->VolSessionTime); + fprintf(fd, "VolFile=%u-%u\n", VolParams[i].StartFile, VolParams[i].EndFile); - fprintf(fd, "VolBlock=%u-%u\n", VolParams[i].StartBlock, + fprintf(fd, "VolBlock=%u-%u\n", VolParams[i].StartBlock, VolParams[i].EndBlock); - fprintf(fd, "FileIndex=%d-%d\n", VolParams[i].FirstIndex, + fprintf(fd, "FileIndex=%d-%d\n", VolParams[i].FirstIndex, VolParams[i].LastIndex); } if (VolParams) { @@ -365,8 +365,8 @@ static void backup_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr } } else { berrno be; - Jmsg(jcr, M_ERROR, 0, _("Could not open WriteBootstrap file:\n" - "%s: ERR=%s\n"), fname, be.strerror()); + Jmsg(jcr, M_ERROR, 0, _("Could not open WriteBootstrap file:\n" + "%s: ERR=%s\n"), fname, be.strerror()); set_jcr_job_status(jcr, JS_ErrorTerminated); } } @@ -375,14 +375,14 @@ static void backup_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr switch (jcr->JobStatus) { case JS_Terminated: if (jcr->Errors || jcr->SDErrors) { - term_msg = _("Backup OK -- with warnings"); + term_msg = _("Backup OK -- with warnings"); } else { - term_msg = _("Backup OK"); + term_msg = _("Backup OK"); } break; case JS_FatalError: case JS_ErrorTerminated: - term_msg = _("*** Backup Error ***"); + term_msg = _("*** Backup Error ***"); msg_type = M_ERROR; /* Generate error message */ if (jcr->store_bsock) { bnet_sig(jcr->store_bsock, BNET_TERMINATE); @@ -392,7 +392,7 @@ static void backup_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr } break; case JS_Canceled: - term_msg = _("Backup Canceled"); + term_msg = _("Backup Canceled"); if (jcr->store_bsock) { bnet_sig(jcr->store_bsock, BNET_TERMINATE); if (jcr->SD_msg_chan) { @@ -402,7 +402,7 @@ static void backup_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr break; default: term_msg = term_code; - sprintf(term_code, _("Inappropriate term code: %c\n"), jcr->JobStatus); + sprintf(term_code, _("Inappropriate term code: %c\n"), jcr->JobStatus); break; } bstrftimes(sdt, sizeof(sdt), jcr->jr.StartTime); @@ -420,8 +420,8 @@ static void backup_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr * it is normal. Or look at it the other way, only for a * normal exit should we complain about this error. */ - if (jcr->JobStatus == JS_Terminated && jcr->jr.JobBytes) { - Jmsg(jcr, M_ERROR, 0, "%s", db_strerror(jcr->db)); + if (jcr->JobStatus == JS_Terminated && jcr->jr.JobBytes) { + Jmsg(jcr, M_ERROR, 0, "%s", db_strerror(jcr->db)); } jcr->VolumeName[0] = 0; /* none */ } @@ -431,9 +431,9 @@ static void backup_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr } else { compression = (double)100 - 100.0 * ((double)jcr->JobBytes / (double)jcr->ReadBytes); if (compression < 0.5) { - bstrncpy(compress, "None", sizeof(compress)); + bstrncpy(compress, "None", sizeof(compress)); } else { - bsnprintf(compress, sizeof(compress), "%.1f %%", (float)compression); + bsnprintf(compress, sizeof(compress), "%.1f %%", (float)compression); } } jobstatus_to_ascii(jcr->FDJobStatus, fd_term_msg, sizeof(fd_term_msg)); @@ -441,31 +441,31 @@ static void backup_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr // bmicrosleep(15, 0); /* for debugging SIGHUP */ - Jmsg(jcr, msg_type, 0, _("Bacula " VERSION " (" LSMDATE "): %s\n\ - JobId: %d\n\ - Job: %s\n\ - Backup Level: %s%s\n\ - Client: %s\n\ - FileSet: \"%s\" %s\n\ - Pool: \"%s\"\n\ - Storage: \"%s\"\n\ - Start time: %s\n\ - End time: %s\n\ - FD Files Written: %s\n\ - SD Files Written: %s\n\ - FD Bytes Written: %s\n\ - SD Bytes Written: %s\n\ - Rate: %.1f KB/s\n\ - Software Compression: %s\n\ - Volume name(s): %s\n\ - Volume Session Id: %d\n\ - Volume Session Time: %d\n\ - Last Volume Bytes: %s\n\ - Non-fatal FD errors: %d\n\ - SD Errors: %d\n\ - FD termination status: %s\n\ - SD termination status: %s\n\ - Termination: %s\n\n"), + Jmsg(jcr, msg_type, 0, _("Bacula " VERSION " (" LSMDATE "): %s\n" +" JobId: %d\n" +" Job: %s\n" +" Backup Level: %s%s\n" +" Client: %s\n" +" FileSet: \"%s\" %s\n" +" Pool: \"%s\"\n" +" Storage: \"%s\"\n" +" Start time: %s\n" +" End time: %s\n" +" FD Files Written: %s\n" +" SD Files Written: %s\n" +" FD Bytes Written: %s\n" +" SD Bytes Written: %s\n" +" Rate: %.1f KB/s\n" +" Software Compression: %s\n" +" Volume name(s): %s\n" +" Volume Session Id: %d\n" +" Volume Session Time: %d\n" +" Last Volume Bytes: %s\n" +" Non-fatal FD errors: %d\n" +" SD Errors: %d\n" +" FD termination status: %s\n" +" SD termination status: %s\n" +" Termination: %s\n\n"), edt, jcr->jr.JobId, jcr->jr.Job, diff --git a/bacula/src/dird/bsr.c b/bacula/src/dird/bsr.c index 6e6e374c3f..4545d65504 100644 --- a/bacula/src/dird/bsr.c +++ b/bacula/src/dird/bsr.c @@ -2,7 +2,7 @@ * * Bacula Director -- Bootstrap Record routines. * - * BSR (bootstrap record) handling routines split from + * BSR (bootstrap record) handling routines split from * ua_restore.c July MMIII * * Kern Sibbald, July MMII @@ -39,9 +39,9 @@ void print_bsr(UAContext *ua, RBSR *bsr); /* - * Create new FileIndex entry for BSR + * Create new FileIndex entry for BSR */ -RBSR_FINDEX *new_findex() +RBSR_FINDEX *new_findex() { RBSR_FINDEX *fi = (RBSR_FINDEX *)bmalloc(sizeof(RBSR_FINDEX)); memset(fi, 0, sizeof(RBSR_FINDEX)); @@ -61,14 +61,14 @@ static void free_findex(RBSR_FINDEX *fi) * Our data structures were not designed completely * correctly, so the file indexes cover the full * range regardless of volume. The FirstIndex and LastIndex - * passed in here are for the current volume, so when + * passed in here are for the current volume, so when * writing out the fi, constrain them to those values. * * We are called here once for each JobMedia record * for each Volume. */ -static uint32_t write_findex(UAContext *ua, RBSR_FINDEX *fi, - int32_t FirstIndex, int32_t LastIndex, FILE *fd) +static uint32_t write_findex(UAContext *ua, RBSR_FINDEX *fi, + int32_t FirstIndex, int32_t LastIndex, FILE *fd) { uint32_t count = 0; for ( ; fi; fi=fi->next) { @@ -79,10 +79,10 @@ static uint32_t write_findex(UAContext *ua, RBSR_FINDEX *fi, findex = fi->findex < FirstIndex ? FirstIndex : fi->findex; findex2 = fi->findex2 > LastIndex ? LastIndex : fi->findex2; if (findex == findex2) { - fprintf(fd, "FileIndex=%d\n", findex); + fprintf(fd, "FileIndex=%d\n", findex); count++; } else { - fprintf(fd, "FileIndex=%d-%d\n", findex, findex2); + fprintf(fd, "FileIndex=%d-%d\n", findex, findex2); count += findex2 - findex + 1; } } @@ -94,8 +94,8 @@ static uint32_t write_findex(UAContext *ua, RBSR_FINDEX *fi, * Find out if Volume defined with FirstIndex and LastIndex * falls within the range of selected files in the bsr. */ -static bool is_volume_selected(RBSR_FINDEX *fi, - int32_t FirstIndex, int32_t LastIndex) +static bool is_volume_selected(RBSR_FINDEX *fi, + int32_t FirstIndex, int32_t LastIndex) { if (fi) { if ((fi->findex >= FirstIndex && fi->findex <= LastIndex) || @@ -115,10 +115,10 @@ static void print_findex(UAContext *ua, RBSR_FINDEX *fi) bsendmsg(ua, "fi=0x%lx\n", fi); for ( ; fi; fi=fi->next) { if (fi->findex == fi->findex2) { - bsendmsg(ua, "FileIndex=%d\n", fi->findex); + bsendmsg(ua, "FileIndex=%d\n", fi->findex); // Dmsg1(100, "FileIndex=%d\n", fi->findex); } else { - bsendmsg(ua, "FileIndex=%d-%d\n", fi->findex, fi->findex2); + bsendmsg(ua, "FileIndex=%d-%d\n", fi->findex, fi->findex2); // Dmsg2(100, "FileIndex=%d-%d\n", fi->findex, fi->findex2); } } @@ -156,14 +156,14 @@ int complete_bsr(UAContext *ua, RBSR *bsr) memset(&jr, 0, sizeof(jr)); jr.JobId = bsr->JobId; if (!db_get_job_record(ua->jcr, ua->db, &jr)) { - bsendmsg(ua, _("Unable to get Job record. ERR=%s\n"), db_strerror(ua->db)); + bsendmsg(ua, _("Unable to get Job record. ERR=%s\n"), db_strerror(ua->db)); return 0; } bsr->VolSessionId = jr.VolSessionId; bsr->VolSessionTime = jr.VolSessionTime; - if ((bsr->VolCount=db_get_job_volume_parameters(ua->jcr, ua->db, bsr->JobId, + if ((bsr->VolCount=db_get_job_volume_parameters(ua->jcr, ua->db, bsr->JobId, &(bsr->VolParams))) == 0) { - bsendmsg(ua, _("Unable to get Job Volume Parameters. ERR=%s\n"), db_strerror(ua->db)); + bsendmsg(ua, _("Unable to get Job Volume Parameters. ERR=%s\n"), db_strerror(ua->db)); if (bsr->VolParams) { free(bsr->VolParams); bsr->VolParams = NULL; @@ -189,7 +189,7 @@ uint32_t write_bsr_file(UAContext *ua, RBSR *bsr) fd = fopen(fname, "w+"); if (!fd) { berrno be; - bsendmsg(ua, _("Unable to create bootstrap file %s. ERR=%s\n"), + bsendmsg(ua, _("Unable to create bootstrap file %s. ERR=%s\n"), fname, be.strerror()); goto bail_out; } @@ -237,7 +237,7 @@ bail_out: static uint32_t write_bsr(UAContext *ua, RBSR *bsr, FILE *fd) { uint32_t count = 0; - uint32_t total_count = 0; + uint32_t total_count = 0; uint32_t LastIndex = 0; bool first = true; if (bsr) { @@ -251,19 +251,19 @@ static uint32_t write_bsr(UAContext *ua, RBSR *bsr, FILE *fd) bsr->VolParams[i].VolumeName[0] = 0; /* zap VolumeName */ continue; } - fprintf(fd, "Volume=\"%s\"\n", bsr->VolParams[i].VolumeName); - fprintf(fd, "VolSessionId=%u\n", bsr->VolSessionId); - fprintf(fd, "VolSessionTime=%u\n", bsr->VolSessionTime); + fprintf(fd, "Volume=\"%s\"\n", bsr->VolParams[i].VolumeName); + fprintf(fd, "VolSessionId=%u\n", bsr->VolSessionId); + fprintf(fd, "VolSessionTime=%u\n", bsr->VolSessionTime); if (bsr->VolParams[i].StartFile == bsr->VolParams[i].EndFile) { - fprintf(fd, "VolFile=%u\n", bsr->VolParams[i].StartFile); + fprintf(fd, "VolFile=%u\n", bsr->VolParams[i].StartFile); } else { - fprintf(fd, "VolFile=%u-%u\n", bsr->VolParams[i].StartFile, + fprintf(fd, "VolFile=%u-%u\n", bsr->VolParams[i].StartFile, bsr->VolParams[i].EndFile); } if (bsr->VolParams[i].StartBlock == bsr->VolParams[i].EndBlock) { - fprintf(fd, "VolFile=%u\n", bsr->VolParams[i].StartBlock); + fprintf(fd, "VolFile=%u\n", bsr->VolParams[i].StartBlock); } else { - fprintf(fd, "VolBlock=%u-%u\n", bsr->VolParams[i].StartBlock, + fprintf(fd, "VolBlock=%u-%u\n", bsr->VolParams[i].StartBlock, bsr->VolParams[i].EndBlock); } // Dmsg2(100, "bsr VolParam FI=%u LI=%u\n", @@ -272,7 +272,7 @@ static uint32_t write_bsr(UAContext *ua, RBSR *bsr, FILE *fd) count = write_findex(ua, bsr->fi, bsr->VolParams[i].FirstIndex, bsr->VolParams[i].LastIndex, fd); if (count) { - fprintf(fd, "Count=%u\n", count); + fprintf(fd, "Count=%u\n", count); } total_count += count; /* If the same file is present on two tapes or in two files @@ -294,12 +294,12 @@ void print_bsr(UAContext *ua, RBSR *bsr) { if (bsr) { for (int i=0; i < bsr->VolCount; i++) { - bsendmsg(ua, "Volume=\"%s\"\n", bsr->VolParams[i].VolumeName); - bsendmsg(ua, "VolSessionId=%u\n", bsr->VolSessionId); - bsendmsg(ua, "VolSessionTime=%u\n", bsr->VolSessionTime); - bsendmsg(ua, "VolFile=%u-%u\n", bsr->VolParams[i].StartFile, + bsendmsg(ua, "Volume=\"%s\"\n", bsr->VolParams[i].VolumeName); + bsendmsg(ua, "VolSessionId=%u\n", bsr->VolSessionId); + bsendmsg(ua, "VolSessionTime=%u\n", bsr->VolSessionTime); + bsendmsg(ua, "VolFile=%u-%u\n", bsr->VolParams[i].StartFile, bsr->VolParams[i].EndFile); - bsendmsg(ua, "VolBlock=%u-%u\n", bsr->VolParams[i].StartBlock, + bsendmsg(ua, "VolBlock=%u-%u\n", bsr->VolParams[i].StartBlock, bsr->VolParams[i].EndBlock); print_findex(ua, bsr->fi); } @@ -321,7 +321,7 @@ void add_findex(RBSR *bsr, uint32_t JobId, int32_t findex) if (findex == 0) { return; /* probably a dummy directory */ } - + if (bsr->fi == NULL) { /* if no FI add one */ /* This is the first FileIndex item in the chain */ bsr->fi = new_findex(); @@ -341,7 +341,7 @@ void add_findex(RBSR *bsr, uint32_t JobId, int32_t findex) if (!nbsr) { /* Must add new JobId */ /* Add new JobId at end of chain */ - for (nbsr=bsr; nbsr->next; nbsr=nbsr->next) + for (nbsr=bsr; nbsr->next; nbsr=nbsr->next) { } nbsr->next = new_bsr(); nbsr->next->JobId = JobId; @@ -352,7 +352,7 @@ void add_findex(RBSR *bsr, uint32_t JobId, int32_t findex) } } - /* + /* * At this point, bsr points to bsr containing this JobId, * and we are sure that there is at least one fi record. */ @@ -373,13 +373,13 @@ void add_findex(RBSR *bsr, uint32_t JobId, int32_t findex) /* Walk down fi chain and find where to insert insert new FileIndex */ for ( ; fi; fi=fi->next) { if (findex == (fi->findex2 + 1)) { /* extend up */ - RBSR_FINDEX *nfi; + RBSR_FINDEX *nfi; fi->findex2 = findex; /* * If the following record contains one higher, merge its * file index by extending it up. */ - if (fi->next && ((findex+1) == fi->next->findex)) { + if (fi->next && ((findex+1) == fi->next->findex)) { nfi = fi->next; fi->findex2 = nfi->findex2; fi->next = nfi->next; diff --git a/bacula/src/dird/bsr.h b/bacula/src/dird/bsr.h index d4d9be09f3..aea7e18af2 100644 --- a/bacula/src/dird/bsr.h +++ b/bacula/src/dird/bsr.h @@ -2,7 +2,7 @@ * * Bootstrap Record header file * - * BSR (bootstrap record) handling routines split from + * BSR (bootstrap record) handling routines split from * ua_restore.c July MMIII * * Kern Sibbald, July MMII @@ -38,8 +38,8 @@ struct RBSR_FINDEX { int32_t findex2; }; -/* - * Restore bootstrap record -- not the real one, but useful here +/* + * Restore bootstrap record -- not the real one, but useful here * The restore bsr is a chain of BSR records (linked by next). * Each BSR represents a single JobId, and within it, it * contains a linked list of file indexes for that JobId. @@ -49,7 +49,7 @@ struct RBSR_FINDEX { struct RBSR { RBSR *next; /* next JobId */ uint32_t JobId; /* JobId this bsr */ - uint32_t VolSessionId; + uint32_t VolSessionId; uint32_t VolSessionTime; int VolCount; /* Volume parameter count */ VOL_PARAMS *VolParams; /* Volume, start/end file/blocks */ diff --git a/bacula/src/dird/catreq.c b/bacula/src/dird/catreq.c index cae33b8ea9..0c5abb76c1 100644 --- a/bacula/src/dird/catreq.c +++ b/bacula/src/dird/catreq.c @@ -44,14 +44,14 @@ static char Find_media[] = "CatReq Job=%127s FindMedia=%d\n"; static char Get_Vol_Info[] = "CatReq Job=%127s GetVolInfo VolName=%127s write=%d\n"; -static char Update_media[] = "CatReq Job=%127s UpdateMedia VolName=%s\ - VolJobs=%u VolFiles=%u VolBlocks=%u VolBytes=%" lld " VolMounts=%u\ - VolErrors=%u VolWrites=%u MaxVolBytes=%" lld " EndTime=%d VolStatus=%10s\ - Slot=%d relabel=%d InChanger=%d VolReadTime=%" lld " VolWriteTime=%" lld "\n"; +static char Update_media[] = "CatReq Job=%127s UpdateMedia VolName=%s" +" VolJobs=%u VolFiles=%u VolBlocks=%u VolBytes=%" lld " VolMounts=%u" +" VolErrors=%u VolWrites=%u MaxVolBytes=%" lld " EndTime=%d VolStatus=%10s" +" Slot=%d relabel=%d InChanger=%d VolReadTime=%" lld " VolWriteTime=%" lld "\n"; -static char Create_job_media[] = "CatReq Job=%127s CreateJobMedia \ - FirstIndex=%u LastIndex=%u StartFile=%u EndFile=%u \ - StartBlock=%u EndBlock=%u\n"; +static char Create_job_media[] = "CatReq Job=%127s CreateJobMedia " +" FirstIndex=%u LastIndex=%u StartFile=%u EndFile=%u " +" StartBlock=%u EndBlock=%u\n"; /* Responses sent to Storage daemon */ @@ -64,7 +64,7 @@ static char OK_media[] = "1000 OK VolName=%s VolJobs=%u VolFiles=%u" static char OK_create[] = "1000 OK CreateJobMedia\n"; -static int send_volume_info_to_storage_daemon(JCR *jcr, BSOCK *sd, MEDIA_DBR *mr) +static int send_volume_info_to_storage_daemon(JCR *jcr, BSOCK *sd, MEDIA_DBR *mr) { int stat; char ed1[50], ed2[50], ed3[50], ed4[50], ed5[50]; @@ -74,8 +74,8 @@ static int send_volume_info_to_storage_daemon(JCR *jcr, BSOCK *sd, MEDIA_DBR *mr bash_spaces(mr->VolumeName); stat = bnet_fsend(sd, OK_media, mr->VolumeName, mr->VolJobs, mr->VolFiles, mr->VolBlocks, edit_uint64(mr->VolBytes, ed1), - mr->VolMounts, mr->VolErrors, mr->VolWrites, - edit_uint64(mr->MaxVolBytes, ed2), + mr->VolMounts, mr->VolErrors, mr->VolWrites, + edit_uint64(mr->MaxVolBytes, ed2), edit_uint64(mr->VolCapacityBytes, ed3), mr->VolStatus, mr->Slot, mr->MaxVolJobs, mr->MaxVolFiles, mr->InChanger, @@ -89,7 +89,7 @@ static int send_volume_info_to_storage_daemon(JCR *jcr, BSOCK *sd, MEDIA_DBR *mr void catalog_request(JCR *jcr, BSOCK *bs, char *msg) { - MEDIA_DBR mr, sdmr; + MEDIA_DBR mr, sdmr; JOBMEDIA_DBR jm; char Job[MAX_NAME_LENGTH]; int index, ok, label, writing; @@ -106,15 +106,15 @@ void catalog_request(JCR *jcr, BSOCK *bs, char *msg) if (sscanf(bs->msg, Find_media, &Job, &index) == 2) { ok = find_next_volume_for_append(jcr, &mr, true /*permit create new vol*/); /* - * Send Find Media response to Storage daemon + * Send Find Media response to Storage daemon */ if (ok) { send_volume_info_to_storage_daemon(jcr, bs, &mr); } else { - bnet_fsend(bs, "1901 No Media.\n"); + bnet_fsend(bs, "1901 No Media.\n"); } - /* + /* * Request to find specific Volume information */ } else if (sscanf(bs->msg, Get_Vol_Info, &Job, &mr.VolumeName, &writing) == 3) { @@ -125,34 +125,34 @@ void catalog_request(JCR *jcr, BSOCK *bs, char *msg) unbash_spaces(mr.VolumeName); if (db_get_media_record(jcr, jcr->db, &mr)) { const char *reason = NULL; /* detailed reason for rejection */ - /* + /* * If we are reading, accept any volume (reason == NULL) - * If we are writing, check if the Volume is valid + * If we are writing, check if the Volume is valid * for this job, and do a recycle if necessary - */ + */ if (writing) { - /* + /* * SD wants to write this Volume, so make * sure it is suitable for this job, i.e. - * Pool matches, and it is either Append or Recycle + * Pool matches, and it is either Append or Recycle * and Media Type matches and Pool allows any volume. */ if (mr.PoolId != jcr->PoolId) { - reason = "not in Pool"; + reason = "not in Pool"; } else if (strcmp(mr.MediaType, jcr->store->media_type) != 0) { - reason = "not correct MediaType"; + reason = "not correct MediaType"; } else { - /* - * ****FIXME*** + /* + * ****FIXME*** * This test (accept_any_volume) is turned off - * because it doesn't properly check if the volume + * because it doesn't properly check if the volume * really is out of sequence! * * } else if (!jcr->pool->accept_any_volume) { - * reason = "Volume not in sequence"; + * reason = "Volume not in sequence"; */ - /* + /* * Now try recycling if necessary * reason set non-NULL if we cannot use it */ @@ -161,20 +161,20 @@ void catalog_request(JCR *jcr, BSOCK *bs, char *msg) } if (reason == NULL) { /* - * Send Find Media response to Storage daemon + * Send Find Media response to Storage daemon */ send_volume_info_to_storage_daemon(jcr, bs, &mr); - } else { + } else { /* Not suitable volume */ - bnet_fsend(bs, "1998 Volume \"%s\" status is %s, %s.\n", mr.VolumeName, + bnet_fsend(bs, "1998 Volume \"%s\" status is %s, %s.\n", mr.VolumeName, mr.VolStatus, reason); } } else { - bnet_fsend(bs, "1997 Volume \"%s\" not in catalog.\n", mr.VolumeName); + bnet_fsend(bs, "1997 Volume \"%s\" not in catalog.\n", mr.VolumeName); } - + /* * Request to update Media record. Comes typically at the end * of a Storage daemon Job Session, when labeling/relabeling a @@ -182,8 +182,8 @@ void catalog_request(JCR *jcr, BSOCK *bs, char *msg) */ } else if (sscanf(bs->msg, Update_media, &Job, &sdmr.VolumeName, &sdmr.VolJobs, &sdmr.VolFiles, &sdmr.VolBlocks, &sdmr.VolBytes, &sdmr.VolMounts, &sdmr.VolErrors, - &sdmr.VolWrites, &sdmr.MaxVolBytes, &sdmr.LastWritten, &sdmr.VolStatus, - &sdmr.Slot, &label, &sdmr.InChanger, &sdmr.VolReadTime, + &sdmr.VolWrites, &sdmr.MaxVolBytes, &sdmr.LastWritten, &sdmr.VolStatus, + &sdmr.Slot, &label, &sdmr.InChanger, &sdmr.VolReadTime, &sdmr.VolWriteTime) == 17) { db_lock(jcr->db); @@ -192,9 +192,9 @@ void catalog_request(JCR *jcr, BSOCK *bs, char *msg) bstrncpy(mr.VolumeName, sdmr.VolumeName, sizeof(mr.VolumeName)); /* copy Volume name */ unbash_spaces(mr.VolumeName); if (!db_get_media_record(jcr, jcr->db, &mr)) { - Jmsg(jcr, M_ERROR, 0, _("Unable to get Media record for Volume %s: ERR=%s\n"), + Jmsg(jcr, M_ERROR, 0, _("Unable to get Media record for Volume %s: ERR=%s\n"), mr.VolumeName, db_strerror(jcr->db)); - bnet_fsend(bs, "1991 Catalog Request failed: %s", db_strerror(jcr->db)); + bnet_fsend(bs, "1991 Catalog Request failed: %s", db_strerror(jcr->db)); db_unlock(jcr->db); return; } @@ -211,7 +211,7 @@ void catalog_request(JCR *jcr, BSOCK *bs, char *msg) * Insanity check for VolFiles get set to a smaller value */ if (sdmr.VolFiles < mr.VolFiles) { - Jmsg(jcr, M_ERROR, 0, _("ERROR!! Volume Files at %u being set to %u. This is probably wrong.\n"), + Jmsg(jcr, M_ERROR, 0, _("ERROR!! Volume Files at %u being set to %u. This is probably wrong.\n"), mr.VolFiles, sdmr.VolFiles); } } @@ -241,10 +241,10 @@ void catalog_request(JCR *jcr, BSOCK *bs, char *msg) } else if (db_update_media_record(jcr, jcr->db, &mr)) { send_volume_info_to_storage_daemon(jcr, bs, &mr); } else { - Jmsg(jcr, M_ERROR, 0, _("Catalog error updating Media record. %s"), + Jmsg(jcr, M_ERROR, 0, _("Catalog error updating Media record. %s"), db_strerror(jcr->db)); - bnet_fsend(bs, "1992 Update Media error\n"); - Dmsg0(190, "send error\n"); + bnet_fsend(bs, "1992 Update Media error\n"); + Dmsg0(190, "send error\n"); } db_unlock(jcr->db); @@ -260,18 +260,18 @@ void catalog_request(JCR *jcr, BSOCK *bs, char *msg) Dmsg6(300, "create_jobmedia JobId=%d MediaId=%d SF=%d EF=%d FI=%d LI=%d\n", jm.JobId, jm.MediaId, jm.StartFile, jm.EndFile, jm.FirstIndex, jm.LastIndex); if (!db_create_jobmedia_record(jcr, jcr->db, &jm)) { - Jmsg(jcr, M_ERROR, 0, _("Catalog error creating JobMedia record. %s"), + Jmsg(jcr, M_ERROR, 0, _("Catalog error creating JobMedia record. %s"), db_strerror(jcr->db)); - bnet_fsend(bs, "1991 Update JobMedia error\n"); + bnet_fsend(bs, "1991 Update JobMedia error\n"); } else { - Dmsg0(300, "JobMedia record created\n"); + Dmsg0(300, "JobMedia record created\n"); bnet_fsend(bs, OK_create); } } else { omsg = get_memory(bs->msglen+1); pm_strcpy(omsg, bs->msg); - bnet_fsend(bs, "1990 Invalid Catalog Request: %s", omsg); + bnet_fsend(bs, "1990 Invalid Catalog Request: %s", omsg); Jmsg1(jcr, M_ERROR, 0, _("Invalid Catalog request: %s"), omsg); free_memory(omsg); } @@ -284,7 +284,7 @@ void catalog_request(JCR *jcr, BSOCK *bs, char *msg) * Update File Attributes in the catalog with data * sent by the Storage daemon. Note, we receive the whole * attribute record, but we select out only the stat packet, - * VolSessionId, VolSessionTime, FileIndex, and file name + * VolSessionId, VolSessionTime, FileIndex, and file name * to store in the catalog. */ void catalog_update(JCR *jcr, BSOCK *bs, char *msg) @@ -332,7 +332,7 @@ void catalog_update(JCR *jcr, BSOCK *bs, char *msg) Dmsg2(300, "dirddb, &ar)) { - Jmsg1(jcr, M_FATAL, 0, _("Attribute create error. %s"), db_strerror(jcr->db)); + Jmsg1(jcr, M_FATAL, 0, _("Attribute create error. %s"), db_strerror(jcr->db)); } /* Save values for SIG update */ jcr->FileId = ar.FileId; jcr->FileIndex = FileIndex; } else if (Stream == STREAM_MD5_SIGNATURE || Stream == STREAM_SHA1_SIGNATURE) { fname = p; - if (jcr->FileIndex != FileIndex) { - Jmsg(jcr, M_WARNING, 0, "Got MD5/SHA1 but not same File as attributes\n"); + if (jcr->FileIndex != FileIndex) { + Jmsg(jcr, M_WARNING, 0, "Got MD5/SHA1 but not same File as attributes\n"); } else { /* Update signature in catalog */ char SIGbuf[50]; /* 24 bytes should be enough */ @@ -364,9 +364,9 @@ void catalog_update(JCR *jcr, BSOCK *bs, char *msg) type = SHA1_SIG; } bin_to_base64(SIGbuf, fname, len); - Dmsg3(190, "SIGlen=%d SIG=%s type=%d\n", strlen(SIGbuf), SIGbuf, Stream); + Dmsg3(190, "SIGlen=%d SIG=%s type=%d\n", strlen(SIGbuf), SIGbuf, Stream); if (!db_add_SIG_to_file_record(jcr, jcr->db, jcr->FileId, SIGbuf, type)) { - Jmsg(jcr, M_ERROR, 0, _("Catalog error updating MD5/SHA1. %s"), + Jmsg(jcr, M_ERROR, 0, _("Catalog error updating MD5/SHA1. %s"), db_strerror(jcr->db)); } } diff --git a/bacula/src/dird/dird.c b/bacula/src/dird/dird.c index fb0aa19100..e9a680feb8 100644 --- a/bacula/src/dird/dird.c +++ b/bacula/src/dird/dird.c @@ -86,7 +86,7 @@ static void usage() " -t test - read configuration and exit\n" " -u userid\n" " -v verbose user messages\n" -" -? print this message.\n" +" -? print this message.\n" "\n")); exit(1); @@ -126,9 +126,9 @@ int main (int argc, char *argv[]) case 'd': /* set debug level */ debug_level = atoi(optarg); if (debug_level <= 0) { - debug_level = 1; + debug_level = 1; } - Dmsg1(0, "Debug level = %d\n", debug_level); + Dmsg1(0, "Debug level = %d\n", debug_level); break; case 'f': /* run in foreground */ @@ -168,7 +168,7 @@ int main (int argc, char *argv[]) default: usage(); - } + } } argc -= optind; argv += optind; @@ -182,7 +182,7 @@ int main (int argc, char *argv[]) free(configfile); } configfile = bstrdup(*argv); - argc--; + argc--; argv++; } if (argc) { @@ -237,7 +237,7 @@ int main (int argc, char *argv[]) init_jcr_subsystem(); /* start JCR watchdogs etc. */ init_job_server(director->MaxConcurrentJobs); - + Dmsg0(200, "wait for next job\n"); /* Main loop -- call scheduler to get next job to run */ while ((jcr = wait_for_next_job(runjob))) { @@ -272,14 +272,14 @@ static void terminate_dird(int sig) free(configfile); } if (debug_level > 5) { - print_memory_pool_stats(); + print_memory_pool_stats(); } free_config_resources(); term_ua_server(); term_msg(); /* terminate message handler */ stop_watchdog(); close_memory_pool(); /* release free memory in pool */ - sm_dump(false); + sm_dump(false); exit(sig); } @@ -291,7 +291,7 @@ struct RELOAD_TABLE { static const int max_reloads = 10; static RELOAD_TABLE reload_table[max_reloads]; -static void init_reload(void) +static void init_reload(void) { for (int i=0; i < max_reloads; i++) { reload_table[i].job_count = 0; @@ -350,10 +350,10 @@ static int find_free_reload_table_entry() /* * If we get here, we have received a SIGHUP, which means to - * reread our configuration file. + * reread our configuration file. * * The algorithm used is as follows: we count how many jobs are - * running and mark the running jobs to make a callback on + * running and mark the running jobs to make a callback on * exiting. The old config is saved with the reload table * id in a reload table. The new config file is read. Now, as * each job exits, it calls back to the reload_job_end_cb(), which @@ -371,7 +371,7 @@ extern "C" void reload_config(int sig) { static bool already_here = false; - sigset_t set; + sigset_t set; JCR *jcr; int njobs = 0; /* number of running jobs */ int table, rtable; @@ -405,10 +405,10 @@ void reload_config(int sig) if (!check_resources()) { rtable = find_free_reload_table_entry(); /* save new, bad table */ if (rtable < 0) { - Jmsg(NULL, M_ERROR, 0, _("Please correct configuration file: %s\n"), configfile); - Jmsg(NULL, M_ERROR_TERM, 0, _("Out of reload table entries. Giving up.\n")); + Jmsg(NULL, M_ERROR, 0, _("Please correct configuration file: %s\n"), configfile); + Jmsg(NULL, M_ERROR_TERM, 0, _("Out of reload table entries. Giving up.\n")); } else { - Jmsg(NULL, M_ERROR, 0, _("Please correct configuration file: %s\n"), configfile); + Jmsg(NULL, M_ERROR, 0, _("Please correct configuration file: %s\n"), configfile); } reload_table[rtable].res_table = save_config_resources(); /* Now restore old resoure values */ @@ -420,7 +420,7 @@ void reload_config(int sig) table = rtable; /* release new, bad, saved table below */ } else { /* - * Hook all active jobs so that they release this table + * Hook all active jobs so that they release this table */ foreach_jcr(jcr) { if (jcr->JobType != JT_SYSTEM) { @@ -437,7 +437,7 @@ void reload_config(int sig) FDConnectTimeout = director->FDConnectTimeout; SDConnectTimeout = director->SDConnectTimeout; Dmsg0(0, "Director's configuration file reread.\n"); - + /* Now release saved resources, if no jobs using the resources */ if (njobs == 0) { free_saved_resources(table); @@ -468,23 +468,23 @@ static int check_resources() job = (JOB *)GetNextRes(R_JOB, NULL); director = (DIRRES *)GetNextRes(R_DIRECTOR, NULL); if (!director) { - Jmsg(NULL, M_FATAL, 0, _("No Director resource defined in %s\n\ -Without that I don't know who I am :-(\n"), configfile); + Jmsg(NULL, M_FATAL, 0, _("No Director resource defined in %s\n" +"Without that I don't know who I am :-(\n"), configfile); OK = false; } else { set_working_directory(director->working_directory); if (!director->messages) { /* If message resource not specified */ director->messages = (MSGS *)GetNextRes(R_MSGS, NULL); if (!director->messages) { - Jmsg(NULL, M_FATAL, 0, _("No Messages resource defined in %s\n"), configfile); + Jmsg(NULL, M_FATAL, 0, _("No Messages resource defined in %s\n"), configfile); OK = false; } } if (GetNextRes(R_DIRECTOR, (RES *)director) != NULL) { - Jmsg(NULL, M_FATAL, 0, _("Only one Director resource permitted in %s\n"), + Jmsg(NULL, M_FATAL, 0, _("Only one Director resource permitted in %s\n"), configfile); OK = false; - } + } } if (!job) { @@ -514,40 +514,40 @@ Without that I don't know who I am :-(\n"), configfile); int64_t *def_lvalue, *lvalue; /* 64 bit values */ uint32_t offset; - Dmsg4(400, "Job \"%s\", field \"%s\" bit=%d def=%d\n", - job->hdr.name, job_items[i].name, - bit_is_set(i, job->hdr.item_present), + Dmsg4(400, "Job \"%s\", field \"%s\" bit=%d def=%d\n", + job->hdr.name, job_items[i].name, + bit_is_set(i, job->hdr.item_present), bit_is_set(i, job->jobdefs->hdr.item_present)); if (!bit_is_set(i, job->hdr.item_present) && - bit_is_set(i, job->jobdefs->hdr.item_present)) { - Dmsg2(400, "Job \"%s\", field \"%s\": getting default.\n", + bit_is_set(i, job->jobdefs->hdr.item_present)) { + Dmsg2(400, "Job \"%s\", field \"%s\": getting default.\n", job->hdr.name, job_items[i].name); - offset = (char *)(job_items[i].value) - (char *)&res_all; + offset = (char *)(job_items[i].value) - (char *)&res_all; /* * Handle strings and directory strings */ if (job_items[i].handler == store_str || job_items[i].handler == store_dir) { def_svalue = (char **)((char *)(job->jobdefs) + offset); - Dmsg5(400, "Job \"%s\", field \"%s\" def_svalue=%s item %d offset=%u\n", + Dmsg5(400, "Job \"%s\", field \"%s\" def_svalue=%s item %d offset=%u\n", job->hdr.name, job_items[i].name, *def_svalue, i, offset); svalue = (char **)((char *)job + offset); if (*svalue) { - Pmsg1(000, "Hey something is wrong. p=0x%lu\n", *svalue); + Pmsg1(000, "Hey something is wrong. p=0x%lu\n", *svalue); } *svalue = bstrdup(*def_svalue); set_bit(i, job->hdr.item_present); /* - * Handle resources + * Handle resources */ } else if (job_items[i].handler == store_res) { def_svalue = (char **)((char *)(job->jobdefs) + offset); - Dmsg4(400, "Job \"%s\", field \"%s\" item %d offset=%u\n", + Dmsg4(400, "Job \"%s\", field \"%s\" item %d offset=%u\n", job->hdr.name, job_items[i].name, i, offset); svalue = (char **)((char *)job + offset); if (*svalue) { - Pmsg1(000, "Hey something is wrong. p=0x%lu\n", *svalue); + Pmsg1(000, "Hey something is wrong. p=0x%lu\n", *svalue); } *svalue = *def_svalue; set_bit(i, job->hdr.item_present); @@ -555,11 +555,11 @@ Without that I don't know who I am :-(\n"), configfile); * Handle alist resources */ } else if (job_items[i].handler == store_alist_res) { - if (bit_is_set(i, job->jobdefs->hdr.item_present)) { + if (bit_is_set(i, job->jobdefs->hdr.item_present)) { set_bit(i, job->hdr.item_present); } /* - * Handle integer fields + * Handle integer fields * Note, our store_yesno does not handle bitmaped fields */ } else if (job_items[i].handler == store_yesno || @@ -569,19 +569,19 @@ Without that I don't know who I am :-(\n"), configfile); job_items[i].handler == store_pint || job_items[i].handler == store_replace) { def_ivalue = (int *)((char *)(job->jobdefs) + offset); - Dmsg5(400, "Job \"%s\", field \"%s\" def_ivalue=%d item %d offset=%u\n", + Dmsg5(400, "Job \"%s\", field \"%s\" def_ivalue=%d item %d offset=%u\n", job->hdr.name, job_items[i].name, *def_ivalue, i, offset); ivalue = (int *)((char *)job + offset); *ivalue = *def_ivalue; set_bit(i, job->hdr.item_present); /* - * Handle 64 bit integer fields + * Handle 64 bit integer fields */ } else if (job_items[i].handler == store_time || job_items[i].handler == store_size || job_items[i].handler == store_int64) { def_lvalue = (int64_t *)((char *)(job->jobdefs) + offset); - Dmsg5(400, "Job \"%s\", field \"%s\" def_lvalue=%" lld " item %d offset=%u\n", + Dmsg5(400, "Job \"%s\", field \"%s\" def_lvalue=%" lld " item %d offset=%u\n", job->hdr.name, job_items[i].name, *def_lvalue, i, offset); lvalue = (int64_t *)((char *)job + offset); *lvalue = *def_lvalue; @@ -590,20 +590,20 @@ Without that I don't know who I am :-(\n"), configfile); } } } - /* + /* * Ensure that all required items are present */ for (i=0; job_items[i].name; i++) { if (job_items[i].flags & ITEM_REQUIRED) { - if (!bit_is_set(i, job->hdr.item_present)) { - Jmsg(NULL, M_FATAL, 0, "\"%s\" directive in Job \"%s\" resource is required, but not found.\n", + if (!bit_is_set(i, job->hdr.item_present)) { + Jmsg(NULL, M_FATAL, 0, "\"%s\" directive in Job \"%s\" resource is required, but not found.\n", job_items[i].name, job->hdr.name); OK = false; } } /* If this triggers, take a look at lib/parse_conf.h */ if (i >= MAX_RES_ITEMS) { - Emsg0(M_ERROR_TERM, 0, "Too many items in Job resource\n"); + Emsg0(M_ERROR_TERM, 0, "Too many items in Job resource\n"); } } } /* End loop over Job res */ @@ -618,23 +618,23 @@ Without that I don't know who I am :-(\n"), configfile); */ db = db_init_database(NULL, catalog->db_name, catalog->db_user, catalog->db_password, catalog->db_address, - catalog->db_port, catalog->db_socket, + catalog->db_port, catalog->db_socket, catalog->mult_db_connections); if (!db || !db_open_database(NULL, db)) { - Jmsg(NULL, M_FATAL, 0, _("Could not open database \"%s\".\n"), + Jmsg(NULL, M_FATAL, 0, _("Could not open database \"%s\".\n"), catalog->db_name); if (db) { - Jmsg(NULL, M_FATAL, 0, _("%s"), db_strerror(db)); + Jmsg(NULL, M_FATAL, 0, _("%s"), db_strerror(db)); } OK = false; continue; - } + } /* Loop over all pools, defining/updating them in each database */ POOL *pool; foreach_res(pool, R_POOL) { create_pool(NULL, db, pool, POOL_OP_UPDATE); /* update request */ - } + } /* Loop over all counters, defining them in each database */ /* Set default value in all counters */ @@ -655,9 +655,9 @@ Without that I don't know who I am :-(\n"), configfile); if (db_create_counter_record(NULL, db, &cr)) { counter->CurrentValue = cr.CurrentValue; counter->created = true; - Dmsg2(100, "Create counter %s val=%d\n", counter->hdr.name, counter->CurrentValue); + Dmsg2(100, "Create counter %s val=%d\n", counter->hdr.name, counter->CurrentValue); } - } + } if (!counter->created) { counter->CurrentValue = counter->MinValue; /* default value */ } diff --git a/bacula/src/dird/dird_conf.c b/bacula/src/dird/dird_conf.c index 433945d9bd..255ba70cd5 100644 --- a/bacula/src/dird/dird_conf.c +++ b/bacula/src/dird/dird_conf.c @@ -7,7 +7,7 @@ * * 1. The generic lexical scanner in lib/lex.c and lib/lex.h * - * 2. The generic config scanner in lib/parse_config.c and + * 2. The generic config scanner in lib/parse_config.c and * lib/parse_config.h. * These files contain the parser code, some utility * routines, and the common store routines (name, int, @@ -77,10 +77,10 @@ int res_all_size = sizeof(res_all); /* Definition of records permitted within each - * resource with the routine to process the record + * resource with the routine to process the record * information. NOTE! quoted names must be in lower case. - */ -/* + */ +/* * Director Resource * * name handler value code flags default_value @@ -106,7 +106,7 @@ static RES_ITEM dir_items[] = { {NULL, NULL, NULL, 0, 0, 0} }; -/* +/* * Console Resource * * name handler value code flags default_value @@ -129,7 +129,7 @@ static RES_ITEM con_items[] = { }; -/* +/* * Client or File daemon resource * * name handler value code flags default_value @@ -149,7 +149,7 @@ static RES_ITEM cli_items[] = { {"autoprune", store_yesno, ITEM(res_client.AutoPrune), 1, ITEM_DEFAULT, 1}, {"enablessl", store_yesno, ITEM(res_client.enable_ssl), 1, ITEM_DEFAULT, 0}, {"maximumconcurrentjobs", store_pint, ITEM(res_client.MaxConcurrentJobs), 0, ITEM_DEFAULT, 1}, - {NULL, NULL, NULL, 0, 0, 0} + {NULL, NULL, NULL, 0, 0, 0} }; /* Storage daemon resource @@ -171,10 +171,10 @@ static RES_ITEM store_items[] = { {"enablessl", store_yesno, ITEM(res_store.enable_ssl), 1, ITEM_DEFAULT, 0}, {"maximumconcurrentjobs", store_pint, ITEM(res_store.MaxConcurrentJobs), 0, ITEM_DEFAULT, 1}, {"sddport", store_pint, ITEM(res_store.SDDport), 0, 0, 0}, /* deprecated */ - {NULL, NULL, NULL, 0, 0, 0} + {NULL, NULL, NULL, 0, 0, 0} }; -/* +/* * Catalog Resource Directives * * name handler value code flags default_value @@ -190,12 +190,12 @@ static RES_ITEM cat_items[] = { {"dbpassword", store_str, ITEM(res_cat.db_password), 0, 0, 0}, {"user", store_str, ITEM(res_cat.db_user), 0, 0, 0}, {"dbname", store_str, ITEM(res_cat.db_name), 0, ITEM_REQUIRED, 0}, - {"dbsocket", store_str, ITEM(res_cat.db_socket), 0, 0, 0}, + {"dbsocket", store_str, ITEM(res_cat.db_socket), 0, 0, 0}, {"multipleconnections", store_yesno, ITEM(res_cat.mult_db_connections), 1, 0, 0}, - {NULL, NULL, NULL, 0, 0, 0} + {NULL, NULL, NULL, 0, 0, 0} }; -/* +/* * Job Resource Directives * * name handler value code flags default_value @@ -241,7 +241,7 @@ RES_ITEM job_items[] = { {"rescheduleinterval", store_time, ITEM(res_job.RescheduleInterval), 0, ITEM_DEFAULT, 60 * 30}, {"rescheduletimes", store_pint, ITEM(res_job.RescheduleTimes), 0, 0, 0}, {"priority", store_pint, ITEM(res_job.Priority), 0, ITEM_DEFAULT, 10}, - {NULL, NULL, NULL, 0, 0, 0} + {NULL, NULL, NULL, 0, 0, 0} }; /* FileSet resource @@ -254,7 +254,7 @@ static RES_ITEM fs_items[] = { {"include", store_inc, NULL, 0, ITEM_NO_EQUALS, 0}, {"exclude", store_inc, NULL, 1, ITEM_NO_EQUALS, 0}, {"ignorefilesetchanges", store_yesno, ITEM(res_fs.ignore_fs_changes), 1, ITEM_DEFAULT, 0}, - {NULL, NULL, NULL, 0, 0, 0} + {NULL, NULL, NULL, 0, 0, 0} }; /* Schedule -- see run_conf.c */ @@ -266,7 +266,7 @@ static RES_ITEM sch_items[] = { {"name", store_name, ITEM(res_sch.hdr.name), 0, ITEM_REQUIRED, 0}, {"description", store_str, ITEM(res_sch.hdr.desc), 0, 0, 0}, {"run", store_run, ITEM(res_sch.run), 0, 0, 0}, - {NULL, NULL, NULL, 0, 0, 0} + {NULL, NULL, NULL, 0, 0, 0} }; /* Pool resource @@ -294,10 +294,10 @@ static RES_ITEM pool_items[] = { {"volumeuseduration", store_time, ITEM(res_pool.VolUseDuration),0, 0, 0}, {"autoprune", store_yesno, ITEM(res_pool.AutoPrune), 1, ITEM_DEFAULT, 1}, {"recycle", store_yesno, ITEM(res_pool.Recycle), 1, ITEM_DEFAULT, 1}, - {NULL, NULL, NULL, 0, 0, 0} + {NULL, NULL, NULL, 0, 0, 0} }; -/* +/* * Counter Resource * name handler value code flags default_value */ @@ -308,15 +308,15 @@ static RES_ITEM counter_items[] = { {"maximum", store_pint, ITEM(res_counter.MaxValue), 0, ITEM_DEFAULT, INT32_MAX}, {"wrapcounter", store_res, ITEM(res_counter.WrapCounter), R_COUNTER, 0, 0}, {"catalog", store_res, ITEM(res_counter.Catalog), R_CATALOG, 0, 0}, - {NULL, NULL, NULL, 0, 0, 0} + {NULL, NULL, NULL, 0, 0, 0} }; /* Message resource */ extern RES_ITEM msgs_items[]; -/* - * This is the master resource definition. +/* + * This is the master resource definition. * It must have one item for each of the resources. * * NOTE!!! keep it in the same order as the R_codes @@ -341,7 +341,7 @@ RES_TABLE resources[] = { }; -/* Keywords (RHS) permitted in Job Level records +/* Keywords (RHS) permitted in Job Level records * * level_name level job_type */ @@ -361,7 +361,7 @@ struct s_jl joblevels[] = { {NULL, 0, 0} }; -/* Keywords (RHS) permitted in Job type records +/* Keywords (RHS) permitted in Job type records * * type_name job_type */ @@ -379,7 +379,7 @@ struct s_jt jobtypes[] = { static struct s_kw BakVerFields[] = { {"client", 'C'}, {"fileset", 'F'}, - {"level", 'L'}, + {"level", 'L'}, {NULL, 0} }; @@ -437,35 +437,35 @@ void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fm } switch (type) { case R_DIRECTOR: - sendit(sock, "Director: name=%s MaxJobs=%d FDtimeout=%s SDtimeout=%s\n", - reshdr->name, res->res_dir.MaxConcurrentJobs, + sendit(sock, "Director: name=%s MaxJobs=%d FDtimeout=%s SDtimeout=%s\n", + reshdr->name, res->res_dir.MaxConcurrentJobs, edit_uint64(res->res_dir.FDConnectTimeout, ed1), edit_uint64(res->res_dir.SDConnectTimeout, ed2)); if (res->res_dir.query_file) { - sendit(sock, " query_file=%s\n", res->res_dir.query_file); + sendit(sock, " query_file=%s\n", res->res_dir.query_file); } if (res->res_dir.messages) { - sendit(sock, " --> "); + sendit(sock, " --> "); dump_resource(-R_MSGS, (RES *)res->res_dir.messages, sendit, sock); } break; case R_CONSOLE: - sendit(sock, "Console: name=%s SSL=%d\n", + sendit(sock, "Console: name=%s SSL=%d\n", res->res_con.hdr.name, res->res_con.enable_ssl); break; case R_COUNTER: if (res->res_counter.WrapCounter) { - sendit(sock, "Counter: name=%s min=%d max=%d cur=%d wrapcntr=%s\n", - res->res_counter.hdr.name, res->res_counter.MinValue, + sendit(sock, "Counter: name=%s min=%d max=%d cur=%d wrapcntr=%s\n", + res->res_counter.hdr.name, res->res_counter.MinValue, res->res_counter.MaxValue, res->res_counter.CurrentValue, res->res_counter.WrapCounter->hdr.name); } else { - sendit(sock, "Counter: name=%s min=%d max=%d\n", - res->res_counter.hdr.name, res->res_counter.MinValue, + sendit(sock, "Counter: name=%s min=%d max=%d\n", + res->res_counter.hdr.name, res->res_counter.MinValue, res->res_counter.MaxValue); } if (res->res_counter.Catalog) { - sendit(sock, " --> "); + sendit(sock, " --> "); dump_resource(-R_CATALOG, (RES *)res->res_counter.Catalog, sendit, sock); } break; @@ -479,29 +479,29 @@ void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fm edit_utime(res->res_client.FileRetention, ed2, sizeof(ed2)), res->res_client.AutoPrune); if (res->res_client.catalog) { - sendit(sock, " --> "); + sendit(sock, " --> "); dump_resource(-R_CATALOG, (RES *)res->res_client.catalog, sendit, sock); } break; case R_STORAGE: - sendit(sock, "Storage: name=%s address=%s SDport=%d MaxJobs=%u\n\ - DeviceName=%s MediaType=%s\n", + sendit(sock, "Storage: name=%s address=%s SDport=%d MaxJobs=%u\n" +" DeviceName=%s MediaType=%s\n", res->res_store.hdr.name, res->res_store.address, res->res_store.SDport, res->res_store.MaxConcurrentJobs, res->res_store.dev_name, res->res_store.media_type); break; case R_CATALOG: - sendit(sock, "Catalog: name=%s address=%s DBport=%d db_name=%s\n\ - db_user=%s MutliDBConn=%d\n", + sendit(sock, "Catalog: name=%s address=%s DBport=%d db_name=%s\n" +" db_user=%s MutliDBConn=%d\n", res->res_cat.hdr.name, NPRT(res->res_cat.db_address), - res->res_cat.db_port, res->res_cat.db_name, NPRT(res->res_cat.db_user), + res->res_cat.db_port, res->res_cat.db_name, NPRT(res->res_cat.db_user), res->res_cat.mult_db_connections); break; case R_JOB: case R_JOBDEFS: - sendit(sock, "%s: name=%s JobType=%d level=%s Priority=%d MaxJobs=%u\n", - type == R_JOB ? "Job" : "JobDefs", - res->res_job.hdr.name, res->res_job.JobType, + sendit(sock, "%s: name=%s JobType=%d level=%s Priority=%d MaxJobs=%u\n", + type == R_JOB ? "Job" : "JobDefs", + res->res_job.hdr.name, res->res_job.JobType, level_to_str(res->res_job.JobLevel), res->res_job.Priority, res->res_job.MaxConcurrentJobs); sendit(sock, " Resched=%d Times=%d Interval=%s Spool=%d\n", @@ -509,63 +509,63 @@ void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fm edit_uint64_with_commas(res->res_job.RescheduleInterval, ed1), res->res_job.spool_data); if (res->res_job.client) { - sendit(sock, " --> "); + sendit(sock, " --> "); dump_resource(-R_CLIENT, (RES *)res->res_job.client, sendit, sock); } if (res->res_job.fileset) { - sendit(sock, " --> "); + sendit(sock, " --> "); dump_resource(-R_FILESET, (RES *)res->res_job.fileset, sendit, sock); } if (res->res_job.schedule) { - sendit(sock, " --> "); + sendit(sock, " --> "); dump_resource(-R_SCHEDULE, (RES *)res->res_job.schedule, sendit, sock); } if (res->res_job.RestoreWhere) { - sendit(sock, " --> Where=%s\n", NPRT(res->res_job.RestoreWhere)); + sendit(sock, " --> Where=%s\n", NPRT(res->res_job.RestoreWhere)); } if (res->res_job.RestoreBootstrap) { - sendit(sock, " --> Bootstrap=%s\n", NPRT(res->res_job.RestoreBootstrap)); + sendit(sock, " --> Bootstrap=%s\n", NPRT(res->res_job.RestoreBootstrap)); } if (res->res_job.RunBeforeJob) { - sendit(sock, " --> RunBefore=%s\n", NPRT(res->res_job.RunBeforeJob)); + sendit(sock, " --> RunBefore=%s\n", NPRT(res->res_job.RunBeforeJob)); } if (res->res_job.RunAfterJob) { - sendit(sock, " --> RunAfter=%s\n", NPRT(res->res_job.RunAfterJob)); + sendit(sock, " --> RunAfter=%s\n", NPRT(res->res_job.RunAfterJob)); } if (res->res_job.RunAfterFailedJob) { - sendit(sock, " --> RunAfterFailed=%s\n", NPRT(res->res_job.RunAfterFailedJob)); + sendit(sock, " --> RunAfterFailed=%s\n", NPRT(res->res_job.RunAfterFailedJob)); } if (res->res_job.WriteBootstrap) { - sendit(sock, " --> WriteBootstrap=%s\n", NPRT(res->res_job.WriteBootstrap)); + sendit(sock, " --> WriteBootstrap=%s\n", NPRT(res->res_job.WriteBootstrap)); } if (res->res_job.storage[0]) { - sendit(sock, " --> "); + sendit(sock, " --> "); /* ***FIXME*** */ // dump_resource(-R_STORAGE, (RES *)res->res_job.storage, sendit, sock); } if (res->res_job.pool) { - sendit(sock, " --> "); + sendit(sock, " --> "); dump_resource(-R_POOL, (RES *)res->res_job.pool, sendit, sock); } if (res->res_job.full_pool) { - sendit(sock, " --> "); + sendit(sock, " --> "); dump_resource(-R_POOL, (RES *)res->res_job.full_pool, sendit, sock); } if (res->res_job.inc_pool) { - sendit(sock, " --> "); + sendit(sock, " --> "); dump_resource(-R_POOL, (RES *)res->res_job.inc_pool, sendit, sock); } if (res->res_job.dif_pool) { - sendit(sock, " --> "); + sendit(sock, " --> "); dump_resource(-R_POOL, (RES *)res->res_job.dif_pool, sendit, sock); } if (res->res_job.verify_job) { - sendit(sock, " --> "); + sendit(sock, " --> "); dump_resource(-type, (RES *)res->res_job.verify_job, sendit, sock); } break; if (res->res_job.messages) { - sendit(sock, " --> "); + sendit(sock, " --> "); dump_resource(-R_MSGS, (RES *)res->res_job.messages, sendit, sock); } break; @@ -577,42 +577,42 @@ void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fm INCEXE *incexe = res->res_fs.include_items[i]; for (j=0; jnum_opts; j++) { FOPTS *fo = incexe->opts_list[j]; - sendit(sock, " O %s\n", fo->opts); + sendit(sock, " O %s\n", fo->opts); for (k=0; kregex.size(); k++) { - sendit(sock, " R %s\n", fo->regex.get(k)); + sendit(sock, " R %s\n", fo->regex.get(k)); } for (k=0; kwild.size(); k++) { - sendit(sock, " W %s\n", fo->wild.get(k)); + sendit(sock, " W %s\n", fo->wild.get(k)); } for (k=0; kbase.size(); k++) { - sendit(sock, " B %s\n", fo->base.get(k)); + sendit(sock, " B %s\n", fo->base.get(k)); } for (k=0; kfstype.size(); k++) { - sendit(sock, " X %s\n", fo->fstype.get(k)); + sendit(sock, " X %s\n", fo->fstype.get(k)); } if (fo->reader) { - sendit(sock, " D %s\n", fo->reader); + sendit(sock, " D %s\n", fo->reader); } if (fo->writer) { - sendit(sock, " T %s\n", fo->writer); + sendit(sock, " T %s\n", fo->writer); } - sendit(sock, " N\n"); + sendit(sock, " N\n"); } for (j=0; jname_list.size(); j++) { - sendit(sock, " I %s\n", incexe->name_list.get(j)); + sendit(sock, " I %s\n", incexe->name_list.get(j)); } if (incexe->name_list.size()) { - sendit(sock, " N\n"); + sendit(sock, " N\n"); } } - + for (i=0; ires_fs.num_excludes; i++) { INCEXE *incexe = res->res_fs.exclude_items[i]; for (j=0; jname_list.size(); j++) { - sendit(sock, " E %s\n", incexe->name_list.get(j)); + sendit(sock, " E %s\n", incexe->name_list.get(j)); } if (incexe->name_list.size()) { - sendit(sock, " N\n"); + sendit(sock, " N\n"); } } break; @@ -622,77 +622,77 @@ void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fm int i; RUN *run = res->res_sch.run; char buf[1000], num[30]; - sendit(sock, "Schedule: name=%s\n", res->res_sch.hdr.name); + sendit(sock, "Schedule: name=%s\n", res->res_sch.hdr.name); if (!run) { break; } next_run: - sendit(sock, " --> Run Level=%s\n", level_to_str(run->level)); - bstrncpy(buf, " hour=", sizeof(buf)); + sendit(sock, " --> Run Level=%s\n", level_to_str(run->level)); + bstrncpy(buf, " hour=", sizeof(buf)); for (i=0; i<24; i++) { if (bit_is_set(i, run->hour)) { - bsnprintf(num, sizeof(num), "%d ", i); + bsnprintf(num, sizeof(num), "%d ", i); bstrncat(buf, num, sizeof(buf)); } } - bstrncat(buf, "\n", sizeof(buf)); + bstrncat(buf, "\n", sizeof(buf)); sendit(sock, buf); - bstrncpy(buf, " mday=", sizeof(buf)); + bstrncpy(buf, " mday=", sizeof(buf)); for (i=0; i<31; i++) { if (bit_is_set(i, run->mday)) { - bsnprintf(num, sizeof(num), "%d ", i); + bsnprintf(num, sizeof(num), "%d ", i); bstrncat(buf, num, sizeof(buf)); } } - bstrncat(buf, "\n", sizeof(buf)); + bstrncat(buf, "\n", sizeof(buf)); sendit(sock, buf); - bstrncpy(buf, " month=", sizeof(buf)); + bstrncpy(buf, " month=", sizeof(buf)); for (i=0; i<12; i++) { if (bit_is_set(i, run->month)) { - bsnprintf(num, sizeof(num), "%d ", i); + bsnprintf(num, sizeof(num), "%d ", i); bstrncat(buf, num, sizeof(buf)); } } - bstrncat(buf, "\n", sizeof(buf)); + bstrncat(buf, "\n", sizeof(buf)); sendit(sock, buf); - bstrncpy(buf, " wday=", sizeof(buf)); + bstrncpy(buf, " wday=", sizeof(buf)); for (i=0; i<7; i++) { if (bit_is_set(i, run->wday)) { - bsnprintf(num, sizeof(num), "%d ", i); + bsnprintf(num, sizeof(num), "%d ", i); bstrncat(buf, num, sizeof(buf)); } } - bstrncat(buf, "\n", sizeof(buf)); + bstrncat(buf, "\n", sizeof(buf)); sendit(sock, buf); - bstrncpy(buf, " wom=", sizeof(buf)); + bstrncpy(buf, " wom=", sizeof(buf)); for (i=0; i<5; i++) { if (bit_is_set(i, run->wom)) { - bsnprintf(num, sizeof(num), "%d ", i); + bsnprintf(num, sizeof(num), "%d ", i); bstrncat(buf, num, sizeof(buf)); } } - bstrncat(buf, "\n", sizeof(buf)); + bstrncat(buf, "\n", sizeof(buf)); sendit(sock, buf); - bstrncpy(buf, " woy=", sizeof(buf)); + bstrncpy(buf, " woy=", sizeof(buf)); for (i=0; i<54; i++) { if (bit_is_set(i, run->woy)) { - bsnprintf(num, sizeof(num), "%d ", i); + bsnprintf(num, sizeof(num), "%d ", i); bstrncat(buf, num, sizeof(buf)); } } - bstrncat(buf, "\n", sizeof(buf)); + bstrncat(buf, "\n", sizeof(buf)); sendit(sock, buf); - sendit(sock, " mins=%d\n", run->minute); + sendit(sock, " mins=%d\n", run->minute); if (run->pool) { - sendit(sock, " --> "); + sendit(sock, " --> "); dump_resource(-R_POOL, (RES *)run->pool, sendit, sock); } if (run->storage) { - sendit(sock, " --> "); + sendit(sock, " --> "); dump_resource(-R_STORAGE, (RES *)run->storage, sendit, sock); } if (run->msgs) { - sendit(sock, " --> "); + sendit(sock, " --> "); dump_resource(-R_MSGS, (RES *)run->msgs, sendit, sock); } /* If another Run record is chained in, go print it */ @@ -701,7 +701,7 @@ next_run: goto next_run; } } else { - sendit(sock, "Schedule: name=%s\n", res->res_sch.hdr.name); + sendit(sock, "Schedule: name=%s\n", res->res_sch.hdr.name); } break; case R_POOL: @@ -713,23 +713,23 @@ next_run: sendit(sock, " max_vols=%d auto_prune=%d VolRetention=%s\n", res->res_pool.max_volumes, res->res_pool.AutoPrune, edit_utime(res->res_pool.VolRetention, ed1, sizeof(ed1))); - sendit(sock, " VolUse=%s recycle=%d LabelFormat=%s\n", + sendit(sock, " VolUse=%s recycle=%d LabelFormat=%s\n", edit_utime(res->res_pool.VolUseDuration, ed1, sizeof(ed1)), res->res_pool.Recycle, NPRT(res->res_pool.label_format)); sendit(sock, " CleaningPrefix=%s\n", NPRT(res->res_pool.cleaning_prefix)); sendit(sock, " RecyleOldest=%d PurgeOldest=%d MaxVolJobs=%d MaxVolFiles=%d\n", - res->res_pool.recycle_oldest_volume, - res->res_pool.purge_oldest_volume, + res->res_pool.recycle_oldest_volume, + res->res_pool.purge_oldest_volume, res->res_pool.MaxVolJobs, res->res_pool.MaxVolFiles); break; case R_MSGS: sendit(sock, "Messages: name=%s\n", res->res_msgs.hdr.name); - if (res->res_msgs.mail_cmd) - sendit(sock, " mailcmd=%s\n", res->res_msgs.mail_cmd); - if (res->res_msgs.operator_cmd) - sendit(sock, " opcmd=%s\n", res->res_msgs.operator_cmd); + if (res->res_msgs.mail_cmd) + sendit(sock, " mailcmd=%s\n", res->res_msgs.mail_cmd); + if (res->res_msgs.operator_cmd) + sendit(sock, " opcmd=%s\n", res->res_msgs.operator_cmd); break; default: sendit(sock, "Unknown resource type %d in dump_resource.\n", type); @@ -766,10 +766,10 @@ static void free_incexe(INCEXE *incexe) free(incexe); } -/* +/* * Free memory of resource -- called when daemon terminates. * NB, we don't need to worry about freeing any references - * to other resources as they will be freed when that + * to other resources as they will be freed when that * resource chain is traversed. Mainly we worry about freeing * allocated strings (names). */ @@ -869,14 +869,14 @@ void free_resource(RES *sres, int type) break; case R_FILESET: if ((num=res->res_fs.num_includes)) { - while (--num >= 0) { + while (--num >= 0) { free_incexe(res->res_fs.include_items[num]); } free(res->res_fs.include_items); } res->res_fs.num_includes = 0; if ((num=res->res_fs.num_excludes)) { - while (--num >= 0) { + while (--num >= 0) { free_incexe(res->res_fs.exclude_items[num]); } free(res->res_fs.exclude_items); @@ -962,7 +962,7 @@ void free_resource(RES *sres, int type) /* * Save the new resource by chaining it into the head list for * the resource. If this is pass 2, we update any resource - * pointers because they may not have been defined until + * pointers because they may not have been defined until * later in pass 1. */ void save_resource(int type, RES_ITEM *items, int pass) @@ -971,28 +971,28 @@ void save_resource(int type, RES_ITEM *items, int pass) int rindex = type - r_first; int i, size; int error = 0; - + /* Check Job requirements after applying JobDefs */ if (type != R_JOB && type != R_JOBDEFS) { - /* + /* * Ensure that all required items are present */ for (i=0; items[i].name; i++) { if (items[i].flags & ITEM_REQUIRED) { - if (!bit_is_set(i, res_all.res_dir.hdr.item_present)) { - Emsg2(M_ERROR_TERM, 0, "%s item is required in %s resource, but not found.\n", + if (!bit_is_set(i, res_all.res_dir.hdr.item_present)) { + Emsg2(M_ERROR_TERM, 0, "%s item is required in %s resource, but not found.\n", items[i].name, resources[rindex]); } } /* If this triggers, take a look at lib/parse_conf.h */ if (i >= MAX_RES_ITEMS) { - Emsg1(M_ERROR_TERM, 0, "Too many items in %s resource\n", resources[rindex]); + Emsg1(M_ERROR_TERM, 0, "Too many items in %s resource\n", resources[rindex]); } } } /* - * During pass 2 in each "store" routine, we looked up pointers + * During pass 2 in each "store" routine, we looked up pointers * to all the resources referrenced in the current resource, now we * must copy their addresses from the static record to the allocated * record. @@ -1011,14 +1011,14 @@ void save_resource(int type, RES_ITEM *items, int pass) /* Resources containing another resource */ case R_DIRECTOR: if ((res = (URES *)GetResWithName(R_DIRECTOR, res_all.res_dir.hdr.name)) == NULL) { - Emsg1(M_ERROR_TERM, 0, "Cannot find Director resource %s\n", res_all.res_dir.hdr.name); + Emsg1(M_ERROR_TERM, 0, "Cannot find Director resource %s\n", res_all.res_dir.hdr.name); } res->res_dir.messages = res_all.res_dir.messages; break; case R_JOB: case R_JOBDEFS: if ((res = (URES *)GetResWithName(type, res_all.res_dir.hdr.name)) == NULL) { - Emsg1(M_ERROR_TERM, 0, "Cannot find Job resource %s\n", + Emsg1(M_ERROR_TERM, 0, "Cannot find Job resource %s\n", res_all.res_dir.hdr.name); } res->res_job.messages = res_all.res_job.messages; @@ -1037,7 +1037,7 @@ void save_resource(int type, RES_ITEM *items, int pass) break; case R_COUNTER: if ((res = (URES *)GetResWithName(R_COUNTER, res_all.res_counter.hdr.name)) == NULL) { - Emsg1(M_ERROR_TERM, 0, "Cannot find Counter resource %s\n", res_all.res_counter.hdr.name); + Emsg1(M_ERROR_TERM, 0, "Cannot find Counter resource %s\n", res_all.res_counter.hdr.name); } res->res_counter.Catalog = res_all.res_counter.Catalog; res->res_counter.WrapCounter = res_all.res_counter.WrapCounter; @@ -1045,24 +1045,24 @@ void save_resource(int type, RES_ITEM *items, int pass) case R_CLIENT: if ((res = (URES *)GetResWithName(R_CLIENT, res_all.res_client.hdr.name)) == NULL) { - Emsg1(M_ERROR_TERM, 0, "Cannot find Client resource %s\n", res_all.res_client.hdr.name); + Emsg1(M_ERROR_TERM, 0, "Cannot find Client resource %s\n", res_all.res_client.hdr.name); } res->res_client.catalog = res_all.res_client.catalog; break; case R_SCHEDULE: /* * Schedule is a bit different in that it contains a RUN record - * chain which isn't a "named" resource. This chain was linked - * in by run_conf.c during pass 2, so here we jam the pointer - * into the Schedule resource. + * chain which isn't a "named" resource. This chain was linked + * in by run_conf.c during pass 2, so here we jam the pointer + * into the Schedule resource. */ if ((res = (URES *)GetResWithName(R_SCHEDULE, res_all.res_client.hdr.name)) == NULL) { - Emsg1(M_ERROR_TERM, 0, "Cannot find Schedule resource %s\n", res_all.res_client.hdr.name); + Emsg1(M_ERROR_TERM, 0, "Cannot find Schedule resource %s\n", res_all.res_client.hdr.name); } res->res_sch.run = res_all.res_sch.run; break; default: - Emsg1(M_ERROR, 0, "Unknown resource type %d in save_resource.\n", type); + Emsg1(M_ERROR, 0, "Unknown resource type %d in save_resource.\n", type); error = 1; break; } @@ -1081,7 +1081,7 @@ void save_resource(int type, RES_ITEM *items, int pass) } /* - * The following code is only executed during pass 1 + * The following code is only executed during pass 1 */ switch (type) { case R_DIRECTOR: @@ -1094,7 +1094,7 @@ void save_resource(int type, RES_ITEM *items, int pass) size =sizeof(CLIENT); break; case R_STORAGE: - size = sizeof(STORE); + size = sizeof(STORE); break; case R_CATALOG: size = sizeof(CAT); @@ -1130,7 +1130,7 @@ void save_resource(int type, RES_ITEM *items, int pass) memcpy(res, &res_all, size); if (!res_head[rindex]) { res_head[rindex] = (RES *)res; /* store first entry */ - Dmsg3(900, "Inserting first %s res: %s index=%d\n", res_to_str(type), + Dmsg3(900, "Inserting first %s res: %s index=%d\n", res_to_str(type), res->res_dir.hdr.name, rindex); } else { RES *next; @@ -1138,24 +1138,24 @@ void save_resource(int type, RES_ITEM *items, int pass) for (next=res_head[rindex]; next->next; next=next->next) { if (strcmp(next->name, res->res_dir.hdr.name) == 0) { Emsg2(M_ERROR_TERM, 0, - _("Attempt to define second %s resource named \"%s\" is not permitted.\n"), + _("Attempt to define second %s resource named \"%s\" is not permitted.\n"), resources[rindex].name, res->res_dir.hdr.name); } } next->next = (RES *)res; - Dmsg4(900, "Inserting %s res: %s index=%d pass=%d\n", res_to_str(type), + Dmsg4(900, "Inserting %s res: %s index=%d pass=%d\n", res_to_str(type), res->res_dir.hdr.name, rindex, pass); } } } -/* +/* * Store JobType (backup, verify, restore) * */ void store_jobtype(LEX *lc, RES_ITEM *item, int index, int pass) { - int token, i; + int token, i; token = lex_get_token(lc, T_NAME); /* Store the type both pass 1 and pass 2 */ @@ -1173,7 +1173,7 @@ void store_jobtype(LEX *lc, RES_ITEM *item, int index, int pass) set_bit(index, res_all.hdr.item_present); } -/* +/* * Store Job Level (Full, Incremental, ...) * */ @@ -1216,7 +1216,7 @@ void store_replace(LEX *lc, RES_ITEM *item, int index, int pass) set_bit(index, res_all.hdr.item_present); } -/* +/* * Store ACL (access control list) * */ @@ -1227,12 +1227,12 @@ void store_acl(LEX *lc, RES_ITEM *item, int index, int pass) for (;;) { token = lex_get_token(lc, T_NAME); if (pass == 1) { - if (((alist **)item->value)[item->code] == NULL) { - ((alist **)item->value)[item->code] = New(alist(10, owned_by_alist)); - Dmsg1(900, "Defined new ACL alist at %d\n", item->code); + if (((alist **)item->value)[item->code] == NULL) { + ((alist **)item->value)[item->code] = New(alist(10, owned_by_alist)); + Dmsg1(900, "Defined new ACL alist at %d\n", item->code); } ((alist **)item->value)[item->code]->append(bstrdup(lc->str)); - Dmsg2(900, "Appended to %d %s\n", item->code, lc->str); + Dmsg2(900, "Appended to %d %s\n", item->code, lc->str); } token = lex_get_token(lc, T_ALL); if (token == T_COMMA) { diff --git a/bacula/src/dird/dird_conf.h b/bacula/src/dird/dird_conf.h index d008a969f7..30c10732ff 100644 --- a/bacula/src/dird/dird_conf.h +++ b/bacula/src/dird/dird_conf.h @@ -28,7 +28,7 @@ /* NOTE: #includes at the end of this file */ /* - * Resource codes -- they must be sequential for indexing + * Resource codes -- they must be sequential for indexing */ enum { R_DIRECTOR = 1001, @@ -61,9 +61,9 @@ enum { /* Used for certain KeyWord tables */ -struct s_kw { +struct s_kw { const char *name; - int token; + int token; }; /* Job Level keyword structure */ @@ -87,8 +87,8 @@ struct FILESET; struct POOL; struct RUN; -/* - * Director Resource +/* + * Director Resource * */ struct DIRRES { @@ -125,7 +125,7 @@ enum { Num_ACL /* keep last */ }; -/* +/* * Console Resource */ struct CONRES { @@ -174,7 +174,7 @@ struct CLIENT { /* * Store Resource - * + * */ struct STORE { RES hdr; @@ -184,7 +184,7 @@ struct STORE { char *address; char *password; char *media_type; - char *dev_name; + char *dev_name; int autochanger; /* set if autochanger */ uint32_t MaxConcurrentJobs; /* Maximume concurrent jobs */ uint32_t NumConcurrentJobs; /* number of concurrent jobs running */ @@ -228,7 +228,7 @@ struct JOB { int RescheduleTimes; /* Number of times to reschedule job */ utime_t RescheduleInterval; /* Reschedule interval */ utime_t JobRetention; /* job retention period in seconds */ - + MSGS *messages; /* How and where to send messages */ SCHED *schedule; /* When -- Automatic schedule */ CLIENT *client; /* Who to backup */ @@ -266,7 +266,7 @@ struct INCEXE { alist name_list; /* filename list -- holds char * */ }; -/* +/* * FileSet Resource * */ @@ -284,8 +284,8 @@ struct FILESET { int ignore_fs_changes; /* Don't force Full if FS changed */ }; - -/* + +/* * Schedule Resource * */ @@ -310,7 +310,7 @@ struct COUNTER { }; /* - * Pool Resource + * Pool Resource * */ struct POOL { @@ -362,7 +362,7 @@ struct RUN { RUN *next; /* points to next run record */ int level; /* level override */ int Priority; /* priority override */ - int job_type; + int job_type; bool spool_data; /* Data spooling override */ bool spool_data_set; /* Data spooling override given */ POOL *pool; /* Pool override */ diff --git a/bacula/src/dird/expand.c b/bacula/src/dird/expand.c index 112da2fe12..feded84c14 100644 --- a/bacula/src/dird/expand.c +++ b/bacula/src/dird/expand.c @@ -32,7 +32,7 @@ -static int date_item(JCR *jcr, int code, +static int date_item(JCR *jcr, int code, const char **val_ptr, int *val_len, int *val_size) { struct tm tm; @@ -71,7 +71,7 @@ static int date_item(JCR *jcr, int code, return 1; } -static int job_item(JCR *jcr, int code, +static int job_item(JCR *jcr, int code, const char **val_ptr, int *val_len, int *val_size) { const char *str = " "; @@ -97,7 +97,7 @@ static int job_item(JCR *jcr, int code, case 6: /* Client */ str = jcr->client->hdr.name; if (!str) { - str = " "; + str = " "; } break; case 7: /* NumVols */ @@ -105,7 +105,7 @@ static int job_item(JCR *jcr, int code, str = buf; break; case 8: /* Pool */ - str = jcr->pool->hdr.name; + str = jcr->pool->hdr.name; break; case 9: /* Storage */ str = jcr->store->hdr.name; @@ -163,8 +163,8 @@ static struct s_built_in_vars built_in_vars[] = { * Search the table of built-in variables, and if found, * call the appropriate subroutine to do the work. */ -static var_rc_t lookup_built_in_var(var_t *ctx, void *my_ctx, - const char *var_ptr, int var_len, int var_index, +static var_rc_t lookup_built_in_var(var_t *ctx, void *my_ctx, + const char *var_ptr, int var_len, int var_index, const char **val_ptr, int *val_len, int *val_size) { JCR *jcr = (JCR *)my_ctx; @@ -185,10 +185,10 @@ static var_rc_t lookup_built_in_var(var_t *ctx, void *my_ctx, /* - * Search counter variables + * Search counter variables */ -static var_rc_t lookup_counter_var(var_t *ctx, void *my_ctx, - const char *var_ptr, int var_len, int var_inc, int var_index, +static var_rc_t lookup_counter_var(var_t *ctx, void *my_ctx, + const char *var_ptr, int var_len, int var_inc, int var_index, const char **val_ptr, int *val_len, int *val_size) { char buf[MAXSTRING]; @@ -202,16 +202,16 @@ static var_rc_t lookup_counter_var(var_t *ctx, void *my_ctx, LockRes(); for (COUNTER *counter=NULL; (counter = (COUNTER *)GetNextRes(R_COUNTER, (RES *)counter)); ) { if (strcmp(counter->hdr.name, buf) == 0) { - Dmsg2(100, "Counter=%s val=%d\n", buf, counter->CurrentValue); + Dmsg2(100, "Counter=%s val=%d\n", buf, counter->CurrentValue); /* -1 => return size of array */ if (var_index == -1) { - bsnprintf(buf, sizeof(buf), "%d", counter->CurrentValue); - *val_len = bsnprintf(buf, sizeof(buf), "%d", strlen(buf)); + bsnprintf(buf, sizeof(buf), "%d", counter->CurrentValue); + *val_len = bsnprintf(buf, sizeof(buf), "%d", strlen(buf)); *val_ptr = buf; - *val_size = 0; /* don't try to free val_ptr */ + *val_size = 0; /* don't try to free val_ptr */ return VAR_OK; } else { - bsnprintf(buf, sizeof(buf), "%d", counter->CurrentValue); + bsnprintf(buf, sizeof(buf), "%d", counter->CurrentValue); *val_ptr = bstrdup(buf); *val_len = strlen(buf); *val_size = *val_len + 1; @@ -230,18 +230,18 @@ static var_rc_t lookup_counter_var(var_t *ctx, void *my_ctx, cr.MinValue = counter->MinValue; cr.MaxValue = counter->MaxValue; cr.CurrentValue = counter->CurrentValue; - Dmsg1(100, "New value=%d\n", cr.CurrentValue); + Dmsg1(100, "New value=%d\n", cr.CurrentValue); if (counter->WrapCounter) { bstrncpy(cr.WrapCounter, counter->WrapCounter->hdr.name, sizeof(cr.WrapCounter)); } else { cr.WrapCounter[0] = 0; } if (!db_update_counter_record(jcr, jcr->db, &cr)) { - Jmsg(jcr, M_ERROR, 0, _("Count not update counter %s: ERR=%s\n"), + Jmsg(jcr, M_ERROR, 0, _("Count not update counter %s: ERR=%s\n"), counter->hdr.name, db_strerror(jcr->db)); } } - } + } stat = VAR_OK; break; } @@ -252,10 +252,10 @@ static var_rc_t lookup_counter_var(var_t *ctx, void *my_ctx, /* - * Called here from "core" expand code to look up a variable + * Called here from "core" expand code to look up a variable */ -static var_rc_t lookup_var(var_t *ctx, void *my_ctx, - const char *var_ptr, int var_len, int var_inc, int var_index, +static var_rc_t lookup_var(var_t *ctx, void *my_ctx, + const char *var_ptr, int var_len, int var_inc, int var_index, const char **val_ptr, int *val_len, int *val_size) { char buf[MAXSTRING], *val, *p, *v; @@ -286,8 +286,8 @@ static var_rc_t lookup_var(var_t *ctx, void *my_ctx, } /* He wants to index the "array" */ count = 1; - /* Find the size of the "array" - * each element is separated by a | + /* Find the size of the "array" + * each element is separated by a | */ for (p = val; *p; p++) { if (*p == '|') { @@ -339,7 +339,7 @@ static var_rc_t lookup_var(var_t *ctx, void *my_ctx, v[p-val] = 0; *val_ptr = v; *val_len = p-val; - *val_size = p-val+1; + *val_size = p-val+1; Dmsg1(100, "v=%s\n", v); return VAR_OK; } @@ -351,10 +351,10 @@ static var_rc_t lookup_var(var_t *ctx, void *my_ctx, * val_ptr points to the value string * out_ptr points to string to be returned */ -static var_rc_t operate_var(var_t *var, void *my_ctx, - const char *op_ptr, int op_len, +static var_rc_t operate_var(var_t *var, void *my_ctx, + const char *op_ptr, int op_len, const char *arg_ptr, int arg_len, - const char *val_ptr, int val_len, + const char *val_ptr, int val_len, char **out_ptr, int *out_len, int *out_size) { var_rc_t stat = VAR_ERR_UNDEFINED_OPERATION; @@ -372,12 +372,12 @@ static var_rc_t operate_var(var_t *var, void *my_ctx, buf[arg_len] = 0; Dmsg1(100, "Arg=%s\n", buf); memcpy(buf, val_ptr, val_len); - buf[val_len] = 0; + buf[val_len] = 0; Dmsg1(100, "Val=%s\n", buf); LockRes(); for (COUNTER *counter=NULL; (counter = (COUNTER *)GetNextRes(R_COUNTER, (RES *)counter)); ) { if (strcmp(counter->hdr.name, buf) == 0) { - Dmsg2(100, "counter=%s val=%s\n", counter->hdr.name, buf); + Dmsg2(100, "counter=%s val=%s\n", counter->hdr.name, buf); break; } } @@ -389,7 +389,7 @@ static var_rc_t operate_var(var_t *var, void *my_ctx, } -/* +/* * Expand an input line and return it. * * Returns: 0 on failure @@ -434,7 +434,7 @@ int variable_expansion(JCR *jcr, char *inp, POOLMEM **exp) /* expand variables */ if ((stat = var_expand(var_ctx, inp, in_len, &outp, &out_len, 0)) != VAR_OK) { - Jmsg(jcr, M_ERROR, 0, _("Cannot expand expression \"%s\": ERR=%s\n"), + Jmsg(jcr, M_ERROR, 0, _("Cannot expand expression \"%s\": ERR=%s\n"), inp, var_strerror(var_ctx, stat)); goto bail_out; } @@ -447,7 +447,7 @@ int variable_expansion(JCR *jcr, char *inp, POOLMEM **exp) pm_strcpy(exp, outp); - rtn_stat = 1; + rtn_stat = 1; bail_out: /* destroy expansion context */ diff --git a/bacula/src/dird/fd_cmds.c b/bacula/src/dird/fd_cmds.c index 77ae25fdbf..20678f4f10 100644 --- a/bacula/src/dird/fd_cmds.c +++ b/bacula/src/dird/fd_cmds.c @@ -6,10 +6,10 @@ * * This routine is run as a separate thread. There may be more * work to be done to make it totally reentrant!!!! - * + * * Utility functions for sending info to File Daemon. * These functions are used by both backup and verify. - * + * * Version $Id$ */ /* @@ -59,14 +59,14 @@ static char OKRunAfter[] = "2000 OK RunAfter\n"; /* External functions */ extern int debug_level; -extern DIRRES *director; +extern DIRRES *director; extern int FDConnectTimeout; #define INC_LIST 0 #define EXC_LIST 1 /* - * Open connection with File daemon. + * Open connection with File daemon. * Try connecting every retry_interval (default 10 sec), and * give up after max_retry_time (default 30 mins). */ @@ -78,7 +78,7 @@ int connect_to_file_daemon(JCR *jcr, int retry_interval, int max_retry_time, if (!jcr->file_bsock) { fd = bnet_connect(jcr, retry_interval, max_retry_time, - _("File daemon"), jcr->client->address, + _("File daemon"), jcr->client->address, NULL, jcr->client->FDport, verbose); if (fd == NULL) { set_jcr_job_status(jcr, JS_ErrorTerminated); @@ -96,11 +96,11 @@ int connect_to_file_daemon(JCR *jcr, int retry_interval, int max_retry_time, set_jcr_job_status(jcr, JS_ErrorTerminated); return 0; } - + /* * Now send JobId and authorization key */ - bnet_fsend(fd, jobcmd, jcr->JobId, jcr->Job, jcr->VolSessionId, + bnet_fsend(fd, jobcmd, jcr->JobId, jcr->Job, jcr->VolSessionId, jcr->VolSessionTime, jcr->sd_auth_key); if (strcmp(jcr->sd_auth_key, "dummy") != 0) { memset(jcr->sd_auth_key, 0, strlen(jcr->sd_auth_key)); @@ -109,7 +109,7 @@ int connect_to_file_daemon(JCR *jcr, int retry_interval, int max_retry_time, if (bget_dirmsg(fd) > 0) { Dmsg1(110, "msg); if (strncmp(fd->msg, OKjob, strlen(OKjob)) != 0) { - Jmsg(jcr, M_FATAL, 0, _("File daemon \"%s\" rejected Job command: %s\n"), + Jmsg(jcr, M_FATAL, 0, _("File daemon \"%s\" rejected Job command: %s\n"), jcr->client->hdr.name, fd->msg); set_jcr_job_status(jcr, JS_ErrorTerminated); return 0; @@ -122,7 +122,7 @@ int connect_to_file_daemon(JCR *jcr, int retry_interval, int max_retry_time, cr.JobRetention = jcr->client->JobRetention; bstrncpy(cr.Uname, fd->msg+strlen(OKjob)+1, sizeof(cr.Uname)); if (!db_update_client_record(jcr, jcr->db, &cr)) { - Jmsg(jcr, M_WARNING, 0, _("Error updating Client record. ERR=%s\n"), + Jmsg(jcr, M_WARNING, 0, _("Error updating Client record. ERR=%s\n"), db_strerror(jcr->db)); } } @@ -137,15 +137,15 @@ int connect_to_file_daemon(JCR *jcr, int retry_interval, int max_retry_time, /* * This subroutine edits the last job start time into a - * "since=date/time" buffer that is returned in the + * "since=date/time" buffer that is returned in the * variable since. This is used for display purposes in - * the job report. The time in jcr->stime is later + * the job report. The time in jcr->stime is later * passed to tell the File daemon what to do. */ void get_level_since_time(JCR *jcr, char *since, int since_len) { int JobLevel; - /* Lookup the last FULL backup job to get the time/date for a + /* Lookup the last FULL backup job to get the time/date for a * differential or incremental save. */ if (!jcr->stime) { @@ -160,24 +160,24 @@ void get_level_since_time(JCR *jcr, char *since, int since_len) jcr->jr.JobId = 0; /* flag for db_find_job_start time */ if (!db_find_job_start_time(jcr, jcr->db, &jcr->jr, &jcr->stime)) { /* No job found, so upgrade this one to Full */ - Jmsg(jcr, M_INFO, 0, "%s", db_strerror(jcr->db)); - Jmsg(jcr, M_INFO, 0, _("No prior or suitable Full backup found. Doing FULL backup.\n")); - bsnprintf(since, since_len, " (upgraded from %s)", + Jmsg(jcr, M_INFO, 0, "%s", db_strerror(jcr->db)); + Jmsg(jcr, M_INFO, 0, _("No prior or suitable Full backup found. Doing FULL backup.\n")); + bsnprintf(since, since_len, " (upgraded from %s)", level_to_str(jcr->JobLevel)); jcr->JobLevel = jcr->jr.JobLevel = L_FULL; } else { if (jcr->job->rerun_failed_levels) { if (db_find_failed_job_since(jcr, jcr->db, &jcr->jr, jcr->stime, JobLevel)) { - Jmsg(jcr, M_INFO, 0, _("Prior failed job found. Upgrading to %s.\n"), + Jmsg(jcr, M_INFO, 0, _("Prior failed job found. Upgrading to %s.\n"), level_to_str(JobLevel)); - bsnprintf(since, since_len, " (upgraded from %s)", + bsnprintf(since, since_len, " (upgraded from %s)", level_to_str(jcr->JobLevel)); jcr->JobLevel = jcr->jr.JobLevel = JobLevel; jcr->jr.JobId = jcr->JobId; break; } - } - bstrncpy(since, ", since=", since_len); + } + bstrncpy(since, ", since=", since_len); bstrncat(since, jcr->stime, since_len); } jcr->jr.JobId = jcr->JobId; @@ -188,15 +188,15 @@ void get_level_since_time(JCR *jcr, char *since, int since_len) /* - * Send level command to FD. + * Send level command to FD. * Used for backup jobs and estimate command. */ -int send_level_command(JCR *jcr) +int send_level_command(JCR *jcr) { BSOCK *fd = jcr->file_bsock; utime_t stime; char ed1[50]; - /* + /* * Send Level command to File daemon */ switch (jcr->JobLevel) { @@ -213,12 +213,12 @@ int send_level_command(JCR *jcr) stime = str_to_utime(jcr->stime); bnet_fsend(fd, levelcmd, "since_utime ", edit_uint64(stime, ed1), 0); while (bget_dirmsg(fd) >= 0) { /* allow him to poll us to sync clocks */ - Jmsg(jcr, M_INFO, 0, "%s\n", fd->msg); + Jmsg(jcr, M_INFO, 0, "%s\n", fd->msg); } break; case L_SINCE: default: - Jmsg2(jcr, M_FATAL, 0, _("Unimplemented backup level %d %c\n"), + Jmsg2(jcr, M_FATAL, 0, _("Unimplemented backup level %d %c\n"), jcr->JobLevel, jcr->JobLevel); return 0; } @@ -265,80 +265,80 @@ static int send_list(JCR *jcr, int list) for (int j=0; jname_list.size(); j++) { p = (char *)ie->name_list.get(j); switch (*p) { - case '|': + case '|': p++; /* skip over the | */ - fd->msg = edit_job_codes(jcr, fd->msg, p, ""); - bpipe = open_bpipe(fd->msg, 0, "r"); + 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"), + 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)); + bstrncat(buf, " ", sizeof(buf)); } else { - bstrncpy(buf, "0 ", sizeof(buf)); + bstrncpy(buf, "0 ", sizeof(buf)); } - Dmsg1(500, "Opts=%s\n", 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); + 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")); + 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"), + Jmsg(jcr, M_FATAL, 0, _("Error running program %p: ERR=%s\n"), p, be.strerror(stat)); goto bail_out; } break; - case '<': + 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)); + 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)); + bstrncat(buf, " ", sizeof(buf)); } else { - bstrncpy(buf, "0 ", sizeof(buf)); + bstrncpy(buf, "0 ", sizeof(buf)); } - Dmsg1(500, "Opts=%s\n", 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); + fd->msglen = Mmsg(fd->msg, "%s", buf); if (!bnet_send(fd)) { - Jmsg(jcr, M_FATAL, 0, _(">filed: write error on socket\n")); + Jmsg(jcr, M_FATAL, 0, _(">filed: write error on socket\n")); goto bail_out; } } fclose(ffd); break; - case '\\': - p++; /* skip over \ */ + 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)); + 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, " "); + pm_strcat(fd->msg, " "); } else { - pm_strcpy(fd->msg, "0 "); + pm_strcpy(fd->msg, "0 "); } fd->msglen = pm_strcat(fd->msg, p); - Dmsg1(500, "Inc/Exc name=%s\n", fd->msg); + Dmsg1(500, "Inc/Exc name=%s\n", fd->msg); if (!bnet_send(fd)) { - Jmsg(jcr, M_FATAL, 0, _(">filed: write error on socket\n")); + Jmsg(jcr, M_FATAL, 0, _(">filed: write error on socket\n")); goto bail_out; } break; @@ -377,7 +377,7 @@ static int send_fileset(JCR *jcr) num = fileset->num_includes; } else { num = fileset->num_excludes; - } + } for (int i=0; iinclude_items[i]; - bnet_fsend(fd, "I\n"); + bnet_fsend(fd, "I\n"); } else { ie = fileset->exclude_items[i]; - bnet_fsend(fd, "E\n"); - } + bnet_fsend(fd, "E\n"); + } for (j=0; jnum_opts; j++) { FOPTS *fo = ie->opts_list[j]; - bnet_fsend(fd, "O %s\n", fo->opts); + bnet_fsend(fd, "O %s\n", fo->opts); for (k=0; kregex.size(); k++) { - bnet_fsend(fd, "R %s\n", fo->regex.get(k)); + bnet_fsend(fd, "R %s\n", fo->regex.get(k)); } for (k=0; kwild.size(); k++) { - bnet_fsend(fd, "W %s\n", fo->wild.get(k)); + bnet_fsend(fd, "W %s\n", fo->wild.get(k)); } for (k=0; kbase.size(); k++) { - bnet_fsend(fd, "B %s\n", fo->base.get(k)); + bnet_fsend(fd, "B %s\n", fo->base.get(k)); } for (k=0; kfstype.size(); k++) { - bnet_fsend(fd, "X %s\n", fo->fstype.get(k)); + bnet_fsend(fd, "X %s\n", fo->fstype.get(k)); } if (fo->reader) { - bnet_fsend(fd, "D %s\n", fo->reader); + bnet_fsend(fd, "D %s\n", fo->reader); } if (fo->writer) { - bnet_fsend(fd, "T %s\n", fo->writer); + bnet_fsend(fd, "T %s\n", fo->writer); } - bnet_fsend(fd, "N\n"); + bnet_fsend(fd, "N\n"); } for (j=0; jname_list.size(); j++) { p = (char *)ie->name_list.get(j); switch (*p) { - case '|': + case '|': p++; /* skip over the | */ - fd->msg = edit_job_codes(jcr, fd->msg, p, ""); - bpipe = open_bpipe(fd->msg, 0, "r"); + 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"), + Jmsg(jcr, M_FATAL, 0, _("Cannot run program: %s. ERR=%s\n"), p, be.strerror()); goto bail_out; } - bstrncpy(buf, "F ", sizeof(buf)); - Dmsg1(500, "Opts=%s\n", buf); + bstrncpy(buf, "F ", 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); + 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")); + 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: %s. ERR=%s\n"), + Jmsg(jcr, M_FATAL, 0, _("Error running program: %s. ERR=%s\n"), p, be.strerror(stat)); goto bail_out; } break; - case '<': + case '<': p++; /* skip over < */ - if ((ffd = fopen(p, "r")) == NULL) { + if ((ffd = fopen(p, "r")) == NULL) { berrno be; - Jmsg(jcr, M_FATAL, 0, _("Cannot open included file: %s. ERR=%s\n"), + Jmsg(jcr, M_FATAL, 0, _("Cannot open included file: %s. ERR=%s\n"), p, be.strerror()); goto bail_out; } - bstrncpy(buf, "F ", sizeof(buf)); - Dmsg1(500, "Opts=%s\n", buf); + bstrncpy(buf, "F ", 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); + fd->msglen = Mmsg(fd->msg, "%s", buf); if (!bnet_send(fd)) { - Jmsg(jcr, M_FATAL, 0, _(">filed: write error on socket\n")); + Jmsg(jcr, M_FATAL, 0, _(">filed: write error on socket\n")); goto bail_out; } } fclose(ffd); break; - case '\\': - p++; /* skip over \ */ + case '\\': + p++; /* skip over \ */ /* Note, fall through wanted */ default: - pm_strcpy(fd->msg, "F "); + pm_strcpy(fd->msg, "F "); fd->msglen = pm_strcat(fd->msg, p); - Dmsg1(500, "Inc/Exc name=%s\n", fd->msg); + Dmsg1(500, "Inc/Exc name=%s\n", fd->msg); if (!bnet_send(fd)) { - Jmsg(jcr, M_FATAL, 0, _(">filed: write error on socket\n")); + Jmsg(jcr, M_FATAL, 0, _(">filed: write error on socket\n")); goto bail_out; } break; } } - bnet_fsend(fd, "N\n"); + bnet_fsend(fd, "N\n"); } if (!include) { /* If we just did excludes */ break; /* all done */ @@ -521,7 +521,7 @@ int send_include_list(JCR *jcr) /* - * Send exclude list to File daemon + * Send exclude list to File daemon */ int send_exclude_list(JCR *jcr) { @@ -552,14 +552,14 @@ int send_bootstrap_file(JCR *jcr) bs = fopen(jcr->RestoreBootstrap, "r"); if (!bs) { berrno be; - Jmsg(jcr, M_FATAL, 0, _("Could not open bootstrap file %s: ERR=%s\n"), + Jmsg(jcr, M_FATAL, 0, _("Could not open bootstrap file %s: ERR=%s\n"), jcr->RestoreBootstrap, be.strerror()); set_jcr_job_status(jcr, JS_ErrorTerminated); return 0; } bnet_fsend(fd, bootstrap); while (fgets(buf, sizeof(buf), bs)) { - bnet_fsend(fd, "%s", buf); + bnet_fsend(fd, "%s", buf); } bnet_sig(fd, BNET_EOD); fclose(bs); @@ -602,7 +602,7 @@ int send_run_before_and_after_commands(JCR *jcr) } -/* +/* * Read the attributes from the File daemon for * a Verify job and store them in the catalog. */ @@ -621,7 +621,7 @@ int get_attributes_and_put_in_catalog(JCR *jcr) /* Pickup file attributes and signature */ while (!fd->errors && (n = bget_dirmsg(fd)) > 0) { - /*****FIXME****** improve error handling to stop only on + /*****FIXME****** improve error handling to stop only on * really fatal problems, or the number of errors is too * large. */ @@ -633,8 +633,8 @@ int get_attributes_and_put_in_catalog(JCR *jcr) jcr->fname = check_pool_memory_size(jcr->fname, fd->msglen); if ((len = sscanf(fd->msg, "%ld %d %s", &file_index, &stream, Opts_SIG)) != 3) { - Jmsg(jcr, M_FATAL, 0, _("msglen, fd->msg); + Jmsg(jcr, M_FATAL, 0, _("msglen, fd->msg); set_jcr_job_status(jcr, JS_ErrorTerminated); return 0; } @@ -643,7 +643,7 @@ msglen=%d msg=%s\n"), len, fd->msglen, fd->msg); skip_spaces(&p); skip_nonspaces(&p); /* skip Stream */ skip_spaces(&p); - skip_nonspaces(&p); /* skip Opts_SHA1 */ + skip_nonspaces(&p); /* skip Opts_SHA1 */ p++; /* skip space */ fn = jcr->fname; while (*p != 0) { @@ -665,33 +665,33 @@ msglen=%d msg=%s\n"), len, fd->msglen, fd->msg); ar.PathId = 0; ar.FilenameId = 0; - Dmsg2(111, "dirdfname); - Dmsg1(120, "dirdfname); + Dmsg1(120, "dirddb, &ar)) { - Jmsg1(jcr, M_ERROR, 0, "%s", db_strerror(jcr->db)); + Jmsg1(jcr, M_ERROR, 0, "%s", db_strerror(jcr->db)); set_jcr_job_status(jcr, JS_Error); continue; } jcr->FileId = ar.FileId; } else if (stream == STREAM_MD5_SIGNATURE || stream == STREAM_SHA1_SIGNATURE) { if (jcr->FileIndex != (uint32_t)file_index) { - Jmsg2(jcr, M_ERROR, 0, _("MD5/SHA1 index %d not same as attributes %d\n"), + Jmsg2(jcr, M_ERROR, 0, _("MD5/SHA1 index %d not same as attributes %d\n"), file_index, jcr->FileIndex); set_jcr_job_status(jcr, JS_Error); continue; } db_escape_string(SIG, Opts_SIG, strlen(Opts_SIG)); - Dmsg2(120, "SIGlen=%d SIG=%s\n", strlen(SIG), SIG); - if (!db_add_SIG_to_file_record(jcr, jcr->db, jcr->FileId, SIG, + Dmsg2(120, "SIGlen=%d SIG=%s\n", strlen(SIG), SIG); + if (!db_add_SIG_to_file_record(jcr, jcr->db, jcr->FileId, SIG, stream==STREAM_MD5_SIGNATURE?MD5_SIG:SHA1_SIG)) { - Jmsg1(jcr, M_ERROR, 0, "%s", db_strerror(jcr->db)); + Jmsg1(jcr, M_ERROR, 0, "%s", db_strerror(jcr->db)); set_jcr_job_status(jcr, JS_Error); } } jcr->jr.JobFiles = jcr->JobFiles = file_index; jcr->jr.LastIndex = file_index; - } + } if (is_bnet_error(fd)) { Jmsg1(jcr, M_FATAL, 0, _("msglen); + Emsg1(M_WARNING, 0, _("bget_dirmsg: unknown bnet signal %d\n"), bs->msglen); return n; } continue; } - + /* Handle normal data */ if (n > 0 && B_ISDIGIT(bs->msg[0])) { /* response? */ return n; /* yes, return it */ } - + /* * If we get here, it must be a request. Either * a message to dispatch, or a catalog request. * Try to fulfill it. */ if (sscanf(bs->msg, "%020s Job=%127s ", MsgType, Job) != 2) { - Emsg1(M_ERROR, 0, _("Malformed message: %s\n"), bs->msg); + Emsg1(M_ERROR, 0, _("Malformed message: %s\n"), bs->msg); continue; } if (!(jcr=get_jcr_by_full_name(Job))) { - Emsg1(M_ERROR, 0, _("Job not found: %s\n"), bs->msg); + Emsg1(M_ERROR, 0, _("Job not found: %s\n"), bs->msg); continue; } Dmsg1(200, "Getmsg got jcr 0x%x\n", jcr); /* Skip past "Jmsg Job=nnn" */ if (!(msg=find_msg_start(bs->msg))) { - Emsg1(M_ERROR, 0, _("Malformed message: %s\n"), bs->msg); + Emsg1(M_ERROR, 0, _("Malformed message: %s\n"), bs->msg); free_jcr(jcr); continue; } - /* + /* * Here we are expecting a message of the following format: * Jmsg Job=nnn type=nnn level=nnn Message-string */ if (bs->msg[0] == 'J') { /* Job message */ - if (sscanf(bs->msg, "Jmsg Job=%127s type=%d level=%d", + if (sscanf(bs->msg, "Jmsg Job=%127s type=%d level=%d", Job, &type, &level) != 3) { - Emsg1(M_ERROR, 0, _("Malformed message: %s\n"), bs->msg); + Emsg1(M_ERROR, 0, _("Malformed message: %s\n"), bs->msg); free_jcr(jcr); continue; } - Dmsg1(120, "Got msg: %s\n", bs->msg); + Dmsg1(120, "Got msg: %s\n", bs->msg); skip_spaces(&msg); skip_nonspaces(&msg); /* skip type=nnn */ skip_spaces(&msg); skip_nonspaces(&msg); /* skip level=nnn */ - if (*msg == ' ') { + if (*msg == ' ') { msg++; /* skip leading space */ } - Dmsg1(120, "Dispatch msg: %s", msg); + Dmsg1(120, "Dispatch msg: %s", msg); dispatch_message(jcr, type, level, msg); free_jcr(jcr); continue; } - /* + /* * Here we expact a CatReq message * CatReq Job=nn Catalog-Request-Message */ if (bs->msg[0] == 'C') { /* Catalog request */ - Dmsg2(120, "Catalog req jcr 0x%x: %s", jcr, bs->msg); + Dmsg2(120, "Catalog req jcr 0x%x: %s", jcr, bs->msg); catalog_request(jcr, bs, msg); - Dmsg1(200, "Calling freejcr 0x%x\n", jcr); + Dmsg1(200, "Calling freejcr 0x%x\n", jcr); free_jcr(jcr); continue; } if (bs->msg[0] == 'U') { /* Catalog update */ - Dmsg2(120, "Catalog upd jcr 0x%x: %s", jcr, bs->msg); + Dmsg2(120, "Catalog upd jcr 0x%x: %s", jcr, bs->msg); catalog_update(jcr, bs, msg); - Dmsg1(200, "Calling freejcr 0x%x\n", jcr); + Dmsg1(200, "Calling freejcr 0x%x\n", jcr); free_jcr(jcr); continue; } if (bs->msg[0] == 'M') { /* Mount request */ - Dmsg1(120, "Mount req: %s", bs->msg); + Dmsg1(120, "Mount req: %s", bs->msg); mount_request(jcr, bs, msg); free_jcr(jcr); continue; @@ -227,11 +227,11 @@ int response(JCR *jcr, BSOCK *fd, char *resp, const char *cmd, e_prtmsg prtmsg) return 1; } if (prtmsg == DISPLAY_ERROR) { - Jmsg(jcr, M_FATAL, 0, _("FD gave bad response to %s command: wanted %s got: %s\n"), + Jmsg(jcr, M_FATAL, 0, _("FD gave bad response to %s command: wanted %s got: %s\n"), cmd, resp, fd->msg); } return 0; - } + } Jmsg(jcr, M_FATAL, 0, _("Socket error from Filed on %s command: ERR=%s\n"), cmd, bnet_strerror(fd)); return 0; diff --git a/bacula/src/dird/inc_conf.c b/bacula/src/dird/inc_conf.c index 079904c94c..e723ce4c7e 100644 --- a/bacula/src/dird/inc_conf.c +++ b/bacula/src/dird/inc_conf.c @@ -7,7 +7,7 @@ * Version $Id$ */ /* - Copyright (C) 2003-2004 Kern Sibbald and John Walker + Copyright (C) 2003-2004 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 @@ -60,14 +60,14 @@ extern int res_all_size; /* We build the current new Include and Exclude items here */ static INCEXE res_incexe; -/* +/* * new Include/Exclude items * name handler value code flags default_value */ static RES_ITEM newinc_items[] = { {"file", store_fname, NULL, 0, 0, 0}, {"options", options_res, NULL, 0, 0, 0}, - {NULL, NULL, NULL, 0, 0, 0} + {NULL, NULL, NULL, 0, 0, 0} }; /* @@ -96,7 +96,7 @@ static RES_ITEM options_items[] = { {"ignorecase", store_opts, NULL, 0, 0, 0}, {"fstype", store_fstype, NULL, 0, 0, 0}, {"hfsplussupport", store_opts, NULL, 0, 0, 0}, - {NULL, NULL, NULL, 0, 0, 0} + {NULL, NULL, NULL, 0, 0, 0} }; @@ -157,7 +157,7 @@ struct s_fs_opt { }; /* - * Options permitted for each keyword and resulting value. + * Options permitted for each keyword and resulting value. * The output goes into opts, which are then transmitted to * the FD for application as options to the following list of * included files. @@ -209,8 +209,8 @@ static struct s_fs_opt FS_options[] = { -/* - * Scan for right hand side of Include options (keyword=option) is +/* + * Scan for right hand side of Include options (keyword=option) is * converted into one or two characters. Verifyopts=xxxx is Vxxxx: * Whatever is found is concatenated to the opts string. * This code is also used inside an Options resource. @@ -219,10 +219,12 @@ static void scan_include_options(LEX *lc, int keyword, char *opts, int optlen) { int token, i; char option[3]; + int lcopts = lc->options; option[0] = 0; /* default option = none */ option[2] = 0; /* terminate options */ - token = lex_get_token(lc, T_NAME); /* expect at least one option */ + lc->options |= LOPT_STRING; /* force string */ + token = lex_get_token(lc, T_STRING); /* expect at least one option */ if (keyword == INC_KW_VERIFY) { /* special case */ /* ***FIXME**** ensure these are in permitted set */ bstrncat(opts, "V", optlen); /* indicate Verify */ @@ -231,7 +233,7 @@ static void scan_include_options(LEX *lc, int keyword, char *opts, int optlen) Dmsg3(900, "Catopts=%s option=%s optlen=%d\n", opts, option,optlen); /* - * Standard keyword options for Include/Exclude + * Standard keyword options for Include/Exclude */ } else { for (i=0; FS_options[i].name; i++) { @@ -250,6 +252,7 @@ static void scan_include_options(LEX *lc, int keyword, char *opts, int optlen) Dmsg3(900, "Catopts=%s option=%s optlen=%d\n", opts, option,optlen); } } + lc->options = lcopts; /* If option terminated by comma, eat it */ if (lc->ch == ',') { @@ -257,9 +260,9 @@ static void scan_include_options(LEX *lc, int keyword, char *opts, int optlen) } } -/* - * - * Store FileSet Include/Exclude info +/* + * + * Store FileSet Include/Exclude info * NEW style includes are handled in store_newinc() */ void store_inc(LEX *lc, RES_ITEM *item, int index, int pass) @@ -275,7 +278,7 @@ void store_inc(LEX *lc, RES_ITEM *item, int index, int pass) * new Include is followed immediately by open brace, whereas the * old include has options following the Include. */ - token = lex_get_token(lc, T_SKIP_EOL); + token = lex_get_token(lc, T_SKIP_EOL); if (token == T_BOB) { store_newinc(lc, item, index, pass); return; @@ -292,7 +295,7 @@ void store_inc(LEX *lc, RES_ITEM *item, int index, int pass) /* 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) { @@ -377,11 +380,11 @@ void store_inc(LEX *lc, RES_ITEM *item, int index, int pass) 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) + while (lex_get_token(lc, T_ALL) != T_EOB) {} } scan_to_eol(lc); @@ -391,7 +394,7 @@ void store_inc(LEX *lc, RES_ITEM *item, int index, int pass) /* - * Store NEW style FileSet FInclude/FExclude info + * Store NEW style FileSet FInclude/FExclude info * * Note, when this routine is called, we are inside a FileSet * resource. We treat the Include/Execlude like a sort of @@ -401,7 +404,7 @@ static void store_newinc(LEX *lc, RES_ITEM *item, int index, int pass) { int token, i; INCEXE *incexe; - bool options; + bool options; if (!res_all.res_fs.have_MD5) { MD5Init(&res_all.res_fs.md5c); @@ -471,7 +474,7 @@ static void store_regex(LEX *lc, RES_ITEM *item, int index, int pass) regex_t preg; char prbuf[500]; - token = lex_get_token(lc, T_SKIP_EOL); + token = lex_get_token(lc, T_SKIP_EOL); if (pass == 1) { /* Pickup regex string */ @@ -488,12 +491,12 @@ static void store_regex(LEX *lc, RES_ITEM *item, int index, int pass) } regfree(&preg); res_incexe.current_opts->regex.append(bstrdup(lc->str)); - Dmsg3(900, "set regex %p size=%d %s\n", + Dmsg3(900, "set regex %p size=%d %s\n", res_incexe.current_opts, res_incexe.current_opts->regex.size(),lc->str); break; default: scan_err1(lc, _("Expected a regex string, got: %s\n"), lc->str); - } + } } scan_to_eol(lc); } @@ -503,7 +506,7 @@ static void store_base(LEX *lc, RES_ITEM *item, int index, int pass) { int token; - token = lex_get_token(lc, T_NAME); + token = lex_get_token(lc, T_NAME); if (pass == 1) { /* * Pickup Base Job Name @@ -518,12 +521,12 @@ static void store_reader(LEX *lc, RES_ITEM *item, int index, int pass) { int token; - token = lex_get_token(lc, T_NAME); + token = lex_get_token(lc, T_NAME); if (pass == 1) { /* * Pickup reader command */ - res_incexe.current_opts->reader = bstrdup(lc->str); + res_incexe.current_opts->reader = bstrdup(lc->str); } scan_to_eol(lc); } @@ -533,7 +536,7 @@ static void store_writer(LEX *lc, RES_ITEM *item, int index, int pass) { int token; - token = lex_get_token(lc, T_NAME); + token = lex_get_token(lc, T_NAME); if (pass == 1) { /* * Pickup writer command @@ -550,7 +553,7 @@ static void store_wild(LEX *lc, RES_ITEM *item, int index, int pass) { int token; - token = lex_get_token(lc, T_SKIP_EOL); + token = lex_get_token(lc, T_SKIP_EOL); if (pass == 1) { /* * Pickup Wild-card string @@ -560,12 +563,12 @@ static void store_wild(LEX *lc, RES_ITEM *item, int index, int pass) case T_UNQUOTED_STRING: case T_QUOTED_STRING: res_incexe.current_opts->wild.append(bstrdup(lc->str)); - Dmsg3(900, "set wild %p size=%d %s\n", + Dmsg3(900, "set wild %p size=%d %s\n", res_incexe.current_opts, res_incexe.current_opts->wild.size(),lc->str); break; default: scan_err1(lc, _("Expected a wild-card string, got: %s\n"), lc->str); - } + } } scan_to_eol(lc); } @@ -575,7 +578,7 @@ static void store_fstype(LEX *lc, RES_ITEM *item, int index, int pass) { int token; - token = lex_get_token(lc, T_SKIP_EOL); + token = lex_get_token(lc, T_SKIP_EOL); if (pass == 1) { /* Pickup fstype string */ switch (token) { @@ -583,12 +586,12 @@ static void store_fstype(LEX *lc, RES_ITEM *item, int index, int pass) case T_UNQUOTED_STRING: case T_QUOTED_STRING: res_incexe.current_opts->fstype.append(bstrdup(lc->str)); - Dmsg3(900, "set fstype %p size=%d %s\n", + Dmsg3(900, "set fstype %p size=%d %s\n", res_incexe.current_opts, res_incexe.current_opts->fstype.size(), lc->str); break; default: scan_err1(lc, _("Expected an fstype string, got: %s\n"), lc->str); - } + } } scan_to_eol(lc); } @@ -603,7 +606,7 @@ static void store_fname(LEX *lc, RES_ITEM *item, int index, int pass) int token; INCEXE *incexe; - token = lex_get_token(lc, T_SKIP_EOL); + token = lex_get_token(lc, T_SKIP_EOL); if (pass == 1) { /* Pickup Filename string */ @@ -623,7 +626,7 @@ static void store_fname(LEX *lc, RES_ITEM *item, int index, int pass) break; default: scan_err1(lc, _("Expected a filename, got: %s"), lc->str); - } + } } scan_to_eol(lc); } @@ -636,7 +639,7 @@ static void options_res(LEX *lc, RES_ITEM *item, int index, int pass) { int token, i; - token = lex_get_token(lc, T_SKIP_EOL); + token = lex_get_token(lc, T_SKIP_EOL); if (token != T_BOB) { scan_err1(lc, "Expecting open brace. Got %s", lc->str); } @@ -644,7 +647,7 @@ static void options_res(LEX *lc, RES_ITEM *item, int index, int pass) if (pass == 1) { setup_current_opts(); } - + while ((token = lex_get_token(lc, T_ALL)) != T_EOF) { if (token == T_EOL) { continue; diff --git a/bacula/src/dird/job.c b/bacula/src/dird/job.c index c6811ac05e..44d14fec75 100644 --- a/bacula/src/dird/job.c +++ b/bacula/src/dird/job.c @@ -56,7 +56,7 @@ void init_job_server(int max_workers) { int stat; watchdog_t *wd; - + if ((stat = jobq_init(&job_queue, max_workers, job_thread)) != 0) { berrno be; Emsg1(M_ABORT, 0, _("Could not init job queue: ERR=%s\n"), be.strerror(stat)); @@ -121,7 +121,7 @@ JobId_t run_job(JCR *jcr) Dmsg0(50, "DB opened\n"); /* - * Create Job record + * Create Job record */ create_unique_job_name(jcr, jcr->job->hdr.name); set_jcr_job_status(jcr, JS_Created); @@ -132,7 +132,7 @@ JobId_t run_job(JCR *jcr) } JobId = jcr->JobId = jcr->jr.JobId; - Dmsg4(100, "Created job record JobId=%d Name=%s Type=%c Level=%c\n", + Dmsg4(100, "Created job record JobId=%d Name=%s Type=%c Level=%c\n", jcr->JobId, jcr->Job, jcr->jr.JobType, jcr->jr.JobLevel); Dmsg0(200, "Add jrc to work queue\n"); @@ -156,8 +156,8 @@ bail_out: } -/* - * This is the engine called by jobq.c:jobq_add() when we were pulled +/* + * This is the engine called by jobq.c:jobq_add() when we were pulled * from the work queue. * At this point, we are running in our own thread and all * necessary resources are allocated -- see jobq.c @@ -195,7 +195,7 @@ static void *job_thread(void *arg) int status; BPIPE *bpipe; char line[MAXSTRING]; - + before = edit_job_codes(jcr, before, jcr->job->RunBeforeJob, ""); bpipe = open_bpipe(before, 0, "r"); free_pool_memory(before); @@ -254,7 +254,7 @@ static void *job_thread(void *arg) int status; BPIPE *bpipe; char line[MAXSTRING]; - + if (jcr->JobStatus == JS_Terminated) { after = edit_job_codes(jcr, after, jcr->job->RunAfterJob, ""); } else { @@ -268,7 +268,7 @@ static void *job_thread(void *arg) status = close_bpipe(bpipe); /* * Note, if we get an error here, do not mark the - * job in error, simply report the error condition. + * job in error, simply report the error condition. */ if (status != 0) { berrno be; @@ -298,7 +298,7 @@ bail_out: /* * Cancel a job -- typically called by the UA (Console program), but may also * be called by the job watchdog. - * + * * Returns: 1 if cancel appears to be successful * 0 on failure. Message sent to ua->jcr. */ @@ -319,7 +319,7 @@ int cancel_job(UAContext *ua, JCR *jcr) jcr->JobId, jcr->Job); jobq_remove(&job_queue, jcr); /* attempt to remove it from queue */ return 1; - + default: set_jcr_job_status(jcr, JS_Canceled); @@ -550,7 +550,7 @@ bool get_or_create_client_record(JCR *jcr) } pm_strcpy(jcr->client_name, jcr->client->hdr.name); if (!db_create_client_record(jcr, jcr->db, &cr)) { - Jmsg(jcr, M_FATAL, 0, _("Could not create Client record. ERR=%s\n"), + Jmsg(jcr, M_FATAL, 0, _("Could not create Client record. ERR=%s\n"), db_strerror(jcr->db)); return false; } @@ -561,7 +561,7 @@ bool get_or_create_client_record(JCR *jcr) } pm_strcpy(jcr->client_uname, cr.Uname); } - Dmsg2(100, "Created Client %s record %d\n", jcr->client->hdr.name, + Dmsg2(100, "Created Client %s record %d\n", jcr->client->hdr.name, jcr->jr.ClientId); return true; } @@ -586,17 +586,17 @@ bool get_or_create_fileset_record(JCR *jcr, FILESET_DBR *fsr) if (!jcr->fileset->ignore_fs_changes || !db_get_fileset_record(jcr, jcr->db, fsr)) { if (!db_create_fileset_record(jcr, jcr->db, fsr)) { - Jmsg(jcr, M_ERROR, 0, _("Could not create FileSet \"%s\" record. ERR=%s\n"), + Jmsg(jcr, M_ERROR, 0, _("Could not create FileSet \"%s\" record. ERR=%s\n"), fsr->FileSet, db_strerror(jcr->db)); return false; - } + } } jcr->jr.FileSetId = fsr->FileSetId; if (fsr->created) { - Jmsg(jcr, M_INFO, 0, _("Created new FileSet record \"%s\" %s\n"), + Jmsg(jcr, M_INFO, 0, _("Created new FileSet record \"%s\" %s\n"), fsr->FileSet, fsr->cCreateTime); } - Dmsg2(119, "Created FileSet %s record %u\n", jcr->fileset->hdr.name, + Dmsg2(119, "Created FileSet %s record %u\n", jcr->fileset->hdr.name, jcr->jr.FileSetId); return true; } @@ -628,7 +628,7 @@ void update_job_end_record(JCR *jcr) jcr->jr.VolSessionId = jcr->VolSessionId; jcr->jr.VolSessionTime = jcr->VolSessionTime; if (!db_update_job_end_record(jcr, jcr->db, &jcr->jr)) { - Jmsg(jcr, M_WARNING, 0, _("Error updating job record. %s"), + Jmsg(jcr, M_WARNING, 0, _("Error updating job record. %s"), db_strerror(jcr->db)); } } @@ -652,7 +652,7 @@ void create_unique_job_name(JCR *jcr, const char *base_name) char *p; /* Guarantee unique start time -- maximum one per second, and - * thus unique Job Name + * thus unique Job Name */ P(mutex); /* lock creation of jobs */ now = time(NULL); @@ -666,7 +666,7 @@ void create_unique_job_name(JCR *jcr, const char *base_name) /* Form Unique JobName */ localtime_r(&now, &tm); /* Use only characters that are permitted in Windows filenames */ - strftime(dt, sizeof(dt), "%Y-%m-%d_%H.%M.%S", &tm); + strftime(dt, sizeof(dt), "%Y-%m-%d_%H.%M.%S", &tm); bstrncpy(name, base_name, sizeof(name)); name[sizeof(name)-22] = 0; /* truncate if too long */ bsnprintf(jcr->Job, sizeof(jcr->Job), "%s.%s", name, dt); /* add date & time */ @@ -705,7 +705,7 @@ void dird_free_jcr(JCR *jcr) bnet_close(jcr->store_bsock); jcr->store_bsock = NULL; } - if (jcr->fname) { + if (jcr->fname) { Dmsg0(200, "Free JCR fname\n"); free_pool_memory(jcr->fname); jcr->fname = NULL; @@ -758,9 +758,12 @@ void set_jcr_defaults(JCR *jcr, JOB *job) } jcr->JobPriority = job->Priority; /* Copy storage definitions -- deleted in dir_free_jcr above */ - for (int i=0; istorage[i]) { + if (jcr->storage[i]) { + delete jcr->storage[i]; + } jcr->storage[i] = New(alist(10, not_owned_by_alist)); foreach_alist(st, job->storage[i]) { jcr->storage[i]->append(st); @@ -781,7 +784,7 @@ void set_jcr_defaults(JCR *jcr, JOB *job) jcr->dif_pool = job->dif_pool; jcr->catalog = job->client->catalog; jcr->fileset = job->fileset; - jcr->messages = job->messages; + jcr->messages = job->messages; jcr->spool_data = job->spool_data; if (jcr->RestoreBootstrap) { free(jcr->RestoreBootstrap); @@ -812,10 +815,10 @@ void set_jcr_defaults(JCR *jcr, JOB *job) } } -/* +/* * copy the storage definitions from an old JCR to a new one */ -void copy_storage(JCR *new_jcr, JCR *old_jcr) +void copy_storage(JCR *new_jcr, JCR *old_jcr) { for (int i=0; i < MAX_STORE; i++) { if (old_jcr->storage[i]) { diff --git a/bacula/src/dird/jobq.c b/bacula/src/dird/jobq.c index 1cde7a505c..4ca44bc37a 100755 --- a/bacula/src/dird/jobq.c +++ b/bacula/src/dird/jobq.c @@ -50,7 +50,7 @@ static int start_server(jobq_t *jq); -/* +/* * Initialize a job queue * * Returns: 0 on success @@ -60,7 +60,7 @@ int jobq_init(jobq_t *jq, int threads, void *(*engine)(void *arg)) { int stat; jobq_item_t *item = NULL; - + if ((stat = pthread_attr_init(&jq->attr)) != 0) { berrno be; Jmsg1(NULL, M_ERROR, 0, "pthread_attr_init: ERR=%s\n", be.strerror(stat)); @@ -88,7 +88,7 @@ int jobq_init(jobq_t *jq, int threads, void *(*engine)(void *arg)) jq->num_workers = 0; /* no threads yet */ jq->idle_workers = 0; /* no idle threads */ jq->engine = engine; /* routine to run */ - jq->valid = JOBQ_VALID; + jq->valid = JOBQ_VALID; /* Initialize the job queues */ jq->waiting_jobs = New(dlist(item, &item->link)); jq->running_jobs = New(dlist(item, &item->link)); @@ -164,7 +164,7 @@ struct wait_pkt { * most jobs are put into the job queue only when their * scheduled time arives. */ -extern "C" +extern "C" void *sched_wait(void *arg) { JCR *jcr = ((wait_pkt *)arg)->jcr; @@ -176,10 +176,10 @@ void *sched_wait(void *arg) set_jcr_job_status(jcr, JS_WaitStartTime); /* Wait until scheduled time arrives */ if (wtime > 0) { - Jmsg(jcr, M_INFO, 0, _("Job %s waiting %d seconds for scheduled start time.\n"), + Jmsg(jcr, M_INFO, 0, _("Job %s waiting %d seconds for scheduled start time.\n"), jcr->Job, wtime); } - /* Check every 30 seconds if canceled */ + /* Check every 30 seconds if canceled */ while (wtime > 0) { Dmsg2(300, "Waiting on sched time, jobid=%d secs=%d\n", jcr->JobId, wtime); if (wtime > 30) { @@ -202,9 +202,9 @@ void *sched_wait(void *arg) /* * Add a job to the queue * jq is a queue that was created with jobq_init - * + * * On entry jcr->mutex must be locked. - * + * */ int jobq_add(jobq_t *jq, JCR *jcr) { @@ -214,7 +214,7 @@ int jobq_add(jobq_t *jq, JCR *jcr) time_t wtime = jcr->sched_time - time(NULL); pthread_t id; wait_pkt *sched_pkt; - + Dmsg3(300, "jobq_add jobid=%d jcr=0x%x use_count=%d\n", jcr->JobId, jcr, jcr->use_count); if (jq->valid != JOBQ_VALID) { Jmsg0(jcr, M_ERROR, 0, "Jobq_add queue not initialized.\n"); @@ -257,11 +257,11 @@ int jobq_add(jobq_t *jq, JCR *jcr) } else { /* Add this job to the wait queue in priority sorted order */ foreach_dlist(li, jq->waiting_jobs) { - Dmsg2(300, "waiting item jobid=%d priority=%d\n", + Dmsg2(300, "waiting item jobid=%d priority=%d\n", li->jcr->JobId, li->jcr->JobPriority); if (li->jcr->JobPriority > jcr->JobPriority) { jq->waiting_jobs->insert_before(item, li); - Dmsg2(300, "insert_before jobid=%d before waiting job=%d\n", + Dmsg2(300, "insert_before jobid=%d before waiting job=%d\n", li->jcr->JobId, jcr->JobId); inserted = true; break; @@ -270,7 +270,7 @@ int jobq_add(jobq_t *jq, JCR *jcr) /* If not jobs in wait queue, append it */ if (!inserted) { jq->waiting_jobs->append(item); - Dmsg1(300, "Appended item jobid=%d to waiting queue\n", jcr->JobId); + Dmsg1(300, "Appended item jobid=%d to waiting queue\n", jcr->JobId); } } @@ -296,7 +296,7 @@ int jobq_remove(jobq_t *jq, JCR *jcr) int stat; bool found = false; jobq_item_t *item; - + Dmsg2(300, "jobq_remove jobid=%d jcr=0x%x\n", jcr->JobId, jcr); if (jq->valid != JOBQ_VALID) { return EINVAL; @@ -324,7 +324,7 @@ int jobq_remove(jobq_t *jq, JCR *jcr) jq->waiting_jobs->remove(item); jq->ready_jobs->prepend(item); Dmsg2(300, "jobq_remove jobid=%d jcr=0x%x moved to ready queue\n", jcr->JobId, jcr); - + stat = start_server(jq); pthread_mutex_unlock(&jq->mutex); @@ -363,12 +363,12 @@ static int start_server(jobq_t *jq) } -/* +/* * This is the worker thread that serves the job queue. - * When all the resources are acquired for the job, + * When all the resources are acquired for the job, * it will call the user's engine. */ -extern "C" +extern "C" void *jobq_server(void *arg) { struct timespec timeout; @@ -400,33 +400,33 @@ void *jobq_server(void *arg) /* * Wait 4 seconds, then if no more work, exit */ - Dmsg0(300, "pthread_cond_timedwait()\n"); + Dmsg0(300, "pthread_cond_timedwait()\n"); stat = pthread_cond_timedwait(&jq->work, &jq->mutex, &timeout); if (stat == ETIMEDOUT) { - Dmsg0(300, "timedwait timedout.\n"); + Dmsg0(300, "timedwait timedout.\n"); timedout = true; break; } else if (stat != 0) { - /* This shouldn't happen */ - Dmsg0(300, "This shouldn't happen\n"); + /* This shouldn't happen */ + Dmsg0(300, "This shouldn't happen\n"); jq->num_workers--; pthread_mutex_unlock(&jq->mutex); return NULL; } break; - } + } } - /* + /* * If anything is in the ready queue, run it */ Dmsg0(300, "Checking ready queue.\n"); while (!jq->ready_jobs->empty() && !jq->quit) { JCR *jcr; - je = (jobq_item_t *)jq->ready_jobs->first(); + je = (jobq_item_t *)jq->ready_jobs->first(); jcr = je->jcr; jq->ready_jobs->remove(je); if (!jq->ready_jobs->empty()) { - Dmsg0(300, "ready queue not empty start server\n"); + Dmsg0(300, "ready queue not empty start server\n"); if (start_server(jq) != 0) { jq->num_workers--; pthread_mutex_unlock(&jq->mutex); @@ -460,7 +460,7 @@ void *jobq_server(void *arg) } Dmsg0(200, "Done lock mutex after running job. Release locks.\n"); jq->running_jobs->remove(je); - /* + /* * Release locks if acquired. Note, they will not have * been acquired for jobs canceled before they were * put into the ready queue. @@ -468,7 +468,7 @@ void *jobq_server(void *arg) if (jcr->acquired_resource_locks) { jcr->store->NumConcurrentJobs--; if (jcr->JobType == JT_RESTORE || jcr->JobType == JT_VERIFY) { - jcr->store->MaxConcurrentJobs = jcr->saveMaxConcurrentJobs; + jcr->store->MaxConcurrentJobs = jcr->saveMaxConcurrentJobs; } jcr->client->NumConcurrentJobs--; jcr->job->NumConcurrentJobs--; @@ -477,10 +477,10 @@ void *jobq_server(void *arg) /* * Reschedule the job if necessary and requested */ - if (jcr->job->RescheduleOnError && + if (jcr->job->RescheduleOnError && jcr->JobStatus != JS_Terminated && - jcr->JobStatus != JS_Canceled && - jcr->job->RescheduleTimes > 0 && + jcr->JobStatus != JS_Canceled && + jcr->job->RescheduleTimes > 0 && jcr->reschedule_count < jcr->job->RescheduleTimes) { char dt[50]; @@ -490,16 +490,16 @@ void *jobq_server(void *arg) */ jcr->reschedule_count++; jcr->sched_time = time(NULL) + jcr->job->RescheduleInterval; - Dmsg2(300, "Rescheduled Job %s to re-run in %d seconds.\n", jcr->Job, + Dmsg2(300, "Rescheduled Job %s to re-run in %d seconds.\n", jcr->Job, (int)jcr->job->RescheduleInterval); bstrftime(dt, sizeof(dt), time(NULL)); - Jmsg(jcr, M_INFO, 0, _("Rescheduled Job %s at %s to re-run in %d seconds.\n"), + Jmsg(jcr, M_INFO, 0, _("Rescheduled Job %s at %s to re-run in %d seconds.\n"), jcr->Job, dt, (int)jcr->job->RescheduleInterval); dird_free_jcr(jcr); /* partial cleanup old stuff */ jcr->JobStatus = JS_WaitStartTime; jcr->SDJobStatus = 0; if (jcr->JobBytes == 0) { - Dmsg1(300, "Requeue job=%d\n", jcr->JobId); + Dmsg1(300, "Requeue job=%d\n", jcr->JobId); jcr->JobStatus = JS_WaitStartTime; V(jq->mutex); jobq_add(jq, jcr); /* queue the job to run again */ @@ -507,7 +507,7 @@ void *jobq_server(void *arg) free(je); /* free the job entry */ continue; /* look for another job to run */ } - /* + /* * Something was actually backed up, so we cannot reuse * the old JobId or there will be database record * conflicts. We now create a new job, copying the @@ -520,19 +520,19 @@ void *jobq_server(void *arg) njcr->JobStatus = jcr->JobStatus; copy_storage(njcr, jcr); njcr->messages = jcr->messages; - Dmsg0(300, "Call to run new job\n"); + Dmsg0(300, "Call to run new job\n"); V(jq->mutex); - run_job(njcr); /* This creates a "new" job */ - free_jcr(njcr); /* release "new" jcr */ + run_job(njcr); /* This creates a "new" job */ + free_jcr(njcr); /* release "new" jcr */ P(jq->mutex); - Dmsg0(300, "Back from running new job.\n"); + Dmsg0(300, "Back from running new job.\n"); } /* Clean up and release old jcr */ if (jcr->db) { db_close_database(jcr, jcr->db); jcr->db = NULL; } - Dmsg2(300, "====== Termination job=%d use_cnt=%d\n", jcr->JobId, jcr->use_count); + Dmsg2(300, "====== Termination job=%d use_cnt=%d\n", jcr->JobId, jcr->use_count); jcr->SDJobStatus = 0; V(jq->mutex); /* release internal lock */ free_jcr(jcr); @@ -546,14 +546,14 @@ void *jobq_server(void *arg) Dmsg0(300, "Done check ready, now check wait queue.\n"); while (!jq->waiting_jobs->empty() && !jq->quit) { int Priority; - je = (jobq_item_t *)jq->waiting_jobs->first(); + je = (jobq_item_t *)jq->waiting_jobs->first(); jobq_item_t *re = (jobq_item_t *)jq->running_jobs->first(); if (re) { Priority = re->jcr->JobPriority; - Dmsg2(300, "JobId %d is running. Look for pri=%d\n", re->jcr->JobId, Priority); + Dmsg2(300, "JobId %d is running. Look for pri=%d\n", re->jcr->JobId, Priority); } else { Priority = je->jcr->JobPriority; - Dmsg1(300, "No job running. Look for Job pri=%d\n", Priority); + Dmsg1(300, "No job running. Look for Job pri=%d\n", Priority); } /* * Walk down the list of waiting jobs and attempt @@ -564,7 +564,7 @@ void *jobq_server(void *arg) JCR *jcr = je->jcr; bool skip_this_jcr = false; jobq_item_t *jn = (jobq_item_t *)jq->waiting_jobs->next(je); - Dmsg3(300, "Examining Job=%d JobPri=%d want Pri=%d\n", + Dmsg3(300, "Examining Job=%d JobPri=%d want Pri=%d\n", jcr->JobId, jcr->JobPriority, Priority); /* Take only jobs of correct Priority */ if (jcr->JobPriority != Priority) { @@ -586,10 +586,10 @@ void *jobq_server(void *arg) } else if (jcr->store->NumConcurrentJobs == 0 && jcr->store->NumConcurrentJobs < jcr->store->MaxConcurrentJobs) { /* Simple case, first job */ - jcr->store->NumConcurrentJobs = 1; + jcr->store->NumConcurrentJobs = 1; } else if (jcr->store->NumConcurrentJobs < jcr->store->MaxConcurrentJobs) { /* - * At this point, we already have at least one Job running + * At this point, we already have at least one Job running * for this Storage daemon, so we must ensure that there * is no Volume conflict. In general, it should be OK, if * all Jobs pull from the same Pool, so we check the Pools. @@ -604,12 +604,12 @@ void *jobq_server(void *arg) skip_this_jcr = true; break; } - } + } unlock_jcr_chain(); if (!skip_this_jcr) { - jcr->store->NumConcurrentJobs++; + jcr->store->NumConcurrentJobs++; } - } + } if (skip_this_jcr) { set_jcr_job_status(jcr, JS_WaitStoreRes); je = jn; /* point to next waiting job */ @@ -622,7 +622,7 @@ void *jobq_server(void *arg) /* Back out previous locks */ jcr->store->NumConcurrentJobs--; if (jcr->JobType == JT_RESTORE || jcr->JobType == JT_VERIFY) { - jcr->store->MaxConcurrentJobs = jcr->saveMaxConcurrentJobs; + jcr->store->MaxConcurrentJobs = jcr->saveMaxConcurrentJobs; } set_jcr_job_status(jcr, JS_WaitClientRes); je = jn; /* point to next waiting job */ @@ -634,7 +634,7 @@ void *jobq_server(void *arg) /* Back out previous locks */ jcr->store->NumConcurrentJobs--; if (jcr->JobType == JT_RESTORE || jcr->JobType == JT_VERIFY) { - jcr->store->MaxConcurrentJobs = jcr->saveMaxConcurrentJobs; + jcr->store->MaxConcurrentJobs = jcr->saveMaxConcurrentJobs; } jcr->client->NumConcurrentJobs--; set_jcr_job_status(jcr, JS_WaitJobRes); @@ -642,12 +642,12 @@ void *jobq_server(void *arg) continue; } /* Got all locks, now remove it from wait queue and append it - * to the ready queue + * to the ready queue */ jcr->acquired_resource_locks = true; jq->waiting_jobs->remove(je); jq->ready_jobs->append(je); - Dmsg1(300, "moved JobId=%d from wait to ready queue\n", je->jcr->JobId); + Dmsg1(300, "moved JobId=%d from wait to ready queue\n", je->jcr->JobId); je = jn; /* Point to next waiting job */ } /* end for loop */ break; @@ -659,27 +659,27 @@ void *jobq_server(void *arg) if (jq->ready_jobs->empty() && jq->quit) { jq->num_workers--; if (jq->num_workers == 0) { - Dmsg0(300, "Wake up destroy routine\n"); + Dmsg0(300, "Wake up destroy routine\n"); /* Wake up destroy routine if he is waiting */ pthread_cond_broadcast(&jq->work); } break; } Dmsg0(300, "Check for work request\n"); - /* + /* * If no more work requests, and we waited long enough, quit */ Dmsg2(300, "timedout=%d read empty=%d\n", timedout, jq->ready_jobs->empty()); if (jq->ready_jobs->empty() && timedout) { - Dmsg0(300, "break big loop\n"); + Dmsg0(300, "break big loop\n"); jq->num_workers--; break; } work = !jq->ready_jobs->empty() || !jq->waiting_jobs->empty(); if (work) { - /* + /* * If a job is waiting on a Resource, don't consume all * the CPU time looping looking for work, and even more * important, release the lock so that a job that has diff --git a/bacula/src/dird/jobq.h b/bacula/src/dird/jobq.h index 355e61a3cf..1a919df00a 100644 --- a/bacula/src/dird/jobq.h +++ b/bacula/src/dird/jobq.h @@ -1,5 +1,5 @@ /* - * Bacula job queue routines. + * Bacula job queue routines. * * Kern Sibbald, July MMIII * @@ -29,10 +29,10 @@ */ -#ifndef __JOBQ_H +#ifndef __JOBQ_H #define __JOBQ_H 1 -/* +/* * Structure to keep track of job queue request */ struct jobq_item_t { @@ -40,7 +40,7 @@ struct jobq_item_t { JCR *jcr; }; -/* +/* * Structure describing a work queue */ struct jobq_t { diff --git a/bacula/src/dird/mac.c b/bacula/src/dird/mac.c index 02d86f80cc..c9853bdd68 100644 --- a/bacula/src/dird/mac.c +++ b/bacula/src/dird/mac.c @@ -1,6 +1,6 @@ /* * - * Bacula Director -- mac.c -- responsible for doing + * Bacula Director -- mac.c -- responsible for doing * migration, archive, and copy jobs. * * Kern Sibbald, September MMIV @@ -45,13 +45,13 @@ static void mac_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr, /* External functions */ -/* +/* * Do a Migration, Archive, or Copy of a previous job - * + * * Returns: false on failure * true on success */ -bool do_mac(JCR *jcr) +bool do_mac(JCR *jcr) { char since[MAXSTRING]; int stat; @@ -93,7 +93,7 @@ bool do_mac(JCR *jcr) Dmsg1(100, "find last jobid for: %s\n", NPRT(Name)); if (!db_find_last_jobid(jcr, jcr->db, Name, &jr)) { Jmsg(jcr, M_FATAL, 0, _( - "Unable to find JobId of previous Job for this client.\n")); + "Unable to find JobId of previous Job for this client.\n")); goto bail_out; } input_jobid = jr.JobId; @@ -102,23 +102,23 @@ bool do_mac(JCR *jcr) jcr->fname = get_pool_memory(PM_FNAME); - /* - * Get the Pool record -- first apply any level defined pools + /* + * Get the Pool record -- first apply any level defined pools */ switch (jcr->JobLevel) { case L_FULL: if (jcr->full_pool) { - jcr->pool = jcr->full_pool; + jcr->pool = jcr->full_pool; } break; case L_INCREMENTAL: if (jcr->inc_pool) { - jcr->pool = jcr->inc_pool; + jcr->pool = jcr->inc_pool; } break; case L_DIFFERENTIAL: if (jcr->dif_pool) { - jcr->pool = jcr->dif_pool; + jcr->pool = jcr->dif_pool; } break; } @@ -128,11 +128,11 @@ bool do_mac(JCR *jcr) while (!db_get_pool_record(jcr, jcr->db, &pr)) { /* get by Name */ /* Try to create the pool */ if (create_pool(jcr, jcr->db, jcr->pool, POOL_OP_CREATE) < 0) { - Jmsg(jcr, M_FATAL, 0, _("Pool %s not in database. %s"), pr.Name, + Jmsg(jcr, M_FATAL, 0, _("Pool %s not in database. %s"), pr.Name, db_strerror(jcr->db)); goto bail_out; } else { - Jmsg(jcr, M_INFO, 0, _("Pool %s created in database.\n"), pr.Name); + Jmsg(jcr, M_INFO, 0, _("Pool %s created in database.\n"), pr.Name); } } jcr->PoolId = pr.PoolId; /****FIXME**** this can go away */ @@ -160,7 +160,7 @@ bool do_mac(JCR *jcr) Dmsg0(110, "Open connection with storage daemon\n"); set_jcr_job_status(jcr, JS_WaitSD); /* - * Start conversation with Storage daemon + * Start conversation with Storage daemon */ if (!connect_to_storage_daemon(jcr, 10, SDConnectTimeout, 1)) { goto bail_out; @@ -179,7 +179,7 @@ bool do_mac(JCR *jcr) } Dmsg0(150, "Storage daemon connection OK\n"); - /* Pickup Job termination data */ + /* Pickup Job termination data */ set_jcr_job_status(jcr, JS_Running); /* Note, the SD stores in jcr->JobFiles/ReadBytes/JobBytes/Errors */ @@ -220,22 +220,22 @@ static void mac_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr, set_jcr_job_status(jcr, TermCode); update_job_end_record(jcr); /* update database */ - + if (!db_get_job_record(jcr, jcr->db, &jcr->jr)) { - Jmsg(jcr, M_WARNING, 0, _("Error getting job record for stats: %s"), + Jmsg(jcr, M_WARNING, 0, _("Error getting job record for stats: %s"), db_strerror(jcr->db)); set_jcr_job_status(jcr, JS_ErrorTerminated); } bstrncpy(mr.VolumeName, jcr->VolumeName, sizeof(mr.VolumeName)); if (!db_get_media_record(jcr, jcr->db, &mr)) { - Jmsg(jcr, M_WARNING, 0, _("Error getting Media record for Volume \"%s\": ERR=%s"), + Jmsg(jcr, M_WARNING, 0, _("Error getting Media record for Volume \"%s\": ERR=%s"), mr.VolumeName, db_strerror(jcr->db)); set_jcr_job_status(jcr, JS_ErrorTerminated); } /* Now update the bootstrap file if any */ - if (jcr->JobStatus == JS_Terminated && jcr->jr.JobBytes && + if (jcr->JobStatus == JS_Terminated && jcr->jr.JobBytes && jcr->job->WriteBootstrap) { FILE *fd; BPIPE *bpipe = NULL; @@ -247,18 +247,18 @@ static void mac_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr, if (*fname == '|') { fname++; got_pipe = 1; - bpipe = open_bpipe(fname, 0, "w"); + bpipe = open_bpipe(fname, 0, "w"); fd = bpipe ? bpipe->wfd : NULL; } else { /* ***FIXME*** handle BASE */ - fd = fopen(fname, jcr->JobLevel==L_FULL?"w+":"a+"); + fd = fopen(fname, jcr->JobLevel==L_FULL?"w+":"a+"); } if (fd) { VolCount = db_get_job_volume_parameters(jcr, jcr->db, jcr->JobId, &VolParams); if (VolCount == 0) { - Jmsg(jcr, M_ERROR, 0, _("Could not get Job Volume Parameters to " - "update Bootstrap file. ERR=%s\n"), db_strerror(jcr->db)); + Jmsg(jcr, M_ERROR, 0, _("Could not get Job Volume Parameters to " + "update Bootstrap file. ERR=%s\n"), db_strerror(jcr->db)); if (jcr->SDJobFiles != 0) { set_jcr_job_status(jcr, JS_ErrorTerminated); } @@ -266,14 +266,14 @@ static void mac_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr, } for (int i=0; i < VolCount; i++) { /* Write the record */ - fprintf(fd, "Volume=\"%s\"\n", VolParams[i].VolumeName); - fprintf(fd, "VolSessionId=%u\n", jcr->VolSessionId); - fprintf(fd, "VolSessionTime=%u\n", jcr->VolSessionTime); - fprintf(fd, "VolFile=%u-%u\n", VolParams[i].StartFile, + fprintf(fd, "Volume=\"%s\"\n", VolParams[i].VolumeName); + fprintf(fd, "VolSessionId=%u\n", jcr->VolSessionId); + fprintf(fd, "VolSessionTime=%u\n", jcr->VolSessionTime); + fprintf(fd, "VolFile=%u-%u\n", VolParams[i].StartFile, VolParams[i].EndFile); - fprintf(fd, "VolBlock=%u-%u\n", VolParams[i].StartBlock, + fprintf(fd, "VolBlock=%u-%u\n", VolParams[i].StartBlock, VolParams[i].EndBlock); - fprintf(fd, "FileIndex=%d-%d\n", VolParams[i].FirstIndex, + fprintf(fd, "FileIndex=%d-%d\n", VolParams[i].FirstIndex, VolParams[i].LastIndex); } if (VolParams) { @@ -286,8 +286,8 @@ static void mac_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr, } } else { berrno be; - Jmsg(jcr, M_ERROR, 0, _("Could not open WriteBootstrap file:\n" - "%s: ERR=%s\n"), fname, be.strerror()); + Jmsg(jcr, M_ERROR, 0, _("Could not open WriteBootstrap file:\n" + "%s: ERR=%s\n"), fname, be.strerror()); set_jcr_job_status(jcr, JS_ErrorTerminated); } } @@ -296,14 +296,14 @@ static void mac_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr, switch (jcr->JobStatus) { case JS_Terminated: if (jcr->Errors || jcr->SDErrors) { - term_msg = _("Backup OK -- with warnings"); + term_msg = _("Backup OK -- with warnings"); } else { - term_msg = _("Backup OK"); + term_msg = _("Backup OK"); } break; case JS_FatalError: case JS_ErrorTerminated: - term_msg = _("*** Backup Error ***"); + term_msg = _("*** Backup Error ***"); msg_type = M_ERROR; /* Generate error message */ if (jcr->store_bsock) { bnet_sig(jcr->store_bsock, BNET_TERMINATE); @@ -313,7 +313,7 @@ static void mac_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr, } break; case JS_Canceled: - term_msg = _("Backup Canceled"); + term_msg = _("Backup Canceled"); if (jcr->store_bsock) { bnet_sig(jcr->store_bsock, BNET_TERMINATE); if (jcr->SD_msg_chan) { @@ -323,7 +323,7 @@ static void mac_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr, break; default: term_msg = term_code; - sprintf(term_code, _("Inappropriate term code: %c\n"), jcr->JobStatus); + sprintf(term_code, _("Inappropriate term code: %c\n"), jcr->JobStatus); break; } bstrftimes(sdt, sizeof(sdt), jcr->jr.StartTime); @@ -341,8 +341,8 @@ static void mac_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr, * it is normal. Or look at it the other way, only for a * normal exit should we complain about this error. */ - if (jcr->JobStatus == JS_Terminated && jcr->jr.JobBytes) { - Jmsg(jcr, M_ERROR, 0, "%s", db_strerror(jcr->db)); + if (jcr->JobStatus == JS_Terminated && jcr->jr.JobBytes) { + Jmsg(jcr, M_ERROR, 0, "%s", db_strerror(jcr->db)); } jcr->VolumeName[0] = 0; /* none */ } @@ -352,9 +352,9 @@ static void mac_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr, } else { compression = (double)100 - 100.0 * ((double)jcr->JobBytes / (double)jcr->ReadBytes); if (compression < 0.5) { - bstrncpy(compress, "None", sizeof(compress)); + bstrncpy(compress, "None", sizeof(compress)); } else { - bsnprintf(compress, sizeof(compress), "%.1f %%", (float)compression); + bsnprintf(compress, sizeof(compress), "%.1f %%", (float)compression); } } jobstatus_to_ascii(jcr->FDJobStatus, fd_term_msg, sizeof(fd_term_msg)); @@ -362,30 +362,30 @@ static void mac_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr, // bmicrosleep(15, 0); /* for debugging SIGHUP */ - Jmsg(jcr, msg_type, 0, _("Bacula " VERSION " (" LSMDATE "): %s\n\ - JobId: %d\n\ - Job: %s\n\ - Backup Level: %s%s\n\ - Client: %s\n\ - FileSet: \"%s\" %s\n\ - Pool: \"%s\"\n\ - Start time: %s\n\ - End time: %s\n\ - FD Files Written: %s\n\ - SD Files Written: %s\n\ - FD Bytes Written: %s\n\ - SD Bytes Written: %s\n\ - Rate: %.1f KB/s\n\ - Software Compression: %s\n\ - Volume name(s): %s\n\ - Volume Session Id: %d\n\ - Volume Session Time: %d\n\ - Last Volume Bytes: %s\n\ - Non-fatal FD errors: %d\n\ - SD Errors: %d\n\ - FD termination status: %s\n\ - SD termination status: %s\n\ - Termination: %s\n\n"), + Jmsg(jcr, msg_type, 0, _("Bacula " VERSION " (" LSMDATE "): %s\n" +" JobId: %d\n" +" Job: %s\n" +" Backup Level: %s%s\n" +" Client: %s\n" +" FileSet: \"%s\" %s\n" +" Pool: \"%s\"\n" +" Start time: %s\n" +" End time: %s\n" +" FD Files Written: %s\n" +" SD Files Written: %s\n" +" FD Bytes Written: %s\n" +" SD Bytes Written: %s\n" +" Rate: %.1f KB/s\n" +" Software Compression: %s\n" +" Volume name(s): %s\n" +" Volume Session Id: %d\n" +" Volume Session Time: %d\n" +" Last Volume Bytes: %s\n" +" Non-fatal FD errors: %d\n" +" SD Errors: %d\n" +" FD termination status: %s\n" +" SD termination status: %s\n" +" Termination: %s\n\n"), edt, jcr->jr.JobId, jcr->jr.Job, diff --git a/bacula/src/dird/msgchan.c b/bacula/src/dird/msgchan.c index 0df166b27d..f5c8ee2ff0 100644 --- a/bacula/src/dird/msgchan.c +++ b/bacula/src/dird/msgchan.c @@ -39,8 +39,8 @@ #include "dird.h" /* Commands sent to Storage daemon */ -static char jobcmd[] = "JobId=%d job=%s job_name=%s client_name=%s \ -type=%d level=%d FileSet=%s NoAttr=%d SpoolAttr=%d FileSetMD5=%s SpoolData=%d"; +static char jobcmd[] = "JobId=%d job=%s job_name=%s client_name=%s " +"type=%d level=%d FileSet=%s NoAttr=%d SpoolAttr=%d FileSetMD5=%s SpoolData=%d"; static char use_device[] = "use device=%s media_type=%s pool_name=%s pool_type=%s\n"; /* Response from Storage daemon */ @@ -49,7 +49,7 @@ static char OK_device[] = "3000 OK use device\n"; /* Storage Daemon requests */ static char Job_start[] = "3010 Job %127s start\n"; -static char Job_end[] = +static char Job_end[] = "3099 Job %127s end JobStatus=%d JobFiles=%d JobBytes=%" lld "\n"; static char Job_status[] = "3012 Job %127s jobstatus %d\n"; @@ -58,9 +58,9 @@ extern "C" void *msg_thread(void *arg); /* * Establish a message channel connection with the Storage daemon - * and perform authentication. + * and perform authentication. */ -bool connect_to_storage_daemon(JCR *jcr, int retry_interval, +bool connect_to_storage_daemon(JCR *jcr, int retry_interval, int max_retry_time, int verbose) { BSOCK *sd; @@ -69,12 +69,12 @@ bool connect_to_storage_daemon(JCR *jcr, int retry_interval, store = (STORE *)jcr->storage[0]->first(); /* - * Open message channel with the Storage daemon + * Open message channel with the Storage daemon */ Dmsg2(200, "bnet_connect to Storage daemon %s:%d\n", store->address, store->SDport); sd = bnet_connect(jcr, retry_interval, max_retry_time, - _("Storage daemon"), store->address, + _("Storage daemon"), store->address, NULL, store->SDport, verbose); if (sd == NULL) { return false; @@ -110,8 +110,8 @@ int start_storage_daemon_job(JCR *jcr) if (jcr->fileset->MD5[0] == 0) { strcpy(jcr->fileset->MD5, "**Dummy**"); } - bnet_fsend(sd, jobcmd, jcr->JobId, jcr->Job, jcr->job->hdr.name, - jcr->client->hdr.name, jcr->JobType, jcr->JobLevel, + bnet_fsend(sd, jobcmd, jcr->JobId, jcr->Job, jcr->job->hdr.name, + jcr->client->hdr.name, jcr->JobType, jcr->JobLevel, jcr->fileset->hdr.name, !jcr->pool->catalog_files, jcr->job->SpoolAttributes, jcr->fileset->MD5, jcr->spool_data); Dmsg1(200, "Jobcmd=%s\n", sd->msg); @@ -120,14 +120,14 @@ int start_storage_daemon_job(JCR *jcr) unbash_spaces(jcr->fileset->hdr.name); if (bget_dirmsg(sd) > 0) { Dmsg1(110, "msg); - if (sscanf(sd->msg, OKjob, &jcr->VolSessionId, + if (sscanf(sd->msg, OKjob, &jcr->VolSessionId, &jcr->VolSessionTime, &auth_key) != 3) { - Dmsg1(100, "BadJob=%s\n", sd->msg); - Jmsg(jcr, M_FATAL, 0, _("Storage daemon rejected Job command: %s\n"), sd->msg); + Dmsg1(100, "BadJob=%s\n", sd->msg); + Jmsg(jcr, M_FATAL, 0, _("Storage daemon rejected Job command: %s\n"), sd->msg); return 0; } else { jcr->sd_auth_key = bstrdup(auth_key); - Dmsg1(150, "sd_auth_key=%s\n", jcr->sd_auth_key); + Dmsg1(150, "sd_auth_key=%s\n", jcr->sd_auth_key); } } else { Jmsg(jcr, M_FATAL, 0, _("stored: %s", sd->msg); - status = response(jcr, sd, OK_device, "Use Device", NO_DISPLAY); + Dmsg1(110, ">stored: %s", sd->msg); + status = response(jcr, sd, OK_device, "Use Device", NO_DISPLAY); if (!status) { pm_strcpy(pool_type, sd->msg); /* save message */ - Jmsg(jcr, M_FATAL, 0, _("\n" - " Storage daemon didn't accept Device \"%s\" because:\n %s"), + Jmsg(jcr, M_FATAL, 0, _("\n" + " Storage daemon didn't accept Device \"%s\" because:\n %s"), device_name.c_str(), pool_type.c_str()/* sd->msg */); } } @@ -165,7 +165,7 @@ int start_storage_daemon_job(JCR *jcr) return status; } -/* +/* * Start a thread to handle Storage daemon messages and * Catalog requests. */ @@ -182,12 +182,12 @@ int start_storage_daemon_message_thread(JCR *jcr) Dmsg0(100, "Start SD msg_thread.\n"); if ((status=pthread_create(&thid, NULL, msg_thread, (void *)jcr)) != 0) { Jmsg1(jcr, M_ABORT, 0, _("Cannot create message thread: %s\n"), strerror(status)); - } + } Dmsg0(100, "SD msg_thread started.\n"); /* Wait for thread to start */ while (jcr->SD_msg_chan == 0) { bmicrosleep(0, 50); - } + } return 1; } @@ -239,13 +239,13 @@ void *msg_thread(void *arg) jcr->SDJobFiles = JobFiles; jcr->SDJobBytes = JobBytes; break; - } + } if (sscanf(sd->msg, Job_status, &Job, &JobStatus) == 2) { jcr->SDJobStatus = JobStatus; /* current status */ continue; } } - if (is_bnet_error(sd)) { + if (is_bnet_error(sd)) { jcr->SDJobStatus = JS_ErrorTerminated; } pthread_cleanup_pop(1); diff --git a/bacula/src/dird/newvol.c b/bacula/src/dird/newvol.c index 39f3280abe..2475f00502 100644 --- a/bacula/src/dird/newvol.c +++ b/bacula/src/dird/newvol.c @@ -59,7 +59,7 @@ bool newVolume(JCR *jcr, MEDIA_DBR *mr) set_pool_dbr_defaults_in_media_dbr(mr, &pr); jcr->VolumeName[0] = 0; bstrncpy(mr->MediaType, jcr->store->media_type, sizeof(mr->MediaType)); - if (generate_event(jcr, "NewVolume") == 1 && jcr->VolumeName[0]) { + if (generate_event(jcr, "NewVolume") == 1 && jcr->VolumeName[0]) { bstrncpy(mr->VolumeName, jcr->VolumeName, sizeof(mr->VolumeName)); /* Check for special characters */ } else if (is_volume_name_legal(NULL, pr.LabelFormat)) { @@ -69,11 +69,11 @@ bool newVolume(JCR *jcr, MEDIA_DBR *mr) } } else { /* try full substitution */ /* Found special characters, so try substitution */ - if (!perform_full_name_substitution(jcr, mr, &pr)) { + if (!perform_full_name_substitution(jcr, mr, &pr)) { goto bail_out; } if (!is_volume_name_legal(NULL, mr->VolumeName)) { - Jmsg(jcr, M_ERROR, 0, _("Illegal character in Volume name \"%s\"\n"), + Jmsg(jcr, M_ERROR, 0, _("Illegal character in Volume name \"%s\"\n"), mr->VolumeName); goto bail_out; } @@ -82,11 +82,11 @@ bool newVolume(JCR *jcr, MEDIA_DBR *mr) if (db_create_media_record(jcr, jcr->db, mr) && db_update_pool_record(jcr, jcr->db, &pr)) { db_unlock(jcr->db); - Jmsg(jcr, M_INFO, 0, _("Created new Volume \"%s\" in catalog.\n"), mr->VolumeName); - Dmsg1(90, "Created new Volume=%s\n", mr->VolumeName); + Jmsg(jcr, M_INFO, 0, _("Created new Volume \"%s\" in catalog.\n"), mr->VolumeName); + Dmsg1(90, "Created new Volume=%s\n", mr->VolumeName); return true; } else { - Jmsg(jcr, M_ERROR, 0, "%s", db_strerror(jcr->db)); + Jmsg(jcr, M_ERROR, 0, "%s", db_strerror(jcr->db)); } } } @@ -110,8 +110,8 @@ static int create_simple_name(JCR *jcr, MEDIA_DBR *mr, POOL_DBR *pr) bstrncpy(tmr.VolumeName, name, sizeof(tmr.VolumeName)); bstrncat(tmr.VolumeName, num, sizeof(tmr.VolumeName)); if (db_get_media_record(jcr, jcr->db, &tmr)) { - Jmsg(jcr, M_WARNING, 0, - _("Wanted to create Volume \"%s\", but it already exists. Trying again.\n"), + Jmsg(jcr, M_WARNING, 0, + _("Wanted to create Volume \"%s\", but it already exists. Trying again.\n"), tmr.VolumeName); continue; } diff --git a/bacula/src/dird/next_vol.c b/bacula/src/dird/next_vol.c index 5f58db8236..34b84b9133 100644 --- a/bacula/src/dird/next_vol.c +++ b/bacula/src/dird/next_vol.c @@ -51,8 +51,8 @@ int find_next_volume_for_append(JCR *jcr, MEDIA_DBR *mr, bool create) bstrncpy(mr->MediaType, store->media_type, sizeof(mr->MediaType)); Dmsg2(120, "CatReq FindMedia: Id=%d, MediaType=%s\n", mr->PoolId, mr->MediaType); /* - * If we are using an Autochanger, restrict Volume - * search to the Autochanger on the first pass + * If we are using an Autochanger, restrict Volume + * search to the Autochanger on the first pass */ InChanger = store->autochanger; /* @@ -64,16 +64,16 @@ int find_next_volume_for_append(JCR *jcr, MEDIA_DBR *mr, bool create) /* * 1. Look for volume with "Append" status. */ - ok = db_find_next_volume(jcr, jcr->db, 1, InChanger, mr); + ok = db_find_next_volume(jcr, jcr->db, 1, InChanger, mr); Dmsg2(100, "catreq after find_next_vol ok=%d FW=%d\n", ok, mr->FirstWritten); if (!ok) { /* * 2. Try finding a recycled volume */ ok = find_recycled_volume(jcr, InChanger, mr); - Dmsg2(100, "find_recycled_volume %d FW=%d\n", ok, mr->FirstWritten); + Dmsg2(100, "find_recycled_volume %d FW=%d\n", ok, mr->FirstWritten); if (!ok) { - /* + /* * 3. Try recycling any purged volume */ ok = recycle_oldest_purged_volume(jcr, InChanger, mr); @@ -81,7 +81,7 @@ int find_next_volume_for_append(JCR *jcr, MEDIA_DBR *mr, bool create) /* * 4. Try pruning Volumes */ - prune_volumes(jcr); + prune_volumes(jcr); ok = recycle_oldest_purged_volume(jcr, InChanger, mr); if (InChanger) { InChanger = false; @@ -89,47 +89,47 @@ int find_next_volume_for_append(JCR *jcr, MEDIA_DBR *mr, bool create) continue; /* retry again accepting any volume */ } } - Dmsg2(200, "find_recycled_volume2 %d FW=%d\n", ok, mr->FirstWritten); + Dmsg2(200, "find_recycled_volume2 %d FW=%d\n", ok, mr->FirstWritten); if (!ok && create) { /* - * 5. Try "creating" a new Volume + * 5. Try "creating" a new Volume */ ok = newVolume(jcr, mr); } } } - /* + /* * Look at more drastic ways to find an Appendable Volume - */ + */ if (!ok && (jcr->pool->purge_oldest_volume || jcr->pool->recycle_oldest_volume)) { - Dmsg2(200, "No next volume found. PurgeOldest=%d\n RecyleOldest=%d", + Dmsg2(200, "No next volume found. PurgeOldest=%d\n RecyleOldest=%d", jcr->pool->purge_oldest_volume, jcr->pool->recycle_oldest_volume); /* Find oldest volume to recycle */ ok = db_find_next_volume(jcr, jcr->db, -1, InChanger, mr); - Dmsg1(400, "Find oldest=%d\n", ok); + Dmsg1(400, "Find oldest=%d\n", ok); if (ok) { UAContext *ua; - Dmsg0(400, "Try purge.\n"); - /* + Dmsg0(400, "Try purge.\n"); + /* * 5. Try to purging oldest volume only if not UA calling us. */ ua = new_ua_context(jcr); if (jcr->pool->purge_oldest_volume && create) { - Jmsg(jcr, M_INFO, 0, _("Purging oldest volume \"%s\"\n"), mr->VolumeName); + Jmsg(jcr, M_INFO, 0, _("Purging oldest volume \"%s\"\n"), mr->VolumeName); ok = purge_jobs_from_volume(ua, mr); /* * 5. or try recycling the oldest volume */ } else if (jcr->pool->recycle_oldest_volume) { - Jmsg(jcr, M_INFO, 0, _("Pruning oldest volume \"%s\"\n"), mr->VolumeName); + Jmsg(jcr, M_INFO, 0, _("Pruning oldest volume \"%s\"\n"), mr->VolumeName); ok = prune_volume(ua, mr); } free_ua_context(ua); if (ok) { ok = recycle_volume(jcr, mr); - Dmsg1(400, "Recycle after purge oldest=%d\n", ok); + Dmsg1(400, "Recycle after purge oldest=%d\n", ok); } } } @@ -167,30 +167,30 @@ bool has_volume_expired(JCR *jcr, MEDIA_DBR *mr) if (strcmp(mr->VolStatus, "Append") == 0 && mr->VolJobs > 0) { /* First handle Max Volume Bytes */ if ((mr->MaxVolBytes > 0 && mr->VolBytes >= mr->MaxVolBytes)) { - Jmsg(jcr, M_INFO, 0, _("Max Volume bytes exceeded. " - "Marking Volume \"%s\" as Full.\n"), mr->VolumeName); - bstrncpy(mr->VolStatus, "Full", sizeof(mr->VolStatus)); + Jmsg(jcr, M_INFO, 0, _("Max Volume bytes exceeded. " + "Marking Volume \"%s\" as Full.\n"), mr->VolumeName); + bstrncpy(mr->VolStatus, "Full", sizeof(mr->VolStatus)); expired = true; /* Now see if Volume should only be used once */ } else if (mr->VolBytes > 0 && jcr->pool->use_volume_once) { - Jmsg(jcr, M_INFO, 0, _("Volume used once. " - "Marking Volume \"%s\" as Used.\n"), mr->VolumeName); - bstrncpy(mr->VolStatus, "Used", sizeof(mr->VolStatus)); + Jmsg(jcr, M_INFO, 0, _("Volume used once. " + "Marking Volume \"%s\" as Used.\n"), mr->VolumeName); + bstrncpy(mr->VolStatus, "Used", sizeof(mr->VolStatus)); expired = true; /* Now see if Max Jobs written to volume */ } else if (mr->MaxVolJobs > 0 && mr->MaxVolJobs <= mr->VolJobs) { - Jmsg(jcr, M_INFO, 0, _("Max Volume jobs exceeded. " - "Marking Volume \"%s\" as Used.\n"), mr->VolumeName); - bstrncpy(mr->VolStatus, "Used", sizeof(mr->VolStatus)); + Jmsg(jcr, M_INFO, 0, _("Max Volume jobs exceeded. " + "Marking Volume \"%s\" as Used.\n"), mr->VolumeName); + bstrncpy(mr->VolStatus, "Used", sizeof(mr->VolStatus)); expired = true; /* Now see if Max Files written to volume */ } else if (mr->MaxVolFiles > 0 && mr->MaxVolFiles <= mr->VolFiles) { - Jmsg(jcr, M_INFO, 0, _("Max Volume files exceeded. " - "Marking Volume \"%s\" as Used.\n"), mr->VolumeName); - bstrncpy(mr->VolStatus, "Used", sizeof(mr->VolStatus)); + Jmsg(jcr, M_INFO, 0, _("Max Volume files exceeded. " + "Marking Volume \"%s\" as Used.\n"), mr->VolumeName); + bstrncpy(mr->VolStatus, "Used", sizeof(mr->VolStatus)); expired = true; /* Finally, check Use duration expiration */ @@ -198,9 +198,9 @@ bool has_volume_expired(JCR *jcr, MEDIA_DBR *mr) utime_t now = time(NULL); /* See if Vol Use has expired */ if (mr->VolUseDuration <= (now - mr->FirstWritten)) { - Jmsg(jcr, M_INFO, 0, _("Max configured use duration exceeded. " - "Marking Volume \"%s\" as Used.\n"), mr->VolumeName); - bstrncpy(mr->VolStatus, "Used", sizeof(mr->VolStatus)); + Jmsg(jcr, M_INFO, 0, _("Max configured use duration exceeded. " + "Marking Volume \"%s\" as Used.\n"), mr->VolumeName); + bstrncpy(mr->VolStatus, "Used", sizeof(mr->VolStatus)); expired = true; } } @@ -208,10 +208,10 @@ bool has_volume_expired(JCR *jcr, MEDIA_DBR *mr) if (expired) { /* Need to update media */ if (!db_update_media_record(jcr, jcr->db, mr)) { - Jmsg(jcr, M_ERROR, 0, _("Catalog error updating volume \"%s\". ERR=%s"), + Jmsg(jcr, M_ERROR, 0, _("Catalog error updating volume \"%s\". ERR=%s"), mr->VolumeName, db_strerror(jcr->db)); - } - } + } + } return expired; } @@ -241,25 +241,25 @@ void check_if_volume_valid_or_recyclable(JCR *jcr, MEDIA_DBR *mr, const char **r *reason = NULL; return; } - + /* * Check if the Volume is already marked for recycling */ if (strcmp(mr->VolStatus, "Purged") == 0) { if (recycle_volume(jcr, mr)) { - Jmsg(jcr, M_INFO, 0, "Recycled current volume \"%s\"\n", mr->VolumeName); + Jmsg(jcr, M_INFO, 0, "Recycled current volume \"%s\"\n", mr->VolumeName); *reason = NULL; return; } else { - /* In principle this shouldn't happen */ - *reason = "and recycling of current volume failed"; + /* In principle this shouldn't happen */ + *reason = "and recycling of current volume failed"; return; } } - + /* At this point, the volume is not valid for writing */ *reason = "but should be Append, Purged or Recycle"; - + /* * What we're trying to do here is see if the current volume is * "recyclable" - ie. if we prune all expired jobs off it, is @@ -268,30 +268,30 @@ void check_if_volume_valid_or_recyclable(JCR *jcr, MEDIA_DBR *mr, const char **r */ if ((mr->LastWritten + mr->VolRetention) < (utime_t)time(NULL) && mr->Recycle && jcr->pool->recycle_current_volume - && (strcmp(mr->VolStatus, "Full") == 0 || - strcmp(mr->VolStatus, "Used") == 0)) { + && (strcmp(mr->VolStatus, "Full") == 0 || + strcmp(mr->VolStatus, "Used") == 0)) { /* * Attempt prune of current volume to see if we can * recycle it for use. */ UAContext *ua; - + ua = new_ua_context(jcr); ok = prune_volume(ua, mr); free_ua_context(ua); - + if (ok) { /* If fully purged, recycle current volume */ if (recycle_volume(jcr, mr)) { - Jmsg(jcr, M_INFO, 0, "Recycled current volume \"%s\"\n", mr->VolumeName); + Jmsg(jcr, M_INFO, 0, "Recycled current volume \"%s\"\n", mr->VolumeName); *reason = NULL; } else { - *reason = "but should be Append, Purged or Recycle (recycling of the " - "current volume failed)"; + *reason = "but should be Append, Purged or Recycle (recycling of the " + "current volume failed)"; } } else { - *reason = "but should be Append, Purged or Recycle (cannot automatically " - "recycle current volume, as it still contains unpruned data)"; + *reason = "but should be Append, Purged or Recycle (cannot automatically " + "recycle current volume, as it still contains unpruned data)"; } } } diff --git a/bacula/src/dird/protos.h b/bacula/src/dird/protos.h index c0891d1b13..81ae6d5c0b 100644 --- a/bacula/src/dird/protos.h +++ b/bacula/src/dird/protos.h @@ -69,7 +69,7 @@ extern int send_bootstrap_file(JCR *jcr); extern int 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, +extern int put_file_into_catalog(JCR *jcr, long file_index, char *fname, char *link, char *attr, int stream); extern void get_level_since_time(JCR *jcr, char *since, int since_len); extern int send_run_before_and_after_commands(JCR *jcr); @@ -97,7 +97,7 @@ extern void set_storage(JCR *jcr, STORE *store); extern void mount_request(JCR *jcr, BSOCK *bs, char *buf); /* msgchan.c */ -extern bool connect_to_storage_daemon(JCR *jcr, int retry_interval, +extern bool connect_to_storage_daemon(JCR *jcr, int retry_interval, int max_retry_time, int verbose); extern int start_storage_daemon_job(JCR *jcr); extern int start_storage_daemon_message_thread(JCR *jcr); @@ -123,7 +123,7 @@ int qmessagescmd(UAContext *ua, const char *cmd); int open_db(UAContext *ua); void close_db(UAContext *ua); enum e_pool_op { - POOL_OP_UPDATE, + POOL_OP_UPDATE, POOL_OP_CREATE }; int create_pool(JCR *jcr, B_DB *db, POOL *pool, e_pool_op op); @@ -163,7 +163,7 @@ int select_client_dbr(UAContext *ua, CLIENT_DBR *cr); void start_prompt(UAContext *ua, const char *msg); void add_prompt(UAContext *ua, const char *prompt); int do_prompt(UAContext *ua, const char *automsg, const char *msg, char *prompt, int max_prompt); -CAT *get_catalog_resource(UAContext *ua); +CAT *get_catalog_resource(UAContext *ua); STORE *get_storage_resource(UAContext *ua, int use_default); int get_media_type(UAContext *ua, char *MediaType, int max_media); bool get_pool_dbr(UAContext *ua, POOL_DBR *pr); diff --git a/bacula/src/dird/python.c b/bacula/src/dird/python.c index f84fa637eb..ba1562c148 100644 --- a/bacula/src/dird/python.c +++ b/bacula/src/dird/python.c @@ -1,5 +1,5 @@ /* - * + * * Bacula interface to Python for the Director * * Kern Sibbald, November MMIV @@ -9,7 +9,7 @@ */ /* - + Copyright (C) 2004 Kern Sibbald This program is free software; you can redistribute it and/or @@ -46,7 +46,7 @@ PyObject *bacula_run(PyObject *self, PyObject *args); PyMethodDef BaculaMethods[] = { {"get", bacula_get, METH_VARARGS, "Get Bacula variables."}, {"set", (PyCFunction)bacula_set, METH_VARARGS|METH_KEYWORDS, - "Set Bacula variables."}, + "Set Bacula variables."}, {"run", (PyCFunction)bacula_run, METH_VARARGS, "Run a Bacula command."}, {NULL, NULL, 0, NULL} /* last item */ }; @@ -55,7 +55,7 @@ PyMethodDef BaculaMethods[] = { struct s_vars { const char *name; char *fmt; -}; +}; static struct s_vars vars[] = { { N_("Job"), "s"}, @@ -71,7 +71,7 @@ static struct s_vars vars[] = { { N_("MediaType"), "s"}, { N_("JobName"), "s"}, { N_("JobStatus"), "s"}, - + { NULL, NULL} }; @@ -139,7 +139,7 @@ PyObject *bacula_set(PyObject *self, PyObject *args, PyObject *keyw) char *msg = NULL; char *VolumeName = NULL; static char *kwlist[] = {"jcr", "JobReport", "VolumeName", NULL}; - if (!PyArg_ParseTupleAndKeywords(args, keyw, "O|ss:set", kwlist, + if (!PyArg_ParseTupleAndKeywords(args, keyw, "O|ss:set", kwlist, &CObject, &msg, &VolumeName)) { return NULL; } diff --git a/bacula/src/dird/recycle.c b/bacula/src/dird/recycle.c index 84a39a9dc4..1b785dfbde 100644 --- a/bacula/src/dird/recycle.c +++ b/bacula/src/dird/recycle.c @@ -72,10 +72,10 @@ int recycle_oldest_purged_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr) struct s_oldest_ctx oldest; POOLMEM *query = get_pool_memory(PM_EMSG); const char *select = - "SELECT MediaId,LastWritten FROM Media " - "WHERE PoolId=%u AND Recycle=1 AND VolStatus='Purged' " - "AND MediaType='%s' %s" - "ORDER BY LastWritten ASC,MediaId LIMIT 1"; + "SELECT MediaId,LastWritten FROM Media " + "WHERE PoolId=%u AND Recycle=1 AND VolStatus='Purged' " + "AND MediaType='%s' %s" + "ORDER BY LastWritten ASC,MediaId LIMIT 1"; Dmsg0(100, "Enter recycle_oldest_purged_volume\n"); oldest.MediaId = 0; @@ -97,15 +97,15 @@ int recycle_oldest_purged_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr) mr->MediaId = oldest.MediaId; if (db_get_media_record(jcr, jcr->db, mr)) { if (recycle_volume(jcr, mr)) { - Jmsg(jcr, M_INFO, 0, "Recycled volume \"%s\"\n", mr->VolumeName); - Dmsg1(100, "return 1 recycle_oldest_purged_volume Vol=%s\n", mr->VolumeName); + Jmsg(jcr, M_INFO, 0, "Recycled volume \"%s\"\n", mr->VolumeName); + Dmsg1(100, "return 1 recycle_oldest_purged_volume Vol=%s\n", mr->VolumeName); return 1; } } Jmsg(jcr, M_ERROR, 0, "%s", db_strerror(jcr->db)); } Dmsg0(100, "return 0 recycle_oldest_purged_volume end\n"); - return 0; + return 0; } /* diff --git a/bacula/src/dird/restore.c b/bacula/src/dird/restore.c index 27c3abc025..d8a894bf24 100644 --- a/bacula/src/dird/restore.c +++ b/bacula/src/dird/restore.c @@ -3,8 +3,8 @@ * * Kern Sibbald, November MM * - * This routine is run as a separate thread. - * + * This routine is run as a separate thread. + * * Current implementation is Catalog verification only (i.e. no * verification versus tape). * @@ -44,7 +44,7 @@ /* Commands sent to File daemon */ static char restorecmd[] = "restore replace=%c prelinks=%d where=%s\n"; static char storaddr[] = "storage address=%s port=%d ssl=0\n"; -static char sessioncmd[] = "session %s %ld %ld %ld %ld %ld %ld\n"; +static char sessioncmd[] = "session %s %ld %ld %ld %ld %ld %ld\n"; /* Responses received from File daemon */ static char OKrestore[] = "2000 OK restore\n"; @@ -56,13 +56,13 @@ static void restore_cleanup(JCR *jcr, int status); /* External functions */ -/* +/* * Do a restore of the specified files - * + * * Returns: 0 on failure * 1 on success */ -int do_restore(JCR *jcr) +int do_restore(JCR *jcr) { BSOCK *fd; JOB_DBR rjr; /* restore job record */ @@ -84,7 +84,7 @@ int do_restore(JCR *jcr) Dmsg1(20, "RestoreJobId=%d\n", jcr->job->RestoreJobId); - /* + /* * The following code is kept temporarily for compatibility. * It is the predecessor to the Bootstrap file. * DEPRECATED @@ -99,7 +99,7 @@ int do_restore(JCR *jcr) rjr.JobId = jcr->job->RestoreJobId; /* specified by Job Resource */ } if (!db_get_job_record(jcr, jcr->db, &rjr)) { - Jmsg2(jcr, M_FATAL, 0, _("Cannot get job record id=%d %s"), rjr.JobId, + Jmsg2(jcr, M_FATAL, 0, _("Cannot get job record id=%d %s"), rjr.JobId, db_strerror(jcr->db)); restore_cleanup(jcr, JS_ErrorTerminated); return 0; @@ -111,14 +111,14 @@ int do_restore(JCR *jcr) jcr->VolumeName[0] = 0; if (!db_get_job_volume_names(jcr, jcr->db, rjr.JobId, &jcr->VolumeName) || jcr->VolumeName[0] == 0) { - Jmsg(jcr, M_FATAL, 0, _("Cannot find Volume names for restore Job %d. %s"), + Jmsg(jcr, M_FATAL, 0, _("Cannot find Volume names for restore Job %d. %s"), rjr.JobId, db_strerror(jcr->db)); restore_cleanup(jcr, JS_ErrorTerminated); return 0; } Dmsg1(20, "Got job Volume Names: %s\n", jcr->VolumeName); } - + /* Print Job Start message */ Jmsg(jcr, M_INFO, 0, _("Start Restore Job %s\n"), jcr->Job); @@ -132,7 +132,7 @@ int do_restore(JCR *jcr) Dmsg0(10, "Open connection with storage daemon\n"); set_jcr_job_status(jcr, JS_WaitSD); /* - * Start conversation with Storage daemon + * Start conversation with Storage daemon */ if (!connect_to_storage_daemon(jcr, 10, SDConnectTimeout, 1)) { restore_cleanup(jcr, JS_ErrorTerminated); @@ -154,8 +154,8 @@ int do_restore(JCR *jcr) } Dmsg0(50, "Storage daemon connection OK\n"); - /* - * Start conversation with File daemon + /* + * Start conversation with File daemon */ set_jcr_job_status(jcr, JS_WaitFD); if (!connect_to_file_daemon(jcr, 10, FDConnectTimeout, 1)) { @@ -176,7 +176,7 @@ int do_restore(JCR *jcr) return 0; } - /* + /* * send Storage daemon address to the File daemon, * then wait for File daemon to make connection * with Storage daemon. @@ -191,7 +191,7 @@ int do_restore(JCR *jcr) return 0; } - /* + /* * Send the bootstrap file -- what Volumes/files to restore */ if (!send_bootstrap_file(jcr)) { @@ -199,18 +199,18 @@ int do_restore(JCR *jcr) return 0; } - /* - * The following code is deprecated + /* + * The following code is deprecated */ if (!jcr->RestoreBootstrap) { /* * Pass the VolSessionId, VolSessionTime, Start and * end File and Blocks on the session command. */ - bnet_fsend(fd, sessioncmd, + bnet_fsend(fd, sessioncmd, jcr->VolumeName, - rjr.VolSessionId, rjr.VolSessionTime, - rjr.StartFile, rjr.EndFile, rjr.StartBlock, + rjr.VolSessionId, rjr.VolSessionTime, + rjr.StartFile, rjr.EndFile, rjr.StartBlock, rjr.EndBlock); if (!response(jcr, fd, OKsession, "Session", DISPLAY_ERROR)) { restore_cleanup(jcr, JS_ErrorTerminated); @@ -226,7 +226,7 @@ int do_restore(JCR *jcr) /* Send restore command */ char replace, *where; char empty = '\0'; - + if (jcr->replace != 0) { replace = jcr->replace; } else if (jcr->job->replace != 0) { @@ -281,14 +281,14 @@ static void restore_cleanup(JCR *jcr, int TermCode) switch (TermCode) { case JS_Terminated: if (jcr->ExpectedFiles > jcr->jr.JobFiles) { - term_msg = _("Restore OK -- warning file count mismatch"); + term_msg = _("Restore OK -- warning file count mismatch"); } else { - term_msg = _("Restore OK"); + term_msg = _("Restore OK"); } break; case JS_FatalError: case JS_ErrorTerminated: - term_msg = _("*** Restore Error ***"); + term_msg = _("*** Restore Error ***"); msg_type = M_ERROR; /* Generate error message */ if (jcr->store_bsock) { bnet_sig(jcr->store_bsock, BNET_TERMINATE); @@ -325,20 +325,20 @@ static void restore_cleanup(JCR *jcr, int TermCode) jobstatus_to_ascii(jcr->FDJobStatus, fd_term_msg, sizeof(fd_term_msg)); jobstatus_to_ascii(jcr->SDJobStatus, sd_term_msg, sizeof(sd_term_msg)); - Jmsg(jcr, msg_type, 0, _("Bacula " VERSION " (" LSMDATE "): %s\n\ - JobId: %d\n\ - Job: %s\n\ - Client: %s\n\ - Start time: %s\n\ - End time: %s\n\ - Files Expected: %s\n\ - Files Restored: %s\n\ - Bytes Restored: %s\n\ - Rate: %.1f KB/s\n\ - FD Errors: %d\n\ - FD termination status: %s\n\ - SD termination status: %s\n\ - Termination: %s\n\n"), + Jmsg(jcr, msg_type, 0, _("Bacula " VERSION " (" LSMDATE "): %s\n" +" JobId: %d\n" +" Job: %s\n" +" Client: %s\n" +" Start time: %s\n" +" End time: %s\n" +" Files Expected: %s\n" +" Files Restored: %s\n" +" Bytes Restored: %s\n" +" Rate: %.1f KB/s\n" +" FD Errors: %d\n" +" FD termination status: %s\n" +" SD termination status: %s\n" +" Termination: %s\n\n"), edt, jcr->jr.JobId, jcr->jr.Job, diff --git a/bacula/src/dird/run_conf.c b/bacula/src/dird/run_conf.c index 0d31987a23..cd3092a262 100644 --- a/bacula/src/dird/run_conf.c +++ b/bacula/src/dird/run_conf.c @@ -49,7 +49,7 @@ enum e_state { s_hourly, s_wom, /* 1st, 2nd, ...*/ s_woy /* week of year w00 - w53 */ -}; +}; struct s_keyw { const char *name; /* keyword */ @@ -151,15 +151,15 @@ static struct s_kw RunFields[] = { {NULL, 0} }; -/* - * Store Schedule Run information - * +/* + * Store Schedule Run information + * * Parse Run statement: * * Run [on] 2 january at 23:45 * * Default Run time is daily at 0:0 - * + * * There can be multiple run statements, they are simply chained * together. * @@ -170,7 +170,7 @@ void store_run(LEX *lc, RES_ITEM *item, int index, int pass) bool found; int token, state, state2 = 0, code = 0, code2 = 0; int options = lc->options; - RUN **run = (RUN **)(item->value); + RUN **run = (RUN **)(item->value); RUN *trun; char *p; RES *res; @@ -189,23 +189,23 @@ void store_run(LEX *lc, RES_ITEM *item, int index, int pass) if (strcasecmp(lc->str, RunFields[i].name) == 0) { found = true; if (lex_get_token(lc, T_ALL) != T_EQUALS) { - scan_err1(lc, "Expected an equals, got: %s", lc->str); - /* NOT REACHED */ + scan_err1(lc, "Expected an equals, got: %s", lc->str); + /* NOT REACHED */ } switch (RunFields[i].token) { - case 's': /* Data spooling */ + case 's': /* Data spooling */ token = lex_get_token(lc, T_NAME); - if (strcasecmp(lc->str, "yes") == 0) { + if (strcasecmp(lc->str, "yes") == 0) { lrun.spool_data = true; lrun.spool_data_set = true; - } else if (strcasecmp(lc->str, "no") == 0) { + } else if (strcasecmp(lc->str, "no") == 0) { lrun.spool_data = false; lrun.spool_data_set = true; } else { - scan_err1(lc, _("Expect a YES or NO, got: %s"), lc->str); + scan_err1(lc, _("Expect a YES or NO, got: %s"), lc->str); } break; - case 'L': /* level */ + case 'L': /* level */ token = lex_get_token(lc, T_NAME); for (j=0; joblevels[j].level_name; j++) { if (strcasecmp(lc->str, joblevels[j].level_name) == 0) { @@ -216,62 +216,62 @@ void store_run(LEX *lc, RES_ITEM *item, int index, int pass) } } if (j != 0) { - scan_err1(lc, _("Job level field: %s not found in run record"), lc->str); + scan_err1(lc, _("Job level field: %s not found in run record"), lc->str); /* NOT REACHED */ } break; - case 'p': /* Priority */ + case 'p': /* Priority */ token = lex_get_token(lc, T_PINT32); if (pass == 2) { lrun.Priority = lc->pint32_val; } break; - case 'P': /* Pool */ - case 'f': /* FullPool */ - case 'i': /* IncPool */ - case 'd': /* DifPool */ + case 'P': /* Pool */ + case 'f': /* FullPool */ + case 'i': /* IncPool */ + case 'd': /* DifPool */ token = lex_get_token(lc, T_NAME); if (pass == 2) { res = GetResWithName(R_POOL, lc->str); if (res == NULL) { - scan_err1(lc, "Could not find specified Pool Resource: %s", + scan_err1(lc, "Could not find specified Pool Resource: %s", lc->str); /* NOT REACHED */ } switch(RunFields[i].token) { - case 'P': + case 'P': lrun.pool = (POOL *)res; break; - case 'f': + case 'f': lrun.full_pool = (POOL *)res; break; - case 'i': + case 'i': lrun.inc_pool = (POOL *)res; break; - case 'd': + case 'd': lrun.dif_pool = (POOL *)res; break; } } break; - case 'S': /* storage */ + case 'S': /* storage */ token = lex_get_token(lc, T_NAME); if (pass == 2) { res = GetResWithName(R_STORAGE, lc->str); if (res == NULL) { - scan_err1(lc, "Could not find specified Storage Resource: %s", + scan_err1(lc, "Could not find specified Storage Resource: %s", lc->str); /* NOT REACHED */ } lrun.storage = (STORE *)res; } break; - case 'M': /* messages */ + case 'M': /* messages */ token = lex_get_token(lc, T_NAME); if (pass == 2) { res = GetResWithName(R_MSGS, lc->str); if (res == NULL) { - scan_err1(lc, "Could not find specified Messages Resource: %s", + scan_err1(lc, "Could not find specified Messages Resource: %s", lc->str); /* NOT REACHED */ } @@ -279,10 +279,10 @@ void store_run(LEX *lc, RES_ITEM *item, int index, int pass) } break; default: - scan_err1(lc, "Expected a keyword name, got: %s", lc->str); + scan_err1(lc, "Expected a keyword name, got: %s", lc->str); /* NOT REACHED */ break; - } /* end switch */ + } /* end switch */ } /* end if strcasecmp */ } /* end for RunFields */ @@ -314,24 +314,24 @@ void store_run(LEX *lc, RES_ITEM *item, int index, int pass) state = s_mday; code = atoi(lc->str) - 1; if (code < 0 || code > 30) { - scan_err0(lc, _("Day number out of range (1-31)")); + scan_err0(lc, _("Day number out of range (1-31)")); } break; case T_NAME: /* this handles drop through from keyword */ case T_UNQUOTED_STRING: - if (strchr(lc->str, (int)'-')) { + if (strchr(lc->str, (int)'-')) { state = s_range; break; } - if (strchr(lc->str, (int)':')) { + if (strchr(lc->str, (int)':')) { state = s_time; break; } - if (lc->str_len == 3 && (lc->str[0] == 'w' || lc->str[0] == 'W') && + if (lc->str_len == 3 && (lc->str[0] == 'w' || lc->str[0] == 'W') && is_an_integer(lc->str+1)) { code = atoi(lc->str+1); if (code < 0 || code > 53) { - scan_err0(lc, _("Week number out of range (0-53)")); + scan_err0(lc, _("Week number out of range (0-53)")); } state = s_woy; /* week of year */ break; @@ -346,14 +346,14 @@ void store_run(LEX *lc, RES_ITEM *item, int index, int pass) } } if (i != 0) { - scan_err1(lc, _("Job type field: %s in run record not found"), lc->str); + scan_err1(lc, _("Job type field: %s in run record not found"), lc->str); /* NOT REACHED */ } break; case T_COMMA: continue; default: - scan_err2(lc, _("Unexpected token: %d:%s"), token, lc->str); + scan_err2(lc, _("Unexpected token: %d:%s"), token, lc->str); /* NOT REACHED */ break; } @@ -397,27 +397,27 @@ void store_run(LEX *lc, RES_ITEM *item, int index, int pass) break; case s_time: /* time */ if (!have_at) { - scan_err0(lc, _("Time must be preceded by keyword AT.")); + scan_err0(lc, _("Time must be preceded by keyword AT.")); /* NOT REACHED */ } if (!have_hour) { clear_bits(0, 23, lrun.hour); } - p = strchr(lc->str, ':'); + p = strchr(lc->str, ':'); if (!p) { - scan_err0(lc, _("Time logic error.\n")); + scan_err0(lc, _("Time logic error.\n")); /* NOT REACHED */ } *p++ = 0; /* separate two halves */ code = atoi(lc->str); len = strlen(p); - if (len > 2 && p[len-1] == 'm') { - if (p[len-2] == 'a') { + if (len > 2 && p[len-1] == 'm') { + if (p[len-2] == 'a') { pm = 0; - } else if (p[len-2] == 'p') { + } else if (p[len-2] == 'p') { pm = 1; } else { - scan_err0(lc, _("Bad time specification.")); + scan_err0(lc, _("Bad time specification.")); /* NOT REACHED */ } } else { @@ -428,7 +428,7 @@ void store_run(LEX *lc, RES_ITEM *item, int index, int pass) code += 12; } if (code < 0 || code > 23 || code2 < 0 || code2 > 59) { - scan_err0(lc, _("Bad time specification.")); + scan_err0(lc, _("Bad time specification.")); /* NOT REACHED */ } /****FIXME**** convert to UTC */ @@ -440,9 +440,9 @@ void store_run(LEX *lc, RES_ITEM *item, int index, int pass) have_at = true; break; case s_range: - p = strchr(lc->str, '-'); + p = strchr(lc->str, '-'); if (!p) { - scan_err0(lc, _("Range logic error.\n")); + scan_err0(lc, _("Range logic error.\n")); } *p++ = 0; /* separate two halves */ @@ -451,7 +451,7 @@ void store_run(LEX *lc, RES_ITEM *item, int index, int pass) code = atoi(lc->str) - 1; code2 = atoi(p) - 1; if (code < 0 || code > 30 || code2 < 0 || code2 > 30) { - scan_err0(lc, _("Bad day range specification.")); + scan_err0(lc, _("Bad day range specification.")); } if (!have_mday) { clear_bits(0, 30, lrun.mday); @@ -467,13 +467,13 @@ void store_run(LEX *lc, RES_ITEM *item, int index, int pass) } /* Check for week of year range */ if (strlen(lc->str) == 3 && strlen(p) == 3 && - (lc->str[0] == 'w' || lc->str[0] == 'W') && - (p[0] == 'w' || p[0] == 'W') && + (lc->str[0] == 'w' || lc->str[0] == 'W') && + (p[0] == 'w' || p[0] == 'W') && is_an_integer(lc->str+1) && is_an_integer(p+1)) { code = atoi(lc->str+1); code2 = atoi(p+1); if (code < 0 || code > 53 || code2 < 0 || code2 > 53) { - scan_err0(lc, _("Week number out of range (0-53)")); + scan_err0(lc, _("Week number out of range (0-53)")); } if (!have_woy) { clear_bits(0, 53, lrun.woy); @@ -498,7 +498,7 @@ void store_run(LEX *lc, RES_ITEM *item, int index, int pass) } } if (i != 0 || (state != s_month && state != s_wday && state != s_wom)) { - scan_err0(lc, _("Invalid month, week or position day range")); + scan_err0(lc, _("Invalid month, week or position day range")); /* NOT REACHED */ } @@ -513,7 +513,7 @@ void store_run(LEX *lc, RES_ITEM *item, int index, int pass) } } if (i != 0 || state != state2 || code == code2) { - scan_err0(lc, _("Invalid month, weekday or position range")); + scan_err0(lc, _("Invalid month, weekday or position range")); /* NOT REACHED */ } if (state == s_wday) { @@ -551,7 +551,7 @@ void store_run(LEX *lc, RES_ITEM *item, int index, int pass) set_bits(code, 4, lrun.wom); set_bits(0, code2, lrun.wom); } - } + } break; case s_hourly: have_hour = true; @@ -572,14 +572,14 @@ void store_run(LEX *lc, RES_ITEM *item, int index, int pass) set_bits(0, 11, lrun.month); break; default: - scan_err0(lc, _("Unexpected run state\n")); + scan_err0(lc, _("Unexpected run state\n")); /* NOT REACHED */ break; } } /* Allocate run record, copy new stuff into it, - * and link it into the list of run records + * and link it into the list of run records * in the schedule resource. */ if (pass == 2) { diff --git a/bacula/src/dird/scheduler.c b/bacula/src/dird/scheduler.c index 80182c2612..abe5668a86 100644 --- a/bacula/src/dird/scheduler.c +++ b/bacula/src/dird/scheduler.c @@ -2,7 +2,7 @@ * * Bacula scheduler * It looks at what jobs are to be run and when - * and waits around until it is time to + * and waits around until it is time to * fire them up. * * Kern Sibbald, May MM, major revision December MMIII @@ -36,13 +36,13 @@ /* Local variables */ -struct job_item { +struct job_item { RUN *run; JOB *job; time_t runtime; int Priority; dlink link; /* link for list */ -}; +}; /* List of jobs to be run. They were scheduled in this hour or the next */ static dlist *jobs_to_run; /* list of jobs to be run */ @@ -82,9 +82,9 @@ JCR *wait_for_next_job(char *one_shot_job_to_run) if (one_shot_job_to_run) { /* one shot */ job = (JOB *)GetResWithName(R_JOB, one_shot_job_to_run); if (!job) { - Emsg1(M_ABORT, 0, _("Job %s not found\n"), one_shot_job_to_run); + Emsg1(M_ABORT, 0, _("Job %s not found\n"), one_shot_job_to_run); } - Dmsg1(5, "Found one_shot_job_to_run %s\n", one_shot_job_to_run); + Dmsg1(5, "Found one_shot_job_to_run %s\n", one_shot_job_to_run); jcr = new_jcr(sizeof(JCR), dird_free_jcr); set_jcr_defaults(jcr, job); return jcr; @@ -107,7 +107,7 @@ JCR *wait_for_next_job(char *one_shot_job_to_run) dump_job(je, "Walk queue"); } #endif - /* + /* * Pull the first job to run (already sorted by runtime and * Priority, then wait around until it is time to run it. */ @@ -174,7 +174,7 @@ JCR *wait_for_next_job(char *one_shot_job_to_run) /* - * Shutdown the scheduler + * Shutdown the scheduler */ void term_scheduler() { @@ -188,7 +188,7 @@ void term_scheduler() } } -/* +/* * Find all jobs to be run this hour and the next hour. */ static void find_runs() @@ -205,7 +205,7 @@ static void find_runs() Dmsg0(200, "enter find_runs()\n"); - + /* compute values for time now */ now = time(NULL); localtime_r(&now, &tm); @@ -217,12 +217,12 @@ static void find_runs() wom = mday / 7; woy = tm_woy(now); /* get week of year */ - /* + /* * Compute values for next hour from now. * We do this to be sure we don't miss a job while * sleeping. */ - next_hour = now + 3600; + next_hour = now + 3600; localtime_r(&next_hour, &tm); nh_hour = tm.tm_hour; nh_mday = tm.tm_mday - 1; @@ -242,14 +242,14 @@ static void find_runs() Dmsg1(200, "Got job: %s\n", job->hdr.name); for (run=sched->run; run; run=run->next) { bool run_now, run_nh; - /* + /* * Find runs scheduled between now and the next hour. */ #ifdef xxxx - Dmsg0(000, "\n"); - Dmsg6(000, "run h=%d m=%d md=%d wd=%d wom=%d woy=%d\n", + Dmsg0(000, "\n"); + Dmsg6(000, "run h=%d m=%d md=%d wd=%d wom=%d woy=%d\n", hour, month, mday, wday, wom, woy); - Dmsg6(000, "bitset bsh=%d bsm=%d bsmd=%d bswd=%d bswom=%d bswoy=%d\n", + Dmsg6(000, "bitset bsh=%d bsm=%d bsmd=%d bswd=%d bswom=%d bswoy=%d\n", bit_is_set(hour, run->hour), bit_is_set(month, run->month), bit_is_set(mday, run->mday), @@ -257,9 +257,9 @@ static void find_runs() bit_is_set(wom, run->wom), bit_is_set(woy, run->woy)); - Dmsg6(000, "nh_run h=%d m=%d md=%d wd=%d wom=%d woy=%d\n", + Dmsg6(000, "nh_run h=%d m=%d md=%d wd=%d wom=%d woy=%d\n", nh_hour, nh_month, nh_mday, nh_wday, nh_wom, nh_woy); - Dmsg6(000, "nh_bitset bsh=%d bsm=%d bsmd=%d bswd=%d bswom=%d bswoy=%d\n", + Dmsg6(000, "nh_bitset bsh=%d bsm=%d bsmd=%d bswd=%d bswom=%d bswoy=%d\n", bit_is_set(nh_hour, run->hour), bit_is_set(nh_month, run->month), bit_is_set(nh_mday, run->mday), @@ -269,20 +269,20 @@ static void find_runs() #endif run_now = bit_is_set(hour, run->hour) && - bit_is_set(mday, run->mday) && + bit_is_set(mday, run->mday) && bit_is_set(wday, run->wday) && bit_is_set(month, run->month) && bit_is_set(wom, run->wom) && bit_is_set(woy, run->woy); run_nh = bit_is_set(nh_hour, run->hour) && - bit_is_set(nh_mday, run->mday) && + bit_is_set(nh_mday, run->mday) && bit_is_set(nh_wday, run->wday) && bit_is_set(nh_month, run->month) && bit_is_set(nh_wom, run->wom) && bit_is_set(nh_woy, run->woy); - Dmsg2(200, "run_now=%d run_nh=%d\n", run_now, run_nh); + Dmsg2(200, "run_now=%d run_nh=%d\n", run_now, run_nh); /* find time (time_t) job is to be run */ localtime_r(&now, &tm); /* reset tm structure */ @@ -302,7 +302,7 @@ static void find_runs() runtime = mktime(&tm); add_job(job, run, now, runtime); } - } + } } UnlockRes(); Dmsg0(200, "Leave find_runs()\n"); @@ -319,10 +319,10 @@ static void add_job(JOB *job, RUN *run, time_t now, time_t runtime) if (((runtime - run->last_run) < 61) || ((runtime+59) < now)) { #ifdef SCHED_DEBUG char dt[50], dt1[50], dt2[50]; - bstrftime_nc(dt, sizeof(dt), runtime); + bstrftime_nc(dt, sizeof(dt), runtime); bstrftime_nc(dt1, sizeof(dt1), run->last_run); bstrftime_nc(dt2, sizeof(dt2), now); - Dmsg4(000, "Drop: Job=\"%s\" run=%s. last_run=%s. now=%s\n", job->hdr.name, + Dmsg4(000, "Drop: Job=\"%s\" run=%s. last_run=%s. now=%s\n", job->hdr.name, dt, dt1, dt2); fflush(stdout); #endif @@ -341,10 +341,10 @@ static void add_job(JOB *job, RUN *run, time_t now, time_t runtime) /* Add this job to the wait queue in runtime, priority sorted order */ foreach_dlist(ji, jobs_to_run) { - if (ji->runtime > je->runtime || + if (ji->runtime > je->runtime || (ji->runtime == je->runtime && ji->Priority > je->Priority)) { jobs_to_run->insert_before(je, ji); - dump_job(je, "Inserted job"); + dump_job(je, "Inserted job"); inserted = true; break; } @@ -362,7 +362,7 @@ static void add_job(JOB *job, RUN *run, time_t now, time_t runtime) #endif } -static void dump_job(job_item *ji, const char *msg) +static void dump_job(job_item *ji, const char *msg) { #ifdef SCHED_DEBUG char dt[MAX_TIME_LENGTH]; @@ -371,8 +371,8 @@ static void dump_job(job_item *ji, const char *msg) if (debug_level < 200) { return; } - bstrftime_nc(dt, sizeof(dt), ji->runtime); - Dmsg4(200, "%s: Job=%s priority=%d run %s\n", msg, ji->job->hdr.name, + bstrftime_nc(dt, sizeof(dt), ji->runtime); + Dmsg4(200, "%s: Job=%s priority=%d run %s\n", msg, ji->job->hdr.name, ji->Priority, dt); fflush(stdout); debug_level = save_debug; diff --git a/bacula/src/dird/sql_cmds.c b/bacula/src/dird/sql_cmds.c index f664722120..99708e41ae 100644 --- a/bacula/src/dird/sql_cmds.c +++ b/bacula/src/dird/sql_cmds.c @@ -52,13 +52,13 @@ const char *del_File = "DELETE FROM File WHERE JobId=%u"; const char *upd_Purged = "UPDATE Job Set PurgedFiles=1 WHERE JobId=%u"; const char *cnt_DelCand = "SELECT count(*) FROM DelCandidates"; const char *del_Job = "DELETE FROM Job WHERE JobId=%u"; -const char *del_JobMedia = "DELETE FROM JobMedia WHERE JobId=%u"; +const char *del_JobMedia = "DELETE FROM JobMedia WHERE JobId=%u"; const char *cnt_JobMedia = "SELECT count(*) FROM JobMedia WHERE MediaId=%u"; const char *sel_JobMedia = "SELECT JobId FROM JobMedia WHERE MediaId=%u"; /* Select JobIds for File deletion. */ const char *select_job = - "SELECT JobId from Job " + "SELECT JobId from Job " "WHERE JobTDate<%s " "AND ClientId=%u " "AND PurgedFiles=0"; @@ -100,11 +100,11 @@ const char *create_deltabs[] = { /* Fill candidates table with all Jobs subject to being deleted. * This is used for pruning Jobs (first the files, then the Jobs). */ -const char *insert_delcand = +const char *insert_delcand = "INSERT INTO DelCandidates " "SELECT JobId,PurgedFiles,FileSetId,JobFiles,JobStatus FROM Job " "WHERE Type='%c' " - "AND JobTDate<%s " + "AND JobTDate<%s " "AND ClientId=%u"; /* Select Jobs from the DelCandidates table that have a @@ -149,7 +149,7 @@ const char *select_restore_del = "FROM Job,DelCandidates " "WHERE (Job.JobTdate<%s AND delCandidates.JobStatus!='T') OR " "(Job.JobTDate>%s " - "AND Job.ClientId=%u " + "AND Job.ClientId=%u " "AND Job.Type='R')"; /* Select Jobs from the DelCandidates table. @@ -160,7 +160,7 @@ const char *select_admin_del = "FROM Job,DelCandidates " "WHERE (Job.JobTdate<%s AND delCandidates.JobStatus!='T') OR " "(Job.JobTDate>%s " - "AND Job.ClientId=%u " + "AND Job.ClientId=%u " "AND Job.Type='D')"; @@ -169,7 +169,7 @@ const char *uar_count_files = "SELECT JobFiles FROM Job WHERE JobId=%u"; /* List last 20 Jobs */ -const char *uar_list_jobs = +const char *uar_list_jobs = "SELECT JobId,Client.Name as Client,StartTime,Level as " "JobLevel,JobFiles,JobBytes " "FROM Client,Job WHERE Client.ClientId=Job.ClientId AND JobStatus='T' " @@ -178,7 +178,7 @@ const char *uar_list_jobs = #ifdef HAVE_MYSQL /* MYSQL IS NOT STANDARD SQL !!!!! */ /* List Jobs where a particular file is saved */ -const char *uar_file = +const char *uar_file = "SELECT Job.JobId as JobId, Client.Name as Client, " "CONCAT(Path.Path,Filename.Name) as Name, " "StartTime,Type as JobType,JobFiles,JobBytes " @@ -188,7 +188,7 @@ const char *uar_file = "AND Filename.Name='%s' ORDER BY StartTime DESC LIMIT 20"; #else /* List Jobs where a particular file is saved */ -const char *uar_file = +const char *uar_file = "SELECT Job.JobId as JobId, Client.Name as Client, " "Path.Path||Filename.Name as Name, " "StartTime,Type as JobType,JobFiles,JobBytes " @@ -203,7 +203,7 @@ const char *uar_file = * Find all files for a particular JobId and insert them into * the tree during a restore. */ -const char *uar_sel_files = +const char *uar_sel_files = "SELECT Path.Path,Filename.Name,FileIndex,JobId,LStat " "FROM File,Filename,Path " "WHERE File.JobId=%u AND Filename.FilenameId=File.FilenameId " @@ -212,7 +212,7 @@ const char *uar_sel_files = const char *uar_del_temp = "DROP TABLE temp"; const char *uar_del_temp1 = "DROP TABLE temp1"; -const char *uar_create_temp = +const char *uar_create_temp = "CREATE TABLE temp (" #ifdef HAVE_POSTGRESQL "JobId INTEGER NOT NULL," @@ -238,7 +238,7 @@ const char *uar_create_temp = "VolSessionTime INTEGER UNSIGNED)"; #endif -const char *uar_create_temp1 = +const char *uar_create_temp1 = "CREATE TABLE temp1 (" #ifdef HAVE_POSTGRESQL "JobId INTEGER NOT NULL," @@ -261,8 +261,8 @@ const char *uar_last_full = "%s" "ORDER BY Job.JobTDate DESC LIMIT 1"; -const char *uar_full = - "INSERT INTO temp SELECT Job.JobId,Job.JobTDate," +const char *uar_full = + "INSERT INTO temp SELECT Job.JobId,Job.JobTDate," " Job.ClientId,Job.Level,Job.JobFiles," " StartTime,VolumeName,JobMedia.StartFile,VolSessionId,VolSessionTime " "FROM temp1,Job,JobMedia,Media WHERE temp1.JobId=Job.JobId " @@ -270,7 +270,7 @@ const char *uar_full = "AND JobMedia.JobId=Job.JobId " "AND JobMedia.MediaId=Media.MediaId"; -const char *uar_dif = +const char *uar_dif = "INSERT INTO temp SELECT Job.JobId,Job.JobTDate,Job.ClientId," "Job.Level,Job.JobFiles,Job.StartTime,Media.VolumeName,JobMedia.StartFile," "Job.VolSessionId,Job.VolSessionTime " @@ -282,7 +282,7 @@ const char *uar_dif = "AND Job.Level='D' AND JobStatus='T' " "AND Job.FileSetId=FileSet.FileSetId " "AND FileSet.FileSet='%s' " - "%s" + "%s" "ORDER BY Job.JobTDate DESC LIMIT 1"; const char *uar_inc = @@ -299,7 +299,7 @@ const char *uar_inc = "AND FileSet.FileSet='%s' " "%s"; -const char *uar_list_temp = +const char *uar_list_temp = "SELECT JobId,Level,JobFiles,StartTime,VolumeName,StartFile," "VolSessionId,VolSessionTime FROM temp " "ORDER BY StartTime ASC"; @@ -314,7 +314,7 @@ const char *uar_sel_all_temp = "SELECT * FROM temp"; /* Select FileSet names for this Client */ -const char *uar_sel_fileset = +const char *uar_sel_fileset = "SELECT DISTINCT FileSet.FileSet FROM Job," "Client,FileSet WHERE Job.FileSetId=FileSet.FileSetId " "AND Job.ClientId=%u AND Client.ClientId=%u " @@ -325,11 +325,11 @@ const char *uar_mediatype = "SELECT MediaType FROM JobMedia,Media WHERE JobMedia.JobId=%u " "AND JobMedia.MediaId=Media.MediaId"; -/* - * Find JobId, FileIndex for a given path/file and date +/* + * Find JobId, FileIndex for a given path/file and date * for use when inserting individual files into the tree. */ -const char *uar_jobid_fileindex = +const char *uar_jobid_fileindex = "SELECT Job.JobId, File.FileIndex FROM Job,File,Path,Filename,Client " "WHERE Job.JobId=File.JobId " "AND Job.StartTime<'%s' " @@ -341,7 +341,7 @@ const char *uar_jobid_fileindex = "AND Filename.FilenameId=File.FilenameId " "ORDER BY Job.StartTime DESC LIMIT 1"; -const char *uar_jobids_fileindex = +const char *uar_jobids_fileindex = "SELECT Job.JobId, File.FileIndex FROM Job,File,Path,Filename,Client " "WHERE Job.JobId IN (%s) " "AND Job.JobId=File.JobId " diff --git a/bacula/src/dird/ua.h b/bacula/src/dird/ua.h index ac3b02dbea..0c07a1c872 100644 --- a/bacula/src/dird/ua.h +++ b/bacula/src/dird/ua.h @@ -51,7 +51,7 @@ struct UAContext { bool batch; /* set for non-interactive mode */ uint32_t pint32_val; /* positive integer */ int32_t int32_val; /* positive/negative */ -}; +}; /* Context for insert_tree_handler() */ struct TREE_CTX { diff --git a/bacula/src/dird/ua_acl.c b/bacula/src/dird/ua_acl.c index cb184a0a88..ce70394075 100644 --- a/bacula/src/dird/ua_acl.c +++ b/bacula/src/dird/ua_acl.c @@ -2,7 +2,7 @@ * * Bacula Director -- User Agent Access Control List (ACL) handling * - * Kern Sibbald, January MMIV + * Kern Sibbald, January MMIV * * Version $Id$ */ @@ -30,8 +30,8 @@ #include "bacula.h" #include "dird.h" -/* - * Check if access is permitted to item in acl +/* + * Check if access is permitted to item in acl */ bool acl_access_ok(UAContext *ua, int acl, char *item) { @@ -61,7 +61,7 @@ bool acl_access_ok(UAContext *ua, int acl, char *item, int len) /* Search list for item */ for (int i=0; isize(); i++) { if (strncasecmp(item, (char *)list->get(i), len) == 0) { - Dmsg3(400, "Found %s in %d %s\n", item, acl, (char *)list->get(i)); + Dmsg3(400, "Found %s in %d %s\n", item, acl, (char *)list->get(i)); return true; } } diff --git a/bacula/src/dird/ua_cmds.c b/bacula/src/dird/ua_cmds.c index 3ef87610c3..3a5b0f03fb 100644 --- a/bacula/src/dird/ua_cmds.c +++ b/bacula/src/dird/ua_cmds.c @@ -61,9 +61,9 @@ extern int relabel_cmd(UAContext *ua, const char *cmd); extern int update_slots(UAContext *ua); /* ua_label.c */ /* Forward referenced functions */ -static int add_cmd(UAContext *ua, const char *cmd); -static int create_cmd(UAContext *ua, const char *cmd); -static int cancel_cmd(UAContext *ua, const char *cmd); +static int add_cmd(UAContext *ua, const char *cmd); +static int create_cmd(UAContext *ua, const char *cmd); +static int cancel_cmd(UAContext *ua, const char *cmd); static int setdebug_cmd(UAContext *ua, const char *cmd); static int trace_cmd(UAContext *ua, const char *cmd); static int var_cmd(UAContext *ua, const char *cmd); @@ -94,14 +94,14 @@ int qhelp_cmd(UAContext *ua, const char *cmd); int quit_cmd(UAContext *ua, const char *cmd); -struct cmdstruct { const char *key; int (*func)(UAContext *ua, const char *cmd); const char *help; }; +struct cmdstruct { const char *key; int (*func)(UAContext *ua, const char *cmd); const char *help; }; static struct cmdstruct commands[] = { { N_("add"), add_cmd, _("add media to a pool")}, { N_("autodisplay"), autodisplay_cmd, _("autodisplay [on/off] -- console messages")}, { N_("automount"), automount_cmd, _("automount [on/off] -- after label")}, { N_("cancel"), cancel_cmd, _("cancel job=nnn -- cancel a job")}, - { N_("create"), create_cmd, _("create DB Pool from resource")}, - { N_("delete"), delete_cmd, _("delete [pool= | media volume=]")}, + { N_("create"), create_cmd, _("create DB Pool from resource")}, + { N_("delete"), delete_cmd, _("delete [pool= | media volume=]")}, { N_("estimate"), estimate_cmd, _("performs FileSet estimate, listing gives full listing")}, { N_("exit"), quit_cmd, _("exit = quit")}, { N_("gui"), gui_cmd, _("gui [on/off] -- non-interactive gui mode")}, @@ -125,7 +125,7 @@ static struct cmdstruct commands[] = { { N_("setdebug"), setdebug_cmd, _("sets debug level")}, { N_("setip"), setip_cmd, _("sets new client address -- if authorized")}, { N_("show"), show_cmd, _("show (resource records) [jobs | pools | ... | all]")}, - { N_("sqlquery"), sqlquerycmd, _("use SQL to query catalog")}, + { N_("sqlquery"), sqlquerycmd, _("use SQL to query catalog")}, { N_("time"), time_cmd, _("print current time")}, { N_("trace"), trace_cmd, _("turn on/off trace to file")}, { N_("unmount"), unmount_cmd, _("unmount ")}, @@ -173,7 +173,7 @@ int do_a_command(UAContext *ua, const char *cmd) /* * This is a common routine used to stuff the Pool DB record defaults - * into the Media DB record just before creating a media (Volume) + * into the Media DB record just before creating a media (Volume) * record. */ void set_pool_dbr_defaults_in_media_dbr(MEDIA_DBR *mr, POOL_DBR *pr) @@ -192,7 +192,7 @@ void set_pool_dbr_defaults_in_media_dbr(MEDIA_DBR *mr, POOL_DBR *pr) /* * Add Volumes to an existing Pool */ -static int add_cmd(UAContext *ua, const char *cmd) +static int add_cmd(UAContext *ua, const char *cmd) { POOL_DBR pr; MEDIA_DBR mr; @@ -224,7 +224,7 @@ static int add_cmd(UAContext *ua, const char *cmd) while (pr.MaxVols > 0 && pr.NumVols >= pr.MaxVols) { bsendmsg(ua, _("Pool already has maximum volumes = %d\n"), pr.MaxVols); for (;;) { - if (!get_pint(ua, _("Enter new maximum (zero for unlimited): "))) { + if (!get_pint(ua, _("Enter new maximum (zero for unlimited): "))) { return 1; } pr.MaxVols = ua->pint32_val; @@ -237,21 +237,21 @@ static int add_cmd(UAContext *ua, const char *cmd) } else if (!get_media_type(ua, mr.MediaType, sizeof(mr.MediaType))) { return 1; } - + if (pr.MaxVols == 0) { max = 1000; } else { max = pr.MaxVols - pr.NumVols; } for (;;) { - char buf[100]; + char buf[100]; bsnprintf(buf, sizeof(buf), _("Enter number of Volumes to create. 0=>fixed name. Max=%d: "), max); if (!get_pint(ua, buf)) { return 1; } num = ua->pint32_val; if (num < 0 || num > max) { - bsendmsg(ua, _("The number must be between 0 and %d\n"), max); + bsendmsg(ua, _("The number must be between 0 and %d\n"), max); continue; } break; @@ -284,12 +284,12 @@ getVolName: strcat(name, "%04d"); for (;;) { - if (!get_pint(ua, _("Enter the starting number: "))) { + if (!get_pint(ua, _("Enter the starting number: "))) { return 1; } startnum = ua->pint32_val; if (startnum < 1) { - bsendmsg(ua, _("Start number must be greater than zero.\n")); + bsendmsg(ua, _("Start number must be greater than zero.\n")); continue; } break; @@ -309,15 +309,15 @@ getVolName: } InChanger = ua->pint32_val; } - + set_pool_dbr_defaults_in_media_dbr(&mr, &pr); - for (i=startnum; i < num+startnum; i++) { + for (i=startnum; i < num+startnum; i++) { bsnprintf(mr.VolumeName, sizeof(mr.VolumeName), name, i); mr.Slot = Slot++; mr.InChanger = InChanger; Dmsg1(200, "Create Volume %s\n", mr.VolumeName); if (!db_create_media_record(ua->jcr, ua->db, &mr)) { - bsendmsg(ua, "%s", db_strerror(ua->db)); + bsendmsg(ua, "%s", db_strerror(ua->db)); return 1; } if (i == startnum) { @@ -325,7 +325,7 @@ getVolName: } } pr.NumVols += num; - Dmsg0(200, "Update pool record.\n"); + Dmsg0(200, "Update pool record.\n"); if (db_update_pool_record(ua->jcr, ua->db, &pr) != 1) { bsendmsg(ua, "%s", db_strerror(ua->db)); return 1; @@ -336,9 +336,9 @@ getVolName: } /* - * Turn auto mount on/off - * - * automount on + * Turn auto mount on/off + * + * automount on * automount off */ int automount_cmd(UAContext *ua, const char *cmd) @@ -355,7 +355,7 @@ int automount_cmd(UAContext *ua, const char *cmd) } ua->automount = (strcasecmp(onoff, _("off")) == 0) ? 0 : 1; - return 1; + return 1; } @@ -381,7 +381,7 @@ static int cancel_cmd(UAContext *ua, const char *cmd) } JobId = str_to_int64(ua->argv[i]); if (!(jcr=get_jcr_by_id(JobId))) { - bsendmsg(ua, _("JobId %d is not running.\n"), JobId); + bsendmsg(ua, _("JobId %d is not running.\n"), JobId); return 1; } break; @@ -390,7 +390,7 @@ static int cancel_cmd(UAContext *ua, const char *cmd) break; } if (!(jcr=get_jcr_by_partial_name(ua->argv[i]))) { - bsendmsg(ua, _("Job %s is not running.\n"), ua->argv[i]); + bsendmsg(ua, _("Job %s is not running.\n"), ua->argv[i]); return 1; } break; @@ -413,7 +413,7 @@ static int cancel_cmd(UAContext *ua, const char *cmd) unlock_jcr_chain(); if (njobs == 0) { - bsendmsg(ua, _("No Jobs running.\n")); + bsendmsg(ua, _("No Jobs running.\n")); return 1; } start_prompt(ua, _("Select Job:\n")); @@ -432,14 +432,14 @@ static int cancel_cmd(UAContext *ua, const char *cmd) return 1; } if (njobs == 1) { - if (!get_yesno(ua, _("Confirm cancel (yes/no): ")) || ua->pint32_val == 0) { + if (!get_yesno(ua, _("Confirm cancel (yes/no): ")) || ua->pint32_val == 0) { return 1; } } /* NOTE! This increments the ref_count */ jcr = get_jcr_by_full_name(JobName); if (!jcr) { - bsendmsg(ua, _("Job %s not found.\n"), JobName); + bsendmsg(ua, _("Job %s not found.\n"), JobName); return 1; } } @@ -529,7 +529,7 @@ int create_pool(JCR *jcr, B_DB *db, POOL *pool, e_pool_op op) * Create a Pool Record in the database. * It is always created from the Resource record. */ -static int create_cmd(UAContext *ua, const char *cmd) +static int create_cmd(UAContext *ua, const char *cmd) { POOL *pool; @@ -545,7 +545,7 @@ static int create_cmd(UAContext *ua, const char *cmd) switch (create_pool(ua->jcr, ua->db, pool, POOL_OP_CREATE)) { case 0: bsendmsg(ua, _("Error: Pool %s already exists.\n" - "Use update to change it.\n"), pool->hdr.name); + "Use update to change it.\n"), pool->hdr.name); break; case -1: @@ -571,7 +571,7 @@ static int python_cmd(UAContext *ua, const char *cmd) if (strcasecmp(ua->argk[1], _("restart")) == 0) { term_python_interpreter(); init_python_interpreter(director->hdr.name, director->scripts_directory ? - director->scripts_directory : "."); + director->scripts_directory : "."); bsendmsg(ua, _("Python interpreter restarted.\n")); } else { bsendmsg(ua, _("Nothing done.\n")); @@ -582,13 +582,13 @@ static int python_cmd(UAContext *ua, const char *cmd) /* * Set a new address in a Client resource. We do this only - * if the Console name is the same as the Client name + * if the Console name is the same as the Client name * and the Console can access the client. */ -static int setip_cmd(UAContext *ua, const char *cmd) +static int setip_cmd(UAContext *ua, const char *cmd) { CLIENT *client; - char buf[1024]; + char buf[1024]; if (!ua->cons || !acl_access_ok(ua, Client_ACL, ua->cons->hdr.name)) { bsendmsg(ua, _("Illegal command from this console.\n")); return 1; @@ -604,7 +604,7 @@ static int setip_cmd(UAContext *ua, const char *cmd) free(client->address); } /* MA Bug 6 remove ifdef */ - sockaddr_to_ascii(&(ua->UA_sock->client_addr), buf, sizeof(buf)); + sockaddr_to_ascii(&(ua->UA_sock->client_addr), buf, sizeof(buf)); client->address = bstrdup(buf); bsendmsg(ua, _("Client \"%s\" address set to %s\n"), client->hdr.name, client->address); @@ -625,7 +625,7 @@ get_out: * update slots [scan=...] * updates autochanger slots */ -static int update_cmd(UAContext *ua, const char *cmd) +static int update_cmd(UAContext *ua, const char *cmd) { static const char *kw[] = { N_("media"), /* 0 */ @@ -652,7 +652,7 @@ static int update_cmd(UAContext *ua, const char *cmd) default: break; } - + start_prompt(ua, _("Update choice:\n")); add_prompt(ua, _("Volume parameters")); add_prompt(ua, _("Pool from resource")); @@ -681,8 +681,8 @@ static void update_volstatus(UAContext *ua, const char *val, MEDIA_DBR *mr) "Archive", "Disabled", "Full", - "Used", - "Cleaning", + "Used", + "Cleaning", "Recycle", "Read-Only", NULL}; @@ -701,10 +701,10 @@ static void update_volstatus(UAContext *ua, const char *val, MEDIA_DBR *mr) bstrncpy(mr->VolStatus, kw[i], sizeof(mr->VolStatus)); Mmsg(query, "UPDATE Media SET VolStatus='%s' WHERE MediaId=%u", mr->VolStatus, mr->MediaId); - if (!db_sql_query(ua->db, query, NULL, NULL)) { - bsendmsg(ua, "%s", db_strerror(ua->db)); + if (!db_sql_query(ua->db, query, NULL, NULL)) { + bsendmsg(ua, "%s", db_strerror(ua->db)); } else { - bsendmsg(ua, _("New Volume status is: %s\n"), mr->VolStatus); + bsendmsg(ua, _("New Volume status is: %s\n"), mr->VolStatus); } } free_pool_memory(query); @@ -721,7 +721,7 @@ static void update_volretention(UAContext *ua, char *val, MEDIA_DBR *mr) query = get_pool_memory(PM_MESSAGE); Mmsg(query, "UPDATE Media SET VolRetention=%s WHERE MediaId=%u", edit_uint64(mr->VolRetention, ed1), mr->MediaId); - if (!db_sql_query(ua->db, query, NULL, NULL)) { + if (!db_sql_query(ua->db, query, NULL, NULL)) { bsendmsg(ua, "%s", db_strerror(ua->db)); } else { bsendmsg(ua, _("New retention period is: %s\n"), @@ -742,7 +742,7 @@ static void update_voluseduration(UAContext *ua, char *val, MEDIA_DBR *mr) query = get_pool_memory(PM_MESSAGE); Mmsg(query, "UPDATE Media SET VolUseDuration=%s WHERE MediaId=%u", edit_uint64(mr->VolUseDuration, ed1), mr->MediaId); - if (!db_sql_query(ua->db, query, NULL, NULL)) { + if (!db_sql_query(ua->db, query, NULL, NULL)) { bsendmsg(ua, "%s", db_strerror(ua->db)); } else { bsendmsg(ua, _("New use duration is: %s\n"), @@ -756,7 +756,7 @@ static void update_volmaxjobs(UAContext *ua, char *val, MEDIA_DBR *mr) POOLMEM *query = get_pool_memory(PM_MESSAGE); Mmsg(query, "UPDATE Media SET MaxVolJobs=%s WHERE MediaId=%u", val, mr->MediaId); - if (!db_sql_query(ua->db, query, NULL, NULL)) { + if (!db_sql_query(ua->db, query, NULL, NULL)) { bsendmsg(ua, "%s", db_strerror(ua->db)); } else { bsendmsg(ua, _("New max jobs is: %s\n"), val); @@ -769,7 +769,7 @@ static void update_volmaxfiles(UAContext *ua, char *val, MEDIA_DBR *mr) POOLMEM *query = get_pool_memory(PM_MESSAGE); Mmsg(query, "UPDATE Media SET MaxVolFiles=%s WHERE MediaId=%u", val, mr->MediaId); - if (!db_sql_query(ua->db, query, NULL, NULL)) { + if (!db_sql_query(ua->db, query, NULL, NULL)) { bsendmsg(ua, "%s", db_strerror(ua->db)); } else { bsendmsg(ua, _("New max files is: %s\n"), val); @@ -786,11 +786,11 @@ static void update_volmaxbytes(UAContext *ua, char *val, MEDIA_DBR *mr) if (!size_to_uint64(val, strlen(val), &maxbytes)) { bsendmsg(ua, _("Invalid max. bytes specification: %s\n"), val); return; - } + } query = get_pool_memory(PM_MESSAGE); Mmsg(query, "UPDATE Media SET MaxVolBytes=%s WHERE MediaId=%u", edit_uint64(maxbytes, ed1), mr->MediaId); - if (!db_sql_query(ua->db, query, NULL, NULL)) { + if (!db_sql_query(ua->db, query, NULL, NULL)) { bsendmsg(ua, "%s", db_strerror(ua->db)); } else { bsendmsg(ua, _("New Max bytes is: %s\n"), edit_uint64(maxbytes, ed1)); @@ -813,11 +813,11 @@ static void update_volrecycle(UAContext *ua, char *val, MEDIA_DBR *mr) query = get_pool_memory(PM_MESSAGE); Mmsg(query, "UPDATE Media SET Recycle=%d WHERE MediaId=%u", recycle, mr->MediaId); - if (!db_sql_query(ua->db, query, NULL, NULL)) { + if (!db_sql_query(ua->db, query, NULL, NULL)) { bsendmsg(ua, "%s", db_strerror(ua->db)); - } else { + } else { bsendmsg(ua, _("New Recycle flag is: %s\n"), - mr->Recycle==1?_("yes"):_("no")); + mr->Recycle==1?_("yes"):_("no")); } free_pool_memory(query); } @@ -840,17 +840,17 @@ static void update_vol_pool(UAContext *ua, char *val, MEDIA_DBR *mr, POOL_DBR *o db_lock(ua->db); Mmsg(query, "UPDATE Media SET PoolId=%d WHERE MediaId=%u", mr->PoolId, mr->MediaId); - if (!db_sql_query(ua->db, query, NULL, NULL)) { + if (!db_sql_query(ua->db, query, NULL, NULL)) { bsendmsg(ua, "%s", db_strerror(ua->db)); - } else { + } else { bsendmsg(ua, _("New Pool is: %s\n"), pr.Name); opr->NumVols--; if (!db_update_pool_record(ua->jcr, ua->db, opr)) { - bsendmsg(ua, "%s", db_strerror(ua->db)); + bsendmsg(ua, "%s", db_strerror(ua->db)); } pr.NumVols++; if (!db_update_pool_record(ua->jcr, ua->db, &pr)) { - bsendmsg(ua, "%s", db_strerror(ua->db)); + bsendmsg(ua, "%s", db_strerror(ua->db)); } db_make_inchanger_unique(ua->jcr, ua->db, mr); } @@ -909,7 +909,7 @@ static void update_all_vols_from_pool(UAContext *ua) * Volume status. E.g. if you want Bacula to stop * writing on the volume, set it to anything other * than Append. - */ + */ static int update_volume(UAContext *ua) { MEDIA_DBR mr; @@ -963,7 +963,7 @@ static int update_volume(UAContext *ua) memset(&pr, 0, sizeof(POOL_DBR)); pr.PoolId = mr.PoolId; if (!db_get_pool_record(ua->jcr, ua->db, &pr)) { - bsendmsg(ua, "%s", db_strerror(ua->db)); + bsendmsg(ua, "%s", db_strerror(ua->db)); break; } update_vol_pool(ua, ua->argv[j], &mr, &pr); @@ -1002,60 +1002,60 @@ static int update_volume(UAContext *ua) switch (do_prompt(ua, "", _("Select parameter to modify"), NULL, 0)) { case 0: /* Volume Status */ /* Modify Volume Status */ - bsendmsg(ua, _("Current Volume status is: %s\n"), mr.VolStatus); - start_prompt(ua, _("Possible Values are:\n")); - add_prompt(ua, "Append"); /* Better not translate these as */ - add_prompt(ua, "Archive"); /* They are known in the database code */ - add_prompt(ua, "Disabled"); - add_prompt(ua, "Full"); - add_prompt(ua, "Used"); - add_prompt(ua, "Cleaning"); - if (strcmp(mr.VolStatus, "Purged") == 0) { - add_prompt(ua, "Recycle"); + bsendmsg(ua, _("Current Volume status is: %s\n"), mr.VolStatus); + start_prompt(ua, _("Possible Values are:\n")); + add_prompt(ua, "Append"); /* Better not translate these as */ + add_prompt(ua, "Archive"); /* They are known in the database code */ + add_prompt(ua, "Disabled"); + add_prompt(ua, "Full"); + add_prompt(ua, "Used"); + add_prompt(ua, "Cleaning"); + if (strcmp(mr.VolStatus, "Purged") == 0) { + add_prompt(ua, "Recycle"); } - add_prompt(ua, "Read-Only"); - if (do_prompt(ua, "", _("Choose new Volume Status"), ua->cmd, sizeof(mr.VolStatus)) < 0) { + add_prompt(ua, "Read-Only"); + if (do_prompt(ua, "", _("Choose new Volume Status"), ua->cmd, sizeof(mr.VolStatus)) < 0) { return 1; } update_volstatus(ua, ua->cmd, &mr); break; case 1: /* Retention */ - bsendmsg(ua, _("Current retention period is: %s\n"), + bsendmsg(ua, _("Current retention period is: %s\n"), edit_utime(mr.VolRetention, ed1, sizeof(ed1))); - if (!get_cmd(ua, _("Enter Volume Retention period: "))) { + if (!get_cmd(ua, _("Enter Volume Retention period: "))) { return 0; } update_volretention(ua, ua->cmd, &mr); break; case 2: /* Use Duration */ - bsendmsg(ua, _("Current use duration is: %s\n"), + bsendmsg(ua, _("Current use duration is: %s\n"), edit_utime(mr.VolUseDuration, ed1, sizeof(ed1))); - if (!get_cmd(ua, _("Enter Volume Use Duration: "))) { + if (!get_cmd(ua, _("Enter Volume Use Duration: "))) { return 0; } update_voluseduration(ua, ua->cmd, &mr); break; case 3: /* Max Jobs */ - bsendmsg(ua, _("Current max jobs is: %u\n"), mr.MaxVolJobs); - if (!get_pint(ua, _("Enter new Maximum Jobs: "))) { + bsendmsg(ua, _("Current max jobs is: %u\n"), mr.MaxVolJobs); + if (!get_pint(ua, _("Enter new Maximum Jobs: "))) { return 0; } update_volmaxjobs(ua, ua->cmd, &mr); break; case 4: /* Max Files */ - bsendmsg(ua, _("Current max files is: %u\n"), mr.MaxVolFiles); - if (!get_pint(ua, _("Enter new Maximum Files: "))) { + bsendmsg(ua, _("Current max files is: %u\n"), mr.MaxVolFiles); + if (!get_pint(ua, _("Enter new Maximum Files: "))) { return 0; } update_volmaxfiles(ua, ua->cmd, &mr); break; case 5: /* Max Bytes */ - bsendmsg(ua, _("Current value is: %s\n"), edit_uint64(mr.MaxVolBytes, ed1)); - if (!get_cmd(ua, _("Enter new Maximum Bytes: "))) { + bsendmsg(ua, _("Current value is: %s\n"), edit_uint64(mr.MaxVolBytes, ed1)); + if (!get_cmd(ua, _("Enter new Maximum Bytes: "))) { return 0; } update_volmaxbytes(ua, ua->cmd, &mr); @@ -1063,9 +1063,9 @@ static int update_volume(UAContext *ua) case 6: /* Recycle */ - bsendmsg(ua, _("Current recycle flag is: %s\n"), - mr.Recycle==1?_("yes"):_("no")); - if (!get_yesno(ua, _("Enter new Recycle status: "))) { + bsendmsg(ua, _("Current recycle flag is: %s\n"), + mr.Recycle==1?_("yes"):_("no")); + if (!get_yesno(ua, _("Enter new Recycle status: "))) { return 0; } update_volrecycle(ua, ua->cmd, &mr); @@ -1077,71 +1077,71 @@ static int update_volume(UAContext *ua) memset(&pr, 0, sizeof(POOL_DBR)); pr.PoolId = mr.PoolId; if (!db_get_pool_record(ua->jcr, ua->db, &pr)) { - bsendmsg(ua, "%s", db_strerror(ua->db)); + bsendmsg(ua, "%s", db_strerror(ua->db)); return 0; } - bsendmsg(ua, _("Current Slot is: %d\n"), mr.Slot); - if (!get_pint(ua, _("Enter new Slot: "))) { + bsendmsg(ua, _("Current Slot is: %d\n"), mr.Slot); + if (!get_pint(ua, _("Enter new Slot: "))) { return 0; } Slot = ua->pint32_val; if (pr.MaxVols > 0 && Slot > (int)pr.MaxVols) { - bsendmsg(ua, _("Invalid slot, it must be between 0 and %d\n"), + bsendmsg(ua, _("Invalid slot, it must be between 0 and %d\n"), pr.MaxVols); break; } mr.Slot = Slot; /* * Make sure to use db_update... rather than doing this directly, - * so that any Slot is handled correctly. + * so that any Slot is handled correctly. */ if (!db_update_media_record(ua->jcr, ua->db, &mr)) { - bsendmsg(ua, _("Error updating media record Slot: ERR=%s"), db_strerror(ua->db)); + bsendmsg(ua, _("Error updating media record Slot: ERR=%s"), db_strerror(ua->db)); } else { - bsendmsg(ua, _("New Slot is: %d\n"), mr.Slot); + bsendmsg(ua, _("New Slot is: %d\n"), mr.Slot); } break; case 8: /* InChanger */ - bsendmsg(ua, _("Current InChanger flag is: %d\n"), mr.InChanger); - if (!get_yesno(ua, _("Set InChanger flag? yes/no: "))) { + bsendmsg(ua, _("Current InChanger flag is: %d\n"), mr.InChanger); + if (!get_yesno(ua, _("Set InChanger flag? yes/no: "))) { return 0; } mr.InChanger = ua->pint32_val; /* * Make sure to use db_update... rather than doing this directly, - * so that any Slot is handled correctly. + * so that any Slot is handled correctly. */ if (!db_update_media_record(ua->jcr, ua->db, &mr)) { - bsendmsg(ua, _("Error updating media record Slot: ERR=%s"), db_strerror(ua->db)); + bsendmsg(ua, _("Error updating media record Slot: ERR=%s"), db_strerror(ua->db)); } else { - bsendmsg(ua, _("New InChanger flag is: %d\n"), mr.InChanger); + bsendmsg(ua, _("New InChanger flag is: %d\n"), mr.InChanger); } break; case 9: /* Volume Files */ int32_t VolFiles; - bsendmsg(ua, _("Warning changing Volume Files can result\n" - "in loss of data on your Volume\n\n")); - bsendmsg(ua, _("Current Volume Files is: %u\n"), mr.VolFiles); - if (!get_pint(ua, _("Enter new number of Files for Volume: "))) { + bsendmsg(ua, _("Warning changing Volume Files can result\n" + "in loss of data on your Volume\n\n")); + bsendmsg(ua, _("Current Volume Files is: %u\n"), mr.VolFiles); + if (!get_pint(ua, _("Enter new number of Files for Volume: "))) { return 0; } VolFiles = ua->pint32_val; if (VolFiles != (int)(mr.VolFiles + 1)) { - bsendmsg(ua, _("Normally, you should only increase Volume Files by one!\n")); - if (!get_yesno(ua, _("Continue? (yes/no): ")) || ua->pint32_val == 0) { + bsendmsg(ua, _("Normally, you should only increase Volume Files by one!\n")); + if (!get_yesno(ua, _("Continue? (yes/no): ")) || ua->pint32_val == 0) { break; } } query = get_pool_memory(PM_MESSAGE); - Mmsg(query, "UPDATE Media SET VolFiles=%u WHERE MediaId=%u", + Mmsg(query, "UPDATE Media SET VolFiles=%u WHERE MediaId=%u", VolFiles, mr.MediaId); - if (!db_sql_query(ua->db, query, NULL, NULL)) { - bsendmsg(ua, "%s", db_strerror(ua->db)); + if (!db_sql_query(ua->db, query, NULL, NULL)) { + bsendmsg(ua, "%s", db_strerror(ua->db)); } else { - bsendmsg(ua, _("New Volume Files is: %u\n"), VolFiles); + bsendmsg(ua, _("New Volume Files is: %u\n"), VolFiles); } free_pool_memory(query); break; @@ -1150,11 +1150,11 @@ static int update_volume(UAContext *ua) memset(&pr, 0, sizeof(POOL_DBR)); pr.PoolId = mr.PoolId; if (!db_get_pool_record(ua->jcr, ua->db, &pr)) { - bsendmsg(ua, "%s", db_strerror(ua->db)); + bsendmsg(ua, "%s", db_strerror(ua->db)); return 0; } - bsendmsg(ua, _("Current Pool is: %s\n"), pr.Name); - if (!get_cmd(ua, _("Enter new Pool name: "))) { + bsendmsg(ua, _("Current Pool is: %s\n"), pr.Name); + if (!get_cmd(ua, _("Enter new Pool name: "))) { return 0; } update_vol_pool(ua, ua->cmd, &mr, &pr); @@ -1167,14 +1167,14 @@ static int update_volume(UAContext *ua) update_all_vols_from_pool(ua); return 1; default: /* Done or error */ - bsendmsg(ua, "Selection done.\n"); + bsendmsg(ua, "Selection done.\n"); return 1; } } return 1; } -/* +/* * Update pool record -- pull info from current POOL resource */ static int update_pool(UAContext *ua) @@ -1182,8 +1182,8 @@ static int update_pool(UAContext *ua) POOL_DBR pr; int id; POOL *pool; - POOLMEM *query; - + POOLMEM *query; + pool = get_pool_resource(ua); if (!pool) { return 0; @@ -1218,7 +1218,7 @@ static void do_storage_setdebug(UAContext *ua, STORE *store, int level, int trac set_storage(jcr, store); /* Try connecting for up to 15 seconds */ - bsendmsg(ua, _("Connecting to Storage daemon %s at %s:%d\n"), + bsendmsg(ua, _("Connecting to Storage daemon %s at %s:%d\n"), store->hdr.name, store->address, store->SDport); if (!connect_to_storage_daemon(jcr, 1, 15, 0)) { bsendmsg(ua, _("Failed to connect to Storage daemon.\n")); @@ -1233,9 +1233,9 @@ static void do_storage_setdebug(UAContext *ua, STORE *store, int level, int trac bnet_sig(sd, BNET_TERMINATE); bnet_close(sd); jcr->store_bsock = NULL; - return; + return; } - + static void do_client_setdebug(UAContext *ua, CLIENT *client, int level, int trace_flag) { BSOCK *fd; @@ -1244,7 +1244,7 @@ static void do_client_setdebug(UAContext *ua, CLIENT *client, int level, int tra ua->jcr->client = client; /* Try to connect for 15 seconds */ - bsendmsg(ua, _("Connecting to Client %s at %s:%d\n"), + bsendmsg(ua, _("Connecting to Client %s at %s:%d\n"), client->hdr.name, client->address, client->FDport); if (!connect_to_file_daemon(ua->jcr, 1, 15, 0)) { bsendmsg(ua, _("Failed to connect to Client.\n")); @@ -1259,7 +1259,7 @@ static void do_client_setdebug(UAContext *ua, CLIENT *client, int level, int tra bnet_sig(fd, BNET_TERMINATE); bnet_close(fd); ua->jcr->file_bsock = NULL; - return; + return; } @@ -1280,7 +1280,7 @@ static void do_all_setdebug(UAContext *ua, int level, int trace_flag) i++; } unique_store = (STORE **) malloc(i * sizeof(STORE)); - /* Find Unique Storage address/port */ + /* Find Unique Storage address/port */ store = (STORE *)GetNextRes(R_STORAGE, NULL); i = 0; unique_store[i++] = store; @@ -1295,7 +1295,7 @@ static void do_all_setdebug(UAContext *ua, int level, int trace_flag) } if (!found) { unique_store[i++] = store; - Dmsg2(140, "Stuffing: %s:%d\n", store->address, store->SDport); + Dmsg2(140, "Stuffing: %s:%d\n", store->address, store->SDport); } } UnlockRes(); @@ -1314,7 +1314,7 @@ static void do_all_setdebug(UAContext *ua, int level, int trace_flag) i++; } unique_client = (CLIENT **) malloc(i * sizeof(CLIENT)); - /* Find Unique Client address/port */ + /* Find Unique Client address/port */ client = (CLIENT *)GetNextRes(R_CLIENT, NULL); i = 0; unique_client[i++] = client; @@ -1329,7 +1329,7 @@ static void do_all_setdebug(UAContext *ua, int level, int trace_flag) } if (!found) { unique_client[i++] = client; - Dmsg2(140, "Stuffing: %s:%d\n", client->address, client->FDport); + Dmsg2(140, "Stuffing: %s:%d\n", client->address, client->FDport); } } UnlockRes(); @@ -1385,13 +1385,13 @@ static int setdebug_cmd(UAContext *ua, const char *cmd) return 1; } if (strcasecmp(ua->argk[i], _("dir")) == 0 || - strcasecmp(ua->argk[i], _("director")) == 0) { + strcasecmp(ua->argk[i], _("director")) == 0) { debug_level = level; set_trace(trace_flag); return 1; } if (strcasecmp(ua->argk[i], _("client")) == 0 || - strcasecmp(ua->argk[i], _("fd")) == 0) { + strcasecmp(ua->argk[i], _("fd")) == 0) { client = NULL; if (ua->argv[i]) { client = (CLIENT *)GetResWithName(R_CLIENT, ua->argv[i]); @@ -1400,7 +1400,7 @@ static int setdebug_cmd(UAContext *ua, const char *cmd) return 1; } } - client = select_client_resource(ua); + client = select_client_resource(ua); if (client) { do_client_setdebug(ua, client, level, trace_flag); return 1; @@ -1408,8 +1408,8 @@ static int setdebug_cmd(UAContext *ua, const char *cmd) } if (strcasecmp(ua->argk[i], _("store")) == 0 || - strcasecmp(ua->argk[i], _("storage")) == 0 || - strcasecmp(ua->argk[i], _("sd")) == 0) { + strcasecmp(ua->argk[i], _("storage")) == 0 || + strcasecmp(ua->argk[i], _("sd")) == 0) { store = NULL; if (ua->argv[i]) { store = (STORE *)GetResWithName(R_STORAGE, ua->argv[i]); @@ -1424,7 +1424,7 @@ static int setdebug_cmd(UAContext *ua, const char *cmd) return 1; } } - } + } /* * We didn't find an appropriate keyword above, so * prompt the user. @@ -1477,7 +1477,7 @@ static int trace_cmd(UAContext *ua, const char *cmd) } set_trace((strcasecmp(onoff, _("off")) == 0) ? false : true); - return 1; + return 1; } @@ -1496,7 +1496,7 @@ static int var_cmd(UAContext *ua, const char *cmd) var++; } Dmsg1(100, "Var=%s:\n", var); - variable_expansion(ua->jcr, var, &val); + variable_expansion(ua->jcr, var, &val); bsendmsg(ua, "%s\n", val); free_pool_memory(val); return 1; @@ -1515,7 +1515,7 @@ static int estimate_cmd(UAContext *ua, const char *cmd) jcr->JobLevel = L_FULL; for (int i=1; iargc; i++) { if (strcasecmp(ua->argk[i], _("client")) == 0 || - strcasecmp(ua->argk[i], _("fd")) == 0) { + strcasecmp(ua->argk[i], _("fd")) == 0) { if (ua->argv[i]) { client = (CLIENT *)GetResWithName(R_CLIENT, ua->argv[i]); continue; @@ -1539,11 +1539,11 @@ static int estimate_cmd(UAContext *ua, const char *cmd) } if (strcasecmp(ua->argk[i], _("level")) == 0) { if (!get_level_from_name(ua->jcr, ua->argv[i])) { - bsendmsg(ua, _("Level %s not valid.\n"), ua->argv[i]); + bsendmsg(ua, _("Level %s not valid.\n"), ua->argv[i]); } continue; } - } + } if (!job && !(client && fileset)) { if (!(job = select_job_resource(ua))) { return 1; @@ -1552,7 +1552,7 @@ static int estimate_cmd(UAContext *ua, const char *cmd) if (!job) { job = (JOB *)GetResWithName(R_JOB, ua->argk[1]); if (!job) { - bsendmsg(ua, _("No job specified.\n")); + bsendmsg(ua, _("No job specified.\n")); return 1; } } @@ -1581,7 +1581,7 @@ static int estimate_cmd(UAContext *ua, const char *cmd) if (!get_or_create_fileset_record(jcr, &fsr)) { return 1; } - + get_level_since_time(ua->jcr, since, sizeof(since)); bsendmsg(ua, _("Connecting to Client %s at %s:%d\n"), @@ -1641,7 +1641,7 @@ extern "C" void reload_config(int sig); static int reload_cmd(UAContext *ua, const char *cmd) { - reload_config(1); + reload_config(1); return 1; } @@ -1665,9 +1665,9 @@ static int delete_cmd(UAContext *ua, const char *cmd) return 1; } - switch (find_arg_keyword(ua, keywords)) { + switch (find_arg_keyword(ua, keywords)) { case 0: - delete_volume(ua); + delete_volume(ua); return 1; case 1: delete_pool(ua); @@ -1710,7 +1710,7 @@ static int delete_cmd(UAContext *ua, const char *cmd) * delete_job has been modified to parse JobID lists like the * following: * delete job JobID=3,4,6,7-11,14 - * + * * Thanks to Phil Stracchino for the above addition. */ @@ -1725,32 +1725,32 @@ static void delete_job(UAContext *ua) s = bstrdup(ua->argv[i]); tok = s; /* - * We could use strtok() here. But we're not going to, because: + * We could use strtok() here. But we're not going to, because: * (a) strtok() is deprecated, having been replaced by strsep(); * (b) strtok() is broken in significant ways. - * we could use strsep() instead, but it's not universally available. + * we could use strsep() instead, but it's not universally available. * so we grow our own using strchr(). */ - sep = strchr(tok, ','); + sep = strchr(tok, ','); while (sep != NULL) { - *sep = '\0'; - if (strchr(tok, '-')) { + *sep = '\0'; + if (strchr(tok, '-')) { delete_job_id_range(ua, tok); } else { JobId = str_to_int64(tok); do_job_delete(ua, JobId); } tok = ++sep; - sep = strchr(tok, ','); + sep = strchr(tok, ','); } /* pick up the last token */ - if (strchr(tok, '-')) { + if (strchr(tok, '-')) { delete_job_id_range(ua, tok); } else { JobId = str_to_int64(tok); do_job_delete(ua, JobId); } - + free(s); } else { JobId = str_to_int64(ua->argv[i]); @@ -1802,7 +1802,7 @@ static void do_job_delete(UAContext *ua, JobId_t JobId) } /* - * Delete media records from database -- dangerous + * Delete media records from database -- dangerous */ static int delete_volume(UAContext *ua) { @@ -1825,12 +1825,12 @@ static int delete_volume(UAContext *ua) } /* - * Delete a pool record from the database -- dangerous + * Delete a pool record from the database -- dangerous */ static int delete_pool(UAContext *ua) { POOL_DBR pr; - + memset(&pr, 0, sizeof(pr)); if (!get_pool_dbr(ua, &pr)) { @@ -1937,16 +1937,16 @@ static int use_cmd(UAContext *ua, const char *cmd) return 1; } -int quit_cmd(UAContext *ua, const char *cmd) +int quit_cmd(UAContext *ua, const char *cmd) { ua->quit = TRUE; return 1; } /* - * Wait until no job is running + * Wait until no job is running */ -int wait_cmd(UAContext *ua, const char *cmd) +int wait_cmd(UAContext *ua, const char *cmd) { JCR *jcr; bmicrosleep(0, 200000); /* let job actually start */ @@ -2012,11 +2012,11 @@ int open_db(UAContext *ua) LockRes(); ua->catalog = (CAT *)GetNextRes(R_CATALOG, NULL); UnlockRes(); - if (!ua->catalog) { - bsendmsg(ua, _("Could not find a Catalog resource\n")); + if (!ua->catalog) { + bsendmsg(ua, _("Could not find a Catalog resource\n")); return 0; } else { - bsendmsg(ua, _("Using default Catalog name=%s DB=%s\n"), + bsendmsg(ua, _("Using default Catalog name=%s DB=%s\n"), ua->catalog->hdr.name, ua->catalog->db_name); } } @@ -2032,7 +2032,7 @@ int open_db(UAContext *ua) bsendmsg(ua, _("Could not open database \"%s\".\n"), ua->catalog->db_name); if (ua->db) { - bsendmsg(ua, "%s", db_strerror(ua->db)); + bsendmsg(ua, "%s", db_strerror(ua->db)); } close_db(ua); return 0; diff --git a/bacula/src/dird/ua_dotcmds.c b/bacula/src/dird/ua_dotcmds.c index 291613ccb7..aa18973a42 100644 --- a/bacula/src/dird/ua_dotcmds.c +++ b/bacula/src/dird/ua_dotcmds.c @@ -60,7 +60,7 @@ static int typescmd(UAContext *ua, const char *cmd); static int backupscmd(UAContext *ua, const char *cmd); static int levelscmd(UAContext *ua, const char *cmd); -struct cmdstruct { const char *key; int (*func)(UAContext *ua, const char *cmd); const char *help; }; +struct cmdstruct { const char *key; int (*func)(UAContext *ua, const char *cmd); const char *help; }; static struct cmdstruct commands[] = { { N_(".die"), diecmd, NULL}, { N_(".jobs"), jobscmd, NULL}, @@ -77,7 +77,7 @@ static struct cmdstruct commands[] = { { N_(".messages"), qmessagescmd, NULL}, { N_(".help"), qhelp_cmd, NULL}, { N_(".quit"), quit_cmd, NULL}, - { N_(".exit"), quit_cmd, NULL} + { N_(".exit"), quit_cmd, NULL} }; #define comsize (sizeof(commands)/sizeof(struct cmdstruct)) @@ -87,7 +87,7 @@ static struct cmdstruct commands[] = { int do_a_dot_command(UAContext *ua, const char *cmd) { int i; - int len, stat; + int len, stat; bool found = false; stat = 1; @@ -117,13 +117,13 @@ int do_a_dot_command(UAContext *ua, const char *cmd) } /* - * Create segmentation fault + * Create segmentation fault */ static int diecmd(UAContext *ua, const char *cmd) { JCR *jcr = NULL; int a; - + bsendmsg(ua, "The Director will segment fault.\n"); a = jcr->JobId; /* ref NULL pointer */ jcr->JobId = 1000; /* another ref NULL pointer */ @@ -249,21 +249,21 @@ static int levelscmd(UAContext *ua, const char *cmd) */ static int defaultscmd(UAContext *ua, const char *cmd) { - JOB *job; + JOB *job; if (ua->argc == 2 && strcmp(ua->argk[1], "job") == 0) { job = (JOB *)GetResWithName(R_JOB, ua->argv[1]); if (job) { STORE *store; - bsendmsg(ua, "job=%s", job->hdr.name); - bsendmsg(ua, "pool=%s", job->pool->hdr.name); - bsendmsg(ua, "messages=%s", job->messages->hdr.name); - bsendmsg(ua, "client=%s", job->client->hdr.name); + bsendmsg(ua, "job=%s", job->hdr.name); + bsendmsg(ua, "pool=%s", job->pool->hdr.name); + bsendmsg(ua, "messages=%s", job->messages->hdr.name); + bsendmsg(ua, "client=%s", job->client->hdr.name); store = (STORE *)job->storage[0]->first(); - bsendmsg(ua, "storage=%s", store->hdr.name); - bsendmsg(ua, "where=%s", job->RestoreWhere?job->RestoreWhere:""); - bsendmsg(ua, "level=%s", level_to_str(job->JobLevel)); - bsendmsg(ua, "type=%s", job_type_to_str(job->JobType)); - bsendmsg(ua, "fileset=%s", job->fileset->hdr.name); + bsendmsg(ua, "storage=%s", store->hdr.name); + bsendmsg(ua, "where=%s", job->RestoreWhere?job->RestoreWhere:""); + bsendmsg(ua, "level=%s", level_to_str(job->JobLevel)); + bsendmsg(ua, "type=%s", job_type_to_str(job->JobType)); + bsendmsg(ua, "fileset=%s", job->fileset->hdr.name); } } return 1; diff --git a/bacula/src/dird/ua_input.c b/bacula/src/dird/ua_input.c index 3c3afeac99..658d5e8425 100644 --- a/bacula/src/dird/ua_input.c +++ b/bacula/src/dird/ua_input.c @@ -69,7 +69,7 @@ int get_cmd(UAContext *ua, const char *prompt) return 1; } -/* +/* * Get a positive integer * Returns: 0 if failure * 1 if success => value in ua->pint32_val @@ -83,13 +83,13 @@ int get_pint(UAContext *ua, const char *prompt) return 0; } if (!is_a_number(ua->cmd)) { - bsendmsg(ua, "Expected a positive integer, got: %s\n", ua->cmd); + bsendmsg(ua, "Expected a positive integer, got: %s\n", ua->cmd); continue; } errno = 0; dval = strtod(ua->cmd, NULL); if (errno != 0 || dval < 0) { - bsendmsg(ua, "Expected a positive integer, got: %s\n", ua->cmd); + bsendmsg(ua, "Expected a positive integer, got: %s\n", ua->cmd); continue; } ua->pint32_val = (uint32_t)dval; @@ -97,7 +97,7 @@ int get_pint(UAContext *ua, const char *prompt) } } -/* +/* * Gets a yes or no response * Returns: 0 if failure * 1 if success => ua->pint32_val == 1 for yes @@ -126,7 +126,7 @@ int get_yesno(UAContext *ua, const char *prompt) bsendmsg(ua, _("Invalid response. You must answer yes or no.\n")); } } - + void parse_ua_args(UAContext *ua) { diff --git a/bacula/src/dird/ua_label.c b/bacula/src/dird/ua_label.c index bd260da887..a6d9396889 100644 --- a/bacula/src/dird/ua_label.c +++ b/bacula/src/dird/ua_label.c @@ -41,7 +41,7 @@ typedef struct s_vol_list { /* Forward referenced functions */ static int do_label(UAContext *ua, const char *cmd, int relabel); static void label_from_barcodes(UAContext *ua); -static bool send_label_request(UAContext *ua, MEDIA_DBR *mr, MEDIA_DBR *omr, +static bool send_label_request(UAContext *ua, MEDIA_DBR *mr, MEDIA_DBR *omr, POOL_DBR *pr, int relabel, bool media_record_exits); static vol_list_t *get_vol_list_from_SD(UAContext *ua, bool scan); static void free_vol_list(vol_list_t *vol_list); @@ -52,8 +52,8 @@ static char *get_volume_name_from_SD(UAContext *ua, int Slot); /* - * Label a tape - * + * Label a tape + * * label storage=xxx volume=vvv */ int label_cmd(UAContext *ua, const char *cmd) @@ -85,54 +85,54 @@ static bool get_user_slot_list(UAContext *ua, char *slot_list, int num_slots) strip_trailing_junk(ua->argv[i]); for (p=ua->argv[i]; p && *p; p=e) { /* Check for list */ - e = strchr(p, ','); + e = strchr(p, ','); if (e) { *e++ = 0; } /* Check for range */ - h = strchr(p, '-'); /* range? */ + h = strchr(p, '-'); /* range? */ if (h == p) { - msg = _("Negative numbers not permitted\n"); + msg = _("Negative numbers not permitted\n"); goto bail_out; } if (h) { *h++ = 0; if (!is_an_integer(h)) { - msg = _("Range end is not integer.\n"); + msg = _("Range end is not integer.\n"); goto bail_out; } skip_spaces(&p); if (!is_an_integer(p)) { - msg = _("Range start is not an integer.\n"); + msg = _("Range start is not an integer.\n"); goto bail_out; } beg = atoi(p); end = atoi(h); if (end < beg) { - msg = _("Range end not bigger than start.\n"); + msg = _("Range end not bigger than start.\n"); goto bail_out; } } else { skip_spaces(&p); if (!is_an_integer(p)) { - msg = _("Input value is not an integer.\n"); + msg = _("Input value is not an integer.\n"); goto bail_out; } beg = end = atoi(p); } if (beg <= 0 || end <= 0) { - msg = _("Values must be be greater than zero.\n"); + msg = _("Values must be be greater than zero.\n"); goto bail_out; } if (end >= num_slots) { - msg = _("Slot too large.\n"); + msg = _("Slot too large.\n"); goto bail_out; } for (i=beg; i<=end; i++) { slot_list[i] = 1; /* Turn on specified range */ } } - } else { + } else { /* Turn everything on */ for (i=0; inext) { if (vl->Slot >= max_slots) { - bsendmsg(ua, _("Slot %d larger than max %d ignored.\n")); + bsendmsg(ua, _("Slot %d larger than max %d ignored.\n")); continue; } /* Check if user wants us to look at this slot */ if (!slot_list[vl->Slot]) { - Dmsg1(100, "Skipping slot=%d\n", vl->Slot); + Dmsg1(100, "Skipping slot=%d\n", vl->Slot); continue; } /* If scanning, we read the label rather than the barcode */ @@ -205,11 +205,11 @@ int update_slots(UAContext *ua) vl->VolName = NULL; } vl->VolName = get_volume_name_from_SD(ua, vl->Slot); - Dmsg2(100, "Got Vol=%s from SD for Slot=%d\n", vl->VolName, vl->Slot); + Dmsg2(100, "Got Vol=%s from SD for Slot=%d\n", vl->VolName, vl->Slot); } slot_list[vl->Slot] = 0; /* clear Slot */ if (!vl->VolName) { - Dmsg1(100, "No VolName for Slot=%d setting InChanger to zero.\n", vl->Slot); + Dmsg1(100, "No VolName for Slot=%d setting InChanger to zero.\n", vl->Slot); memset(&mr, 0, sizeof(mr)); mr.Slot = vl->Slot; mr.InChanger = 1; @@ -217,7 +217,7 @@ int update_slots(UAContext *ua) db_lock(ua->db); db_make_inchanger_unique(ua->jcr, ua->db, &mr); db_unlock(ua->db); - bsendmsg(ua, _("No VolName for Slot=%d set InChanger to zero.\n"), vl->Slot); + bsendmsg(ua, _("No VolName for Slot=%d set InChanger to zero.\n"), vl->Slot); continue; } memset(&mr, 0, sizeof(mr)); @@ -228,20 +228,20 @@ int update_slots(UAContext *ua) mr.Slot = vl->Slot; mr.InChanger = 1; if (!db_update_media_record(ua->jcr, ua->db, &mr)) { - bsendmsg(ua, "%s", db_strerror(ua->db)); + bsendmsg(ua, "%s", db_strerror(ua->db)); } else { bsendmsg(ua, _( - "Catalog record for Volume \"%s\" updated to reference slot %d.\n"), + "Catalog record for Volume \"%s\" updated to reference slot %d.\n"), mr.VolumeName, mr.Slot); } } else { - bsendmsg(ua, _("Catalog record for Volume \"%s\" is up to date.\n"), + bsendmsg(ua, _("Catalog record for Volume \"%s\" is up to date.\n"), mr.VolumeName); - } + } db_unlock(ua->db); continue; } else { - bsendmsg(ua, _("Record for Volume \"%s\" not found in catalog.\n"), + bsendmsg(ua, _("Record for Volume \"%s\" not found in catalog.\n"), mr.VolumeName); } db_unlock(ua->db); @@ -257,7 +257,7 @@ int update_slots(UAContext *ua) } } db_unlock(ua->db); - + bail_out: free_vol_list(vol_list); @@ -306,14 +306,14 @@ static int do_label(UAContext *ua, const char *cmd, int relabel) /* If relabel get name of Volume to relabel */ if (relabel) { /* Check for oldvolume=name */ - i = find_arg_with_value(ua, "oldvolume"); + i = find_arg_with_value(ua, "oldvolume"); if (i >= 0) { memset(&omr, 0, sizeof(omr)); bstrncpy(omr.VolumeName, ua->argv[i], sizeof(omr.VolumeName)); if (db_get_media_record(ua->jcr, ua->db, &omr)) { goto checkVol; - } - bsendmsg(ua, "%s", db_strerror(ua->db)); + } + bsendmsg(ua, "%s", db_strerror(ua->db)); } /* No keyword or Vol not found, ask user to select */ if (!select_media_dbr(ua, &omr)) { @@ -323,7 +323,7 @@ static int do_label(UAContext *ua, const char *cmd, int relabel) /* Require Volume to be Purged or Recycled */ checkVol: if (strcmp(omr.VolStatus, "Purged") != 0 && strcmp(omr.VolStatus, "Recycle") != 0) { - bsendmsg(ua, _("Volume \"%s\" has VolStatus %s. It must be Purged or Recycled before relabeling.\n"), + bsendmsg(ua, _("Volume \"%s\" has VolStatus %s. It must be Purged or Recycled before relabeling.\n"), omr.VolumeName, omr.VolStatus); return 1; } @@ -352,7 +352,7 @@ checkName: /* If VolBytes are zero the Volume is not labeled */ if (db_get_media_record(ua->jcr, ua->db, &mr)) { if (mr.VolBytes != 0) { - bsendmsg(ua, _("Media record for new Volume \"%s\" already exists.\n"), + bsendmsg(ua, _("Media record for new Volume \"%s\" already exists.\n"), mr.VolumeName); continue; } @@ -363,7 +363,7 @@ checkName: /* If autochanger, request slot */ if (store->autochanger) { - i = find_arg_with_value(ua, "slot"); + i = find_arg_with_value(ua, "slot"); if (i >= 0) { mr.Slot = atoi(ua->argv[i]); } else if (!get_pint(ua, _("Enter slot (0 for none): "))) { @@ -392,34 +392,34 @@ checkName: if (relabel) { /* Delete the old media record */ if (!db_delete_media_record(ua->jcr, ua->db, &omr)) { - bsendmsg(ua, _("Delete of Volume \"%s\" failed. ERR=%s"), + bsendmsg(ua, _("Delete of Volume \"%s\" failed. ERR=%s"), omr.VolumeName, db_strerror(ua->db)); } else { - bsendmsg(ua, _("Old volume \"%s\" deleted from catalog.\n"), + bsendmsg(ua, _("Old volume \"%s\" deleted from catalog.\n"), omr.VolumeName); /* Update the number of Volumes in the pool */ pr.NumVols--; if (!db_update_pool_record(ua->jcr, ua->db, &pr)) { - bsendmsg(ua, "%s", db_strerror(ua->db)); + bsendmsg(ua, "%s", db_strerror(ua->db)); } } } if (ua->automount) { bstrncpy(dev_name, store->dev_name, sizeof(dev_name)); - bsendmsg(ua, _("Requesting to mount %s ...\n"), dev_name); + bsendmsg(ua, _("Requesting to mount %s ...\n"), dev_name); bash_spaces(dev_name); - bnet_fsend(sd, "mount %s", dev_name); + bnet_fsend(sd, "mount %s", dev_name); unbash_spaces(dev_name); while (bnet_recv(sd) >= 0) { - bsendmsg(ua, "%s", sd->msg); + bsendmsg(ua, "%s", sd->msg); /* Here we can get * 3001 OK mount. Device=xxx or * 3001 Mounted Volume vvvv * 3906 is cannot mount non-tape * So for those, no need to print a reminder */ - if (strncmp(sd->msg, "3001 ", 5) == 0 || - strncmp(sd->msg, "3906 ", 5) == 0) { + if (strncmp(sd->msg, "3001 ", 5) == 0 || + strncmp(sd->msg, "3906 ", 5) == 0) { print_reminder = false; } } @@ -460,8 +460,8 @@ static void label_from_barcodes(UAContext *ua) /* Display list of Volumes and ask if he really wants to proceed */ bsendmsg(ua, _("The following Volumes will be labeled:\n" - "Slot Volume\n" - "==============\n")); + "Slot Volume\n" + "==============\n")); for (vl=vol_list; vl; vl=vl->next) { if (!vl->VolName || !slot_list[vl->Slot]) { continue; @@ -489,16 +489,16 @@ static void label_from_barcodes(UAContext *ua) media_record_exists = false; if (db_get_media_record(ua->jcr, ua->db, &mr)) { if (mr.VolBytes != 0) { - bsendmsg(ua, _("Media record for Slot %d Volume \"%s\" already exists.\n"), + bsendmsg(ua, _("Media record for Slot %d Volume \"%s\" already exists.\n"), vl->Slot, mr.VolumeName); if (!mr.InChanger) { mr.InChanger = 1; if (!db_update_media_record(ua->jcr, ua->db, &mr)) { - bsendmsg(ua, "Error setting InChanger: ERR=%s", db_strerror(ua->db)); + bsendmsg(ua, "Error setting InChanger: ERR=%s", db_strerror(ua->db)); } } continue; - } + } media_record_exists = true; } mr.InChanger = 1; @@ -510,19 +510,19 @@ static void label_from_barcodes(UAContext *ua) if (media_record_exists) { /* we update it */ mr.VolBytes = 1; if (!db_update_media_record(ua->jcr, ua->db, &mr)) { - bsendmsg(ua, "%s", db_strerror(ua->db)); + bsendmsg(ua, "%s", db_strerror(ua->db)); } } else { /* create the media record */ set_pool_dbr_defaults_in_media_dbr(&mr, &pr); if (db_create_media_record(ua->jcr, ua->db, &mr)) { - bsendmsg(ua, _("Catalog record for cleaning tape \"%s\" successfully created.\n"), + bsendmsg(ua, _("Catalog record for cleaning tape \"%s\" successfully created.\n"), mr.VolumeName); pr.NumVols++; /* this is a bit suspect */ if (!db_update_pool_record(ua->jcr, ua->db, &pr)) { - bsendmsg(ua, "%s", db_strerror(ua->db)); + bsendmsg(ua, "%s", db_strerror(ua->db)); } } else { - bsendmsg(ua, "Catalog error on cleaning tape: %s", db_strerror(ua->db)); + bsendmsg(ua, "Catalog error on cleaning tape: %s", db_strerror(ua->db)); } } continue; /* done, go handle next volume */ @@ -542,7 +542,7 @@ bail_out: return; } -/* +/* * Check if the Volume name has legal characters * If ua is non-NULL send the message */ @@ -558,20 +558,20 @@ bool is_volume_name_legal(UAContext *ua, const char *name) continue; } if (ua) { - bsendmsg(ua, _("Illegal character \"%c\" in a volume name.\n"), *p); + bsendmsg(ua, _("Illegal character \"%c\" in a volume name.\n"), *p); } return 0; } len = strlen(name); if (len >= MAX_NAME_LENGTH) { if (ua) { - bsendmsg(ua, _("Volume name too long.\n")); + bsendmsg(ua, _("Volume name too long.\n")); } return 0; } if (len == 0) { if (ua) { - bsendmsg(ua, _("Volume name must be at least one character long.\n")); + bsendmsg(ua, _("Volume name must be at least one character long.\n")); } return 0; } @@ -581,7 +581,7 @@ bool is_volume_name_legal(UAContext *ua, const char *name) /* * NOTE! This routine opens the SD socket but leaves it open */ -static bool send_label_request(UAContext *ua, MEDIA_DBR *mr, MEDIA_DBR *omr, +static bool send_label_request(UAContext *ua, MEDIA_DBR *mr, MEDIA_DBR *omr, POOL_DBR *pr, int relabel, bool media_record_exists) { BSOCK *sd; @@ -598,16 +598,16 @@ static bool send_label_request(UAContext *ua, MEDIA_DBR *mr, MEDIA_DBR *omr, bash_spaces(pr->Name); if (relabel) { bash_spaces(omr->VolumeName); - bnet_fsend(sd, "relabel %s OldName=%s NewName=%s PoolName=%s MediaType=%s Slot=%d", + bnet_fsend(sd, "relabel %s OldName=%s NewName=%s PoolName=%s MediaType=%s Slot=%d", dev_name, omr->VolumeName, mr->VolumeName, pr->Name, mr->MediaType, mr->Slot); bsendmsg(ua, _("Sending relabel command from \"%s\" to \"%s\" ...\n"), omr->VolumeName, mr->VolumeName); } else { - bnet_fsend(sd, "label %s VolumeName=%s PoolName=%s MediaType=%s Slot=%d", + bnet_fsend(sd, "label %s VolumeName=%s PoolName=%s MediaType=%s Slot=%d", dev_name, mr->VolumeName, pr->Name, mr->MediaType, mr->Slot); - bsendmsg(ua, _("Sending label command for Volume \"%s\" Slot %d ...\n"), + bsendmsg(ua, _("Sending label command for Volume \"%s\" Slot %d ...\n"), mr->VolumeName, mr->Slot); - Dmsg5(200, "label %s VolumeName=%s PoolName=%s MediaType=%s Slot=%d\n", + Dmsg5(200, "label %s VolumeName=%s PoolName=%s MediaType=%s Slot=%d\n", dev_name, mr->VolumeName, pr->Name, mr->MediaType, mr->Slot); } @@ -615,7 +615,7 @@ static bool send_label_request(UAContext *ua, MEDIA_DBR *mr, MEDIA_DBR *omr, bsendmsg(ua, "%s", sd->msg); if (strncmp(sd->msg, "3000 OK label.", 14) == 0) { ok = true; - } + } } unbash_spaces(mr->VolumeName); unbash_spaces(mr->MediaType); @@ -626,7 +626,7 @@ static bool send_label_request(UAContext *ua, MEDIA_DBR *mr, MEDIA_DBR *omr, mr->VolBytes = 1; mr->InChanger = 1; if (!db_update_media_record(ua->jcr, ua->db, mr)) { - bsendmsg(ua, "%s", db_strerror(ua->db)); + bsendmsg(ua, "%s", db_strerror(ua->db)); ok = false; } } else { /* create the media record */ @@ -634,15 +634,15 @@ static bool send_label_request(UAContext *ua, MEDIA_DBR *mr, MEDIA_DBR *omr, mr->VolBytes = 1; /* flag indicating Volume labeled */ mr->InChanger = 1; if (db_create_media_record(ua->jcr, ua->db, mr)) { - bsendmsg(ua, _("Catalog record for Volume \"%s\", Slot %d successfully created.\n"), + bsendmsg(ua, _("Catalog record for Volume \"%s\", Slot %d successfully created.\n"), mr->VolumeName, mr->Slot); /* Update number of volumes in pool */ pr->NumVols++; if (!db_update_pool_record(ua->jcr, ua->db, pr)) { - bsendmsg(ua, "%s", db_strerror(ua->db)); + bsendmsg(ua, "%s", db_strerror(ua->db)); } } else { - bsendmsg(ua, "%s", db_strerror(ua->db)); + bsendmsg(ua, "%s", db_strerror(ua->db)); ok = false; } } @@ -652,15 +652,15 @@ static bool send_label_request(UAContext *ua, MEDIA_DBR *mr, MEDIA_DBR *omr, return ok; } -static BSOCK *open_sd_bsock(UAContext *ua) +static BSOCK *open_sd_bsock(UAContext *ua) { STORE *store = ua->jcr->store; if (!ua->jcr->store_bsock) { - bsendmsg(ua, _("Connecting to Storage daemon %s at %s:%d ...\n"), + bsendmsg(ua, _("Connecting to Storage daemon %s at %s:%d ...\n"), store->hdr.name, store->address, store->SDport); if (!connect_to_storage_daemon(ua->jcr, 10, SDConnectTimeout, 1)) { - bsendmsg(ua, _("Failed to connect to Storage daemon.\n")); + bsendmsg(ua, _("Failed to connect to Storage daemon.\n")); return NULL; } } @@ -676,7 +676,7 @@ static void close_sd_bsock(UAContext *ua) } } -static char *get_volume_name_from_SD(UAContext *ua, int Slot) +static char *get_volume_name_from_SD(UAContext *ua, int Slot) { STORE *store = ua->jcr->store; BSOCK *sd; @@ -700,7 +700,7 @@ static char *get_volume_name_from_SD(UAContext *ua, int Slot) Dmsg1(100, "Got: %s", sd->msg); if (strncmp(sd->msg, "3001 Volume=", 12) == 0) { VolName = (char *)malloc(sd->msglen); - if (sscanf(sd->msg, "3001 Volume=%s Slot=%d", VolName, &rtn_slot) == 2) { + if (sscanf(sd->msg, "3001 Volume=%s Slot=%d", VolName, &rtn_slot) == 2) { break; } free(VolName); @@ -717,7 +717,7 @@ static char *get_volume_name_from_SD(UAContext *ua, int Slot) * If scan is set, we return all slots found, * otherwise, we return only slots with valid barcodes (Volume names) */ -static vol_list_t *get_vol_list_from_SD(UAContext *ua, bool scan) +static vol_list_t *get_vol_list_from_SD(UAContext *ua, bool scan) { STORE *store = ua->jcr->store; char dev_name[MAX_NAME_LENGTH]; @@ -744,8 +744,8 @@ static vol_list_t *get_vol_list_from_SD(UAContext *ua, bool scan) /* Check for returned SD messages */ if (sd->msg[0] == '3' && B_ISDIGIT(sd->msg[1]) && B_ISDIGIT(sd->msg[2]) && B_ISDIGIT(sd->msg[3]) && - sd->msg[4] == ' ') { - bsendmsg(ua, "%s\n", sd->msg); /* pass them on to user */ + sd->msg[4] == ' ') { + bsendmsg(ua, "%s\n", sd->msg); /* pass them on to user */ continue; } @@ -756,8 +756,8 @@ static vol_list_t *get_vol_list_from_SD(UAContext *ua, bool scan) Slot = atoi(sd->msg); if (Slot <= 0) { p--; - *p = ':'; - bsendmsg(ua, _("Invalid Slot number: %s\n"), sd->msg); + *p = ':'; + bsendmsg(ua, _("Invalid Slot number: %s\n"), sd->msg); continue; } } else { @@ -766,8 +766,8 @@ static vol_list_t *get_vol_list_from_SD(UAContext *ua, bool scan) *p++ = 0; if (!is_an_integer(sd->msg) || (Slot=atoi(sd->msg)) <= 0) { p--; - *p = ':'; - bsendmsg(ua, _("Invalid Slot number: %s\n"), sd->msg); + *p = ':'; + bsendmsg(ua, _("Invalid Slot number: %s\n"), sd->msg); continue; } } else { @@ -775,8 +775,8 @@ static vol_list_t *get_vol_list_from_SD(UAContext *ua, bool scan) } if (!is_volume_name_legal(ua, p)) { p--; - *p = ':'; - bsendmsg(ua, _("Invalid Volume name: %s\n"), sd->msg); + *p = ':'; + bsendmsg(ua, _("Invalid Volume name: %s\n"), sd->msg); continue; } } @@ -785,7 +785,7 @@ static vol_list_t *get_vol_list_from_SD(UAContext *ua, bool scan) vl = (vol_list_t *)malloc(sizeof(vol_list_t)); vl->Slot = Slot; if (p) { - if (*p == ':') { + if (*p == ':') { p++; /* skip separator */ } vl->VolName = bstrdup(p); @@ -830,7 +830,7 @@ static void free_vol_list(vol_list_t *vol_list) /* * Check if this is a cleaning tape by comparing the Volume name - * with the Cleaning Prefix. If they match, this is a cleaning + * with the Cleaning Prefix. If they match, this is a cleaning * tape. */ static bool is_cleaning_tape(UAContext *ua, MEDIA_DBR *mr, POOL_DBR *pr) @@ -846,7 +846,7 @@ static bool is_cleaning_tape(UAContext *ua, MEDIA_DBR *mr, POOL_DBR *pr) } Dmsg4(100, "CLNprefix=%s: Vol=%s: len=%d strncmp=%d\n", ua->jcr->pool->cleaning_prefix, mr->VolumeName, - strlen(ua->jcr->pool->cleaning_prefix), + strlen(ua->jcr->pool->cleaning_prefix), strncmp(mr->VolumeName, ua->jcr->pool->cleaning_prefix, strlen(ua->jcr->pool->cleaning_prefix))); return strncmp(mr->VolumeName, ua->jcr->pool->cleaning_prefix, diff --git a/bacula/src/dird/ua_output.c b/bacula/src/dird/ua_output.c index d9eed92902..41ad6b3cc2 100644 --- a/bacula/src/dird/ua_output.c +++ b/bacula/src/dird/ua_output.c @@ -54,7 +54,7 @@ static bool list_nextvol(UAContext *ua); int autodisplay_cmd(UAContext *ua, const char *cmd) { static const char *kw[] = { - N_("on"), + N_("on"), N_("off"), NULL}; @@ -69,7 +69,7 @@ int autodisplay_cmd(UAContext *ua, const char *cmd) bsendmsg(ua, _("ON or OFF keyword missing.\n")); break; } - return 1; + return 1; } /* @@ -78,7 +78,7 @@ int autodisplay_cmd(UAContext *ua, const char *cmd) int gui_cmd(UAContext *ua, const char *cmd) { static const char *kw[] = { - N_("on"), + N_("on"), N_("off"), NULL}; @@ -95,7 +95,7 @@ int gui_cmd(UAContext *ua, const char *cmd) bsendmsg(ua, _("ON or OFF keyword missing.\n")); break; } - return 1; + return 1; } @@ -128,7 +128,7 @@ static struct showstruct reses[] = { */ int show_cmd(UAContext *ua, const char *cmd) { - int i, j, type, len; + int i, j, type, len; int recurse; char *res_name; RES *res = NULL; @@ -139,7 +139,7 @@ int show_cmd(UAContext *ua, const char *cmd) LockRes(); for (i=1; iargc; i++) { type = 0; - res_name = ua->argk[i]; + res_name = ua->argk[i]; if (!ua->argv[i]) { /* was a name given? */ /* No name, dump all resources of specified type */ recurse = 1; @@ -176,21 +176,21 @@ int show_cmd(UAContext *ua, const char *cmd) switch (type) { case -1: /* all */ for (j=r_first; j<=r_last; j++) { - dump_resource(j, res_head[j-r_first], bsendmsg, ua); -// dump_resource(j, resources[j-r_first].res_head, bsendmsg, ua); + dump_resource(j, res_head[j-r_first], bsendmsg, ua); +// dump_resource(j, resources[j-r_first].res_head, bsendmsg, ua); } break; case -2: - bsendmsg(ua, _("Keywords for the show command are:\n")); + bsendmsg(ua, _("Keywords for the show command are:\n")); for (j=0; reses[j].res_name; j++) { - bsendmsg(ua, "%s\n", _(reses[j].res_name)); + bsendmsg(ua, "%s\n", _(reses[j].res_name)); } goto bail_out; case -3: - bsendmsg(ua, _("%s resource %s not found.\n"), res_name, ua->argv[i]); + bsendmsg(ua, _("%s resource %s not found.\n"), res_name, ua->argv[i]); goto bail_out; case 0: - bsendmsg(ua, _("Resource %s not found\n"), res_name); + bsendmsg(ua, _("Resource %s not found\n"), res_name); goto bail_out; default: dump_resource(recurse?type:-type, res, bsendmsg, ua); @@ -289,12 +289,12 @@ static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist) } else if (strcasecmp(ua->argk[i], _("files")) == 0) { for (j=i+1; jargc; j++) { - if (strcasecmp(ua->argk[j], _("job")) == 0 && ua->argv[j]) { + if (strcasecmp(ua->argk[j], _("job")) == 0 && ua->argv[j]) { bstrncpy(jr.Job, ua->argv[j], MAX_NAME_LENGTH); jr.JobId = 0; db_get_job_record(ua->jcr, ua->db, &jr); jobid = jr.JobId; - } else if (strcasecmp(ua->argk[j], _("jobid")) == 0 && ua->argv[j]) { + } else if (strcasecmp(ua->argk[j], _("jobid")) == 0 && ua->argv[j]) { jobid = atoi(ua->argv[j]); } else { continue; @@ -303,17 +303,17 @@ static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist) db_list_files_for_job(ua->jcr, ua->db, jobid, prtit, ua); } } - + /* List JOBMEDIA */ } else if (strcasecmp(ua->argk[i], _("jobmedia")) == 0) { int done = FALSE; for (j=i+1; jargc; j++) { - if (strcasecmp(ua->argk[j], _("job")) == 0 && ua->argv[j]) { + if (strcasecmp(ua->argk[j], _("job")) == 0 && ua->argv[j]) { bstrncpy(jr.Job, ua->argv[j], MAX_NAME_LENGTH); jr.JobId = 0; db_get_job_record(ua->jcr, ua->db, &jr); jobid = jr.JobId; - } else if (strcasecmp(ua->argk[j], _("jobid")) == 0 && ua->argv[j]) { + } else if (strcasecmp(ua->argk[j], _("jobid")) == 0 && ua->argv[j]) { jobid = atoi(ua->argv[j]); } else { continue; @@ -336,22 +336,22 @@ static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist) /* List MEDIA or VOLUMES */ } else if (strcasecmp(ua->argk[i], _("media")) == 0 || - strcasecmp(ua->argk[i], _("volumes")) == 0) { + strcasecmp(ua->argk[i], _("volumes")) == 0) { bool done = false; for (j=i+1; jargc; j++) { - if (strcasecmp(ua->argk[j], _("job")) == 0 && ua->argv[j]) { + if (strcasecmp(ua->argk[j], _("job")) == 0 && ua->argv[j]) { bstrncpy(jr.Job, ua->argv[j], MAX_NAME_LENGTH); jr.JobId = 0; db_get_job_record(ua->jcr, ua->db, &jr); jobid = jr.JobId; - } else if (strcasecmp(ua->argk[j], _("jobid")) == 0 && ua->argv[j]) { + } else if (strcasecmp(ua->argk[j], _("jobid")) == 0 && ua->argv[j]) { jobid = atoi(ua->argv[j]); } else { continue; } VolumeName = get_pool_memory(PM_FNAME); n = db_get_job_volume_names(ua->jcr, ua->db, jobid, &VolumeName); - bsendmsg(ua, _("Jobid %d used %d Volume(s): %s\n"), jobid, n, VolumeName); + bsendmsg(ua, _("Jobid %d used %d Volume(s): %s\n"), jobid, n, VolumeName); free_pool_memory(VolumeName); done = true; } @@ -361,9 +361,9 @@ static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist) uint32_t *ids; /* Is a specific pool wanted? */ for (i=1; iargc; i++) { - if (strcasecmp(ua->argk[i], _("pool")) == 0) { + if (strcasecmp(ua->argk[i], _("pool")) == 0) { if (!get_pool_dbr(ua, &pr)) { - bsendmsg(ua, _("No Pool specified.\n")); + bsendmsg(ua, _("No Pool specified.\n")); return 1; } mr.PoolId = pr.PoolId; @@ -373,7 +373,7 @@ static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist) } /* List Volumes in all pools */ if (!db_get_pool_ids(ua->jcr, ua->db, &num_pools, &ids)) { - bsendmsg(ua, _("Error obtaining pool ids. ERR=%s\n"), + bsendmsg(ua, _("Error obtaining pool ids. ERR=%s\n"), db_strerror(ua->db)); return 1; } @@ -383,7 +383,7 @@ static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist) for (i=0; i < num_pools; i++) { pr.PoolId = ids[i]; if (db_get_pool_record(ua->jcr, ua->db, &pr)) { - bsendmsg(ua, _("Pool: %s\n"), pr.Name); + bsendmsg(ua, _("Pool: %s\n"), pr.Name); } mr.PoolId = ids[i]; db_list_media_records(ua->jcr, ua->db, &mr, prtit, ua, llist); @@ -394,18 +394,18 @@ static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist) /* List a specific volume */ } else if (strcasecmp(ua->argk[i], _("volume")) == 0) { if (!ua->argv[i]) { - bsendmsg(ua, _("No Volume Name specified.\n")); + bsendmsg(ua, _("No Volume Name specified.\n")); return 1; } bstrncpy(mr.VolumeName, ua->argv[i], sizeof(mr.VolumeName)); db_list_media_records(ua->jcr, ua->db, &mr, prtit, ua, llist); return 1; /* List next volume */ - } else if (strcasecmp(ua->argk[i], _("nextvol")) == 0 || - strcasecmp(ua->argk[i], _("nextvolume")) == 0) { + } else if (strcasecmp(ua->argk[i], _("nextvol")) == 0 || + strcasecmp(ua->argk[i], _("nextvolume")) == 0) { list_nextvol(ua); } else { - bsendmsg(ua, _("Unknown list keyword: %s\n"), NPRT(ua->argk[i])); + bsendmsg(ua, _("Unknown list keyword: %s\n"), NPRT(ua->argk[i])); } } return 1; @@ -430,7 +430,7 @@ static bool list_nextvol(UAContext *ua) } else { job = (JOB *)GetResWithName(R_JOB, ua->argv[i]); if (!job) { - Jmsg(jcr, M_ERROR, 0, _("%s is not a job name.\n"), ua->argv[i]); + Jmsg(jcr, M_ERROR, 0, _("%s is not a job name.\n"), ua->argv[i]); if ((job = select_job_resource(ua)) == NULL) { return false; } @@ -441,11 +441,11 @@ static bool list_nextvol(UAContext *ua) if (!complete_jcr_for_job(jcr, job, pool)) { return false; } - + if (!find_next_volume_for_append(jcr, &mr, 0)) { - bsendmsg(ua, _("Could not find next Volume.\n")); + bsendmsg(ua, _("Could not find next Volume.\n")); } else { - bsendmsg(ua, _("The next Volume to be used by Job \"%s\" will be %s\n"), + bsendmsg(ua, _("The next Volume to be used by Job \"%s\" will be %s\n"), job->hdr.name, mr.VolumeName); found = true; } @@ -462,7 +462,7 @@ static bool list_nextvol(UAContext *ua) } -/* +/* * For a given job, we examine all his run records * to see if it is scheduled today or tomorrow. */ @@ -479,7 +479,7 @@ RUN *find_next_run(RUN *run, JOB *job, time_t &runtime) if (sched == NULL) { /* scheduled? */ return NULL; /* no nothing to report */ } - /* Break down current time into components */ + /* Break down current time into components */ now = time(NULL); localtime_r(&now, &tm); mday = tm.tm_mday - 1; @@ -503,10 +503,10 @@ RUN *find_next_run(RUN *run, JOB *job, time_t &runtime) run = run->next; } for ( ; run; run=run->next) { - /* + /* * Find runs in next 24 hours */ - tod = bit_is_set(mday, run->mday) && bit_is_set(wday, run->wday) && + tod = bit_is_set(mday, run->mday) && bit_is_set(wday, run->wday) && bit_is_set(month, run->month) && bit_is_set(wom, run->wom) && bit_is_set(woy, run->woy); @@ -525,16 +525,16 @@ RUN *find_next_run(RUN *run, JOB *job, time_t &runtime) if (tod) { /* Jobs scheduled today (next 24 hours) */ #ifdef xxx char buf[300], num[10]; - bsnprintf(buf, sizeof(buf), "tm.hour=%d hour=", tm.tm_hour); + bsnprintf(buf, sizeof(buf), "tm.hour=%d hour=", tm.tm_hour); for (i=0; i<24; i++) { if (bit_is_set(i, run->hour)) { - bsnprintf(num, sizeof(num), "%d ", i); + bsnprintf(num, sizeof(num), "%d ", i); bstrncat(buf, num, sizeof(buf)); } } - bstrncat(buf, "\n", sizeof(buf)); - Dmsg1(000, "%s", buf); -#endif + bstrncat(buf, "\n", sizeof(buf)); + Dmsg1(000, "%s", buf); +#endif /* find time (time_t) job is to be run */ localtime_r(&now, &tm); for (i=tm.tm_hour; i < 24; i++) { @@ -543,9 +543,9 @@ RUN *find_next_run(RUN *run, JOB *job, time_t &runtime) tm.tm_min = run->minute; tm.tm_sec = 0; runtime = mktime(&tm); - Dmsg2(200, "now=%d runtime=%d\n", now, runtime); + Dmsg2(200, "now=%d runtime=%d\n", now, runtime); if (runtime > now) { - Dmsg2(200, "Found it level=%d %c\n", run->level, run->level); + Dmsg2(200, "Found it level=%d %c\n", run->level, run->level); return run; /* found it, return run resource */ } } @@ -561,19 +561,19 @@ RUN *find_next_run(RUN *run, JOB *job, time_t &runtime) tm.tm_min = run->minute; tm.tm_sec = 0; runtime = mktime(&tm); - Dmsg2(200, "now=%d runtime=%d\n", now, runtime); + Dmsg2(200, "now=%d runtime=%d\n", now, runtime); if (runtime < tomorrow) { - Dmsg2(200, "Found it level=%d %c\n", run->level, run->level); + Dmsg2(200, "Found it level=%d %c\n", run->level, run->level); return run; /* found it, return run resource */ } } } } - } /* end for loop over runs */ + } /* end for loop over runs */ /* Nothing found */ return NULL; } -/* +/* * Fill in the remaining fields of the jcr as if it * is going to run the job. */ @@ -581,20 +581,20 @@ int complete_jcr_for_job(JCR *jcr, JOB *job, POOL *pool) { POOL_DBR pr; - memset(&pr, 0, sizeof(POOL_DBR)); + memset(&pr, 0, sizeof(POOL_DBR)); set_jcr_defaults(jcr, job); if (pool) { jcr->pool = pool; /* override */ } jcr->db = jcr->db=db_init_database(jcr, jcr->catalog->db_name, jcr->catalog->db_user, jcr->catalog->db_password, jcr->catalog->db_address, - jcr->catalog->db_port, jcr->catalog->db_socket, + jcr->catalog->db_port, jcr->catalog->db_socket, jcr->catalog->mult_db_connections); if (!jcr->db || !db_open_database(jcr, jcr->db)) { Jmsg(jcr, M_FATAL, 0, _("Could not open database \"%s\".\n"), jcr->catalog->db_name); if (jcr->db) { - Jmsg(jcr, M_FATAL, 0, "%s", db_strerror(jcr->db)); + Jmsg(jcr, M_FATAL, 0, "%s", db_strerror(jcr->db)); } return 0; } @@ -602,7 +602,7 @@ int complete_jcr_for_job(JCR *jcr, JOB *job, POOL *pool) while (!db_get_pool_record(jcr, jcr->db, &pr)) { /* get by Name */ /* Try to create the pool */ if (create_pool(jcr, jcr->db, jcr->pool, POOL_OP_CREATE) < 0) { - Jmsg(jcr, M_FATAL, 0, _("Pool %s not in database. %s"), pr.Name, + Jmsg(jcr, M_FATAL, 0, _("Pool %s not in database. %s"), pr.Name, db_strerror(jcr->db)); if (jcr->db) { db_close_database(jcr, jcr->db); @@ -610,10 +610,10 @@ int complete_jcr_for_job(JCR *jcr, JOB *job, POOL *pool) } return 0; } else { - Jmsg(jcr, M_INFO, 0, _("Pool %s created in database.\n"), pr.Name); + Jmsg(jcr, M_INFO, 0, _("Pool %s created in database.\n"), pr.Name); } } - jcr->PoolId = pr.PoolId; + jcr->PoolId = pr.PoolId; jcr->jr.PoolId = pr.PoolId; return 1; } @@ -627,7 +627,7 @@ static void con_lock_release(void *arg) void do_messages(UAContext *ua, const char *cmd) { char msg[2000]; - int mlen; + int mlen; int do_truncate = FALSE; Pw(con_lock); @@ -675,12 +675,12 @@ int messagescmd(UAContext *ua, const char *cmd) void prtit(void *ctx, const char *msg) { UAContext *ua = (UAContext *)ctx; - + bnet_fsend(ua->UA_sock, "%s", msg); } -/* - * Format message and send to other end. +/* + * Format message and send to other end. * If the UA_sock is NULL, it means that there is no user * agent, so we are being called from Bacula core. In diff --git a/bacula/src/dird/ua_prune.c b/bacula/src/dird/ua_prune.c index d72fe1d370..7f769c75d9 100644 --- a/bacula/src/dird/ua_prune.c +++ b/bacula/src/dird/ua_prune.c @@ -82,7 +82,7 @@ struct s_count_ctx { /* - * Called here to count entries to be deleted + * Called here to count entries to be deleted */ static int count_handler(void *ctx, int num_fields, char **row) { @@ -120,7 +120,7 @@ static int job_delete_handler(void *ctx, int num_fields, char **row) { struct s_job_del_ctx *del = (struct s_job_del_ctx *)ctx; - if (del->num_ids == MAX_DEL_LIST_LEN) { + if (del->num_ids == MAX_DEL_LIST_LEN) { return 1; } if (del->num_ids == del->max_ids) { @@ -137,7 +137,7 @@ static int file_delete_handler(void *ctx, int num_fields, char **row) { struct s_file_del_ctx *del = (struct s_file_del_ctx *)ctx; - if (del->num_ids == MAX_DEL_LIST_LEN) { + if (del->num_ids == MAX_DEL_LIST_LEN) { return 1; } if (del->num_ids == del->max_ids) { @@ -154,7 +154,7 @@ static int file_delete_handler(void *ctx, int num_fields, char **row) * * prune files (from) client=xxx * prune jobs (from) client=xxx - * prune volume=xxx + * prune volume=xxx */ int prunecmd(UAContext *ua, const char *cmd) { @@ -174,12 +174,12 @@ int prunecmd(UAContext *ua, const char *cmd) } /* First search args */ - kw = find_arg_keyword(ua, keywords); + kw = find_arg_keyword(ua, keywords); if (kw < 0 || kw > 2) { /* no args, so ask user */ - kw = do_keyword_prompt(ua, _("Choose item to prune"), keywords); - } - + kw = do_keyword_prompt(ua, _("Choose item to prune"), keywords); + } + switch (kw) { case 0: /* prune files */ client = get_client_resource(ua); @@ -243,21 +243,21 @@ int prune_files(UAContext *ua, CLIENT *client) period = client->FileRetention; now = (utime_t)time(NULL); - + /* Select Jobs -- for counting */ Mmsg(query, select_job, edit_uint64(now - period, ed1), cr.ClientId); Dmsg1(050, "select sql=%s\n", query); if (!db_sql_query(ua->db, query, file_count_handler, (void *)&del)) { if (ua->verbose) { - bsendmsg(ua, "%s", db_strerror(ua->db)); + bsendmsg(ua, "%s", db_strerror(ua->db)); } Dmsg0(050, "Count failed\n"); goto bail_out; } - + if (del.tot_ids == 0) { if (ua->verbose) { - bsendmsg(ua, _("No Files found to prune.\n")); + bsendmsg(ua, _("No Files found to prune.\n")); } goto bail_out; } @@ -265,7 +265,7 @@ int prune_files(UAContext *ua, CLIENT *client) if (del.tot_ids < MAX_DEL_LIST_LEN) { del.max_ids = del.tot_ids + 1; } else { - del.max_ids = MAX_DEL_LIST_LEN; + del.max_ids = MAX_DEL_LIST_LEN; } del.tot_ids = 0; @@ -283,7 +283,7 @@ int prune_files(UAContext *ua, CLIENT *client) del.tot_ids += cnt.count; Mmsg(query, del_File, del.JobId[i]); db_sql_query(ua->db, query, NULL, (void *)NULL); - /* + /* * Now mark Job as having files purged. This is necessary to * avoid having too many Jobs to process in future prunings. If * we don't do this, the number of JobId's in our in memory list @@ -295,9 +295,9 @@ int prune_files(UAContext *ua, CLIENT *client) } edit_uint64_with_commas(del.tot_ids, ed1); edit_uint64_with_commas(del.num_ids, ed2); - bsendmsg(ua, _("Pruned %s Files from %s Jobs for client %s from catalog.\n"), + bsendmsg(ua, _("Pruned %s Files from %s Jobs for client %s from catalog.\n"), ed1, ed2, client->hdr.name); - + bail_out: db_unlock(ua->db); if (del.JobId) { @@ -308,7 +308,7 @@ bail_out: } -static void drop_temp_tables(UAContext *ua) +static void drop_temp_tables(UAContext *ua) { int i; for (i=0; drop_deltabs[i]; i++) { @@ -316,14 +316,14 @@ static void drop_temp_tables(UAContext *ua) } } -static int create_temp_tables(UAContext *ua) +static int create_temp_tables(UAContext *ua) { int i; /* Create temp tables and indicies */ for (i=0; create_deltabs[i]; i++) { if (!db_sql_query(ua->db, create_deltabs[i], NULL, (void *)NULL)) { - bsendmsg(ua, "%s", db_strerror(ua->db)); - Dmsg0(050, "create DelTables table failed\n"); + bsendmsg(ua, "%s", db_strerror(ua->db)); + Dmsg0(050, "create DelTables table failed\n"); return 0; } } @@ -374,7 +374,7 @@ int prune_jobs(UAContext *ua, CLIENT *client, int JobType) goto bail_out; } - /* + /* * Select all files that are older than the JobRetention period * and stuff them into the "DeletionCandidates" table. */ @@ -382,7 +382,7 @@ int prune_jobs(UAContext *ua, CLIENT *client, int JobType) Mmsg(query, insert_delcand, (char)JobType, ed1, cr.ClientId); if (!db_sql_query(ua->db, query, NULL, (void *)NULL)) { if (ua->verbose) { - bsendmsg(ua, "%s", db_strerror(ua->db)); + bsendmsg(ua, "%s", db_strerror(ua->db)); } Dmsg0(050, "insert delcand failed\n"); goto bail_out; @@ -397,10 +397,10 @@ int prune_jobs(UAContext *ua, CLIENT *client, int JobType) Dmsg0(050, "Count failed\n"); goto bail_out; } - + if (cnt.count == 0) { if (ua->verbose) { - bsendmsg(ua, _("No Jobs found to prune.\n")); + bsendmsg(ua, _("No Jobs found to prune.\n")); } goto bail_out; } @@ -408,7 +408,7 @@ int prune_jobs(UAContext *ua, CLIENT *client, int JobType) if (cnt.count < MAX_DEL_LIST_LEN) { del.max_ids = cnt.count + 1; } else { - del.max_ids = MAX_DEL_LIST_LEN; + del.max_ids = MAX_DEL_LIST_LEN; } del.JobId = (JobId_t *)malloc(sizeof(JobId_t) * del.max_ids); del.PurgedFiles = (char *)malloc(del.max_ids); @@ -431,7 +431,7 @@ int prune_jobs(UAContext *ua, CLIENT *client, int JobType) bsendmsg(ua, "%s", db_strerror(ua->db)); } - /* + /* * OK, now we have the list of JobId's to be pruned, first check * if the Files have been purged, if not, purge (delete) them. * Then delete the Job entry, and finally and JobMedia records. @@ -441,26 +441,26 @@ int prune_jobs(UAContext *ua, CLIENT *client, int JobType) if (!del.PurgedFiles[i]) { Mmsg(query, del_File, del.JobId[i]); if (!db_sql_query(ua->db, query, NULL, (void *)NULL)) { - bsendmsg(ua, "%s", db_strerror(ua->db)); + bsendmsg(ua, "%s", db_strerror(ua->db)); } - Dmsg1(050, "Del sql=%s\n", query); + Dmsg1(050, "Del sql=%s\n", query); } Mmsg(query, del_Job, del.JobId[i]); if (!db_sql_query(ua->db, query, NULL, (void *)NULL)) { - bsendmsg(ua, "%s", db_strerror(ua->db)); + bsendmsg(ua, "%s", db_strerror(ua->db)); } Dmsg1(050, "Del sql=%s\n", query); Mmsg(query, del_JobMedia, del.JobId[i]); if (!db_sql_query(ua->db, query, NULL, (void *)NULL)) { - bsendmsg(ua, "%s", db_strerror(ua->db)); + bsendmsg(ua, "%s", db_strerror(ua->db)); } Dmsg1(050, "Del sql=%s\n", query); } bsendmsg(ua, _("Pruned %d %s for client %s from catalog.\n"), del.num_ids, del.num_ids==1?_("Job"):_("Jobs"), client->hdr.name); - + bail_out: drop_temp_tables(ua); db_unlock(ua->db); @@ -491,7 +491,7 @@ int prune_volume(UAContext *ua, MEDIA_DBR *mr) memset(&del, 0, sizeof(del)); /* - * Find out how many Jobs remain on this Volume by + * Find out how many Jobs remain on this Volume by * counting the JobMedia records. */ cnt.count = 0; @@ -501,10 +501,10 @@ int prune_volume(UAContext *ua, MEDIA_DBR *mr) Dmsg0(050, "Count failed\n"); goto bail_out; } - + if (cnt.count == 0) { if (strcmp(mr->VolStatus, "Purged") != 0 && verbose) { - bsendmsg(ua, "There are no Jobs associated with Volume \"%s\". Marking it purged.\n", + bsendmsg(ua, "There are no Jobs associated with Volume \"%s\". Marking it purged.\n", mr->VolumeName); } stat = mark_media_purged(ua, mr); @@ -514,10 +514,10 @@ int prune_volume(UAContext *ua, MEDIA_DBR *mr) if (cnt.count < MAX_DEL_LIST_LEN) { del.max_ids = cnt.count + 1; } else { - del.max_ids = MAX_DEL_LIST_LEN; + del.max_ids = MAX_DEL_LIST_LEN; } - /* + /* * Now get a list of JobIds for Jobs written to this Volume * Could optimize here by adding JobTDate > (now - period). */ @@ -525,7 +525,7 @@ int prune_volume(UAContext *ua, MEDIA_DBR *mr) Mmsg(query, sel_JobMedia, mr->MediaId); if (!db_sql_query(ua->db, query, file_delete_handler, (void *)&del)) { if (ua->verbose) { - bsendmsg(ua, "%s", db_strerror(ua->db)); + bsendmsg(ua, "%s", db_strerror(ua->db)); } Dmsg0(050, "Count failed\n"); goto bail_out; @@ -562,7 +562,7 @@ int prune_volume(UAContext *ua, MEDIA_DBR *mr) } if (ua->verbose && del.num_del != 0) { bsendmsg(ua, _("Pruned %d %s on Volume \"%s\" from catalog.\n"), del.num_del, - del.num_del == 1 ? "Job" : "Jobs", mr->VolumeName); + del.num_del == 1 ? "Job" : "Jobs", mr->VolumeName); } /* If purged, mark it so */ diff --git a/bacula/src/dird/ua_purge.c b/bacula/src/dird/ua_purge.c index 87d43b3d76..349fc68e2c 100644 --- a/bacula/src/dird/ua_purge.c +++ b/bacula/src/dird/ua_purge.c @@ -79,7 +79,7 @@ struct s_count_ctx { }; /* - * Called here to count entries to be deleted + * Called here to count entries to be deleted */ static int count_handler(void *ctx, int num_fields, char **row) { @@ -94,7 +94,7 @@ static int count_handler(void *ctx, int num_fields, char **row) } /* - * Called here to count entries to be deleted + * Called here to count entries to be deleted */ static int file_count_handler(void *ctx, int num_fields, char **row) { @@ -124,7 +124,7 @@ static int job_delete_handler(void *ctx, int num_fields, char **row) { struct s_job_del_ctx *del = (struct s_job_del_ctx *)ctx; - if (del->num_ids == MAX_DEL_LIST_LEN) { + if (del->num_ids == MAX_DEL_LIST_LEN) { return 1; } if (del->num_ids == del->max_ids) { @@ -141,7 +141,7 @@ static int file_delete_handler(void *ctx, int num_fields, char **row) { struct s_file_del_ctx *del = (struct s_file_del_ctx *)ctx; - if (del->num_ids == MAX_DEL_LIST_LEN) { + if (del->num_ids == MAX_DEL_LIST_LEN) { return 1; } if (del->num_ids == del->max_ids) { @@ -184,13 +184,13 @@ int purgecmd(UAContext *ua, const char *cmd) N_("Client"), N_("Volume"), NULL}; - + bsendmsg(ua, _( "\nThis command is can be DANGEROUS!!!\n\n" "It purges (deletes) all Files from a Job,\n" "JobId, Client or Volume; or it purges (deletes)\n" "all Jobs from a Client or Volume without regard\n" - "for retention periods. Normally you should use the\n" + "for retention periods. Normally you should use the\n" "PRUNE command, which respects retention periods.\n")); if (!open_db(ua)) { @@ -240,7 +240,7 @@ int purgecmd(UAContext *ua, const char *cmd) purge_jobs_from_volume(ua, &mr); } *ua->argk[i] = 0; /* zap keyword already seen */ - bsendmsg(ua, "\n"); + bsendmsg(ua, "\n"); } return 1; default: @@ -294,13 +294,13 @@ static int purge_files_from_client(UAContext *ua, CLIENT *client) Mmsg(query, select_jobsfiles_from_client, cr.ClientId); Dmsg1(050, "select sql=%s\n", query); - + if (!db_sql_query(ua->db, query, file_count_handler, (void *)&del)) { bsendmsg(ua, "%s", db_strerror(ua->db)); Dmsg0(050, "Count failed\n"); goto bail_out; } - + if (del.tot_ids == 0) { bsendmsg(ua, _("No Files found for client %s to purge from %s catalog.\n"), client->hdr.name, client->catalog->hdr.name); @@ -310,7 +310,7 @@ static int purge_files_from_client(UAContext *ua, CLIENT *client) if (del.tot_ids < MAX_DEL_LIST_LEN) { del.max_ids = del.tot_ids + 1; } else { - del.max_ids = MAX_DEL_LIST_LEN; + del.max_ids = MAX_DEL_LIST_LEN; } del.tot_ids = 0; @@ -322,7 +322,7 @@ static int purge_files_from_client(UAContext *ua, CLIENT *client) Dmsg1(050, "Delete JobId=%d\n", del.JobId[i]); Mmsg(query, "DELETE FROM File WHERE JobId=%d", del.JobId[i]); db_sql_query(ua->db, query, NULL, (void *)NULL); - /* + /* * Now mark Job as having files purged. This is necessary to * avoid having too many Jobs to process in future prunings. If * we don't do this, the number of JobId's in our in memory list @@ -334,7 +334,7 @@ static int purge_files_from_client(UAContext *ua, CLIENT *client) } bsendmsg(ua, _("%d Files for client \"%s\" purged from %s catalog.\n"), del.num_ids, client->hdr.name, client->catalog->hdr.name); - + bail_out: if (del.JobId) { free(del.JobId); @@ -372,7 +372,7 @@ static int purge_jobs_from_client(UAContext *ua, CLIENT *client) Mmsg(query, select_jobs_from_client, cr.ClientId); Dmsg1(050, "select sql=%s\n", query); - + if (!db_sql_query(ua->db, query, job_count_handler, (void *)&del)) { bsendmsg(ua, "%s", db_strerror(ua->db)); Dmsg0(050, "Count failed\n"); @@ -387,7 +387,7 @@ static int purge_jobs_from_client(UAContext *ua, CLIENT *client) if (del.tot_ids < MAX_DEL_LIST_LEN) { del.max_ids = del.tot_ids + 1; } else { - del.max_ids = MAX_DEL_LIST_LEN; + del.max_ids = MAX_DEL_LIST_LEN; } del.tot_ids = 0; @@ -397,7 +397,7 @@ static int purge_jobs_from_client(UAContext *ua, CLIENT *client) db_sql_query(ua->db, query, job_delete_handler, (void *)&del); - /* + /* * OK, now we have the list of JobId's to be purged, first check * if the Files have been purged, if not, purge (delete) them. * Then delete the Job entry, and finally and JobMedia records. @@ -405,9 +405,9 @@ static int purge_jobs_from_client(UAContext *ua, CLIENT *client) for (i=0; i < del.num_ids; i++) { Dmsg1(050, "Delete JobId=%d\n", del.JobId[i]); if (!del.PurgedFiles[i]) { - Mmsg(query, "DELETE FROM File WHERE JobId=%d", del.JobId[i]); + Mmsg(query, "DELETE FROM File WHERE JobId=%d", del.JobId[i]); db_sql_query(ua->db, query, NULL, (void *)NULL); - Dmsg1(050, "Del sql=%s\n", query); + Dmsg1(050, "Del sql=%s\n", query); } Mmsg(query, "DELETE FROM Job WHERE JobId=%d", del.JobId[i]); @@ -420,7 +420,7 @@ static int purge_jobs_from_client(UAContext *ua, CLIENT *client) } bsendmsg(ua, _("%d Jobs for client %s purged from %s catalog.\n"), del.num_ids, client->hdr.name, client->catalog->hdr.name); - + bail_out: if (del.JobId) { free(del.JobId); @@ -435,7 +435,7 @@ bail_out: void purge_files_from_job(UAContext *ua, JOB_DBR *jr) { char *query = (char *)get_pool_memory(PM_MESSAGE); - + Mmsg(query, "DELETE FROM File WHERE JobId=%u", jr->JobId); db_sql_query(ua->db, query, NULL, (void *)NULL); @@ -445,14 +445,14 @@ void purge_files_from_job(UAContext *ua, JOB_DBR *jr) free_pool_memory(query); } -void purge_files_from_volume(UAContext *ua, MEDIA_DBR *mr ) +void purge_files_from_volume(UAContext *ua, MEDIA_DBR *mr ) {} /* ***FIXME*** implement */ /* * Returns: 1 if Volume purged * 0 if Volume not purged */ -int purge_jobs_from_volume(UAContext *ua, MEDIA_DBR *mr) +int purge_jobs_from_volume(UAContext *ua, MEDIA_DBR *mr) { char *query = (char *)get_pool_memory(PM_MESSAGE); struct s_count_ctx cnt; @@ -460,18 +460,18 @@ int purge_jobs_from_volume(UAContext *ua, MEDIA_DBR *mr) int i, stat = 0; JOB_DBR jr; - stat = strcmp(mr->VolStatus, "Append") == 0 || - strcmp(mr->VolStatus, "Full") == 0 || - strcmp(mr->VolStatus, "Used") == 0 || - strcmp(mr->VolStatus, "Error") == 0; + stat = strcmp(mr->VolStatus, "Append") == 0 || + strcmp(mr->VolStatus, "Full") == 0 || + strcmp(mr->VolStatus, "Used") == 0 || + strcmp(mr->VolStatus, "Error") == 0; if (!stat) { bsendmsg(ua, "\n"); bsendmsg(ua, _("Volume \"%s\" has VolStatus \"%s\" and cannot be purged.\n" - "The VolStatus must be: Append, Full, Used, or Error to be purged.\n"), + "The VolStatus must be: Append, Full, Used, or Error to be purged.\n"), mr->VolumeName, mr->VolStatus); goto bail_out; } - + memset(&jr, 0, sizeof(jr)); memset(&del, 0, sizeof(del)); cnt.count = 0; @@ -481,12 +481,12 @@ int purge_jobs_from_volume(UAContext *ua, MEDIA_DBR *mr) Dmsg0(050, "Count failed\n"); goto bail_out; } - + if (cnt.count == 0) { bsendmsg(ua, "There are no Jobs associated with Volume \"%s\". Marking it purged.\n", mr->VolumeName); if (!mark_media_purged(ua, mr)) { - bsendmsg(ua, "%s", db_strerror(ua->db)); + bsendmsg(ua, "%s", db_strerror(ua->db)); goto bail_out; } goto bail_out; @@ -495,11 +495,11 @@ int purge_jobs_from_volume(UAContext *ua, MEDIA_DBR *mr) if (cnt.count < MAX_DEL_LIST_LEN) { del.max_ids = cnt.count + 1; } else { - del.max_ids = MAX_DEL_LIST_LEN; + del.max_ids = MAX_DEL_LIST_LEN; } /* - * Check if he wants to purge a single jobid + * Check if he wants to purge a single jobid */ i = find_arg_with_value(ua, "jobid"); if (i >= 0) { @@ -507,15 +507,15 @@ int purge_jobs_from_volume(UAContext *ua, MEDIA_DBR *mr) del.num_ids = 1; del.JobId[0] = str_to_int64(ua->argv[i]); } else { - /* - * Purge ALL JobIds + /* + * Purge ALL JobIds */ del.JobId = (JobId_t *)malloc(sizeof(JobId_t) * del.max_ids); Mmsg(query, "SELECT JobId FROM JobMedia WHERE MediaId=%d", mr->MediaId); if (!db_sql_query(ua->db, query, file_delete_handler, (void *)&del)) { - bsendmsg(ua, "%s", db_strerror(ua->db)); - Dmsg0(050, "Count failed\n"); + bsendmsg(ua, "%s", db_strerror(ua->db)); + Dmsg0(050, "Count failed\n"); goto bail_out; } } @@ -545,17 +545,17 @@ int purge_jobs_from_volume(UAContext *ua, MEDIA_DBR *mr) Dmsg0(050, "Count failed\n"); goto bail_out; } - + if (cnt.count == 0) { bsendmsg(ua, "There are no more Jobs associated with Volume \"%s\". Marking it purged.\n", mr->VolumeName); if (!(stat = mark_media_purged(ua, mr))) { - bsendmsg(ua, "%s", db_strerror(ua->db)); + bsendmsg(ua, "%s", db_strerror(ua->db)); goto bail_out; } } -bail_out: +bail_out: free_pool_memory(query); return stat; } @@ -566,9 +566,9 @@ bail_out: */ int mark_media_purged(UAContext *ua, MEDIA_DBR *mr) { - if (strcmp(mr->VolStatus, "Append") == 0 || + if (strcmp(mr->VolStatus, "Append") == 0 || strcmp(mr->VolStatus, "Full") == 0 || - strcmp(mr->VolStatus, "Used") == 0 || + strcmp(mr->VolStatus, "Used") == 0 || strcmp(mr->VolStatus, "Error") == 0) { bstrncpy(mr->VolStatus, "Purged", sizeof(mr->VolStatus)); if (!db_update_media_record(ua->jcr, ua->db, mr)) { diff --git a/bacula/src/dird/ua_query.c b/bacula/src/dird/ua_query.c index 5cf84260a3..9b18ac9406 100644 --- a/bacula/src/dird/ua_query.c +++ b/bacula/src/dird/ua_query.c @@ -32,7 +32,7 @@ extern DIRRES *director; -static POOLMEM *substitute_prompts(UAContext *ua, +static POOLMEM *substitute_prompts(UAContext *ua, POOLMEM *query, char **prompt, int nprompt); /* @@ -57,7 +57,7 @@ int querycmd(UAContext *ua, const char *cmd) char *prompt[9]; int nprompt = 0;; char *query_file = director->query_file; - + if (!open_db(ua)) { goto bail_out; } @@ -106,16 +106,16 @@ int querycmd(UAContext *ua, const char *cmd) len = strlen(line); if (line[0] == '*') { /* prompt */ if (nprompt >= 9) { - bsendmsg(ua, _("Too many prompts in query, max is 9.\n")); + bsendmsg(ua, _("Too many prompts in query, max is 9.\n")); } else { - line[len++] = ' '; + line[len++] = ' '; line[len] = 0; prompt[nprompt++] = bstrdup(line+1); continue; } - } + } if (*query != 0) { - pm_strcat(query, " "); + pm_strcat(query, " "); } pm_strcat(query, line); if (line[len-1] != ';') { @@ -124,11 +124,11 @@ int querycmd(UAContext *ua, const char *cmd) line[len-1] = 0; /* zap ; */ if (query[0] != 0) { query = substitute_prompts(ua, query, prompt, nprompt); - Dmsg1(100, "Query2=%s\n", query); - if (query[0] == '!') { + Dmsg1(100, "Query2=%s\n", query); + if (query[0] == '!') { db_list_sql_query(ua->jcr, ua->db, query+1, prtit, ua, 0, VERT_LIST); } else if (!db_list_sql_query(ua->jcr, ua->db, query, prtit, ua, 1, HORZ_LIST)) { - bsendmsg(ua, "%s\n", query); + bsendmsg(ua, "%s\n", query); } query[0] = 0; } @@ -137,10 +137,10 @@ int querycmd(UAContext *ua, const char *cmd) if (query[0] != 0) { query = substitute_prompts(ua, query, prompt, nprompt); Dmsg1(100, "Query2=%s\n", query); - if (query[0] == '!') { + if (query[0] == '!') { db_list_sql_query(ua->jcr, ua->db, query+1, prtit, ua, 0, VERT_LIST); } else if (!db_list_sql_query(ua->jcr, ua->db, query, prtit, ua, 1, HORZ_LIST)) { - bsendmsg(ua, "%s\n", query); + bsendmsg(ua, "%s\n", query); } } @@ -155,7 +155,7 @@ bail_out: return 1; } -static POOLMEM *substitute_prompts(UAContext *ua, +static POOLMEM *substitute_prompts(UAContext *ua, POOLMEM *query, char **prompt, int nprompt) { char *p, *q, *o; @@ -181,16 +181,16 @@ static POOLMEM *substitute_prompts(UAContext *ua, } p++; switch (*p) { - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - n = (int)(*p) - (int)'1'; + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + n = (int)(*p) - (int)'1'; if (prompt[n]) { if (!subst[n]) { if (!get_cmd(ua, prompt[n])) { @@ -209,16 +209,16 @@ static POOLMEM *substitute_prompts(UAContext *ua, *o++ = *p++; } } else { - bsendmsg(ua, _("Warning prompt %d missing.\n"), n+1); + bsendmsg(ua, _("Warning prompt %d missing.\n"), n+1); } q += 2; break; - case '%': - *o++ = '%'; + case '%': + *o++ = '%'; q += 2; break; default: - *o++ = '%'; + *o++ = '%'; q++; break; } @@ -255,9 +255,9 @@ int sqlquerycmd(UAContext *ua, const char *cmd) } *query = 0; - bsendmsg(ua, _("Entering SQL query mode.\n\ -Terminate each query with a semicolon.\n\ -Terminate query mode with a blank line.\n")); + bsendmsg(ua, _("Entering SQL query mode.\n" +"Terminate each query with a semicolon.\n" +"Terminate query mode with a blank line.\n")); msg = "Enter SQL query: "; while (get_cmd(ua, msg)) { len = strlen(ua->cmd); @@ -267,7 +267,7 @@ Terminate query mode with a blank line.\n")); } query = check_pool_memory_size(query, len + 1); if (*query != 0) { - strcat(query, " "); + strcat(query, " "); } strcat(query, ua->cmd); if (ua->cmd[len-1] == ';') { @@ -275,12 +275,12 @@ Terminate query mode with a blank line.\n")); /* Submit query */ db_list_sql_query(ua->jcr, ua->db, query, prtit, ua, 1, HORZ_LIST); *query = 0; /* start new query */ - msg = _("Enter SQL query: "); + msg = _("Enter SQL query: "); } else { - msg = _("Add to SQL query: "); + msg = _("Add to SQL query: "); } } free_pool_memory(query); bsendmsg(ua, _("End query mode.\n")); - return 1; + return 1; } diff --git a/bacula/src/dird/ua_restore.c b/bacula/src/dird/ua_restore.c index 7f0d5eb8a4..a62b4ec961 100644 --- a/bacula/src/dird/ua_restore.c +++ b/bacula/src/dird/ua_restore.c @@ -149,12 +149,12 @@ int restore_cmd(UAContext *ua, const char *cmd) UnlockRes(); if (!rx.restore_jobs) { bsendmsg(ua, _( - "No Restore Job Resource found. You must create at least\n" - "one before running this command.\n")); + "No Restore Job Resource found. You must create at least\n" + "one before running this command.\n")); goto bail_out; } - /* + /* * Request user to select JobIds or files by various different methods * last 20 jobs, where File saved, most recent backup, ... * In the end, a list of files are pumped into @@ -165,7 +165,7 @@ int restore_cmd(UAContext *ua, const char *cmd) goto bail_out; case 1: /* select by jobid */ if (!build_directory_tree(ua, &rx)) { - bsendmsg(ua, _("Restore not done.\n")); + bsendmsg(ua, _("Restore not done.\n")); goto bail_out; } break; @@ -175,14 +175,14 @@ int restore_cmd(UAContext *ua, const char *cmd) if (rx.bsr->JobId) { if (!complete_bsr(ua, rx.bsr)) { /* find Vol, SessId, SessTime from JobIds */ - bsendmsg(ua, _("Unable to construct a valid BSR. Cannot continue.\n")); + bsendmsg(ua, _("Unable to construct a valid BSR. Cannot continue.\n")); goto bail_out; } if (!write_bsr_file(ua, rx.bsr)) { goto bail_out; } bsendmsg(ua, _("\n%u file%s selected to be restored.\n\n"), rx.selected_files, - rx.selected_files==1?"":"s"); + rx.selected_files==1?"":"s"); } else { bsendmsg(ua, _("No files selected to be restored.\n")); goto bail_out; @@ -205,16 +205,16 @@ int restore_cmd(UAContext *ua, const char *cmd) /* Build run command */ if (rx.where) { - Mmsg(ua->cmd, - "run job=\"%s\" client=\"%s\" storage=\"%s\" bootstrap=\"%s/restore.bsr\"" - " where=\"%s\" files=%d catalog=\"%s\"", - job->hdr.name, rx.ClientName, rx.store?rx.store->hdr.name:"", + Mmsg(ua->cmd, + "run job=\"%s\" client=\"%s\" storage=\"%s\" bootstrap=\"%s/restore.bsr\"" + " where=\"%s\" files=%d catalog=\"%s\"", + job->hdr.name, rx.ClientName, rx.store?rx.store->hdr.name:"", working_directory, rx.where, rx.selected_files, ua->catalog->hdr.name); } else { - Mmsg(ua->cmd, - "run job=\"%s\" client=\"%s\" storage=\"%s\" bootstrap=\"%s/restore.bsr\"" - " files=%d catalog=\"%s\"", - job->hdr.name, rx.ClientName, rx.store?rx.store->hdr.name:"", + Mmsg(ua->cmd, + "run job=\"%s\" client=\"%s\" storage=\"%s\" bootstrap=\"%s/restore.bsr\"" + " files=%d catalog=\"%s\"", + job->hdr.name, rx.ClientName, rx.store?rx.store->hdr.name:"", working_directory, rx.selected_files, ua->catalog->hdr.name); } if (find_arg(ua, _("yes")) > 0) { @@ -232,7 +232,7 @@ bail_out: } -static void free_rx(RESTORE_CTX *rx) +static void free_rx(RESTORE_CTX *rx) { free_bsr(rx->bsr); rx->bsr = NULL; @@ -276,7 +276,7 @@ static int get_client_name(UAContext *ua, RESTORE_CTX *rx) } /* - * The first step in the restore process is for the user to + * The first step in the restore process is for the user to * select a list of JobIds from which he will subsequently * select which files are to be restored. */ @@ -289,11 +289,11 @@ static int user_select_jobids_or_files(UAContext *ua, RESTORE_CTX *rx) JOB_DBR jr; bool done = false; int i, j; - const char *list[] = { + const char *list[] = { "List last 20 Jobs run", "List Jobs where a given File is saved", "Enter list of comma separated JobIds to select", - "Enter SQL list command", + "Enter SQL list command", "Select the most recent backup for a client", "Select backup for a client before a specified time", "Enter a list of files to restore", @@ -329,14 +329,14 @@ static int user_select_jobids_or_files(UAContext *ua, RESTORE_CTX *rx) } } if (!found_kw) { - bsendmsg(ua, _("Unknown keyword: %s\n"), ua->argk[i]); + bsendmsg(ua, _("Unknown keyword: %s\n"), ua->argk[i]); return 0; } /* Found keyword in kw[] list, process it */ switch (j) { case 0: /* jobid */ if (*rx->JobIds != 0) { - pm_strcat(rx->JobIds, ","); + pm_strcat(rx->JobIds, ","); } pm_strcat(rx->JobIds, ua->argv[i]); done = true; @@ -347,7 +347,7 @@ static int user_select_jobids_or_files(UAContext *ua, RESTORE_CTX *rx) break; case 2: /* before */ if (str_to_utime(ua->argv[i]) == 0) { - bsendmsg(ua, _("Improper date format: %s\n"), ua->argv[i]); + bsendmsg(ua, _("Improper date format: %s\n"), ua->argv[i]); return 0; } bstrncpy(date, ua->argv[i], sizeof(date)); @@ -380,19 +380,19 @@ static int user_select_jobids_or_files(UAContext *ua, RESTORE_CTX *rx) case 5: /* pool specified */ rx->pool = (POOL *)GetResWithName(R_POOL, ua->argv[i]); if (!rx->pool) { - bsendmsg(ua, _("Error: Pool resource \"%s\" does not exist.\n"), ua->argv[i]); + bsendmsg(ua, _("Error: Pool resource \"%s\" does not exist.\n"), ua->argv[i]); return 0; } if (!acl_access_ok(ua, Pool_ACL, ua->argv[i])) { rx->pool = NULL; - bsendmsg(ua, _("Error: Pool resource \"%s\" access not allowed.\n"), ua->argv[i]); + bsendmsg(ua, _("Error: Pool resource \"%s\" access not allowed.\n"), ua->argv[i]); return 0; } break; case 6: /* all specified */ rx->all = true; break; - /* + /* * All keywords 7 or greater are ignored or handled by a select prompt */ default: @@ -402,12 +402,12 @@ static int user_select_jobids_or_files(UAContext *ua, RESTORE_CTX *rx) if (rx->name_list.num_ids) { return 2; /* filename list made */ } - + if (!done) { bsendmsg(ua, _("\nFirst you select one or more JobIds that contain files\n" - "to be restored. You will be presented several methods\n" - "of specifying the JobIds. Then you will be allowed to\n" - "select which files from those JobIds are to be restored.\n\n")); + "to be restored. You will be presented several methods\n" + "of specifying the JobIds. Then you will be allowed to\n" + "select which files from those JobIds are to be restored.\n\n")); } /* If choice not already made above, prompt */ @@ -432,7 +432,7 @@ static int user_select_jobids_or_files(UAContext *ua, RESTORE_CTX *rx) done = false; break; case 1: /* list where a file is saved */ - if (!get_cmd(ua, _("Enter Filename (no path):"))) { + if (!get_cmd(ua, _("Enter Filename (no path):"))) { return 0; } len = strlen(ua->cmd); @@ -447,13 +447,13 @@ static int user_select_jobids_or_files(UAContext *ua, RESTORE_CTX *rx) done = false; break; case 2: /* enter a list of JobIds */ - if (!get_cmd(ua, _("Enter JobId(s), comma separated, to restore: "))) { + if (!get_cmd(ua, _("Enter JobId(s), comma separated, to restore: "))) { return 0; } pm_strcpy(rx->JobIds, ua->cmd); break; case 3: /* Enter an SQL list command */ - if (!get_cmd(ua, _("Enter SQL list command: "))) { + if (!get_cmd(ua, _("Enter SQL list command: "))) { return 0; } gui_save = ua->jcr->gui; @@ -481,11 +481,11 @@ static int user_select_jobids_or_files(UAContext *ua, RESTORE_CTX *rx) if (!get_client_name(ua, rx)) { return 0; } - bsendmsg(ua, _("Enter file names with paths, or < to enter a filename\n" - "containg a list of file names with paths, and terminate\n" - "them with a blank line.\n")); + bsendmsg(ua, _("Enter file names with paths, or < to enter a filename\n" + "containg a list of file names with paths, and terminate\n" + "them with a blank line.\n")); for ( ;; ) { - if (!get_cmd(ua, _("Enter full filename: "))) { + if (!get_cmd(ua, _("Enter full filename: "))) { return 0; } len = strlen(ua->cmd); @@ -506,11 +506,11 @@ static int user_select_jobids_or_files(UAContext *ua, RESTORE_CTX *rx) if (!get_client_name(ua, rx)) { return 0; } - bsendmsg(ua, _("Enter file names with paths, or < to enter a filename\n" - "containg a list of file names with paths, and terminate\n" - "them with a blank line.\n")); + bsendmsg(ua, _("Enter file names with paths, or < to enter a filename\n" + "containg a list of file names with paths, and terminate\n" + "them with a blank line.\n")); for ( ;; ) { - if (!get_cmd(ua, _("Enter full filename: "))) { + if (!get_cmd(ua, _("Enter full filename: "))) { return 0; } len = strlen(ua->cmd); @@ -525,7 +525,7 @@ static int user_select_jobids_or_files(UAContext *ua, RESTORE_CTX *rx) } return 2; - + case 8: /* Cancel or quit */ return 0; } @@ -535,7 +535,7 @@ static int user_select_jobids_or_files(UAContext *ua, RESTORE_CTX *rx) bsendmsg(ua, _("No Jobs selected.\n")); return 0; } - bsendmsg(ua, _("You have selected the following JobId%s: %s\n"), + bsendmsg(ua, _("You have selected the following JobId%s: %s\n"), strchr(rx->JobIds,',')?"s":"",rx->JobIds); memset(&jr, 0, sizeof(JOB_DBR)); @@ -544,7 +544,7 @@ static int user_select_jobids_or_files(UAContext *ua, RESTORE_CTX *rx) for (p=rx->JobIds; ; ) { int stat = get_next_jobid_from_list(&p, &JobId); if (stat < 0) { - bsendmsg(ua, _("Invalid JobId in list.\n")); + bsendmsg(ua, _("Invalid JobId in list.\n")); return 0; } if (stat == 0) { @@ -555,27 +555,27 @@ static int user_select_jobids_or_files(UAContext *ua, RESTORE_CTX *rx) } jr.JobId = JobId; if (!db_get_job_record(ua->jcr, ua->db, &jr)) { - bsendmsg(ua, _("Unable to get Job record for JobId=%u: ERR=%s\n"), + bsendmsg(ua, _("Unable to get Job record for JobId=%u: ERR=%s\n"), JobId, db_strerror(ua->db)); return 0; } if (!acl_access_ok(ua, Job_ACL, jr.Name)) { - bsendmsg(ua, _("No authorization. Job \"%s\" not selected.\n"), + bsendmsg(ua, _("No authorization. Job \"%s\" not selected.\n"), jr.Name); - continue; + continue; } rx->TotalFiles += jr.JobFiles; } return 1; } -/* +/* * Get date from user */ static int get_date(UAContext *ua, char *date, int date_len) { bsendmsg(ua, _("The restored files will the most current backup\n" - "BEFORE the date you specify below.\n\n")); + "BEFORE the date you specify below.\n\n")); for ( ;; ) { if (!get_cmd(ua, _("Enter date as YYYY-MM-DD HH:MM:SS :"))) { return 0; @@ -584,13 +584,13 @@ static int get_date(UAContext *ua, char *date, int date_len) break; } bsendmsg(ua, _("Improper date format.\n")); - } + } bstrncpy(date, ua->cmd, date_len); return 1; } /* - * Insert a single file, or read a list of files from a file + * Insert a single file, or read a list of files from a file */ static void insert_one_file(UAContext *ua, RESTORE_CTX *rx, char *date) { @@ -598,19 +598,19 @@ static void insert_one_file(UAContext *ua, RESTORE_CTX *rx, char *date) char file[5000]; char *p = ua->cmd; int line = 0; - + switch (*p) { case '<': p++; if ((ffd = fopen(p, "r")) == NULL) { - bsendmsg(ua, _("Cannot open file %s: ERR=%s\n"), + bsendmsg(ua, _("Cannot open file %s: ERR=%s\n"), p, strerror(errno)); break; } while (fgets(file, sizeof(file), ffd)) { line++; if (!insert_file_into_findex_list(ua, rx, file, date)) { - bsendmsg(ua, _("Error occurred on line %d of %s\n"), line, p); + bsendmsg(ua, _("Error occurred on line %d of %s\n"), line, p); } } fclose(ffd); @@ -626,7 +626,7 @@ static void insert_one_file(UAContext *ua, RESTORE_CTX *rx, char *date) * lookup the most recent backup in the catalog to get the JobId * and FileIndex, then insert them into the findex list. */ -static int insert_file_into_findex_list(UAContext *ua, RESTORE_CTX *rx, char *file, +static int insert_file_into_findex_list(UAContext *ua, RESTORE_CTX *rx, char *file, char *date) { strip_trailing_junk(file); @@ -634,13 +634,13 @@ static int insert_file_into_findex_list(UAContext *ua, RESTORE_CTX *rx, char *fi if (*rx->JobIds == 0) { Mmsg(rx->query, uar_jobid_fileindex, date, rx->path, rx->fname, rx->ClientName); } else { - Mmsg(rx->query, uar_jobids_fileindex, rx->JobIds, date, + Mmsg(rx->query, uar_jobids_fileindex, rx->JobIds, date, rx->path, rx->fname, rx->ClientName); } rx->found = false; /* Find and insert jobid and File Index */ if (!db_sql_query(ua->db, rx->query, jobid_fileindex_handler, (void *)rx)) { - bsendmsg(ua, _("Query failed: %s. ERR=%s\n"), + bsendmsg(ua, _("Query failed: %s. ERR=%s\n"), rx->query, db_strerror(ua->db)); } if (!rx->found) { @@ -663,7 +663,7 @@ static void split_path_and_filename(RESTORE_CTX *rx, char *name) { char *p, *f; - /* Find path without the filename. + /* Find path without the filename. * I.e. everything after the last / is a "filename". * OK, maybe it is a directory name, but we treat it like * a filename. If we don't find a / then the whole name @@ -681,7 +681,7 @@ static void split_path_and_filename(RESTORE_CTX *rx, char *name) } /* If filename doesn't exist (i.e. root directory), we - * simply create a blank name consisting of a single + * simply create a blank name consisting of a single * space. This makes handling zero length filenames * easier. */ @@ -695,7 +695,7 @@ static void split_path_and_filename(RESTORE_CTX *rx, char *name) rx->fnl = 0; } - rx->pnl = f - name; + rx->pnl = f - name; if (rx->pnl > 0) { rx->path = check_pool_memory_size(rx->path, rx->pnl+1); memcpy(rx->path, name, rx->pnl); @@ -716,7 +716,7 @@ static bool build_directory_tree(UAContext *ua, RESTORE_CTX *rx) bool OK = true; memset(&tree, 0, sizeof(TREE_CTX)); - /* + /* * Build the directory tree containing JobIds user selected */ tree.root = new_tree(rx->TotalFiles); @@ -734,7 +734,7 @@ static bool build_directory_tree(UAContext *ua, RESTORE_CTX *rx) /* Use first JobId as estimate of the number of files to restore */ Mmsg(rx->query, uar_count_files, JobId); if (!db_sql_query(ua->db, rx->query, count_handler, (void *)rx)) { - bsendmsg(ua, "%s\n", db_strerror(ua->db)); + bsendmsg(ua, "%s\n", db_strerror(ua->db)); } if (rx->found) { /* Add about 25% more than this job for over estimate */ @@ -744,7 +744,7 @@ static bool build_directory_tree(UAContext *ua, RESTORE_CTX *rx) } for (p=rx->JobIds; get_next_jobid_from_list(&p, &JobId) > 0; ) { - if (JobId == last_JobId) { + if (JobId == last_JobId) { continue; /* eliminate duplicate JobIds */ } last_JobId = JobId; @@ -755,18 +755,18 @@ static bool build_directory_tree(UAContext *ua, RESTORE_CTX *rx) */ Mmsg(rx->query, uar_sel_files, JobId); if (!db_sql_query(ua->db, rx->query, insert_tree_handler, (void *)&tree)) { - bsendmsg(ua, "%s", db_strerror(ua->db)); + bsendmsg(ua, "%s", db_strerror(ua->db)); } /* * Find the MediaTypes for this JobId and add to the name_list */ Mmsg(rx->query, uar_mediatype, JobId); if (!db_sql_query(ua->db, rx->query, unique_name_list_handler, (void *)&rx->name_list)) { - bsendmsg(ua, "%s", db_strerror(ua->db)); + bsendmsg(ua, "%s", db_strerror(ua->db)); } } char ec1[50]; - bsendmsg(ua, "\n%d Job%s, %s files inserted into the tree%s.\n", + bsendmsg(ua, "\n%d Job%s, %s files inserted into the tree%s.\n", items, items==1?"":"s", edit_uint64_with_commas(tree.FileCount, ec1), tree.all?" and marked for extraction":""); @@ -779,14 +779,14 @@ static bool build_directory_tree(UAContext *ua, RESTORE_CTX *rx) } /* - * Walk down through the tree finding all files marked to be + * Walk down through the tree finding all files marked to be * extracted making a bootstrap file. */ if (OK) { for (TREE_NODE *node=first_tree_node(tree.root); node; node=next_tree_node(node)) { - Dmsg2(400, "FI=%d node=0x%x\n", node->FileIndex, node); + Dmsg2(400, "FI=%d node=0x%x\n", node->FileIndex, node); if (node->extract || node->extract_dir) { - Dmsg2(400, "type=%d FI=%d\n", node->type, node->FileIndex); + Dmsg2(400, "type=%d FI=%d\n", node->type, node->FileIndex); add_findex(rx->bsr, node->JobId, node->FileIndex); if (node->extract && node->type != TN_NEWDIR) { rx->selected_files++; /* count only saved files */ @@ -834,14 +834,14 @@ static int select_backups_before_date(UAContext *ua, RESTORE_CTX *rx, char *date bstrncpy(rx->ClientName, cr.Name, sizeof(rx->ClientName)); /* - * Get FileSet + * Get FileSet */ memset(&fsr, 0, sizeof(fsr)); - i = find_arg_with_value(ua, "FileSet"); + i = find_arg_with_value(ua, "FileSet"); if (i >= 0) { bstrncpy(fsr.FileSet, ua->argv[i], sizeof(fsr.FileSet)); if (!db_get_fileset_record(ua->jcr, ua->db, &fsr)) { - bsendmsg(ua, _("Error getting FileSet \"%s\": ERR=%s\n"), fsr.FileSet, + bsendmsg(ua, _("Error getting FileSet \"%s\": ERR=%s\n"), fsr.FileSet, db_strerror(ua->db)); i = -1; } @@ -850,18 +850,18 @@ static int select_backups_before_date(UAContext *ua, RESTORE_CTX *rx, char *date Mmsg(rx->query, uar_sel_fileset, cr.ClientId, cr.ClientId); start_prompt(ua, _("The defined FileSet resources are:\n")); if (!db_sql_query(ua->db, rx->query, fileset_handler, (void *)ua)) { - bsendmsg(ua, "%s\n", db_strerror(ua->db)); + bsendmsg(ua, "%s\n", db_strerror(ua->db)); } - if (do_prompt(ua, _("FileSet"), _("Select FileSet resource"), + if (do_prompt(ua, _("FileSet"), _("Select FileSet resource"), fileset_name, sizeof(fileset_name)) < 0) { goto bail_out; } bstrncpy(fsr.FileSet, fileset_name, sizeof(fsr.FileSet)); if (!db_get_fileset_record(ua->jcr, ua->db, &fsr)) { - bsendmsg(ua, _("Error getting FileSet record: %s\n"), db_strerror(ua->db)); - bsendmsg(ua, _("This probably means you modified the FileSet.\n" - "Continuing anyway.\n")); + bsendmsg(ua, _("Error getting FileSet record: %s\n"), db_strerror(ua->db)); + bsendmsg(ua, _("This probably means you modified the FileSet.\n" + "Continuing anyway.\n")); } } @@ -872,9 +872,9 @@ static int select_backups_before_date(UAContext *ua, RESTORE_CTX *rx, char *date memset(&pr, 0, sizeof(pr)); bstrncpy(pr.Name, rx->pool->hdr.name, sizeof(pr.Name)); if (db_get_pool_record(ua->jcr, ua->db, &pr)) { - bsnprintf(pool_select, sizeof(pool_select), "AND Media.PoolId=%u ", pr.PoolId); + bsnprintf(pool_select, sizeof(pool_select), "AND Media.PoolId=%u ", pr.PoolId); } else { - bsendmsg(ua, _("Pool \"%s\" not found, using any pool.\n"), pr.Name); + bsendmsg(ua, _("Pool \"%s\" not found, using any pool.\n"), pr.Name); } } @@ -937,11 +937,11 @@ static int select_backups_before_date(UAContext *ua, RESTORE_CTX *rx, char *date /* Display a list of Jobs selected for this restore */ db_list_sql_query(ua->jcr, ua->db, uar_list_temp, prtit, ua, 1, HORZ_LIST); } else { - bsendmsg(ua, _("No jobs found.\n")); + bsendmsg(ua, _("No jobs found.\n")); } stat = 1; - + bail_out: db_sql_query(ua->db, uar_del_temp, NULL, NULL); db_sql_query(ua->db, uar_del_temp1, NULL, NULL); @@ -999,7 +999,7 @@ static int jobid_handler(void *ctx, int num_fields, char **row) { RESTORE_CTX *rx = (RESTORE_CTX *)ctx; - if (strcmp(rx->last_jobid, row[0]) == 0) { + if (strcmp(rx->last_jobid, row[0]) == 0) { return 0; /* duplicate id */ } bstrncpy(rx->last_jobid, row[0], sizeof(rx->last_jobid)); @@ -1018,7 +1018,7 @@ static int last_full_handler(void *ctx, int num_fields, char **row) { RESTORE_CTX *rx = (RESTORE_CTX *)ctx; - rx->JobTDate = str_to_int64(row[1]); + rx->JobTDate = str_to_int64(row[1]); return 0; } @@ -1044,7 +1044,7 @@ static int unique_name_list_handler(void *ctx, int num_fields, char **row) { NAME_LIST *name = (NAME_LIST *)ctx; - if (name->num_ids == MAX_ID_LIST_LEN) { + if (name->num_ids == MAX_ID_LIST_LEN) { return 1; } if (name->num_ids == name->max_ids) { @@ -1071,7 +1071,7 @@ static int unique_name_list_handler(void *ctx, int num_fields, char **row) * Print names in the list */ static void print_name_list(UAContext *ua, NAME_LIST *name_list) -{ +{ for (int i=0; i < name_list->num_ids; i++) { bsendmsg(ua, "%s\n", name_list->name[i]); } @@ -1082,7 +1082,7 @@ static void print_name_list(UAContext *ua, NAME_LIST *name_list) * Free names in the list */ static void free_name_list(NAME_LIST *name_list) -{ +{ for (int i=0; i < name_list->num_ids; i++) { free(name_list->name[i]); } @@ -1100,7 +1100,7 @@ static void get_storage_from_mediatype(UAContext *ua, NAME_LIST *name_list, REST if (name_list->num_ids > 1) { bsendmsg(ua, _("Warning, the JobIds that you selected refer to more than one MediaType.\n" - "Restore is not possible. The MediaTypes used are:\n")); + "Restore is not possible. The MediaTypes used are:\n")); print_name_list(ua, name_list); rx->store = select_storage_resource(ua); return; @@ -1115,7 +1115,7 @@ static void get_storage_from_mediatype(UAContext *ua, NAME_LIST *name_list, REST return; } /* - * We have a single MediaType, look it up in our Storage resource + * We have a single MediaType, look it up in our Storage resource */ LockRes(); foreach_res(store, R_STORAGE) { @@ -1131,7 +1131,7 @@ static void get_storage_from_mediatype(UAContext *ua, NAME_LIST *name_list, REST if (rx->store) { /* Check if an explicit storage resource is given */ store = NULL; - int i = find_arg_with_value(ua, "storage"); + int i = find_arg_with_value(ua, "storage"); if (i > 0) { store = (STORE *)GetResWithName(R_STORAGE, ua->argv[i]); if (store && !acl_access_ok(ua, Storage_ACL, store->hdr.name)) { @@ -1139,7 +1139,7 @@ static void get_storage_from_mediatype(UAContext *ua, NAME_LIST *name_list, REST } } if (store && (store != rx->store)) { - bsendmsg(ua, _("Warning default storage overridden by %s on command line.\n"), + bsendmsg(ua, _("Warning default storage overridden by %s on command line.\n"), store->hdr.name); rx->store = store; } @@ -1151,8 +1151,8 @@ static void get_storage_from_mediatype(UAContext *ua, NAME_LIST *name_list, REST if (!rx->store) { bsendmsg(ua, _("\nWarning. Unable to find Storage resource for\n" - "MediaType \"%s\", needed by the Jobs you selected.\n" - "You will be allowed to select a Storage device later.\n"), - name_list->name[0]); + "MediaType \"%s\", needed by the Jobs you selected.\n" + "You will be allowed to select a Storage device later.\n"), + name_list->name[0]); } } diff --git a/bacula/src/dird/ua_run.c b/bacula/src/dird/ua_run.c index 57c69c8263..94dfb2d937 100644 --- a/bacula/src/dird/ua_run.c +++ b/bacula/src/dird/ua_run.c @@ -66,7 +66,7 @@ int run_cmd(UAContext *ua, const char *cmd) N_("job"), /* Used in a switch() */ N_("jobid"), /* 1 */ N_("client"), /* 2 */ - N_("fd"), + N_("fd"), N_("fileset"), /* 4 */ N_("level"), /* 5 */ N_("storage"), /* 6 */ @@ -110,7 +110,7 @@ int run_cmd(UAContext *ua, const char *cmd) for (j=0; !kw_ok && kw[j]; j++) { if (strcasecmp(ua->argk[i], _(kw[j])) == 0) { /* Note, yes and run have no value, so do not err */ - if (!ua->argv[i] && j != YES_POS /*yes*/) { + if (!ua->argv[i] && j != YES_POS /*yes*/) { bsendmsg(ua, _("Value missing for keyword %s\n"), ua->argk[i]); return 1; } @@ -126,7 +126,7 @@ int run_cmd(UAContext *ua, const char *cmd) break; case 1: /* JobId */ if (jid) { - bsendmsg(ua, _("JobId specified twice.\n")); + bsendmsg(ua, _("JobId specified twice.\n")); return 0; } jid = ua->argv[i]; @@ -135,7 +135,7 @@ int run_cmd(UAContext *ua, const char *cmd) case 2: /* client */ case 3: /* fd */ if (client_name) { - bsendmsg(ua, _("Client specified twice.\n")); + bsendmsg(ua, _("Client specified twice.\n")); return 0; } client_name = ua->argv[i]; @@ -143,7 +143,7 @@ int run_cmd(UAContext *ua, const char *cmd) break; case 4: /* fileset */ if (fileset_name) { - bsendmsg(ua, _("FileSet specified twice.\n")); + bsendmsg(ua, _("FileSet specified twice.\n")); return 0; } fileset_name = ua->argv[i]; @@ -151,7 +151,7 @@ int run_cmd(UAContext *ua, const char *cmd) break; case 5: /* level */ if (level_name) { - bsendmsg(ua, _("Level specified twice.\n")); + bsendmsg(ua, _("Level specified twice.\n")); return 0; } level_name = ua->argv[i]; @@ -160,7 +160,7 @@ int run_cmd(UAContext *ua, const char *cmd) case 6: /* storage */ case 7: /* sd */ if (store_name) { - bsendmsg(ua, _("Storage specified twice.\n")); + bsendmsg(ua, _("Storage specified twice.\n")); return 0; } store_name = ua->argv[i]; @@ -168,7 +168,7 @@ int run_cmd(UAContext *ua, const char *cmd) break; case 8: /* pool */ if (pool_name) { - bsendmsg(ua, _("Pool specified twice.\n")); + bsendmsg(ua, _("Pool specified twice.\n")); return 0; } pool_name = ua->argv[i]; @@ -176,7 +176,7 @@ int run_cmd(UAContext *ua, const char *cmd) break; case 9: /* where */ if (where) { - bsendmsg(ua, _("Where specified twice.\n")); + bsendmsg(ua, _("Where specified twice.\n")); return 0; } where = ua->argv[i]; @@ -184,7 +184,7 @@ int run_cmd(UAContext *ua, const char *cmd) break; case 10: /* bootstrap */ if (bootstrap) { - bsendmsg(ua, _("Bootstrap specified twice.\n")); + bsendmsg(ua, _("Bootstrap specified twice.\n")); return 0; } bootstrap = ua->argv[i]; @@ -192,7 +192,7 @@ int run_cmd(UAContext *ua, const char *cmd) break; case 11: /* replace */ if (replace) { - bsendmsg(ua, _("Replace specified twice.\n")); + bsendmsg(ua, _("Replace specified twice.\n")); return 0; } replace = ua->argv[i]; @@ -200,7 +200,7 @@ int run_cmd(UAContext *ua, const char *cmd) break; case 12: /* When */ if (when) { - bsendmsg(ua, _("When specified twice.\n")); + bsendmsg(ua, _("When specified twice.\n")); return 0; } when = ua->argv[i]; @@ -208,12 +208,12 @@ int run_cmd(UAContext *ua, const char *cmd) break; case 13: /* Priority */ if (Priority) { - bsendmsg(ua, _("Priority specified twice.\n")); + bsendmsg(ua, _("Priority specified twice.\n")); return 0; } Priority = atoi(ua->argv[i]); if (Priority <= 0) { - bsendmsg(ua, _("Priority must be positive nonzero setting it to 10.\n")); + bsendmsg(ua, _("Priority must be positive nonzero setting it to 10.\n")); Priority = 10; } kw_ok = true; @@ -223,7 +223,7 @@ int run_cmd(UAContext *ua, const char *cmd) break; case 15: /* Verify Job */ if (verify_job_name) { - bsendmsg(ua, _("Verify Job specified twice.\n")); + bsendmsg(ua, _("Verify Job specified twice.\n")); return 0; } verify_job_name = ua->argv[i]; @@ -248,16 +248,16 @@ int run_cmd(UAContext *ua, const char *cmd) * End of keyword for loop -- if not found, we got a bogus keyword */ if (!kw_ok) { - Dmsg1(200, "%s not found\n", ua->argk[i]); + Dmsg1(200, "%s not found\n", ua->argk[i]); /* * Special case for Job Name, it can be the first * keyword that has no value. */ if (!job_name && !ua->argv[i]) { job_name = ua->argk[i]; /* use keyword as job name */ - Dmsg1(200, "Set jobname=%s\n", job_name); + Dmsg1(200, "Set jobname=%s\n", job_name); } else { - bsendmsg(ua, _("Invalid keyword: %s\n"), ua->argk[i]); + bsendmsg(ua, _("Invalid keyword: %s\n"), ua->argk[i]); return 0; } } @@ -269,7 +269,7 @@ int run_cmd(UAContext *ua, const char *cmd) if (catalog_name != NULL) { catalog = (CAT *)GetResWithName(R_CATALOG, catalog_name); if (catalog == NULL) { - bsendmsg(ua, _("Catalog \"%s\" not found\n"), catalog_name); + bsendmsg(ua, _("Catalog \"%s\" not found\n"), catalog_name); return 0; } } @@ -280,11 +280,11 @@ int run_cmd(UAContext *ua, const char *cmd) job = (JOB *)GetResWithName(R_JOB, job_name); if (!job) { if (*job_name != 0) { - bsendmsg(ua, _("Job \"%s\" not found\n"), job_name); + bsendmsg(ua, _("Job \"%s\" not found\n"), job_name); } job = select_job_resource(ua); } else { - Dmsg1(200, "Found job=%s\n", job_name); + Dmsg1(200, "Found job=%s\n", job_name); } } else { bsendmsg(ua, _("A job name must be specified.\n")); @@ -302,7 +302,7 @@ int run_cmd(UAContext *ua, const char *cmd) store = (STORE *)GetResWithName(R_STORAGE, store_name); if (!store) { if (*store_name != 0) { - bsendmsg(ua, _("Storage \"%s\" not found.\n"), store_name); + bsendmsg(ua, _("Storage \"%s\" not found.\n"), store_name); } store = select_storage_resource(ua); } @@ -322,7 +322,7 @@ int run_cmd(UAContext *ua, const char *cmd) pool = (POOL *)GetResWithName(R_POOL, pool_name); if (!pool) { if (*pool_name != 0) { - bsendmsg(ua, _("Pool \"%s\" not found.\n"), pool_name); + bsendmsg(ua, _("Pool \"%s\" not found.\n"), pool_name); } pool = select_pool_resource(ua); } @@ -342,7 +342,7 @@ int run_cmd(UAContext *ua, const char *cmd) client = (CLIENT *)GetResWithName(R_CLIENT, client_name); if (!client) { if (*client_name != 0) { - bsendmsg(ua, _("Client \"%s\" not found.\n"), client_name); + bsendmsg(ua, _("Client \"%s\" not found.\n"), client_name); } client = select_client_resource(ua); } @@ -361,7 +361,7 @@ int run_cmd(UAContext *ua, const char *cmd) if (fileset_name) { fileset = (FILESET *)GetResWithName(R_FILESET, fileset_name); if (!fileset) { - bsendmsg(ua, _("FileSet \"%s\" not found.\n"), fileset_name); + bsendmsg(ua, _("FileSet \"%s\" not found.\n"), fileset_name); fileset = select_fileset_resource(ua); } } else { @@ -378,7 +378,7 @@ int run_cmd(UAContext *ua, const char *cmd) if (verify_job_name) { verify_job = (JOB *)GetResWithName(R_JOB, verify_job_name); if (!verify_job) { - bsendmsg(ua, _("Verify Job \"%s\" not found.\n"), verify_job_name); + bsendmsg(ua, _("Verify Job \"%s\" not found.\n"), verify_job_name); verify_job = select_job_resource(ua); } } else { @@ -411,11 +411,11 @@ int run_cmd(UAContext *ua, const char *cmd) if (when) { jcr->sched_time = str_to_utime(when); if (jcr->sched_time == 0) { - bsendmsg(ua, _("Invalid time, using current time.\n")); + bsendmsg(ua, _("Invalid time, using current time.\n")); jcr->sched_time = time(NULL); } } - + if (bootstrap) { if (jcr->RestoreBootstrap) { free(jcr->RestoreBootstrap); @@ -431,7 +431,7 @@ int run_cmd(UAContext *ua, const char *cmd) } } if (!jcr->replace) { - bsendmsg(ua, _("Invalid replace option: %s\n"), replace); + bsendmsg(ua, _("Invalid replace option: %s\n"), replace); goto bail_out; } } else if (job->replace) { @@ -443,7 +443,7 @@ int run_cmd(UAContext *ua, const char *cmd) if (Priority) { jcr->JobPriority = Priority; } - + if (find_arg(ua, _("fdcalled")) > 0) { jcr->file_bsock = dup_bsock(ua->UA_sock); ua->quit = true; @@ -458,7 +458,7 @@ try_again: } if (level_name) { if (!get_level_from_name(jcr, level_name)) { - bsendmsg(ua, _("Level %s not valid.\n"), level_name); + bsendmsg(ua, _("Level %s not valid.\n"), level_name); goto bail_out; } } @@ -471,7 +471,7 @@ try_again: goto start_job; } - /* + /* * Prompt User to see if all run job parameters are correct, and * allow him to modify them. */ @@ -480,41 +480,41 @@ try_again: char ec1[30]; char dt[MAX_TIME_LENGTH]; case JT_ADMIN: - bsendmsg(ua, _("Run %s job\n\ -JobName: %s\n\ -FileSet: %s\n\ -Client: %s\n\ -Storage: %s\n\ -When: %s\n\ -Priority: %d\n"), - _("Admin"), + bsendmsg(ua, _("Run %s job\n" +"JobName: %s\n" +"FileSet: %s\n" +"Client: %s\n" +"Storage: %s\n" +"When: %s\n" +"Priority: %d\n"), + _("Admin"), job->hdr.name, jcr->fileset->hdr.name, NPRT(jcr->client->hdr.name), - NPRT(jcr->store->hdr.name), - bstrutime(dt, sizeof(dt), jcr->sched_time), + NPRT(jcr->store->hdr.name), + bstrutime(dt, sizeof(dt), jcr->sched_time), jcr->JobPriority); jcr->JobLevel = L_FULL; break; case JT_BACKUP: case JT_VERIFY: if (jcr->JobType == JT_BACKUP) { - bsendmsg(ua, _("Run %s job\n\ -JobName: %s\n\ -FileSet: %s\n\ -Level: %s\n\ -Client: %s\n\ -Storage: %s\n\ -Pool: %s\n\ -When: %s\n\ -Priority: %d\n"), - _("Backup"), + bsendmsg(ua, _("Run %s job\n" +"JobName: %s\n" +"FileSet: %s\n" +"Level: %s\n" +"Client: %s\n" +"Storage: %s\n" +"Pool: %s\n" +"When: %s\n" +"Priority: %d\n"), + _("Backup"), job->hdr.name, jcr->fileset->hdr.name, level_to_str(jcr->JobLevel), jcr->client->hdr.name, jcr->store->hdr.name, - NPRT(jcr->pool->hdr.name), + NPRT(jcr->pool->hdr.name), bstrutime(dt, sizeof(dt), jcr->sched_time), jcr->JobPriority); } else { /* JT_VERIFY */ @@ -522,26 +522,26 @@ Priority: %d\n"), if (jcr->verify_job) { Name = jcr->verify_job->hdr.name; } else { - Name = ""; + Name = ""; } - bsendmsg(ua, _("Run %s job\n\ -JobName: %s\n\ -FileSet: %s\n\ -Level: %s\n\ -Client: %s\n\ -Storage: %s\n\ -Pool: %s\n\ -Verify Job: %s\n\ -When: %s\n\ -Priority: %d\n"), - _("Verify"), + bsendmsg(ua, _("Run %s job\n" +"JobName: %s\n" +"FileSet: %s\n" +"Level: %s\n" +"Client: %s\n" +"Storage: %s\n" +"Pool: %s\n" +"Verify Job: %s\n" +"When: %s\n" +"Priority: %d\n"), + _("Verify"), job->hdr.name, jcr->fileset->hdr.name, level_to_str(jcr->JobLevel), jcr->client->hdr.name, jcr->store->hdr.name, - NPRT(jcr->pool->hdr.name), - Name, + NPRT(jcr->pool->hdr.name), + Name, bstrutime(dt, sizeof(dt), jcr->sched_time), jcr->JobPriority); } @@ -551,55 +551,55 @@ Priority: %d\n"), if (jid) { jcr->RestoreJobId = atoi(jid); } else { - if (!get_pint(ua, _("Please enter a JobId for restore: "))) { + if (!get_pint(ua, _("Please enter a JobId for restore: "))) { goto bail_out; - } + } jcr->RestoreJobId = ua->pint32_val; } } jcr->JobLevel = L_FULL; /* default level */ Dmsg1(20, "JobId to restore=%d\n", jcr->RestoreJobId); if (jcr->RestoreJobId == 0) { - bsendmsg(ua, _("Run Restore job\n" - "JobName: %s\n" - "Bootstrap: %s\n" - "Where: %s\n" - "Replace: %s\n" - "FileSet: %s\n" - "Client: %s\n" - "Storage: %s\n" - "When: %s\n" - "Catalog: %s\n" - "Priority: %d\n"), + bsendmsg(ua, _("Run Restore job\n" + "JobName: %s\n" + "Bootstrap: %s\n" + "Where: %s\n" + "Replace: %s\n" + "FileSet: %s\n" + "Client: %s\n" + "Storage: %s\n" + "When: %s\n" + "Catalog: %s\n" + "Priority: %d\n"), job->hdr.name, NPRT(jcr->RestoreBootstrap), jcr->where?jcr->where:NPRT(job->RestoreWhere), replace, jcr->fileset->hdr.name, jcr->client->hdr.name, - jcr->store->hdr.name, + jcr->store->hdr.name, bstrutime(dt, sizeof(dt), jcr->sched_time), jcr->catalog->hdr.name, jcr->JobPriority); } else { - bsendmsg(ua, _("Run Restore job\n" - "JobName: %s\n" - "Bootstrap: %s\n" - "Where: %s\n" - "Replace: %s\n" - "Client: %s\n" - "Storage: %s\n" - "JobId: %s\n" - "When: %s\n" - "Catalog: %s\n" - "Priority: %d\n"), + bsendmsg(ua, _("Run Restore job\n" + "JobName: %s\n" + "Bootstrap: %s\n" + "Where: %s\n" + "Replace: %s\n" + "Client: %s\n" + "Storage: %s\n" + "JobId: %s\n" + "When: %s\n" + "Catalog: %s\n" + "Priority: %d\n"), job->hdr.name, NPRT(jcr->RestoreBootstrap), jcr->where?jcr->where:NPRT(job->RestoreWhere), replace, jcr->client->hdr.name, - jcr->store->hdr.name, - jcr->RestoreJobId==0?"*None*":edit_uint64(jcr->RestoreJobId, ec1), + jcr->store->hdr.name, + jcr->RestoreJobId==0?"*None*":edit_uint64(jcr->RestoreJobId, ec1), bstrutime(dt, sizeof(dt), jcr->sched_time), jcr->catalog->hdr.name, jcr->JobPriority); @@ -633,27 +633,27 @@ Priority: %d\n"), add_prompt(ua, _("Priority")); /* 6 */ if (jcr->JobType == JT_BACKUP || jcr->JobType == JT_VERIFY) { - add_prompt(ua, _("Pool")); /* 7 */ + add_prompt(ua, _("Pool")); /* 7 */ if (jcr->JobType == JT_VERIFY) { - add_prompt(ua, _("Verify Job")); /* 8 */ + add_prompt(ua, _("Verify Job")); /* 8 */ } } else if (jcr->JobType == JT_RESTORE) { - add_prompt(ua, _("Bootstrap")); /* 7 */ - add_prompt(ua, _("Where")); /* 8 */ - add_prompt(ua, _("Replace")); /* 9 */ - add_prompt(ua, _("JobId")); /* 10 */ + add_prompt(ua, _("Bootstrap")); /* 7 */ + add_prompt(ua, _("Where")); /* 8 */ + add_prompt(ua, _("Replace")); /* 9 */ + add_prompt(ua, _("JobId")); /* 10 */ } switch (do_prompt(ua, "", _("Select parameter to modify"), NULL, 0)) { case 0: /* Level */ if (jcr->JobType == JT_BACKUP) { - start_prompt(ua, _("Levels:\n")); - add_prompt(ua, _("Base")); - add_prompt(ua, _("Full")); - add_prompt(ua, _("Incremental")); - add_prompt(ua, _("Differential")); - add_prompt(ua, _("Since")); - switch (do_prompt(ua, "", _("Select level"), NULL, 0)) { + start_prompt(ua, _("Levels:\n")); + add_prompt(ua, _("Base")); + add_prompt(ua, _("Full")); + add_prompt(ua, _("Incremental")); + add_prompt(ua, _("Differential")); + add_prompt(ua, _("Since")); + switch (do_prompt(ua, "", _("Select level"), NULL, 0)) { case 0: jcr->JobLevel = L_BASE; break; @@ -674,13 +674,13 @@ Priority: %d\n"), } goto try_again; } else if (jcr->JobType == JT_VERIFY) { - start_prompt(ua, _("Levels:\n")); - add_prompt(ua, _("Initialize Catalog")); - add_prompt(ua, _("Verify Catalog")); - add_prompt(ua, _("Verify Volume to Catalog")); - add_prompt(ua, _("Verify Disk to Catalog")); - add_prompt(ua, _("Verify Volume Data (not yet implemented)")); - switch (do_prompt(ua, "", _("Select level"), NULL, 0)) { + start_prompt(ua, _("Levels:\n")); + add_prompt(ua, _("Initialize Catalog")); + add_prompt(ua, _("Verify Catalog")); + add_prompt(ua, _("Verify Volume to Catalog")); + add_prompt(ua, _("Verify Disk to Catalog")); + add_prompt(ua, _("Verify Volume Data (not yet implemented)")); + switch (do_prompt(ua, "", _("Select level"), NULL, 0)) { case 0: jcr->JobLevel = L_VERIFY_INIT; break; @@ -701,7 +701,7 @@ Priority: %d\n"), } goto try_again; } else { - bsendmsg(ua, _("Level not appropriate for this Job. Cannot be changed.\n")); + bsendmsg(ua, _("Level not appropriate for this Job. Cannot be changed.\n")); } goto try_again; case 1: @@ -727,7 +727,7 @@ Priority: %d\n"), if (fileset) { jcr->fileset = fileset; goto try_again; - } + } break; case 4: /* Client */ @@ -739,7 +739,7 @@ Priority: %d\n"), break; case 5: /* When */ - if (!get_cmd(ua, _("Please enter desired start time as YYYY-MM-DD HH:MM:SS (return for now): "))) { + if (!get_cmd(ua, _("Please enter desired start time as YYYY-MM-DD HH:MM:SS (return for now): "))) { break; } if (ua->cmd[0] == 0) { @@ -747,18 +747,18 @@ Priority: %d\n"), } else { jcr->sched_time = str_to_utime(ua->cmd); if (jcr->sched_time == 0) { - bsendmsg(ua, _("Invalid time, using current time.\n")); + bsendmsg(ua, _("Invalid time, using current time.\n")); jcr->sched_time = time(NULL); } } goto try_again; case 6: /* Priority */ - if (!get_pint(ua, _("Enter new Priority: "))) { + if (!get_pint(ua, _("Enter new Priority: "))) { break; } if (ua->pint32_val == 0) { - bsendmsg(ua, _("Priority must be a positive integer.\n")); + bsendmsg(ua, _("Priority must be a positive integer.\n")); } else { jcr->JobPriority = ua->pint32_val; } @@ -776,7 +776,7 @@ Priority: %d\n"), } /* Bootstrap */ - if (!get_cmd(ua, _("Please enter the Bootstrap file name: "))) { + if (!get_cmd(ua, _("Please enter the Bootstrap file name: "))) { break; } if (jcr->RestoreBootstrap) { @@ -785,9 +785,9 @@ Priority: %d\n"), } if (ua->cmd[0] != 0) { jcr->RestoreBootstrap = bstrdup(ua->cmd); - fd = fopen(jcr->RestoreBootstrap, "r"); + fd = fopen(jcr->RestoreBootstrap, "r"); if (!fd) { - bsendmsg(ua, _("Warning cannot open %s: ERR=%s\n"), + bsendmsg(ua, _("Warning cannot open %s: ERR=%s\n"), jcr->RestoreBootstrap, strerror(errno)); free(jcr->RestoreBootstrap); jcr->RestoreBootstrap = NULL; @@ -806,25 +806,25 @@ Priority: %d\n"), goto try_again; } /* Where */ - if (!get_cmd(ua, _("Please enter path prefix for restore (/ for none): "))) { + if (!get_cmd(ua, _("Please enter path prefix for restore (/ for none): "))) { break; } if (jcr->where) { free(jcr->where); jcr->where = NULL; } - if (ua->cmd[0] == '/' && ua->cmd[1] == 0) { + if (ua->cmd[0] == '/' && ua->cmd[1] == 0) { ua->cmd[0] = 0; } jcr->where = bstrdup(ua->cmd); goto try_again; case 9: /* Replace */ - start_prompt(ua, _("Replace:\n")); + start_prompt(ua, _("Replace:\n")); for (i=0; ReplaceOptions[i].name; i++) { add_prompt(ua, ReplaceOptions[i].name); } - opt = do_prompt(ua, "", _("Select replace option"), NULL, 0); + opt = do_prompt(ua, "", _("Select replace option"), NULL, 0); if (opt >= 0) { jcr->replace = ReplaceOptions[opt].token; } @@ -834,10 +834,10 @@ Priority: %d\n"), jid = NULL; /* force reprompt */ jcr->RestoreJobId = 0; if (jcr->RestoreBootstrap) { - bsendmsg(ua, _("You must set the bootstrap file to NULL to be able to specify a JobId.\n")); + bsendmsg(ua, _("You must set the bootstrap file to NULL to be able to specify a JobId.\n")); } goto try_again; - default: + default: goto try_again; } goto bail_out; @@ -850,9 +850,9 @@ start_job: JobId = run_job(jcr); free_jcr(jcr); /* release jcr */ if (JobId == 0) { - bsendmsg(ua, _("Job failed.\n")); + bsendmsg(ua, _("Job failed.\n")); } else { - bsendmsg(ua, _("Job started. JobId=%u\n"), JobId); + bsendmsg(ua, _("Job started. JobId=%u\n"), JobId); } return JobId; } diff --git a/bacula/src/dird/ua_select.c b/bacula/src/dird/ua_select.c index 4ea140929d..eb8b21533e 100644 --- a/bacula/src/dird/ua_select.c +++ b/bacula/src/dird/ua_select.c @@ -42,17 +42,17 @@ int confirm_retention(UAContext *ua, utime_t *ret, const char *msg) char ed1[100]; for ( ;; ) { - bsendmsg(ua, _("The current %s retention period is: %s\n"), + bsendmsg(ua, _("The current %s retention period is: %s\n"), msg, edit_utime(*ret, ed1, sizeof(ed1))); if (!get_cmd(ua, _("Continue? (yes/mod/no): "))) { return 0; } if (strcasecmp(ua->cmd, _("mod")) == 0) { - if (!get_cmd(ua, _("Enter new retention period: "))) { + if (!get_cmd(ua, _("Enter new retention period: "))) { return 0; } if (!duration_to_utime(ua->cmd, ret)) { - bsendmsg(ua, _("Invalid period.\n")); + bsendmsg(ua, _("Invalid period.\n")); continue; } continue; @@ -67,7 +67,7 @@ int confirm_retention(UAContext *ua, utime_t *ret, const char *msg) return 1; } -/* +/* * Given a list of keywords, find the first one * that is in the argument list. * Returns: -1 if not found @@ -85,7 +85,7 @@ int find_arg_keyword(UAContext *ua, const char **list) return -1; } -/* +/* * Given one keyword, find the first one that * is in the argument list. * Returns: argk index (always gt 0) @@ -101,7 +101,7 @@ int find_arg(UAContext *ua, const char *keyword) return -1; } -/* +/* * Given a single keyword, find it in the argument list, but * it must have a value * Returns: -1 if not found or no value @@ -121,8 +121,8 @@ int find_arg_with_value(UAContext *ua, const char *keyword) return -1; } -/* - * Given a list of keywords, prompt the user +/* + * Given a list of keywords, prompt the user * to choose one. * * Returns: -1 on failure @@ -139,12 +139,12 @@ int do_keyword_prompt(UAContext *ua, const char *msg, const char **list) } -/* +/* * Select a Storage resource from prompt list */ STORE *select_storage_resource(UAContext *ua) { - char name[MAX_NAME_LENGTH]; + char name[MAX_NAME_LENGTH]; STORE *store; start_prompt(ua, _("The defined Storage resources are:\n")); @@ -160,12 +160,12 @@ STORE *select_storage_resource(UAContext *ua) return store; } -/* +/* * Select a FileSet resource from prompt list */ FILESET *select_fileset_resource(UAContext *ua) { - char name[MAX_NAME_LENGTH]; + char name[MAX_NAME_LENGTH]; FILESET *fs; start_prompt(ua, _("The defined FileSet resources are:\n")); @@ -182,12 +182,12 @@ FILESET *select_fileset_resource(UAContext *ua) } -/* +/* * Get a catalog resource from prompt list */ CAT *get_catalog_resource(UAContext *ua) { - char name[MAX_NAME_LENGTH]; + char name[MAX_NAME_LENGTH]; CAT *catalog = NULL; int i; @@ -215,12 +215,12 @@ CAT *get_catalog_resource(UAContext *ua) } -/* +/* * Select a Job resource from prompt list */ JOB *select_job_resource(UAContext *ua) { - char name[MAX_NAME_LENGTH]; + char name[MAX_NAME_LENGTH]; JOB *job; start_prompt(ua, _("The defined Job resources are:\n")); @@ -236,12 +236,12 @@ JOB *select_job_resource(UAContext *ua) return job; } -/* +/* * Select a Restore Job resource from prompt list */ JOB *select_restore_job_resource(UAContext *ua) { - char name[MAX_NAME_LENGTH]; + char name[MAX_NAME_LENGTH]; JOB *job; start_prompt(ua, _("The defined Restore Job resources are:\n")); @@ -259,12 +259,12 @@ JOB *select_restore_job_resource(UAContext *ua) -/* +/* * Select a client resource from prompt list */ CLIENT *select_client_resource(UAContext *ua) { - char name[MAX_NAME_LENGTH]; + char name[MAX_NAME_LENGTH]; CLIENT *client; start_prompt(ua, _("The defined Client resources are:\n")); @@ -289,10 +289,10 @@ CLIENT *get_client_resource(UAContext *ua) { CLIENT *client = NULL; int i; - + for (i=1; iargc; i++) { if ((strcasecmp(ua->argk[i], _("client")) == 0 || - strcasecmp(ua->argk[i], _("fd")) == 0) && ua->argv[i]) { + strcasecmp(ua->argk[i], _("fd")) == 0) && ua->argv[i]) { if (!acl_access_ok(ua, Client_ACL, ua->argv[i])) { break; } @@ -300,7 +300,7 @@ CLIENT *get_client_resource(UAContext *ua) if (client) { return client; } - bsendmsg(ua, _("Error: Client resource %s does not exist.\n"), ua->argv[i]); + bsendmsg(ua, _("Error: Client resource %s does not exist.\n"), ua->argv[i]); break; } } @@ -308,7 +308,7 @@ CLIENT *get_client_resource(UAContext *ua) } /* Scan what the user has entered looking for: - * + * * client= * * if error or not found, put up a list of client DBRs @@ -328,14 +328,14 @@ int get_client_dbr(UAContext *ua, CLIENT_DBR *cr) bsendmsg(ua, _("Could not find Client %s: ERR=%s"), cr->Name, db_strerror(ua->db)); } for (i=1; iargc; i++) { - if ((strcasecmp(ua->argk[i], _("client")) == 0 || - strcasecmp(ua->argk[i], _("fd")) == 0) && ua->argv[i]) { + if ((strcasecmp(ua->argk[i], _("client")) == 0 || + strcasecmp(ua->argk[i], _("fd")) == 0) && ua->argv[i]) { if (!acl_access_ok(ua, Client_ACL, ua->argv[i])) { break; } bstrncpy(cr->Name, ua->argv[i], sizeof(cr->Name)); if (!db_get_client_record(ua->jcr, ua->db, cr)) { - bsendmsg(ua, _("Could not find Client \"%s\": ERR=%s"), ua->argv[i], + bsendmsg(ua, _("Could not find Client \"%s\": ERR=%s"), ua->argv[i], db_strerror(ua->db)); cr->ClientId = 0; break; @@ -359,7 +359,7 @@ int select_client_dbr(UAContext *ua, CLIENT_DBR *cr) CLIENT_DBR ocr; char name[MAX_NAME_LENGTH]; int num_clients, i; - uint32_t *ids; + uint32_t *ids; cr->ClientId = 0; @@ -371,7 +371,7 @@ int select_client_dbr(UAContext *ua, CLIENT_DBR *cr) bsendmsg(ua, _("No clients defined. You must run a job before using this command.\n")); return 0; } - + start_prompt(ua, _("Defined Clients:\n")); for (i=0; i < num_clients; i++) { ocr.ClientId = ids[i]; @@ -399,8 +399,8 @@ int select_client_dbr(UAContext *ua, CLIENT_DBR *cr) /* Scan what the user has entered looking for: - * - * pool= + * + * pool= * * if error or not found, put up a list of pool DBRs * to choose from. @@ -412,7 +412,7 @@ bool get_pool_dbr(UAContext *ua, POOL_DBR *pr) { if (pr->Name[0]) { /* If name already supplied */ if (db_get_pool_record(ua->jcr, ua->db, pr) && - acl_access_ok(ua, Pool_ACL, pr->Name)) { + acl_access_ok(ua, Pool_ACL, pr->Name)) { return true; } bsendmsg(ua, _("Could not find Pool \"%s\": ERR=%s"), pr->Name, db_strerror(ua->db)); @@ -431,14 +431,14 @@ bool select_pool_dbr(UAContext *ua, POOL_DBR *pr) POOL_DBR opr; char name[MAX_NAME_LENGTH]; int num_pools, i; - uint32_t *ids; + uint32_t *ids; for (i=1; iargc; i++) { if (strcasecmp(ua->argk[i], _("pool")) == 0 && ua->argv[i] && acl_access_ok(ua, Pool_ACL, ua->argv[i])) { bstrncpy(pr->Name, ua->argv[i], sizeof(pr->Name)); if (!db_get_pool_record(ua->jcr, ua->db, pr)) { - bsendmsg(ua, _("Could not find Pool \"%s\": ERR=%s"), ua->argv[i], + bsendmsg(ua, _("Could not find Pool \"%s\": ERR=%s"), ua->argv[i], db_strerror(ua->db)); pr->PoolId = 0; break; @@ -456,7 +456,7 @@ bool select_pool_dbr(UAContext *ua, POOL_DBR *pr) bsendmsg(ua, _("No pools defined. Use the \"create\" command to create one.\n")); return false; } - + start_prompt(ua, _("Defined Pools:\n")); for (i=0; i < num_pools; i++) { opr.PoolId = ids[i]; @@ -541,12 +541,12 @@ int select_media_dbr(UAContext *ua, MEDIA_DBR *mr) } -/* +/* * Select a pool resource from prompt list */ POOL *select_pool_resource(UAContext *ua) { - char name[MAX_NAME_LENGTH]; + char name[MAX_NAME_LENGTH]; POOL *pool; start_prompt(ua, _("The defined Pool resources are:\n")); @@ -565,14 +565,14 @@ POOL *select_pool_resource(UAContext *ua) /* * If you are thinking about using it, you - * probably want to use select_pool_dbr() + * probably want to use select_pool_dbr() * or get_pool_dbr() above. */ POOL *get_pool_resource(UAContext *ua) { POOL *pool = NULL; int i; - + i = find_arg_with_value(ua, "pool"); if (i >= 0 && acl_access_ok(ua, Pool_ACL, ua->argv[i])) { pool = (POOL *)GetResWithName(R_POOL, ua->argv[i]); @@ -604,7 +604,7 @@ int select_job_dbr(UAContext *ua, JOB_DBR *jr) /* Scan what the user has entered looking for: - * + * * jobid=nn * * if error or not found, put up a list of Jobs @@ -627,7 +627,7 @@ int get_job_dbr(UAContext *ua, JOB_DBR *jr) continue; } if (!db_get_job_record(ua->jcr, ua->db, jr)) { - bsendmsg(ua, _("Could not find Job \"%s\": ERR=%s"), ua->argv[i], + bsendmsg(ua, _("Could not find Job \"%s\": ERR=%s"), ua->argv[i], db_strerror(ua->db)); jr->JobId = 0; break; @@ -642,7 +642,7 @@ int get_job_dbr(UAContext *ua, JOB_DBR *jr) } /* - * Implement unique set of prompts + * Implement unique set of prompts */ void start_prompt(UAContext *ua, const char *msg) { @@ -655,7 +655,7 @@ void start_prompt(UAContext *ua, const char *msg) } /* - * Add to prompts -- keeping them unique + * Add to prompts -- keeping them unique */ void add_prompt(UAContext *ua, const char *prompt) { @@ -710,30 +710,30 @@ int do_prompt(UAContext *ua, const char *automsg, const char *msg, char *prompt, for ( ;; ) { /* First item is the prompt string, not the items */ - if (ua->num_prompts == 1) { - bsendmsg(ua, _("Selection is empty!\n")); + if (ua->num_prompts == 1) { + bsendmsg(ua, _("Selection is empty!\n")); item = 0; /* list is empty ! */ break; } if (ua->num_prompts == 2) { item = 1; - bsendmsg(ua, _("Item 1 selected automatically.\n")); + bsendmsg(ua, _("Item 1 selected automatically.\n")); if (prompt) { bstrncpy(prompt, ua->prompt[1], max_prompt); } break; } else { - sprintf(pmsg, "%s (1-%d): ", msg, ua->num_prompts-1); + sprintf(pmsg, "%s (1-%d): ", msg, ua->num_prompts-1); } /* Either a . or an @ will get you out of the loop */ if (!get_pint(ua, pmsg)) { item = -1; /* error */ - bsendmsg(ua, _("Selection aborted, nothing done.\n")); + bsendmsg(ua, _("Selection aborted, nothing done.\n")); break; } item = ua->pint32_val; if (item < 1 || item >= ua->num_prompts) { - bsendmsg(ua, _("Please enter a number between 1 and %d\n"), ua->num_prompts-1); + bsendmsg(ua, _("Please enter a number between 1 and %d\n"), ua->num_prompts-1); continue; } if (prompt) { @@ -741,7 +741,7 @@ int do_prompt(UAContext *ua, const char *automsg, const char *msg, char *prompt, } break; } - + done: for (i=0; i < ua->num_prompts; i++) { free(ua->prompt[i]); @@ -769,53 +769,53 @@ STORE *get_storage_resource(UAContext *ua, int use_default) int jobid; JCR *jcr; int i; - + for (i=1; iargc; i++) { if (use_default && !ua->argv[i]) { /* Ignore slots, scan and barcode(s) keywords */ - if (strncasecmp("scan", ua->argk[i], 4) == 0 || - strncasecmp("barcode", ua->argk[i], 7) == 0 || - strncasecmp("slots", ua->argk[i], 5) == 0) { + if (strncasecmp("scan", ua->argk[i], 4) == 0 || + strncasecmp("barcode", ua->argk[i], 7) == 0 || + strncasecmp("slots", ua->argk[i], 5) == 0) { continue; } /* Default argument is storage */ if (store_name) { - bsendmsg(ua, _("Storage name given twice.\n")); + bsendmsg(ua, _("Storage name given twice.\n")); return NULL; } store_name = ua->argk[i]; - if (*store_name == '?') { + if (*store_name == '?') { *store_name = 0; break; } } else { - if (strcasecmp(ua->argk[i], _("storage")) == 0 || - strcasecmp(ua->argk[i], _("sd")) == 0) { + if (strcasecmp(ua->argk[i], _("storage")) == 0 || + strcasecmp(ua->argk[i], _("sd")) == 0) { store_name = ua->argv[i]; break; - } else if (strcasecmp(ua->argk[i], _("jobid")) == 0) { + } else if (strcasecmp(ua->argk[i], _("jobid")) == 0) { jobid = str_to_int64(ua->argv[i]); if (jobid <= 0) { - bsendmsg(ua, _("Expecting jobid=nn command, got: %s\n"), ua->argk[i]); + bsendmsg(ua, _("Expecting jobid=nn command, got: %s\n"), ua->argk[i]); return NULL; } if (!(jcr=get_jcr_by_id(jobid))) { - bsendmsg(ua, _("JobId %d is not running.\n"), jobid); + bsendmsg(ua, _("JobId %d is not running.\n"), jobid); return NULL; } store = jcr->store; free_jcr(jcr); break; - } else if (strcasecmp(ua->argk[i], _("job")) == 0) { + } else if (strcasecmp(ua->argk[i], _("job")) == 0) { if (!ua->argv[i]) { - bsendmsg(ua, _("Expecting job=xxx, got: %s.\n"), ua->argk[i]); + bsendmsg(ua, _("Expecting job=xxx, got: %s.\n"), ua->argk[i]); return NULL; } if (!(jcr=get_jcr_by_partial_name(ua->argv[i]))) { - bsendmsg(ua, _("Job \"%s\" is not running.\n"), ua->argv[i]); + bsendmsg(ua, _("Job \"%s\" is not running.\n"), ua->argv[i]); return NULL; } store = jcr->store; @@ -827,11 +827,11 @@ STORE *get_storage_resource(UAContext *ua, int use_default) if (store && !acl_access_ok(ua, Storage_ACL, store->hdr.name)) { store = NULL; } - + if (!store && store_name) { store = (STORE *)GetResWithName(R_STORAGE, store_name); if (!store) { - bsendmsg(ua, "Storage resource \"%s\": not found\n", store_name); + bsendmsg(ua, "Storage resource \"%s\": not found\n", store_name); } } if (store && !acl_access_ok(ua, Storage_ACL, store->hdr.name)) { @@ -846,7 +846,7 @@ STORE *get_storage_resource(UAContext *ua, int use_default) /* - * Scan looking for mediatype= + * Scan looking for mediatype= * * if not found or error, put up selection list * diff --git a/bacula/src/dird/ua_server.c b/bacula/src/dird/ua_server.c index 1c6da1fbef..3e4adef377 100644 --- a/bacula/src/dird/ua_server.c +++ b/bacula/src/dird/ua_server.c @@ -81,7 +81,7 @@ void start_UA_server(dlist *addrs) return; } -extern "C" +extern "C" void *connect_thread(void *arg) { pthread_detach(pthread_self()); @@ -119,7 +119,7 @@ JCR *new_control_jcr(const char *base_name, int job_type) } /* - * Handle Director User Agent commands + * Handle Director User Agent commands * */ static void *handle_UA_client_request(void *arg) @@ -146,18 +146,18 @@ static void *handle_UA_client_request(void *arg) if (stat >= 0) { pm_strcpy(ua->cmd, ua->UA_sock->msg); parse_ua_args(ua); - if (ua->argc > 0 && ua->argk[0][0] == '.') { + if (ua->argc > 0 && ua->argk[0][0] == '.') { do_a_dot_command(ua, ua->cmd); } else { do_a_command(ua, ua->cmd); } if (!ua->quit) { if (ua->auto_display_messages) { - strcpy(ua->cmd, "messages"); + strcpy(ua->cmd, "messages"); qmessagescmd(ua, ua->cmd); ua->user_notified_msg_pending = FALSE; } else if (!ua->user_notified_msg_pending && console_msg_pending) { - bsendmsg(ua, _("You have messages.\n")); + bsendmsg(ua, _("You have messages.\n")); ua->user_notified_msg_pending = TRUE; } bnet_sig(ua->UA_sock, BNET_EOD); /* send end of command */ @@ -179,7 +179,7 @@ getout: /* * Create a UAContext for a Job that is running so that - * it can the User Agent routines and + * it can the User Agent routines and * to ensure that the Job gets the proper output. * This is a sort of mini-kludge, and should be * unified at some point. @@ -219,7 +219,7 @@ void free_ua_context(UAContext *ua) /* - * Called from main Bacula thread + * Called from main Bacula thread */ void term_ua_server() { diff --git a/bacula/src/dird/ua_status.c b/bacula/src/dird/ua_status.c index 78adcfb54b..4040e9af6e 100644 --- a/bacula/src/dird/ua_status.c +++ b/bacula/src/dird/ua_status.c @@ -52,7 +52,7 @@ int qstatus_cmd(UAContext *ua, const char *cmd) { JCR* njcr; s_last_job* job; - + if (!open_db(ua)) { return 1; } @@ -62,7 +62,7 @@ int qstatus_cmd(UAContext *ua, const char *cmd) bsendmsg(ua, "1900 Bad .status command, missing arguments.\n"); return 1; } - + if (strcasecmp(ua->argk[2], "current") == 0) { bsendmsg(ua, OKqstatus, ua->argk[2]); lock_jcr_chain(); @@ -85,7 +85,7 @@ int qstatus_cmd(UAContext *ua, const char *cmd) bsendmsg(ua, "1900 Bad .status command, wrong argument.\n"); return 1; } - + return 1; } @@ -108,7 +108,7 @@ int status_cmd(UAContext *ua, const char *cmd) do_all_status(ua); return 1; } else if (strcasecmp(ua->argk[i], _("dir")) == 0 || - strcasecmp(ua->argk[i], _("director")) == 0) { + strcasecmp(ua->argk[i], _("director")) == 0) { do_director_status(ua); return 1; } else if (strcasecmp(ua->argk[i], _("client")) == 0) { @@ -126,9 +126,9 @@ int status_cmd(UAContext *ua, const char *cmd) } } /* If no args, ask for status type */ - if (ua->argc == 1) { - char prmt[MAX_NAME_LENGTH]; - + if (ua->argc == 1) { + char prmt[MAX_NAME_LENGTH]; + start_prompt(ua, _("Status available for:\n")); add_prompt(ua, _("Director")); add_prompt(ua, _("Storage")); @@ -139,7 +139,7 @@ int status_cmd(UAContext *ua, const char *cmd) return 1; } Dmsg1(20, "item=%d\n", item); - switch (item) { + switch (item) { case 0: /* Director */ do_director_status(ua); break; @@ -181,7 +181,7 @@ static void do_all_status(UAContext *ua) i++; } unique_store = (STORE **) malloc(i * sizeof(STORE)); - /* Find Unique Storage address/port */ + /* Find Unique Storage address/port */ i = 0; foreach_res(store, R_STORAGE) { found = false; @@ -197,7 +197,7 @@ static void do_all_status(UAContext *ua) } if (!found) { unique_store[i++] = store; - Dmsg2(40, "Stuffing: %s:%d\n", store->address, store->SDport); + Dmsg2(40, "Stuffing: %s:%d\n", store->address, store->SDport); } } UnlockRes(); @@ -215,7 +215,7 @@ static void do_all_status(UAContext *ua) i++; } unique_client = (CLIENT **)malloc(i * sizeof(CLIENT)); - /* Find Unique Client address/port */ + /* Find Unique Client address/port */ i = 0; foreach_res(client, R_CLIENT) { found = false; @@ -231,7 +231,7 @@ static void do_all_status(UAContext *ua) } if (!found) { unique_client[i++] = client; - Dmsg2(40, "Stuffing: %s:%d\n", client->address, client->FDport); + Dmsg2(40, "Stuffing: %s:%d\n", client->address, client->FDport); } } UnlockRes(); @@ -241,7 +241,7 @@ static void do_all_status(UAContext *ua) do_client_status(ua, unique_client[j]); } free(unique_client); - + } static void do_director_status(UAContext *ua) @@ -251,8 +251,8 @@ static void do_director_status(UAContext *ua) bsendmsg(ua, "%s Version: " VERSION " (" BDATE ") %s %s %s\n", my_name, HOST_OS, DISTNAME, DISTVER); bstrftime_nc(dt, sizeof(dt), daemon_start_time); - bsendmsg(ua, _("Daemon started %s, %d Job%s run since started.\n"), - dt, num_jobs_run, num_jobs_run == 1 ? "" : "s"); + bsendmsg(ua, _("Daemon started %s, %d Job%s run since started.\n"), + dt, num_jobs_run, num_jobs_run == 1 ? "" : "s"); if (debug_level > 0) { char b1[35], b2[35], b3[35], b4[35]; bsendmsg(ua, _(" Heap: bytes=%s max_bytes=%s bufs=%s max_bufs=%s\n"), @@ -266,12 +266,12 @@ static void do_director_status(UAContext *ua) */ list_scheduled_jobs(ua); - /* + /* * List running jobs */ list_running_jobs(ua); - /* + /* * List terminated jobs */ list_terminated_jobs(ua); @@ -284,7 +284,7 @@ static void do_storage_status(UAContext *ua, STORE *store) set_storage(ua->jcr, store); /* Try connecting for up to 15 seconds */ - bsendmsg(ua, _("Connecting to Storage daemon %s at %s:%d\n"), + bsendmsg(ua, _("Connecting to Storage daemon %s at %s:%d\n"), store->hdr.name, store->address, store->SDport); if (!connect_to_storage_daemon(ua->jcr, 1, 15, 0)) { bsendmsg(ua, _("\nFailed to connect to Storage daemon %s.\n====\n"), @@ -292,7 +292,7 @@ static void do_storage_status(UAContext *ua, STORE *store) if (ua->jcr->store_bsock) { bnet_close(ua->jcr->store_bsock); ua->jcr->store_bsock = NULL; - } + } return; } Dmsg0(20, _("Connected to storage daemon\n")); @@ -304,9 +304,9 @@ static void do_storage_status(UAContext *ua, STORE *store) bnet_sig(sd, BNET_TERMINATE); bnet_close(sd); ua->jcr->store_bsock = NULL; - return; + return; } - + static void do_client_status(UAContext *ua, CLIENT *client) { BSOCK *fd; @@ -322,7 +322,7 @@ static void do_client_status(UAContext *ua, CLIENT *client) ua->jcr->sd_auth_key = bstrdup("dummy"); /* Try to connect for 15 seconds */ - bsendmsg(ua, _("Connecting to Client %s at %s:%d\n"), + bsendmsg(ua, _("Connecting to Client %s at %s:%d\n"), client->hdr.name, client->address, client->FDport); if (!connect_to_file_daemon(ua->jcr, 1, 15, 0)) { bsendmsg(ua, _("Failed to connect to Client %s.\n====\n"), @@ -330,7 +330,7 @@ static void do_client_status(UAContext *ua, CLIENT *client) if (ua->jcr->file_bsock) { bnet_close(ua->jcr->file_bsock); ua->jcr->file_bsock = NULL; - } + } return; } Dmsg0(20, _("Connected to file daemon\n")); @@ -343,7 +343,7 @@ static void do_client_status(UAContext *ua, CLIENT *client) bnet_close(fd); ua->jcr->file_bsock = NULL; - return; + return; } static void prt_runhdr(UAContext *ua) @@ -365,7 +365,7 @@ struct sched_pkt { static void prt_runtime(UAContext *ua, sched_pkt *sp) { - char dt[MAX_TIME_LENGTH]; + char dt[MAX_TIME_LENGTH]; const char *level_ptr; bool ok = false; bool close_db = false; @@ -382,7 +382,7 @@ static void prt_runtime(UAContext *ua, sched_pkt *sp) ok = find_next_volume_for_append(jcr, &mr, 0); } if (!ok) { - bstrncpy(mr.VolumeName, "*unknown*", sizeof(mr.VolumeName)); + bstrncpy(mr.VolumeName, "*unknown*", sizeof(mr.VolumeName)); } } bstrftime_nc(dt, sizeof(dt), sp->runtime); @@ -395,8 +395,8 @@ static void prt_runtime(UAContext *ua, sched_pkt *sp) level_ptr = level_to_str(sp->level); break; } - bsendmsg(ua, _("%-14s %-8s %3d %-18s %-18s %s\n"), - level_ptr, job_type_to_str(sp->job->JobType), sp->priority, dt, + bsendmsg(ua, _("%-14s %-8s %3d %-18s %-18s %s\n"), + level_ptr, job_type_to_str(sp->job->JobType), sp->priority, dt, sp->job->hdr.name, mr.VolumeName); if (close_db) { db_close_database(jcr, jcr->db); @@ -416,7 +416,7 @@ static int my_compare(void *item1, void *item2) return -1; } else if (p1->runtime > p2->runtime) { return 1; - } + } if (p1->priority < p2->priority) { return -1; } else if (p1->priority > p2->priority) { @@ -425,7 +425,7 @@ static int my_compare(void *item1, void *item2) return 0; } -/* +/* * Find all jobs to be run in roughly the * next 24 hours. */ @@ -453,7 +453,7 @@ static void list_scheduled_jobs(UAContext *ua) if (run->level) { level = run->level; } - priority = job->Priority; + priority = job->Priority; if (run->Priority) { priority = run->Priority; } @@ -477,7 +477,7 @@ static void list_scheduled_jobs(UAContext *ua) } if (num_jobs == 0) { bsendmsg(ua, _("No Scheduled Jobs.\n")); - } + } bsendmsg(ua, "====\n"); Dmsg0(200, "Leave list_sched_jobs_runs()\n"); } @@ -503,7 +503,7 @@ static void list_running_jobs(UAContext *ua) */ if (jcr->JobType == JT_CONSOLE) { bstrftime_nc(dt, sizeof(dt), jcr->start_time); - bsendmsg(ua, _("Console connected at %s\n"), dt); + bsendmsg(ua, _("Console connected at %s\n"), dt); } njobs--; } @@ -527,72 +527,72 @@ static void list_running_jobs(UAContext *ua) njobs++; switch (jcr->JobStatus) { case JS_Created: - msg = _("is waiting execution"); + msg = _("is waiting execution"); break; case JS_Running: - msg = _("is running"); + msg = _("is running"); break; case JS_Blocked: - msg = _("is blocked"); + msg = _("is blocked"); break; case JS_Terminated: - msg = _("has terminated"); + msg = _("has terminated"); break; case JS_ErrorTerminated: - msg = _("has erred"); + msg = _("has erred"); break; case JS_Error: - msg = _("has errors"); + msg = _("has errors"); break; case JS_FatalError: - msg = _("has a fatal error"); + msg = _("has a fatal error"); break; case JS_Differences: - msg = _("has verify differences"); + msg = _("has verify differences"); break; case JS_Canceled: - msg = _("has been canceled"); + msg = _("has been canceled"); break; case JS_WaitFD: emsg = (char *) get_pool_memory(PM_FNAME); - Mmsg(emsg, _("is waiting on Client %s"), jcr->client->hdr.name); + Mmsg(emsg, _("is waiting on Client %s"), jcr->client->hdr.name); pool_mem = true; msg = emsg; break; case JS_WaitSD: emsg = (char *) get_pool_memory(PM_FNAME); - Mmsg(emsg, _("is waiting on Storage %s"), jcr->store->hdr.name); + Mmsg(emsg, _("is waiting on Storage %s"), jcr->store->hdr.name); pool_mem = true; msg = emsg; break; case JS_WaitStoreRes: - msg = _("is waiting on max Storage jobs"); + msg = _("is waiting on max Storage jobs"); break; case JS_WaitClientRes: - msg = _("is waiting on max Client jobs"); + msg = _("is waiting on max Client jobs"); break; case JS_WaitJobRes: - msg = _("is waiting on max Job jobs"); + msg = _("is waiting on max Job jobs"); break; case JS_WaitMaxJobs: - msg = _("is waiting on max total jobs"); + msg = _("is waiting on max total jobs"); break; case JS_WaitStartTime: - msg = _("is waiting for its start time"); + msg = _("is waiting for its start time"); break; case JS_WaitPriority: - msg = _("is waiting for higher priority jobs to finish"); + msg = _("is waiting for higher priority jobs to finish"); break; default: emsg = (char *) get_pool_memory(PM_FNAME); - Mmsg(emsg, _("is in unknown state %c"), jcr->JobStatus); + Mmsg(emsg, _("is in unknown state %c"), jcr->JobStatus); pool_mem = true; msg = emsg; break; } - /* - * Now report Storage daemon status code + /* + * Now report Storage daemon status code */ switch (jcr->SDJobStatus) { case JS_WaitMount: @@ -600,21 +600,21 @@ static void list_running_jobs(UAContext *ua) free_pool_memory(emsg); pool_mem = false; } - msg = _("is waiting for a mount request"); + msg = _("is waiting for a mount request"); break; case JS_WaitMedia: if (pool_mem) { free_pool_memory(emsg); pool_mem = false; } - msg = _("is waiting for an appendable Volume"); + msg = _("is waiting for an appendable Volume"); break; case JS_WaitFD: if (!pool_mem) { emsg = (char *) get_pool_memory(PM_FNAME); pool_mem = true; } - Mmsg(emsg, _("is waiting for Client %s to connect to Storage %s"), + Mmsg(emsg, _("is waiting for Client %s to connect to Storage %s"), jcr->client->hdr.name, jcr->store->hdr.name); msg = emsg; break; @@ -622,7 +622,7 @@ static void list_running_jobs(UAContext *ua) switch (jcr->JobType) { case JT_ADMIN: case JT_RESTORE: - bstrncpy(level, " ", sizeof(level)); + bstrncpy(level, " ", sizeof(level)); break; default: bstrncpy(level, level_to_str(jcr->JobLevel), sizeof(level)); @@ -630,9 +630,9 @@ static void list_running_jobs(UAContext *ua) break; } - bsendmsg(ua, _("%6d %-6s %-20s %s\n"), + bsendmsg(ua, _("%6d %-6s %-20s %s\n"), jcr->JobId, - level, + level, jcr->Job, msg); @@ -669,7 +669,7 @@ static void list_terminated_jobs(UAContext *ua) switch (je->JobType) { case JT_ADMIN: case JT_RESTORE: - bstrncpy(level, " ", sizeof(level)); + bstrncpy(level, " ", sizeof(level)); break; default: bstrncpy(level, level_to_str(je->JobLevel), sizeof(level)); @@ -678,38 +678,38 @@ static void list_terminated_jobs(UAContext *ua) } switch (je->JobStatus) { case JS_Created: - termstat = "Created"; + termstat = "Created"; break; case JS_FatalError: case JS_ErrorTerminated: - termstat = "Error"; + termstat = "Error"; break; case JS_Differences: - termstat = "Diffs"; + termstat = "Diffs"; break; case JS_Canceled: - termstat = "Cancel"; + termstat = "Cancel"; break; case JS_Terminated: - termstat = "OK"; + termstat = "OK"; break; default: - termstat = "Other"; + termstat = "Other"; break; } bstrncpy(JobName, je->Job, sizeof(JobName)); /* There are three periods after the Job name */ char *p; for (int i=0; i<3; i++) { - if ((p=strrchr(JobName, '.')) != NULL) { + if ((p=strrchr(JobName, '.')) != NULL) { *p = 0; } } - bsendmsg(ua, _("%6d %-6s %8s %14s %-7s %-8s %s\n"), + bsendmsg(ua, _("%6d %-6s %8s %14s %-7s %-8s %s\n"), je->JobId, - level, + level, edit_uint64_with_commas(je->JobFiles, b1), - edit_uint64_with_commas(je->JobBytes, b2), + edit_uint64_with_commas(je->JobBytes, b2), termstat, dt, JobName); } diff --git a/bacula/src/dird/ua_tree.c b/bacula/src/dird/ua_tree.c index 024938b2a9..533e0ae86b 100644 --- a/bacula/src/dird/ua_tree.c +++ b/bacula/src/dird/ua_tree.c @@ -58,25 +58,25 @@ static int quitcmd(UAContext *ua, TREE_CTX *tree); static int donecmd(UAContext *ua, TREE_CTX *tree); -struct cmdstruct { const char *key; int (*func)(UAContext *ua, TREE_CTX *tree); const char *help; }; +struct cmdstruct { const char *key; int (*func)(UAContext *ua, TREE_CTX *tree); const char *help; }; static struct cmdstruct commands[] = { { N_("cd"), cdcmd, _("change current directory")}, { N_("count"), countcmd, _("count marked files in and below the cd")}, - { N_("dir"), dircmd, _("list current directory")}, + { N_("dir"), dircmd, _("list current directory")}, { N_("done"), donecmd, _("leave file selection mode")}, { N_("estimate"), estimatecmd, _("estimate restore size")}, { N_("exit"), donecmd, _("exit = done")}, { N_("find"), findcmd, _("find files -- wildcards allowed")}, { N_("help"), helpcmd, _("print help")}, - { N_("ls"), lscmd, _("list current directory -- wildcards allowed")}, - { N_("lsmark"), lsmarkcmd, _("list the marked files in and below the cd")}, + { N_("ls"), lscmd, _("list current directory -- wildcards allowed")}, + { N_("lsmark"), lsmarkcmd, _("list the marked files in and below the cd")}, { N_("mark"), markcmd, _("mark dir/file to be restored -- recursively in dirs")}, { N_("markdir"), markdircmd, _("mark directory name to be restored (no files)")}, { N_("pwd"), pwdcmd, _("print current working directory")}, { N_("unmark"), unmarkcmd, _("unmark dir/file to be restored -- recursively in dir")}, { N_("unmarkdir"), unmarkdircmd, _("unmark directory name only -- no recursion")}, { N_("quit"), quitcmd, _("quit")}, - { N_("?"), helpcmd, _("print help")}, + { N_("?"), helpcmd, _("print help")}, }; #define comsize (sizeof(commands)/sizeof(struct cmdstruct)) @@ -94,7 +94,7 @@ bool user_select_files_from_tree(TREE_CTX *tree) UAContext *ua = new_ua_context(tree->ua->jcr); ua->UA_sock = tree->ua->UA_sock; /* patch in UA socket */ - bsendmsg(tree->ua, _( + bsendmsg(tree->ua, _( "\nYou are now entering file selection mode where you add (mark) and\n" "remove (unmark) files to be restored. No files are initially added, unless\n" "you used the \"all\" keyword on the command line.\n" @@ -106,7 +106,7 @@ bool user_select_files_from_tree(TREE_CTX *tree) tree->node = (TREE_NODE *)tree->root; tree_getpath(tree->node, cwd, sizeof(cwd)); bsendmsg(tree->ua, _("cwd is: %s\n"), cwd); - for ( ;; ) { + for ( ;; ) { int found, len, i; if (!get_cmd(ua, "$ ")) { break; @@ -126,7 +126,7 @@ bool user_select_files_from_tree(TREE_CTX *tree) break; } if (!found) { - bsendmsg(tree->ua, _("Illegal command. Enter \"done\" to exit.\n")); + bsendmsg(tree->ua, _("Illegal command. Enter \"done\" to exit.\n")); continue; } if (!stat) { @@ -208,7 +208,7 @@ int insert_tree_handler(void *ctx, int num_fields, char **row) if (node->inserted) { tree->FileCount++; if (tree->DeltaCount > 0 && (tree->FileCount-tree->LastCount) > tree->DeltaCount) { - bsendmsg(tree->ua, "+"); + bsendmsg(tree->ua, "+"); tree->LastCount = tree->FileCount; } } @@ -219,7 +219,7 @@ int insert_tree_handler(void *ctx, int num_fields, char **row) /* * Set extract to value passed. We recursively walk - * down the tree setting all children if the + * down the tree setting all children if the * node is a directory. */ static int set_extract(UAContext *ua, TREE_NODE *node, TREE_CTX *tree, bool extract) @@ -287,7 +287,7 @@ static int set_extract(UAContext *ua, TREE_NODE *node, TREE_CTX *tree, bool extr } /* - * Recursively mark the current directory to be restored as + * Recursively mark the current directory to be restored as * well as all directories and files below it. */ static int markcmd(UAContext *ua, TREE_CTX *tree) @@ -310,8 +310,8 @@ static int markcmd(UAContext *ua, TREE_CTX *tree) if (count == 0) { bsendmsg(ua, _("No files marked.\n")); } else { - bsendmsg(ua, _("%s file%s marked.\n"), - edit_uint64_with_commas(count, ec1), count==0?"":"s"); + bsendmsg(ua, _("%s file%s marked.\n"), + edit_uint64_with_commas(count, ec1), count==0?"":"s"); } return 1; } @@ -339,8 +339,8 @@ static int markdircmd(UAContext *ua, TREE_CTX *tree) if (count == 0) { bsendmsg(ua, _("No directories marked.\n")); } else { - bsendmsg(ua, _("%s director%s marked.\n"), - edit_uint64_with_commas(count, ec1), count==1?"y":"ies"); + bsendmsg(ua, _("%s director%s marked.\n"), + edit_uint64_with_commas(count, ec1), count==1?"y":"ies"); } return 1; } @@ -360,8 +360,8 @@ static int countcmd(UAContext *ua, TREE_CTX *tree) } } } - bsendmsg(ua, "%s total files/dirs. %s marked to be restored.\n", - edit_uint64_with_commas(total, ec1), + bsendmsg(ua, "%s total files/dirs. %s marked to be restored.\n", + edit_uint64_with_commas(total, ec1), edit_uint64_with_commas(num_extract, ec2)); return 1; } @@ -374,20 +374,20 @@ static int findcmd(UAContext *ua, TREE_CTX *tree) bsendmsg(ua, _("No file specification given.\n")); return 0; } - + for (int i=1; i < ua->argc; i++) { for (TREE_NODE *node=first_tree_node(tree->root); node; node=next_tree_node(node)) { if (fnmatch(ua->argk[i], node->fname, 0) == 0) { const char *tag; tree_getpath(node, cwd, sizeof(cwd)); if (node->extract) { - tag = "*"; + tag = "*"; } else if (node->extract_dir) { - tag = "+"; + tag = "+"; } else { - tag = ""; + tag = ""; } - bsendmsg(ua, "%s%s\n", tag, cwd); + bsendmsg(ua, "%s%s\n", tag, cwd); } } } @@ -400,20 +400,20 @@ static int lscmd(UAContext *ua, TREE_CTX *tree) { TREE_NODE *node; - if (!tree_node_has_child(tree->node)) { + if (!tree_node_has_child(tree->node)) { return 1; } foreach_child(node, tree->node) { if (ua->argc == 1 || fnmatch(ua->argk[1], node->fname, 0) == 0) { const char *tag; if (node->extract) { - tag = "*"; + tag = "*"; } else if (node->extract_dir) { - tag = "+"; + tag = "+"; } else { - tag = ""; + tag = ""; } - bsendmsg(ua, "%s%s%s\n", tag, node->fname, tree_node_has_child(node)?"/":""); + bsendmsg(ua, "%s%s%s\n", tag, node->fname, tree_node_has_child(node)?"/":""); } } return 1; @@ -422,10 +422,10 @@ static int lscmd(UAContext *ua, TREE_CTX *tree) /* * Ls command that lists only the marked files */ -static void rlsmark(UAContext *ua, TREE_NODE *tnode) +static void rlsmark(UAContext *ua, TREE_NODE *tnode) { TREE_NODE *node; - if (!tree_node_has_child(tnode)) { + if (!tree_node_has_child(tnode)) { return; } foreach_child(node, tnode) { @@ -433,13 +433,13 @@ static void rlsmark(UAContext *ua, TREE_NODE *tnode) (node->extract || node->extract_dir)) { const char *tag; if (node->extract) { - tag = "*"; + tag = "*"; } else if (node->extract_dir) { - tag = "+"; + tag = "+"; } else { - tag = ""; + tag = ""; } - bsendmsg(ua, "%s%s%s\n", tag, node->fname, tree_node_has_child(node)?"/":""); + bsendmsg(ua, "%s%s%s\n", tag, node->fname, tree_node_has_child(node)?"/":""); if (tree_node_has_child(node)) { rlsmark(ua, node); } @@ -498,7 +498,7 @@ static int dircmd(UAContext *ua, TREE_CTX *tree) char buf[1100]; char cwd[1100], *pcwd; - if (!tree_node_has_child(tree->node)) { + if (!tree_node_has_child(tree->node)) { bsendmsg(ua, "Node %s has no children.\n", tree->node->fname); return 1; } @@ -507,11 +507,11 @@ static int dircmd(UAContext *ua, TREE_CTX *tree) const char *tag; if (ua->argc == 1 || fnmatch(ua->argk[1], node->fname, 0) == 0) { if (node->extract) { - tag = "*"; + tag = "*"; } else if (node->extract_dir) { - tag = "+"; + tag = "+"; } else { - tag = " "; + tag = " "; } tree_getpath(node, cwd, sizeof(cwd)); fdbr.FileId = 0; @@ -541,7 +541,7 @@ static int dircmd(UAContext *ua, TREE_CTX *tree) memset(&statp, 0, sizeof(statp)); } ls_output(buf, cwd, tag, &statp); - bsendmsg(ua, "%s\n", buf); + bsendmsg(ua, "%s\n", buf); } } return 1; @@ -580,14 +580,14 @@ static int estimatecmd(UAContext *ua, TREE_CTX *tree) } } } - bsendmsg(ua, "%d total files; %d marked to be restored; %s bytes.\n", + bsendmsg(ua, "%d total files; %d marked to be restored; %s bytes.\n", total, num_extract, edit_uint64_with_commas(total_bytes, ec1)); return 1; } -static int helpcmd(UAContext *ua, TREE_CTX *tree) +static int helpcmd(UAContext *ua, TREE_CTX *tree) { unsigned int i; @@ -605,7 +605,7 @@ static int helpcmd(UAContext *ua, TREE_CTX *tree) * we assume it is a Win32 absolute cd rather than relative and * try a second time with /x: ... Win32 kludge. */ -static int cdcmd(UAContext *ua, TREE_CTX *tree) +static int cdcmd(UAContext *ua, TREE_CTX *tree) { TREE_NODE *node; char cwd[2000]; @@ -617,12 +617,12 @@ static int cdcmd(UAContext *ua, TREE_CTX *tree) if (!node) { /* Try once more if Win32 drive -- make absolute */ if (ua->argk[1][1] == ':') { /* win32 drive */ - bstrncpy(cwd, "/", sizeof(cwd)); + bstrncpy(cwd, "/", sizeof(cwd)); bstrncat(cwd, ua->argk[1], sizeof(cwd)); node = tree_cwd(cwd, tree->root, tree->node); } if (!node) { - bsendmsg(ua, _("Invalid path given.\n")); + bsendmsg(ua, _("Invalid path given.\n")); } else { tree->node = node; } @@ -634,7 +634,7 @@ static int cdcmd(UAContext *ua, TREE_CTX *tree) return 1; } -static int pwdcmd(UAContext *ua, TREE_CTX *tree) +static int pwdcmd(UAContext *ua, TREE_CTX *tree) { char cwd[2000]; tree_getpath(tree->node, cwd, sizeof(cwd)); @@ -648,7 +648,7 @@ static int unmarkcmd(UAContext *ua, TREE_CTX *tree) TREE_NODE *node; int count = 0; - if (ua->argc < 2 || !tree_node_has_child(tree->node)) { + if (ua->argc < 2 || !tree_node_has_child(tree->node)) { bsendmsg(ua, _("No files unmarked.\n")); return 1; } @@ -697,12 +697,12 @@ static int unmarkdircmd(UAContext *ua, TREE_CTX *tree) } -static int donecmd(UAContext *ua, TREE_CTX *tree) +static int donecmd(UAContext *ua, TREE_CTX *tree) { return 0; } -static int quitcmd(UAContext *ua, TREE_CTX *tree) +static int quitcmd(UAContext *ua, TREE_CTX *tree) { ua->quit = true; return 0; diff --git a/bacula/src/dird/verify.c b/bacula/src/dird/verify.c index f239fa57b8..0d55d702db 100644 --- a/bacula/src/dird/verify.c +++ b/bacula/src/dird/verify.c @@ -44,7 +44,7 @@ extern int debug_level; /* Commands sent to File daemon */ static char verifycmd[] = "verify level=%s\n"; static char storaddr[] = "storage address=%s port=%d ssl=0\n"; -static char sessioncmd[] = "session %s %ld %ld %ld %ld %ld %ld\n"; +static char sessioncmd[] = "session %s %ld %ld %ld %ld %ld %ld\n"; /* Responses received from File daemon */ static char OKverify[] = "2000 OK verify\n"; @@ -56,13 +56,13 @@ static void verify_cleanup(JCR *jcr, int TermCode); static void prt_fname(JCR *jcr); static int missing_handler(void *ctx, int num_fields, char **row); -/* +/* * Do a verification of the specified files against the Catlaog - * + * * Returns: false on failure * true on success */ -bool do_verify(JCR *jcr) +bool do_verify(JCR *jcr) { const char *level, *Name; BSOCK *fd; @@ -81,12 +81,12 @@ bool do_verify(JCR *jcr) Dmsg1(9, "bdird: created client %s record\n", jcr->client->hdr.name); /* - * Find JobId of last job that ran. E.g. + * Find JobId of last job that ran. E.g. * for VERIFY_CATALOG we want the JobId of the last INIT. - * for VERIFY_VOLUME_TO_CATALOG, we want the JobId of the + * for VERIFY_VOLUME_TO_CATALOG, we want the JobId of the * last backup Job. */ - if (jcr->JobLevel == L_VERIFY_CATALOG || + if (jcr->JobLevel == L_VERIFY_CATALOG || jcr->JobLevel == L_VERIFY_VOLUME_TO_CATALOG || jcr->JobLevel == L_VERIFY_DISK_TO_CATALOG) { memcpy(&jr, &jcr->jr, sizeof(jr)); @@ -101,18 +101,18 @@ bool do_verify(JCR *jcr) if (!db_find_last_jobid(jcr, jcr->db, Name, &jr)) { if (jcr->JobLevel == L_VERIFY_CATALOG) { Jmsg(jcr, M_FATAL, 0, _( - "Unable to find JobId of previous InitCatalog Job.\n" - "Please run a Verify with Level=InitCatalog before\n" - "running the current Job.\n")); + "Unable to find JobId of previous InitCatalog Job.\n" + "Please run a Verify with Level=InitCatalog before\n" + "running the current Job.\n")); } else { Jmsg(jcr, M_FATAL, 0, _( - "Unable to find JobId of previous Job for this client.\n")); - } + "Unable to find JobId of previous Job for this client.\n")); + } goto bail_out; } verify_jobid = jr.JobId; Dmsg1(100, "Last full jobid=%d\n", verify_jobid); - } + } if (!db_update_job_start_record(jcr, jcr->db, &jcr->jr)) { Jmsg(jcr, M_FATAL, 0, "%s", db_strerror(jcr->db)); @@ -131,25 +131,25 @@ bool do_verify(JCR *jcr) * Now get the job record for the previous backup that interests * us. We use the verify_jobid that we found above. */ - if (jcr->JobLevel == L_VERIFY_CATALOG || + if (jcr->JobLevel == L_VERIFY_CATALOG || jcr->JobLevel == L_VERIFY_VOLUME_TO_CATALOG || jcr->JobLevel == L_VERIFY_DISK_TO_CATALOG) { verify_jr.JobId = verify_jobid; if (!db_get_job_record(jcr, jcr->db, &verify_jr)) { - Jmsg(jcr, M_FATAL, 0, _("Could not get job record for previous Job. ERR=%s"), + Jmsg(jcr, M_FATAL, 0, _("Could not get job record for previous Job. ERR=%s"), db_strerror(jcr->db)); goto bail_out; } if (verify_jr.JobStatus != 'T') { - Jmsg(jcr, M_FATAL, 0, _("Last Job %d did not terminate normally. JobStatus=%c\n"), + Jmsg(jcr, M_FATAL, 0, _("Last Job %d did not terminate normally. JobStatus=%c\n"), verify_jobid, verify_jr.JobStatus); goto bail_out; } Jmsg(jcr, M_INFO, 0, _("Verifying against JobId=%d Job=%s\n"), - verify_jr.JobId, verify_jr.Job); + verify_jr.JobId, verify_jr.Job); } - /* + /* * If we are verifying a Volume, we need the Storage * daemon, so open a connection, otherwise, just * create a dummy authorization key (passed to @@ -181,7 +181,7 @@ bool do_verify(JCR *jcr) free_pool_memory(fname); /* - * Start conversation with Storage daemon + * Start conversation with Storage daemon */ set_jcr_job_status(jcr, JS_Blocked); if (!connect_to_storage_daemon(jcr, 10, SDConnectTimeout, 1)) { @@ -232,7 +232,7 @@ bool do_verify(JCR *jcr) goto bail_out; } - /* + /* * Send Level command to File daemon, as well * as the Storage address if appropriate. */ @@ -244,7 +244,7 @@ bool do_verify(JCR *jcr) level = "catalog"; break; case L_VERIFY_VOLUME_TO_CATALOG: - /* + /* * send Storage daemon address to the File daemon */ if (jcr->store->SDDport == 0) { @@ -255,27 +255,27 @@ bool do_verify(JCR *jcr) goto bail_out; } - /* + /* * Send the bootstrap file -- what Volumes/files to restore */ if (!send_bootstrap_file(jcr)) { goto bail_out; } - /* - * The following code is deprecated + /* + * The following code is deprecated */ if (!jcr->RestoreBootstrap) { /* * Pass the VolSessionId, VolSessionTime, Start and * end File and Blocks on the session command. */ - bnet_fsend(fd, sessioncmd, + bnet_fsend(fd, sessioncmd, jcr->VolumeName, - jr.VolSessionId, jr.VolSessionTime, - jr.StartFile, jr.EndFile, jr.StartBlock, + jr.VolSessionId, jr.VolSessionTime, + jr.StartFile, jr.EndFile, jr.StartBlock, jr.EndBlock); - if (!response(jcr, fd, OKsession, "Session", DISPLAY_ERROR)) { + if (!response(jcr, fd, OKsession, "Session", DISPLAY_ERROR)) { goto bail_out; } } @@ -297,7 +297,7 @@ bool do_verify(JCR *jcr) goto bail_out; } - /* + /* * Send verify command/level to File daemon */ bnet_fsend(fd, verifycmd, level); @@ -311,7 +311,7 @@ bool do_verify(JCR *jcr) * catalog depending on the run type. */ /* Compare to catalog */ - switch (jcr->JobLevel) { + switch (jcr->JobLevel) { case L_VERIFY_CATALOG: Dmsg0(10, "Verify level=catalog\n"); jcr->sd_msg_thread_done = true; /* no SD msg thread, so it is done */ @@ -389,7 +389,7 @@ static void verify_cleanup(JCR *jcr, int TermCode) break; case JS_FatalError: case JS_ErrorTerminated: - term_msg = _("*** Verify Error ***"); + term_msg = _("*** Verify Error ***"); msg_type = M_ERROR; /* Generate error message */ break; case JS_Error: @@ -403,8 +403,8 @@ static void verify_cleanup(JCR *jcr, int TermCode) break; default: term_msg = term_code; - bsnprintf(term_code, sizeof(term_code), - _("Inappropriate term code: %d %c\n"), TermCode, TermCode); + bsnprintf(term_code, sizeof(term_code), + _("Inappropriate term code: %d %c\n"), TermCode, TermCode); break; } bstrftimes(sdt, sizeof(sdt), jcr->jr.StartTime); @@ -418,22 +418,22 @@ static void verify_cleanup(JCR *jcr, int TermCode) jobstatus_to_ascii(jcr->FDJobStatus, fd_term_msg, sizeof(fd_term_msg)); if (jcr->JobLevel == L_VERIFY_VOLUME_TO_CATALOG) { jobstatus_to_ascii(jcr->SDJobStatus, sd_term_msg, sizeof(sd_term_msg)); - Jmsg(jcr, msg_type, 0, _("Bacula " VERSION " (" LSMDATE "): %s\n\ - JobId: %d\n\ - Job: %s\n\ - FileSet: %s\n\ - Verify Level: %s\n\ - Client: %s\n\ - Verify JobId: %d\n\ - Verify Job: %s\n\ - Start time: %s\n\ - End time: %s\n\ - Files Expected: %s\n\ - Files Examined: %s\n\ - Non-fatal FD errors: %d\n\ - FD termination status: %s\n\ - SD termination status: %s\n\ - Termination: %s\n\n"), + Jmsg(jcr, msg_type, 0, _("Bacula " VERSION " (" LSMDATE "): %s\n" +" JobId: %d\n" +" Job: %s\n" +" FileSet: %s\n" +" Verify Level: %s\n" +" Client: %s\n" +" Verify JobId: %d\n" +" Verify Job: %s\n" +" Start time: %s\n" +" End time: %s\n" +" Files Expected: %s\n" +" Files Examined: %s\n" +" Non-fatal FD errors: %d\n" +" FD termination status: %s\n" +" SD termination status: %s\n" +" Termination: %s\n\n"), edt, jcr->jr.JobId, jcr->jr.Job, @@ -451,20 +451,20 @@ static void verify_cleanup(JCR *jcr, int TermCode) sd_term_msg, term_msg); } else { - Jmsg(jcr, msg_type, 0, _("Bacula " VERSION " (" LSMDATE "): %s\n\ - JobId: %d\n\ - Job: %s\n\ - FileSet: %s\n\ - Verify Level: %s\n\ - Client: %s\n\ - Verify JobId: %d\n\ - Verify Job: %s\n\ - Start time: %s\n\ - End time: %s\n\ - Files Examined: %s\n\ - Non-fatal FD errors: %d\n\ - FD termination status: %s\n\ - Termination: %s\n\n"), + Jmsg(jcr, msg_type, 0, _("Bacula " VERSION " (" LSMDATE "): %s\n" +" JobId: %d\n" +" Job: %s\n" +" FileSet: %s\n" +" Verify Level: %s\n" +" Client: %s\n" +" Verify JobId: %d\n" +" Verify Job: %s\n" +" Start time: %s\n" +" End time: %s\n" +" Files Examined: %s\n" +" Non-fatal FD errors: %d\n" +" FD termination status: %s\n" +" Termination: %s\n\n"), edt, jcr->jr.JobId, jcr->jr.Job, @@ -507,7 +507,7 @@ int get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId) fd = jcr->file_bsock; fdbr.JobId = JobId; jcr->FileIndex = 0; - + Dmsg0(20, "bdird: waiting to receive file attributes\n"); /* * Get Attributes and Signature from File daemon @@ -527,14 +527,14 @@ int get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId) fname = check_pool_memory_size(fname, fd->msglen); jcr->fname = check_pool_memory_size(jcr->fname, fd->msglen); Dmsg1(200, "Atts+SIG=%s\n", fd->msg); - if ((len = sscanf(fd->msg, "%ld %d %100s", &file_index, &stream, + if ((len = sscanf(fd->msg, "%ld %d %100s", &file_index, &stream, fname)) != 3) { - Jmsg3(jcr, M_FATAL, 0, _("birdmsglen, fd->msg); + Jmsg3(jcr, M_FATAL, 0, _("birdmsglen, fd->msg); goto bail_out; } /* - * We read the Options or Signature into fname + * We read the Options or Signature into fname * to prevent overrun, now copy it to proper location. */ bstrncpy(Opts_SIG, fname, sizeof(Opts_SIG)); @@ -543,7 +543,7 @@ int get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId) skip_spaces(&p); skip_nonspaces(&p); /* skip Stream */ skip_spaces(&p); - skip_nonspaces(&p); /* skip Opts_SIG */ + skip_nonspaces(&p); /* skip Opts_SIG */ p++; /* skip space */ fn = fname; while (*p != 0) { @@ -556,7 +556,7 @@ int get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId) */ if (stream == STREAM_UNIX_ATTRIBUTES || stream == STREAM_UNIX_ATTRIBUTES_EX) { int32_t LinkFIf, LinkFIc; - Dmsg2(400, "file_index=%d attr=%s\n", file_index, attr); + Dmsg2(400, "file_index=%d attr=%s\n", file_index, attr); jcr->JobFiles++; jcr->FileIndex = file_index; /* remember attribute file_index */ decode_stat(attr, &statf, &LinkFIf); /* decode file stat packet */ @@ -564,28 +564,28 @@ int get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId) jcr->fn_printed = false; pm_strcpy(jcr->fname, fname); /* move filename into JCR */ - Dmsg2(040, "dirdfname); - Dmsg1(020, "dirdfname); + Dmsg1(020, "dirddb, jcr->fname, + if (!db_get_file_attributes_record(jcr, jcr->db, jcr->fname, jcr->verify_jr, &fdbr)) { - Jmsg(jcr, M_INFO, 0, _("New file: %s\n"), jcr->fname); - Dmsg1(020, _("File not in catalog: %s\n"), jcr->fname); + Jmsg(jcr, M_INFO, 0, _("New file: %s\n"), jcr->fname); + Dmsg1(020, _("File not in catalog: %s\n"), jcr->fname); stat = JS_Differences; continue; } else { - /* + /* * mark file record as visited by stuffing the * current JobId, which is unique, into the MarkId field. */ db_mark_file_record(jcr, jcr->db, fdbr.FileId, jcr->JobId); } - Dmsg3(400, "Found %s in catalog. inx=%d Opts=%s\n", jcr->fname, + Dmsg3(400, "Found %s in catalog. inx=%d Opts=%s\n", jcr->fname, file_index, Opts_SIG); decode_stat(fdbr.LStat, &statc, &LinkFIc); /* decode catalog stat */ /* @@ -595,95 +595,95 @@ int get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId) for (p=Opts_SIG; *p; p++) { char ed1[30], ed2[30]; switch (*p) { - case 'i': /* compare INODEs */ + case 'i': /* compare INODEs */ if (statc.st_ino != statf.st_ino) { prt_fname(jcr); - Jmsg(jcr, M_INFO, 0, _(" st_ino differ. Cat: %s File: %s\n"), + Jmsg(jcr, M_INFO, 0, _(" st_ino differ. Cat: %s File: %s\n"), edit_uint64((uint64_t)statc.st_ino, ed1), edit_uint64((uint64_t)statf.st_ino, ed2)); stat = JS_Differences; } break; - case 'p': /* permissions bits */ + case 'p': /* permissions bits */ if (statc.st_mode != statf.st_mode) { prt_fname(jcr); - Jmsg(jcr, M_INFO, 0, _(" st_mode differ. Cat: %x File: %x\n"), + Jmsg(jcr, M_INFO, 0, _(" st_mode differ. Cat: %x File: %x\n"), (uint32_t)statc.st_mode, (uint32_t)statf.st_mode); stat = JS_Differences; } break; - case 'n': /* number of links */ + case 'n': /* number of links */ if (statc.st_nlink != statf.st_nlink) { prt_fname(jcr); - Jmsg(jcr, M_INFO, 0, _(" st_nlink differ. Cat: %d File: %d\n"), + Jmsg(jcr, M_INFO, 0, _(" st_nlink differ. Cat: %d File: %d\n"), (uint32_t)statc.st_nlink, (uint32_t)statf.st_nlink); stat = JS_Differences; } break; - case 'u': /* user id */ + case 'u': /* user id */ if (statc.st_uid != statf.st_uid) { prt_fname(jcr); - Jmsg(jcr, M_INFO, 0, _(" st_uid differ. Cat: %u File: %u\n"), + Jmsg(jcr, M_INFO, 0, _(" st_uid differ. Cat: %u File: %u\n"), (uint32_t)statc.st_uid, (uint32_t)statf.st_uid); stat = JS_Differences; } break; - case 'g': /* group id */ + case 'g': /* group id */ if (statc.st_gid != statf.st_gid) { prt_fname(jcr); - Jmsg(jcr, M_INFO, 0, _(" st_gid differ. Cat: %u File: %u\n"), + Jmsg(jcr, M_INFO, 0, _(" st_gid differ. Cat: %u File: %u\n"), (uint32_t)statc.st_gid, (uint32_t)statf.st_gid); stat = JS_Differences; } break; - case 's': /* size */ + case 's': /* size */ if (statc.st_size != statf.st_size) { prt_fname(jcr); - Jmsg(jcr, M_INFO, 0, _(" st_size differ. Cat: %s File: %s\n"), + Jmsg(jcr, M_INFO, 0, _(" st_size differ. Cat: %s File: %s\n"), edit_uint64((uint64_t)statc.st_size, ed1), edit_uint64((uint64_t)statf.st_size, ed2)); stat = JS_Differences; } break; - case 'a': /* access time */ + case 'a': /* access time */ if (statc.st_atime != statf.st_atime) { prt_fname(jcr); - Jmsg(jcr, M_INFO, 0, _(" st_atime differs\n")); + Jmsg(jcr, M_INFO, 0, _(" st_atime differs\n")); stat = JS_Differences; } break; - case 'm': + case 'm': if (statc.st_mtime != statf.st_mtime) { prt_fname(jcr); - Jmsg(jcr, M_INFO, 0, _(" st_mtime differs\n")); + Jmsg(jcr, M_INFO, 0, _(" st_mtime differs\n")); stat = JS_Differences; } break; - case 'c': /* ctime */ + case 'c': /* ctime */ if (statc.st_ctime != statf.st_ctime) { prt_fname(jcr); - Jmsg(jcr, M_INFO, 0, _(" st_ctime differs\n")); + Jmsg(jcr, M_INFO, 0, _(" st_ctime differs\n")); stat = JS_Differences; } break; - case 'd': /* file size decrease */ + case 'd': /* file size decrease */ if (statc.st_size > statf.st_size) { prt_fname(jcr); - Jmsg(jcr, M_INFO, 0, _(" st_size decrease. Cat: %s File: %s\n"), + Jmsg(jcr, M_INFO, 0, _(" st_size decrease. Cat: %s File: %s\n"), edit_uint64((uint64_t)statc.st_size, ed1), edit_uint64((uint64_t)statf.st_size, ed2)); stat = JS_Differences; } break; - case '5': /* compare MD5 */ - Dmsg1(500, "set Do_MD5 for %s\n", jcr->fname); + case '5': /* compare MD5 */ + Dmsg1(500, "set Do_MD5 for %s\n", jcr->fname); do_SIG = MD5_SIG; break; - case '1': /* compare SHA1 */ + case '1': /* compare SHA1 */ do_SIG = SHA1_SIG; break; - case ':': - case 'V': + case ':': + case 'V': default: break; } @@ -693,26 +693,26 @@ int get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId) * It came across in the Opts_SIG field. */ } else if (stream == STREAM_MD5_SIGNATURE || stream == STREAM_SHA1_SIGNATURE) { - Dmsg2(400, "stream=SIG inx=%d SIG=%s\n", file_index, Opts_SIG); - /* + Dmsg2(400, "stream=SIG inx=%d SIG=%s\n", file_index, Opts_SIG); + /* * When ever we get a signature is MUST have been * preceded by an attributes record, which sets attr_file_index */ if (jcr->FileIndex != (uint32_t)file_index) { - Jmsg2(jcr, M_FATAL, 0, _("MD5/SHA1 index %d not same as attributes %d\n"), + Jmsg2(jcr, M_FATAL, 0, _("MD5/SHA1 index %d not same as attributes %d\n"), file_index, jcr->FileIndex); goto bail_out; - } + } if (do_SIG) { db_escape_string(buf, Opts_SIG, strlen(Opts_SIG)); if (strcmp(buf, fdbr.SIG) != 0) { prt_fname(jcr); if (debug_level >= 10) { - Jmsg(jcr, M_INFO, 0, _(" %s not same. File=%s Cat=%s\n"), - stream==STREAM_MD5_SIGNATURE?"MD5":"SHA1", buf, fdbr.SIG); + Jmsg(jcr, M_INFO, 0, _(" %s not same. File=%s Cat=%s\n"), + stream==STREAM_MD5_SIGNATURE?"MD5":"SHA1", buf, fdbr.SIG); } else { - Jmsg(jcr, M_INFO, 0, _(" %s differs.\n"), - stream==STREAM_MD5_SIGNATURE?"MD5":"SHA1"); + Jmsg(jcr, M_INFO, 0, _(" %s differs.\n"), + stream==STREAM_MD5_SIGNATURE?"MD5":"SHA1"); } stat = JS_Differences; } @@ -720,7 +720,7 @@ int get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId) } } jcr->JobFiles = file_index; - } + } if (is_bnet_error(fd)) { Jmsg2(jcr, M_FATAL, 0, _("bdirdfn_printed = false; - sprintf(buf, + sprintf(buf, "SELECT Path.Path,Filename.Name FROM File,Path,Filename " "WHERE File.JobId=%d " "AND File.MarkedId!=%d AND File.PathId=Path.PathId " -"AND File.FilenameId=Filename.FilenameId", +"AND File.FilenameId=Filename.FilenameId", JobId, jcr->JobId); /* missing_handler is called for each file found */ db_sql_query(jcr->db, buf, missing_handler, (void *)jcr); @@ -745,7 +745,7 @@ int get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId) free_pool_memory(fname); set_jcr_job_status(jcr, stat); return 1; - + bail_out: free_pool_memory(fname); set_jcr_job_status(jcr, JS_ErrorTerminated); @@ -772,7 +772,7 @@ static int missing_handler(void *ctx, int num_fields, char **row) } -/* +/* * Print filename for verify */ static void prt_fname(JCR *jcr) diff --git a/bacula/src/filed/authenticate.c b/bacula/src/filed/authenticate.c index d0ad7ab74e..a5728416a7 100644 --- a/bacula/src/filed/authenticate.c +++ b/bacula/src/filed/authenticate.c @@ -4,7 +4,7 @@ * Kern Sibbald, October 2000 * * Version $Id$ - * + * */ /* Copyright (C) 2000-2004 Kern Sibbald and John Walker @@ -25,7 +25,7 @@ MA 02111-1307, USA. */ - + #include "bacula.h" #include "filed.h" @@ -33,7 +33,7 @@ static char OK_hello[] = "2000 OK Hello\n"; static char Dir_sorry[] = "2999 No go\n"; -/********************************************************************* +/********************************************************************* * */ static int authenticate(int rcode, BSOCK *bs, JCR* jcr) @@ -49,9 +49,9 @@ static int authenticate(int rcode, BSOCK *bs, JCR* jcr) return 0; } if (bs->msglen < 25 || bs->msglen > 200) { - Dmsg2(50, _("Bad Hello command from Director at %s. Len=%d.\n"), + Dmsg2(50, _("Bad Hello command from Director at %s. Len=%d.\n"), bs->who, bs->msglen); - Emsg2(M_FATAL, 0, _("Bad Hello command from Director at %s. Len=%d.\n"), + Emsg2(M_FATAL, 0, _("Bad Hello command from Director at %s. Len=%d.\n"), bs->who, bs->msglen); return 0; } @@ -61,9 +61,9 @@ static int authenticate(int rcode, BSOCK *bs, JCR* jcr) if (sscanf(bs->msg, "Hello Director %s calling\n", dirname) != 1) { free_pool_memory(dirname); bs->msg[100] = 0; - Dmsg2(50, _("Bad Hello command from Director at %s: %s\n"), + Dmsg2(50, _("Bad Hello command from Director at %s: %s\n"), bs->who, bs->msg); - Emsg2(M_FATAL, 0, _("Bad Hello command from Director at %s: %s\n"), + Emsg2(M_FATAL, 0, _("Bad Hello command from Director at %s: %s\n"), bs->who, bs->msg); return 0; } @@ -77,25 +77,25 @@ static int authenticate(int rcode, BSOCK *bs, JCR* jcr) if (!director) { Dmsg2(50, _("Connection from unknown Director %s at %s rejected.\n"), dirname, bs->who); - Emsg2(M_FATAL, 0, _("Connection from unknown Director %s at %s rejected.\n" - "Please see http://www.bacula.org/html-manual/faq.html#AuthorizationErrors for help.\n"), + Emsg2(M_FATAL, 0, _("Connection from unknown Director %s at %s rejected.\n" + "Please see http://www.bacula.org/html-manual/faq.html#AuthorizationErrors for help.\n"), dirname, bs->who); free_pool_memory(dirname); return 0; } btimer_t *tid = start_bsock_timer(bs, AUTH_TIMEOUT); - auth = cram_md5_auth(bs, director->password, ssl_need); + auth = cram_md5_auth(bs, director->password, ssl_need); if (auth) { - get_auth = cram_md5_get_auth(bs, director->password, ssl_need); + get_auth = cram_md5_get_auth(bs, director->password, ssl_need); if (!get_auth) { - Dmsg1(50, "cram_get_auth failed for %s\n", bs->who); + Dmsg1(50, "cram_get_auth failed for %s\n", bs->who); } } else { Dmsg1(50, "cram_auth failed for %s\n", bs->who); } if (!auth || !get_auth) { - Emsg1(M_FATAL, 0, _("Incorrect password given by Director at %s.\n" - "Please see http://www.bacula.org/html-manual/faq.html#AuthorizationErrors for help.\n"), + Emsg1(M_FATAL, 0, _("Incorrect password given by Director at %s.\n" + "Please see http://www.bacula.org/html-manual/faq.html#AuthorizationErrors for help.\n"), bs->who); director = NULL; } @@ -108,7 +108,7 @@ static int authenticate(int rcode, BSOCK *bs, JCR* jcr) /* * Inititiate the communications with the Director. * He has made a connection to our server. - * + * * Basic tasks done here: * We read Director's initial message and authorize him. * @@ -137,19 +137,19 @@ int authenticate_storagedaemon(JCR *jcr) bool get_auth, auth = false; btimer_t *tid = start_bsock_timer(sd, AUTH_TIMEOUT); - get_auth = cram_md5_get_auth(sd, jcr->sd_auth_key, ssl_need); + get_auth = cram_md5_get_auth(sd, jcr->sd_auth_key, ssl_need); if (!get_auth) { Dmsg1(50, "cram_get_auth failed for %s\n", sd->who); } else { auth = cram_md5_auth(sd, jcr->sd_auth_key, ssl_need); if (!auth) { - Dmsg1(50, "cram_auth failed for %s\n", sd->who); + Dmsg1(50, "cram_auth failed for %s\n", sd->who); } } stop_bsock_timer(tid); memset(jcr->sd_auth_key, 0, strlen(jcr->sd_auth_key)); if (!get_auth || !auth) { - Jmsg(jcr, M_FATAL, 0, _("Authorization key rejected by Storage daemon.\n" + Jmsg(jcr, M_FATAL, 0, _("Authorization key rejected by Storage daemon.\n" "Please see http://www.bacula.org/html-manual/faq.html#AuthorizationErrors for help.\n")); } return get_auth && auth; diff --git a/bacula/src/filed/backup.c b/bacula/src/filed/backup.c index 2ade1050b1..afbb660329 100644 --- a/bacula/src/filed/backup.c +++ b/bacula/src/filed/backup.c @@ -38,9 +38,9 @@ static int save_file(FF_PKT *ff_pkt, void *pkt); static int send_data(int stream, FF_PKT *ff_pkt, BSOCK *sd, JCR *jcr, struct CHKSUM *chksum); -/* +/* * Find all the requested files and send them - * to the Storage daemon. + * to the Storage daemon. * * Note, we normally carry on a one-way * conversation from this point on with the SD, simply blasting @@ -48,9 +48,9 @@ static int send_data(int stream, FF_PKT *ff_pkt, BSOCK *sd, JCR *jcr, struct CHK * also run a "heartbeat" monitor which reads the socket and * reacts accordingly (at the moment it has nothing to do * except echo the heartbeat to the Director). - * + * */ -bool blast_data_to_storage_daemon(JCR *jcr, char *addr) +bool blast_data_to_storage_daemon(JCR *jcr, char *addr) { BSOCK *sd; bool ok = true; @@ -76,7 +76,7 @@ bool blast_data_to_storage_daemon(JCR *jcr, char *addr) return false; } - jcr->buf_size = sd->msglen; + jcr->buf_size = sd->msglen; /* Adjust for compression so that output buffer is * 12 bytes + 0.1% larger than input buffer plus 18 bytes. * This gives a bit extra plus room for the sparse addr if any. @@ -113,9 +113,9 @@ bool blast_data_to_storage_daemon(JCR *jcr, char *addr) } Dmsg1(300, "end blast_data stat=%d\n", ok); return ok; -} +} -/* +/* * Called here by find() for each file included. * * *****FIXME***** add FSMs File System Modules @@ -162,13 +162,13 @@ static int save_file(FF_PKT *ff_pkt, void *vjcr) case FT_INVALIDFS: case FT_DIREND: if (ff_pkt->type == FT_NORECURSE) { - Jmsg(jcr, M_INFO, 1, _(" Recursion turned off. Will not descend into %s\n"), + Jmsg(jcr, M_INFO, 1, _(" Recursion turned off. Will not descend into %s\n"), ff_pkt->fname); } else if (ff_pkt->type == FT_NOFSCHG) { - Jmsg(jcr, M_INFO, 1, _(" File system change prohibited. Will not descend into %s\n"), + Jmsg(jcr, M_INFO, 1, _(" File system change prohibited. Will not descend into %s\n"), ff_pkt->fname); } else if (ff_pkt->type == FT_INVALIDFS) { - Jmsg(jcr, M_INFO, 1, _(" Disallowed filesystem. Will not descend into %s\n"), + Jmsg(jcr, M_INFO, 1, _(" Disallowed filesystem. Will not descend into %s\n"), ff_pkt->fname); } ff_pkt->type = FT_DIREND; /* value is used below */ @@ -186,7 +186,7 @@ static int save_file(FF_PKT *ff_pkt, void *vjcr) case FT_NOACCESS: { berrno be; be.set_errno(ff_pkt->ff_errno); - Jmsg(jcr, M_NOTSAVED, 0, _(" Could not access %s: ERR=%s\n"), ff_pkt->fname, + Jmsg(jcr, M_NOTSAVED, 0, _(" Could not access %s: ERR=%s\n"), ff_pkt->fname, be.strerror()); jcr->Errors++; return 1; @@ -194,7 +194,7 @@ static int save_file(FF_PKT *ff_pkt, void *vjcr) case FT_NOFOLLOW: { berrno be; be.set_errno(ff_pkt->ff_errno); - Jmsg(jcr, M_NOTSAVED, 0, _(" Could not follow link %s: ERR=%s\n"), ff_pkt->fname, + Jmsg(jcr, M_NOTSAVED, 0, _(" Could not follow link %s: ERR=%s\n"), ff_pkt->fname, be.strerror()); jcr->Errors++; return 1; @@ -202,7 +202,7 @@ static int save_file(FF_PKT *ff_pkt, void *vjcr) case FT_NOSTAT: { berrno be; be.set_errno(ff_pkt->ff_errno); - Jmsg(jcr, M_NOTSAVED, 0, _(" Could not stat %s: ERR=%s\n"), ff_pkt->fname, + Jmsg(jcr, M_NOTSAVED, 0, _(" Could not stat %s: ERR=%s\n"), ff_pkt->fname, be.strerror()); jcr->Errors++; return 1; @@ -217,7 +217,7 @@ static int save_file(FF_PKT *ff_pkt, void *vjcr) case FT_NOOPEN: { berrno be; be.set_errno(ff_pkt->ff_errno); - Jmsg(jcr, M_NOTSAVED, 0, _(" Could not open directory %s: ERR=%s\n"), ff_pkt->fname, + Jmsg(jcr, M_NOTSAVED, 0, _(" Could not open directory %s: ERR=%s\n"), ff_pkt->fname, be.strerror()); jcr->Errors++; return 1; @@ -238,13 +238,13 @@ static int save_file(FF_PKT *ff_pkt, void *vjcr) attr_stream = encode_attribsEx(jcr, attribsEx, ff_pkt); Dmsg3(300, "File %s\nattribs=%s\nattribsEx=%s\n", ff_pkt->fname, attribs, attribsEx); - + P(jcr->mutex); jcr->JobFiles++; /* increment number of files sent */ ff_pkt->FileIndex = jcr->JobFiles; /* return FileIndex */ pm_strcpy(jcr->last_fname, ff_pkt->fname); V(jcr->mutex); - + /* * Send Attributes header to Storage daemon * @@ -271,15 +271,15 @@ static int save_file(FF_PKT *ff_pkt, void *vjcr) */ if (ff_pkt->type == FT_LNK || ff_pkt->type == FT_LNKSAVED) { Dmsg2(300, "Link %s to %s\n", ff_pkt->fname, ff_pkt->link); - stat = bnet_fsend(sd, "%ld %d %s%c%s%c%s%c%s%c", jcr->JobFiles, + stat = bnet_fsend(sd, "%ld %d %s%c%s%c%s%c%s%c", jcr->JobFiles, ff_pkt->type, ff_pkt->fname, 0, attribs, 0, ff_pkt->link, 0, attribsEx, 0); } else if (ff_pkt->type == FT_DIREND) { /* Here link is the canonical filename (i.e. with trailing slash) */ - stat = bnet_fsend(sd, "%ld %d %s%c%s%c%c%s%c", jcr->JobFiles, + stat = bnet_fsend(sd, "%ld %d %s%c%s%c%c%s%c", jcr->JobFiles, ff_pkt->type, ff_pkt->link, 0, attribs, 0, 0, attribsEx, 0); } else { - stat = bnet_fsend(sd, "%ld %d %s%c%s%c%c%s%c", jcr->JobFiles, + stat = bnet_fsend(sd, "%ld %d %s%c%s%c%c%s%c", jcr->JobFiles, ff_pkt->type, ff_pkt->fname, 0, attribs, 0, 0, attribsEx, 0); } @@ -306,17 +306,17 @@ static int save_file(FF_PKT *ff_pkt, void *vjcr) set_prog(&ff_pkt->bfd, ff_pkt->reader, jcr); } - /* + /* * Open any file with data that we intend to save, then save it. * * Note, if is_win32_backup, we must open the Directory so that * the BackupRead will save its permissions and ownership streams. */ - if (ff_pkt->type != FT_LNKSAVED && (S_ISREG(ff_pkt->statp.st_mode) && - ff_pkt->statp.st_size > 0) || + if (ff_pkt->type != FT_LNKSAVED && (S_ISREG(ff_pkt->statp.st_mode) && + ff_pkt->statp.st_size > 0) || ff_pkt->type == FT_RAW || ff_pkt->type == FT_FIFO || (!is_portable_backup(&ff_pkt->bfd) && ff_pkt->type == FT_DIREND)) { - btimer_t *tid; + btimer_t *tid; if (ff_pkt->type == FT_FIFO) { tid = start_thread_timer(pthread_self(), 60); } else { @@ -325,7 +325,7 @@ static int save_file(FF_PKT *ff_pkt, void *vjcr) if (bopen(&ff_pkt->bfd, ff_pkt->fname, O_RDONLY | O_BINARY, 0) < 0) { ff_pkt->ff_errno = errno; berrno be; - Jmsg(jcr, M_NOTSAVED, 0, _(" Cannot open %s: ERR=%s.\n"), ff_pkt->fname, + Jmsg(jcr, M_NOTSAVED, 0, _(" Cannot open %s: ERR=%s.\n"), ff_pkt->fname, be.strerror()); jcr->Errors++; if (tid) { @@ -354,7 +354,7 @@ static int save_file(FF_PKT *ff_pkt, void *vjcr) if (!bopen_rsrc(&ff_pkt->bfd, ff_pkt->fname, O_RDONLY | O_BINARY, 0) < 0) { ff_pkt->ff_errno = errno; berrno be; - Jmsg(jcr, M_NOTSAVED, -1, _(" Cannot open resource fork for %s: ERR=%s.\n"), ff_pkt->fname, + Jmsg(jcr, M_NOTSAVED, -1, _(" Cannot open resource fork for %s: ERR=%s.\n"), ff_pkt->fname, be.strerror()); jcr->Errors++; if (is_bopen(&ff_pkt->bfd)) { @@ -389,51 +389,51 @@ static int save_file(FF_PKT *ff_pkt, void *vjcr) if (ff_pkt->flags & FO_ACL) { char *acl_text = NULL; char *aclDef_text = NULL; - + /* Read ACLs for files, dirs and links */ if (ff_pkt->type == FT_DIREND) { /* Directory: Check for default ACL*/ acl_t myDefAcl = acl_get_file(ff_pkt->fname, ACL_TYPE_DEFAULT); - /* Check for Access ACL */ - acl_t myAccAcl = acl_get_file(ff_pkt->fname, ACL_TYPE_ACCESS); - if (!myDefAcl || !myAccAcl) { - Jmsg1(jcr, M_WARNING, 0, "Error while trying to get ACL of directory: %s!\n", ff_pkt->fname); - } - if(myDefAcl){ - aclDef_text = acl_to_any_text(myDefAcl, NULL, ',', TEXT_ABBREVIATE); - acl_free(myDefAcl); - } - if(myAccAcl){ - acl_text = acl_to_any_text(myAccAcl, NULL, ',', TEXT_ABBREVIATE); - acl_free(myAccAcl); - } + /* Check for Access ACL */ + acl_t myAccAcl = acl_get_file(ff_pkt->fname, ACL_TYPE_ACCESS); + if (!myDefAcl || !myAccAcl) { + Jmsg1(jcr, M_WARNING, 0, "Error while trying to get ACL of directory: %s!\n", ff_pkt->fname); + } + if(myDefAcl){ + aclDef_text = acl_to_any_text(myDefAcl, NULL, ',', TEXT_ABBREVIATE); + acl_free(myDefAcl); + } + if(myAccAcl){ + acl_text = acl_to_any_text(myAccAcl, NULL, ',', TEXT_ABBREVIATE); + acl_free(myAccAcl); + } } else { /* Files or links */ - acl_t myAcl = acl_get_file(ff_pkt->fname, ACL_TYPE_ACCESS); + acl_t myAcl = acl_get_file(ff_pkt->fname, ACL_TYPE_ACCESS); if (!myAcl) { - Jmsg1(jcr, M_WARNING, 0, "Error while trying to get ACL of file: %s!\n", ff_pkt->fname); + Jmsg1(jcr, M_WARNING, 0, "Error while trying to get ACL of file: %s!\n", ff_pkt->fname); acl_free(myAcl); } - acl_text = acl_to_any_text(myAcl, NULL, ',', TEXT_ABBREVIATE); + acl_text = acl_to_any_text(myAcl, NULL, ',', TEXT_ABBREVIATE); acl_free(myAcl); } - + POOLMEM *msgsave; - + /* If there is an ACL, send it to the Storage daemon */ if (acl_text != NULL) { sd = jcr->store_bsock; pm_strcpy(&jcr->last_fname, ff_pkt->fname); - - + + // Send ACL header - if (!bnet_fsend(sd, "%ld %d 0", jcr->JobFiles, STREAM_UNIX_ATTRIBUTES_ACCESS_ACL)) { + if (!bnet_fsend(sd, "%ld %d 0", jcr->JobFiles, STREAM_UNIX_ATTRIBUTES_ACCESS_ACL)) { berrno be; - Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"), + Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"), bnet_strerror(sd)); return 0; } - + /* Send the buffer to the storage deamon */ msgsave = sd->msg; sd->msg = acl_text; @@ -442,34 +442,34 @@ static int save_file(FF_PKT *ff_pkt, void *vjcr) berrno be; sd->msg = msgsave; sd->msglen = 0; - Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"), + Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"), bnet_strerror(sd)); } else { jcr->JobBytes += sd->msglen; sd->msg = msgsave; if (!bnet_sig(sd, BNET_EOD)) { berrno be; - Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"), + Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"), bnet_strerror(sd)); } else { - Dmsg1(200, "ACL of file: %s successfully backed up!\n", ff_pkt->fname); + Dmsg1(200, "ACL of file: %s successfully backed up!\n", ff_pkt->fname); } - } + } } /* If there is an Default ACL, send it to the Storage daemon */ if (aclDef_text != NULL) { sd = jcr->store_bsock; pm_strcpy(&jcr->last_fname, ff_pkt->fname); - - + + // Send ACL header if (!bnet_fsend(sd, "%ld %d 0", jcr->JobFiles, STREAM_UNIX_ATTRIBUTES_DEFAULT_ACL)) { berrno be; - Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"), + Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"), bnet_strerror(sd)); return 0; } - + // Send the buffer to the storage deamon msgsave = sd->msg; sd->msg = aclDef_text; @@ -478,21 +478,21 @@ static int save_file(FF_PKT *ff_pkt, void *vjcr) berrno be; sd->msg = msgsave; sd->msglen = 0; - Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"), + Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"), bnet_strerror(sd)); } else { jcr->JobBytes += sd->msglen; sd->msg = msgsave; if (!bnet_sig(sd, BNET_EOD)) { berrno be; - Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"), + Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"), bnet_strerror(sd)); } else { - Dmsg1(200, "ACL of file: %s successfully backed up!\n", ff_pkt->fname); + Dmsg1(200, "ACL of file: %s successfully backed up!\n", ff_pkt->fname); } - } + } } - } + } #endif /* Terminate any signature and send it to Storage daemon and the Director */ @@ -504,11 +504,11 @@ static int save_file(FF_PKT *ff_pkt, void *vjcr) } else if (chksum.type == CHKSUM_SHA1) { stream = STREAM_SHA1_SIGNATURE; } else { - Jmsg1(jcr, M_WARNING, 0, _("Unknown signature type %i."), chksum.type); + Jmsg1(jcr, M_WARNING, 0, _("Unknown signature type %i."), chksum.type); } if (stream != 0) { - bnet_fsend(sd, "%ld %d 0", jcr->JobFiles, stream); - Dmsg1(300, "bfiled>stored:header %s\n", sd->msg); + bnet_fsend(sd, "%ld %d 0", jcr->JobFiles, stream); + Dmsg1(300, "bfiled>stored:header %s\n", sd->msg); memcpy(sd->msg, chksum.signature, chksum.length); sd->msglen = chksum.length; bnet_send(sd); @@ -537,7 +537,7 @@ int send_data(int stream, FF_PKT *ff_pkt, BSOCK *sd, JCR *jcr, struct CHKSUM *ch POOLMEM *msgsave; msgsave = sd->msg; - rbuf = sd->msg; /* read buffer */ + rbuf = sd->msg; /* read buffer */ wbuf = sd->msg; /* write buffer */ @@ -574,13 +574,13 @@ int send_data(int stream, FF_PKT *ff_pkt, BSOCK *sd, JCR *jcr, struct CHKSUM *ch /* * Make space at beginning of buffer for fileAddr because this - * same buffer will be used for writing if compression if off. + * same buffer will be used for writing if compression if off. */ if (ff_pkt->flags & FO_SPARSE) { rbuf += SPARSE_FADDR_SIZE; rsize -= SPARSE_FADDR_SIZE; #ifdef HAVE_FREEBSD_OS - /* + /* * To read FreeBSD partitions, the read size must be * a multiple of 512. */ @@ -588,7 +588,7 @@ int send_data(int stream, FF_PKT *ff_pkt, BSOCK *sd, JCR *jcr, struct CHKSUM *ch #endif } - /* + /* * Read the file data */ while ((sd->msglen=(uint32_t)bread(&ff_pkt->bfd, rbuf, rsize)) > 0) { @@ -597,14 +597,14 @@ int send_data(int stream, FF_PKT *ff_pkt, BSOCK *sd, JCR *jcr, struct CHKSUM *ch /* Check for sparse blocks */ if (ff_pkt->flags & FO_SPARSE) { ser_declare; - if (sd->msglen == rsize && + if (sd->msglen == rsize && (fileAddr+sd->msglen < (uint64_t)ff_pkt->statp.st_size)) { sparseBlock = is_buf_zero(rbuf, rsize); } - + ser_begin(wbuf, SPARSE_FADDR_SIZE); ser_uint64(fileAddr); /* store fileAddr in begin of buffer */ - } + } jcr->ReadBytes += sd->msglen; /* count bytes read */ fileAddr += sd->msglen; @@ -617,19 +617,19 @@ int send_data(int stream, FF_PKT *ff_pkt, BSOCK *sd, JCR *jcr, struct CHKSUM *ch if (!sparseBlock && ff_pkt->flags & FO_GZIP) { int zstat; compress_len = max_compress_len; - Dmsg4(400, "cbuf=0x%x len=%u rbuf=0x%x len=%u\n", cbuf, compress_len, + Dmsg4(400, "cbuf=0x%x len=%u rbuf=0x%x len=%u\n", cbuf, compress_len, rbuf, sd->msglen); /* NOTE! This call modifies compress_len !!! */ - if ((zstat=compress2((Bytef *)cbuf, &compress_len, + if ((zstat=compress2((Bytef *)cbuf, &compress_len, (const Bytef *)rbuf, (uLong)sd->msglen, ff_pkt->GZIP_level)) != Z_OK) { - Jmsg(jcr, M_FATAL, 0, _("Compression error: %d\n"), zstat); + Jmsg(jcr, M_FATAL, 0, _("Compression error: %d\n"), zstat); sd->msg = msgsave; sd->msglen = 0; set_jcr_job_status(jcr, JS_ErrorTerminated); return 0; } - Dmsg2(400, "compressed len=%d uncompressed len=%d\n", + Dmsg2(400, "compressed len=%d uncompressed len=%d\n", compress_len, sd->msglen); sd->msglen = compress_len; /* set compressed length */ @@ -644,7 +644,7 @@ int send_data(int stream, FF_PKT *ff_pkt, BSOCK *sd, JCR *jcr, struct CHKSUM *ch sd->msg = wbuf; /* set correct write buffer */ if (!bnet_send(sd)) { berrno be; - Jmsg2(jcr, M_FATAL, 0, _("Network send error %d to SD. ERR=%s\n"), + Jmsg2(jcr, M_FATAL, 0, _("Network send error %d to SD. ERR=%s\n"), sd->msglen, bnet_strerror(sd)); sd->msg = msgsave; /* restore bnet buffer */ sd->msglen = 0; diff --git a/bacula/src/filed/chksum.c b/bacula/src/filed/chksum.c index 4453d7d6af..300b492852 100644 --- a/bacula/src/filed/chksum.c +++ b/bacula/src/filed/chksum.c @@ -45,7 +45,7 @@ int chksum_init(CHKSUM *chksum, int flags) status = SHA1Init(&chksum->context.sha1); if (status == 0) { chksum->type = CHKSUM_SHA1; - bstrncpy(chksum->name, "SHA1", sizeof(chksum->name)); + bstrncpy(chksum->name, "SHA1", sizeof(chksum->name)); } } return status; diff --git a/bacula/src/filed/estimate.c b/bacula/src/filed/estimate.c index eaa181a6b2..56ff5e736c 100644 --- a/bacula/src/filed/estimate.c +++ b/bacula/src/filed/estimate.c @@ -1,5 +1,5 @@ /* - * Bacula File Daemon estimate.c + * Bacula File Daemon estimate.c * Make and estimate of the number of files and size to be saved. * * Kern Sibbald, September MMI @@ -32,7 +32,7 @@ static int tally_file(FF_PKT *ff_pkt, void *pkt); -/* +/* * Find all the requested files and count them. */ int make_estimate(JCR *jcr) @@ -45,9 +45,9 @@ int make_estimate(JCR *jcr) stat = find_files(jcr, (FF_PKT *)jcr->ff, tally_file, (void *)jcr); return stat; -} +} -/* +/* * Called here by find() for each file included. * */ @@ -86,14 +86,14 @@ static int tally_file(FF_PKT *ff_pkt, void *ijcr) if (ff_pkt->type != FT_LNKSAVED && S_ISREG(ff_pkt->statp.st_mode)) { if (ff_pkt->statp.st_size > 0) { - jcr->JobBytes += ff_pkt->statp.st_size; + jcr->JobBytes += ff_pkt->statp.st_size; } #ifdef HAVE_DARWIN_OS if (ff_pkt->flags & FO_HFSPLUS) { - if (ff_pkt->hfsinfo.rsrclength > 0) { - jcr->JobBytes += ff_pkt->hfsinfo.rsrclength; - } - jcr->JobBytes += 32; /* Finder info */ + if (ff_pkt->hfsinfo.rsrclength > 0) { + jcr->JobBytes += ff_pkt->hfsinfo.rsrclength; + } + jcr->JobBytes += 32; /* Finder info */ } #endif } diff --git a/bacula/src/filed/filed.c b/bacula/src/filed/filed.c index 7e0b61effc..71c2b14bbd 100644 --- a/bacula/src/filed/filed.c +++ b/bacula/src/filed/filed.c @@ -65,7 +65,7 @@ static void usage() fprintf(stderr, _( "Copyright (C) 2000-2004 Kern Sibbald and John Walker\n" "\nVersion: " VERSION " (" BDATE ")\n\n" -"Usage: bacula-fd [-f -s] [-c config_file] [-d debug_level]\n" +"Usage: bacula-fd [-f -s] [-c config_file] [-d debug_level]\n" " -c use as configuration file\n" " -dnn set debug level to nn\n" " -f run in foreground (for debugging)\n" @@ -76,14 +76,14 @@ static void usage() " -u userid\n" " -v verbose user messages\n" " -? print this message.\n" -"\n")); +"\n")); exit(1); } -/********************************************************************* +/********************************************************************* * - * Main Bacula Unix Client Program + * Main Bacula Unix Client Program * */ #if defined(HAVE_CYGWIN) || defined(HAVE_WIN32) @@ -116,7 +116,7 @@ int main (int argc, char *argv[]) case 'd': /* debug level */ debug_level = atoi(optarg); if (debug_level <= 0) { - debug_level = 1; + debug_level = 1; } break; @@ -151,7 +151,7 @@ int main (int argc, char *argv[]) default: usage(); - } + } } argc -= optind; argv += optind; @@ -160,7 +160,7 @@ int main (int argc, char *argv[]) if (configfile != NULL) free(configfile); configfile = bstrdup(*argv); - argc--; + argc--; argv++; } if (argc) { @@ -193,8 +193,8 @@ int main (int argc, char *argv[]) me = (CLIENT *)GetNextRes(R_CLIENT, NULL); UnlockRes(); if (!me) { - Emsg1(M_ABORT, 0, _("No File daemon resource defined in %s\n\ -Without that I don't know who I am :-(\n"), configfile); + Emsg1(M_ABORT, 0, _("No File daemon resource defined in %s\n" +"Without that I don't know who I am :-(\n"), configfile); } else { my_name_is(0, NULL, me->hdr.name); if (!me->messages) { @@ -202,7 +202,7 @@ Without that I don't know who I am :-(\n"), configfile); me->messages = (MSGS *)GetNextRes(R_MSGS, NULL); UnlockRes(); if (!me->messages) { - Emsg1(M_ABORT, 0, _("No Messages resource defined in %s\n"), configfile); + Emsg1(M_ABORT, 0, _("No Messages resource defined in %s\n"), configfile); } } close_msg(NULL); /* close temp message handler */ @@ -239,7 +239,7 @@ Without that I don't know who I am :-(\n"), configfile); server_tid = pthread_self(); if (inetd_request) { - /* Socket is on fd 0 */ + /* Socket is on fd 0 */ struct sockaddr client_addr; int port = -1; socklen_t client_addr_len = sizeof(client_addr); @@ -253,7 +253,7 @@ Without that I don't know who I am :-(\n"), configfile); /* Become server, and handle requests */ IPADDR *p; foreach_dlist(p, me->FDaddrs) { - Dmsg1(10, "filed: listening on port %d\n", p->get_port_host_order()); + Dmsg1(10, "filed: listening on port %d\n", p->get_port_host_order()); } bnet_thread_server(me->FDaddrs, me->MaxConcurrentJobs, &dir_workq, handle_client_request); } @@ -271,7 +271,7 @@ void terminate_filed(int sig) free(configfile); } if (debug_level > 5) { - print_memory_pool_stats(); + print_memory_pool_stats(); } free_config_resources(); term_msg(); diff --git a/bacula/src/filed/filed.h b/bacula/src/filed/filed.h index 48817cd136..a49139a996 100644 --- a/bacula/src/filed/filed.h +++ b/bacula/src/filed/filed.h @@ -1,7 +1,7 @@ /* * Bacula File Daemon specific configuration and defines * - * Kern Sibbald, Jan MMI + * Kern Sibbald, Jan MMI * * Version $Id$ */ diff --git a/bacula/src/filed/filed_conf.c b/bacula/src/filed/filed_conf.c index aaa3b33707..47bd9a6ba8 100644 --- a/bacula/src/filed/filed_conf.c +++ b/bacula/src/filed/filed_conf.c @@ -7,7 +7,7 @@ * * 1. The generic lexical scanner in lib/lex.c and lib/lex.h * - * 2. The generic config scanner in lib/parse_config.c and + * 2. The generic config scanner in lib/parse_config.c and * lib/parse_config.h. * These files contain the parser code, some utility * routines, and the common store routines (name, int, @@ -74,9 +74,9 @@ int res_all_size = sizeof(res_all); #endif /* Definition of records permitted within each - * resource with the routine to process the record + * resource with the routine to process the record * information. - */ + */ /* Client or File daemon "Global" resources */ static RES_ITEM cli_items[] = { @@ -86,16 +86,16 @@ static RES_ITEM cli_items[] = { {"fdaddress", store_addresses_address, ITEM(res_client.FDaddrs), 0, ITEM_DEFAULT, 9102}, {"fdaddresses", store_addresses, ITEM(res_client.FDaddrs), 0, ITEM_DEFAULT, 9102}, - {"workingdirectory", store_dir, ITEM(res_client.working_directory), 0, ITEM_REQUIRED, 0}, - {"piddirectory", store_dir, ITEM(res_client.pid_directory), 0, ITEM_REQUIRED, 0}, - {"subsysdirectory", store_dir, ITEM(res_client.subsys_directory), 0, 0, 0}, + {"workingdirectory", store_dir, ITEM(res_client.working_directory), 0, ITEM_REQUIRED, 0}, + {"piddirectory", store_dir, ITEM(res_client.pid_directory), 0, ITEM_REQUIRED, 0}, + {"subsysdirectory", store_dir, ITEM(res_client.subsys_directory), 0, 0, 0}, {"requiressl", store_yesno, ITEM(res_client.require_ssl), 1, ITEM_DEFAULT, 0}, {"maximumconcurrentjobs", store_pint, ITEM(res_client.MaxConcurrentJobs), 0, ITEM_DEFAULT, 10}, {"messages", store_res, ITEM(res_client.messages), R_MSGS, 0, 0}, {"heartbeatinterval", store_time, ITEM(res_client.heartbeat_interval), 0, ITEM_DEFAULT, 0}, {"sdconnecttimeout", store_time,ITEM(res_client.SDConnectTimeout), 0, ITEM_DEFAULT, 60 * 30}, {"maximumnetworkbuffersize", store_pint, ITEM(res_client.max_network_buffer_size), 0, 0, 0}, - {NULL, NULL, NULL, 0, 0, 0} + {NULL, NULL, NULL, 0, 0, 0} }; /* Directors that can use our services */ @@ -106,14 +106,14 @@ static RES_ITEM dir_items[] = { {"address", store_str, ITEM(res_dir.address), 0, 0, 0}, {"enablessl", store_yesno, ITEM(res_dir.enable_ssl),1, ITEM_DEFAULT, 0}, {"monitor", store_yesno, ITEM(res_dir.monitor), 1, ITEM_DEFAULT, 0}, - {NULL, NULL, NULL, 0, 0, 0} + {NULL, NULL, NULL, 0, 0, 0} }; /* Message resource */ extern RES_ITEM msgs_items[]; -/* - * This is the master resource definition. +/* + * This is the master resource definition. * It must have one item for each of the resources. */ RES_TABLE resources[] = { @@ -141,31 +141,31 @@ void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fm } switch (type) { case R_DIRECTOR: - sendit(sock, "Director: name=%s password=%s\n", reshdr->name, + sendit(sock, "Director: name=%s password=%s\n", reshdr->name, res->res_dir.password); break; case R_CLIENT: - sendit(sock, "Client: name=%s FDport=%d\n", reshdr->name, + sendit(sock, "Client: name=%s FDport=%d\n", reshdr->name, get_first_port_host_order(res->res_client.FDaddrs)); break; case R_MSGS: - sendit(sock, "Messages: name=%s\n", res->res_msgs.hdr.name); - if (res->res_msgs.mail_cmd) - sendit(sock, " mailcmd=%s\n", res->res_msgs.mail_cmd); - if (res->res_msgs.operator_cmd) - sendit(sock, " opcmd=%s\n", res->res_msgs.operator_cmd); + sendit(sock, "Messages: name=%s\n", res->res_msgs.hdr.name); + if (res->res_msgs.mail_cmd) + sendit(sock, " mailcmd=%s\n", res->res_msgs.mail_cmd); + if (res->res_msgs.operator_cmd) + sendit(sock, " opcmd=%s\n", res->res_msgs.operator_cmd); break; default: - sendit(sock, "Unknown resource type %d\n", type); + sendit(sock, "Unknown resource type %d\n", type); } if (recurse && res->res_dir.hdr.next) dump_resource(type, res->res_dir.hdr.next, sendit, sock); } -/* - * Free memory of resource. +/* + * Free memory of resource. * NB, we don't need to worry about freeing any references - * to other resources as they will be freed when that + * to other resources as they will be freed when that * resource chain is traversed. Mainly we worry about freeing * allocated strings (names). */ @@ -240,13 +240,13 @@ void save_resource(int type, RES_ITEM *items, int pass) int i, size; int error = 0; - /* + /* * Ensure that all required items are present */ for (i=0; items[i].name; i++) { if (items[i].flags & ITEM_REQUIRED) { - if (!bit_is_set(i, res_all.res_dir.hdr.item_present)) { - Emsg2(M_ABORT, 0, _("%s item is required in %s resource, but not found.\n"), + if (!bit_is_set(i, res_all.res_dir.hdr.item_present)) { + Emsg2(M_ABORT, 0, _("%s item is required in %s resource, but not found.\n"), items[i].name, resources[rindex]); } } @@ -267,12 +267,12 @@ void save_resource(int type, RES_ITEM *items, int pass) /* Resources containing another resource */ case R_CLIENT: if ((res = (URES *)GetResWithName(R_CLIENT, res_all.res_dir.hdr.name)) == NULL) { - Emsg1(M_ABORT, 0, "Cannot find Client resource %s\n", res_all.res_dir.hdr.name); + Emsg1(M_ABORT, 0, "Cannot find Client resource %s\n", res_all.res_dir.hdr.name); } res->res_client.messages = res_all.res_client.messages; break; default: - Emsg1(M_ERROR, 0, _("Unknown resource type %d\n"), type); + Emsg1(M_ERROR, 0, _("Unknown resource type %d\n"), type); error = 1; break; } @@ -302,7 +302,7 @@ void save_resource(int type, RES_ITEM *items, int pass) size = sizeof(MSGS); break; default: - printf(_("Unknown resource type %d\n"), type); + printf(_("Unknown resource type %d\n"), type); error = 1; size = 1; break; @@ -319,12 +319,12 @@ void save_resource(int type, RES_ITEM *items, int pass) for (next=res_head[rindex]; next->next; next=next->next) { if (strcmp(next->name, res->res_dir.hdr.name) == 0) { Emsg2(M_ERROR_TERM, 0, - _("Attempt to define second %s resource named \"%s\" is not permitted.\n"), + _("Attempt to define second %s resource named \"%s\" is not permitted.\n"), resources[rindex].name, res->res_dir.hdr.name); } } next->next = (RES *)res; - Dmsg2(90, "Inserting %s res: %s\n", res_to_str(type), + Dmsg2(90, "Inserting %s res: %s\n", res_to_str(type), res->res_dir.hdr.name); } } diff --git a/bacula/src/filed/filed_conf.h b/bacula/src/filed/filed_conf.h index f1d9fa5210..4abd87f1ac 100644 --- a/bacula/src/filed/filed_conf.h +++ b/bacula/src/filed/filed_conf.h @@ -26,7 +26,7 @@ */ /* - * Resource codes -- they must be sequential for indexing + * Resource codes -- they must be sequential for indexing */ #define R_FIRST 1001 diff --git a/bacula/src/filed/heartbeat.c b/bacula/src/filed/heartbeat.c index edbad95136..c13a6feff1 100644 --- a/bacula/src/filed/heartbeat.c +++ b/bacula/src/filed/heartbeat.c @@ -36,7 +36,7 @@ #define pthread_kill(x, y) /* Use shorter wait interval on Cygwin because no kill */ #define WAIT_INTERVAL 10 - + #else /* Unix systems */ #define WAIT_INTERVAL 60 #endif @@ -45,7 +45,7 @@ extern "C" void *sd_heartbeat_thread(void *arg); extern "C" void *dir_heartbeat_thread(void *arg); extern bool no_signals; -/* +/* * Listen on the SD socket for heartbeat signals. * Send heartbeats to the Director every HB_TIME * seconds. @@ -83,9 +83,9 @@ extern "C" void *sd_heartbeat_thread(void *arg) if (n == 1) { /* input waiting */ bnet_recv(sd); /* read it -- probably heartbeat from sd */ if (sd->msglen <= 0) { - Dmsg1(100, "Got BNET_SIG %d from SD\n", sd->msglen); + Dmsg1(100, "Got BNET_SIG %d from SD\n", sd->msglen); } else { - Dmsg2(100, "Got %d bytes from SD. MSG=%s\n", sd->msglen, sd->msg); + Dmsg2(100, "Got %d bytes from SD. MSG=%s\n", sd->msglen, sd->msg); } } } @@ -98,7 +98,7 @@ extern "C" void *sd_heartbeat_thread(void *arg) /* Startup the heartbeat thread -- see above */ void start_heartbeat_monitor(JCR *jcr) { - /* + /* * If no signals are set, do not start the heartbeat because * it gives a constant stream of TIMEOUT_SIGNAL signals that * make debugging impossible. @@ -110,7 +110,7 @@ void start_heartbeat_monitor(JCR *jcr) } /* Terminate the heartbeat thread. Used for both SD and DIR */ -void stop_heartbeat_monitor(JCR *jcr) +void stop_heartbeat_monitor(JCR *jcr) { int cnt = 0; if (no_signals) { diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index 1cbb589aa0..e931e31791 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -31,7 +31,7 @@ extern char my_name[]; extern CLIENT *me; /* our client resource */ - + /* Imported functions */ extern int status_cmd(JCR *jcr); extern int qstatus_cmd(JCR *jcr); @@ -70,8 +70,8 @@ struct s_cmds { int monitoraccess; /* specify if monitors have access to this function */ }; -/* - * The following are the recognized commands from the Director. +/* + * The following are the recognized commands from the Director. */ static struct s_cmds cmds[] = { {"backup", backup_cmd, 0}, @@ -146,7 +146,7 @@ static char read_open[] = "read open session = %s %ld %ld %ld %ld %ld %ld\n"; static char read_data[] = "read data %d\n"; static char read_close[] = "read close session %d\n"; -/* +/* * Accept requests from a Director * * NOTE! We are running as a separate thread @@ -165,7 +165,7 @@ static char read_close[] = "read close session %d\n"; */ void *handle_client_request(void *dirp) { - int i; + int i; bool found, quit; JCR *jcr; BSOCK *dir = (BSOCK *)dirp; @@ -201,15 +201,15 @@ void *handle_client_request(void *dirp) break; } if ((jcr->authenticated) && (!cmds[i].monitoraccess) && (jcr->director->monitor)) { - Dmsg1(100, "Command %s illegal.\n", cmds[i].cmd); + Dmsg1(100, "Command %s illegal.\n", cmds[i].cmd); bnet_fsend(dir, illegal_cmd); bnet_sig(dir, BNET_EOD); break; } - Dmsg1(100, "Executing %s command.\n", cmds[i].cmd); + Dmsg1(100, "Executing %s command.\n", cmds[i].cmd); if (!cmds[i].func(jcr)) { /* do command */ quit = true; /* error or fully terminated, get out */ - Dmsg0(20, "Quit command loop due to command error or Job done.\n"); + Dmsg0(20, "Quit command loop due to command error or Job done.\n"); } break; } @@ -288,7 +288,7 @@ void *handle_client_request(void *dirp) } /* - * Hello from Director he must identify himself and provide his + * Hello from Director he must identify himself and provide his * password. */ static int hello_cmd(JCR *jcr) @@ -313,13 +313,13 @@ static int cancel_cmd(JCR *jcr) if (sscanf(dir->msg, "cancel Job=%127s", Job) == 1) { if (!(cjcr=get_jcr_by_full_name(Job))) { - bnet_fsend(dir, "2901 Job %s not found.\n", Job); + bnet_fsend(dir, "2901 Job %s not found.\n", Job); } else { if (cjcr->store_bsock) { P(cjcr->mutex); cjcr->store_bsock->timed_out = 1; cjcr->store_bsock->terminated = 1; -/* +/* * #if !defined(HAVE_CYGWIN) && !defined(HAVE_WIN32) */ #if !defined(HAVE_CYGWIN) @@ -329,7 +329,7 @@ static int cancel_cmd(JCR *jcr) } set_jcr_job_status(cjcr, JS_Canceled); free_jcr(cjcr); - bnet_fsend(dir, _("2001 Job %s marked to be canceled.\n"), Job); + bnet_fsend(dir, _("2001 Job %s marked to be canceled.\n"), Job); } } else { bnet_fsend(dir, _("2902 Error scanning cancel command.\n")); @@ -352,7 +352,7 @@ static int setdebug_cmd(JCR *jcr) if (sscanf(dir->msg, "setdebug=%d trace=%d", &level, &trace_flag) != 2 || level < 0) { pm_strcpy(jcr->errmsg, dir->msg); bnet_fsend(dir, "2991 Bad setdebug command: %s\n", jcr->errmsg); - return 0; + return 0; } debug_level = level; set_trace(trace_flag); @@ -372,7 +372,7 @@ static int estimate_cmd(JCR *jcr) return 0; } make_estimate(jcr); - bnet_fsend(dir, OKest, jcr->num_files_examined, + bnet_fsend(dir, OKest, jcr->num_files_examined, edit_uint64_with_commas(jcr->JobBytes, ed2)); bnet_sig(dir, BNET_EOD); return 1; @@ -387,7 +387,7 @@ static int job_cmd(JCR *jcr) POOLMEM *sd_auth_key; sd_auth_key = get_memory(dir->msglen); - if (sscanf(dir->msg, jobcmd, &jcr->JobId, jcr->Job, + if (sscanf(dir->msg, jobcmd, &jcr->JobId, jcr->Job, &jcr->VolSessionId, &jcr->VolSessionTime, sd_auth_key) != 5) { pm_strcpy(jcr->errmsg, dir->msg); @@ -459,7 +459,7 @@ static int run_cmd(JCR *jcr, char *cmd, const char *name) int status; BPIPE *bpipe; char line[MAXSTRING]; - + ecmd = edit_job_codes(jcr, ecmd, cmd, ""); bpipe = open_bpipe(ecmd, 0, "r"); free_pool_memory(ecmd); @@ -513,7 +513,7 @@ static void add_fname_to_list(JCR *jcr, char *fname, int list) bpipe = open_bpipe(fn, 0, "r"); free_pool_memory(fn); if (!bpipe) { - Jmsg(jcr, M_FATAL, 0, _("Cannot run program: %s. ERR=%s\n"), + Jmsg(jcr, M_FATAL, 0, _("Cannot run program: %s. ERR=%s\n"), p, strerror(errno)); return; } @@ -521,7 +521,7 @@ static void add_fname_to_list(JCR *jcr, char *fname, int list) if (list == INC_LIST) { *q = 0; /* terminate options */ strcpy(buf, fname); - strcat(buf, " "); + strcat(buf, " "); optlen = strlen(buf); } else { optlen = 0; @@ -535,7 +535,7 @@ static void add_fname_to_list(JCR *jcr, char *fname, int list) } } if ((stat=close_bpipe(bpipe)) != 0) { - Jmsg(jcr, M_FATAL, 0, _("Error running program: %s. RtnStat=%d ERR=%s\n"), + Jmsg(jcr, M_FATAL, 0, _("Error running program: %s. RtnStat=%d ERR=%s\n"), p, stat, strerror(errno)); return; } @@ -544,15 +544,15 @@ static void add_fname_to_list(JCR *jcr, char *fname, int list) 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()); + 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 */ strcpy(buf, fname); - strcat(buf, " "); + strcat(buf, " "); optlen = strlen(buf); } else { optlen = 0; @@ -577,8 +577,8 @@ static void add_fname_to_list(JCR *jcr, char *fname, int list) } } -/* - * +/* + * * Get list of files/directories to include from Director * */ @@ -596,12 +596,12 @@ static int include_cmd(JCR *jcr) return bnet_fsend(dir, OKinc); } -static bool init_fileset(JCR *jcr) +static bool init_fileset(JCR *jcr) { FF_PKT *ff; findFILESET *fileset; - if (!jcr->ff) { + if (!jcr->ff) { return false; } ff = (FF_PKT *)jcr->ff; @@ -659,7 +659,7 @@ static void add_file_to_fileset(JCR *jcr, const char *fname, findFILESET *filese bpipe = open_bpipe(fn, 0, "r"); free_pool_memory(fn); if (!bpipe) { - Jmsg(jcr, M_FATAL, 0, _("Cannot run program: %s. ERR=%s\n"), + Jmsg(jcr, M_FATAL, 0, _("Cannot run program: %s. ERR=%s\n"), p, strerror(errno)); return; } @@ -668,7 +668,7 @@ static void add_file_to_fileset(JCR *jcr, const char *fname, findFILESET *filese fileset->incexe->name_list.append(bstrdup(buf)); } if ((stat=close_bpipe(bpipe)) != 0) { - Jmsg(jcr, M_FATAL, 0, _("Error running program: %s. RtnStat=%d ERR=%s\n"), + Jmsg(jcr, M_FATAL, 0, _("Error running program: %s. RtnStat=%d ERR=%s\n"), p, stat, strerror(errno)); return; } @@ -677,7 +677,7 @@ static void add_file_to_fileset(JCR *jcr, const char *fname, findFILESET *filese p++; /* skip over < */ if ((ffd = fopen(p, "r")) == NULL) { berrno be; - Jmsg(jcr, M_FATAL, 0, _("Cannot open FileSet input file: %s. ERR=%s\n"), + Jmsg(jcr, M_FATAL, 0, _("Cannot open FileSet input file: %s. ERR=%s\n"), p, be.strerror()); return; } @@ -693,7 +693,7 @@ static void add_file_to_fileset(JCR *jcr, const char *fname, findFILESET *filese } } - + static void add_fileset(JCR *jcr, const char *item) { FF_PKT *ff = (FF_PKT *)jcr->ff; @@ -742,15 +742,15 @@ static void add_fileset(JCR *jcr, const char *item) char prbuf[500]; preg = (regex_t *)malloc(sizeof(regex_t)); if (current_opts->flags & FO_IGNORECASE) { - rc = regcomp(preg, item, REG_EXTENDED|REG_ICASE); + rc = regcomp(preg, item, REG_EXTENDED|REG_ICASE); } else { - rc = regcomp(preg, item, REG_EXTENDED); + rc = regcomp(preg, item, REG_EXTENDED); } if (rc != 0) { regerror(rc, preg, prbuf, sizeof(prbuf)); regfree(preg); free(preg); - Jmsg(jcr, M_FATAL, 0, "REGEX %s compile error. ERR=%s\n", item, prbuf); + Jmsg(jcr, M_FATAL, 0, "REGEX %s compile error. ERR=%s\n", item, prbuf); state = state_error; break; } @@ -772,7 +772,7 @@ static void add_fileset(JCR *jcr, const char *item) current_opts->wild.append(bstrdup(item)); state = state_options; break; - case 'O': + case 'O': current_opts = start_options(ff); set_options(current_opts, item); state = state_options; @@ -807,26 +807,26 @@ static bool term_fileset(JCR *jcr) for (j=0; jopts_list.size(); j++) { findFOPTS *fo = (findFOPTS *)incexe->opts_list.get(j); for (k=0; kregex.size(); k++) { - Dmsg1(400, "R %s\n", (char *)fo->regex.get(k)); + Dmsg1(400, "R %s\n", (char *)fo->regex.get(k)); } for (k=0; kwild.size(); k++) { - Dmsg1(400, "W %s\n", (char *)fo->wild.get(k)); + Dmsg1(400, "W %s\n", (char *)fo->wild.get(k)); } for (k=0; kbase.size(); k++) { - Dmsg1(400, "B %s\n", (char *)fo->base.get(k)); + Dmsg1(400, "B %s\n", (char *)fo->base.get(k)); } for (k=0; kfstype.size(); k++) { - Dmsg1(400, "X %s\n", (char *)fo->fstype.get(k)); + Dmsg1(400, "X %s\n", (char *)fo->fstype.get(k)); } if (fo->reader) { - Dmsg1(400, "D %s\n", fo->reader); + Dmsg1(400, "D %s\n", fo->reader); } if (fo->writer) { - Dmsg1(400, "T %s\n", 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)); + Dmsg1(400, "F %s\n", (char *)incexe->name_list.get(j)); } } for (i=0; iexclude_list.size(); i++) { @@ -835,20 +835,20 @@ static bool term_fileset(JCR *jcr) for (j=0; jopts_list.size(); j++) { findFOPTS *fo = (findFOPTS *)incexe->opts_list.get(j); for (k=0; kregex.size(); k++) { - Dmsg1(400, "R %s\n", (char *)fo->regex.get(k)); + Dmsg1(400, "R %s\n", (char *)fo->regex.get(k)); } for (k=0; kwild.size(); k++) { - Dmsg1(400, "W %s\n", (char *)fo->wild.get(k)); + Dmsg1(400, "W %s\n", (char *)fo->wild.get(k)); } for (k=0; kbase.size(); k++) { - Dmsg1(400, "B %s\n", (char *)fo->base.get(k)); + Dmsg1(400, "B %s\n", (char *)fo->base.get(k)); } for (k=0; kfstype.size(); k++) { - Dmsg1(400, "X %s\n", (char *)fo->fstype.get(k)); + Dmsg1(400, "X %s\n", (char *)fo->fstype.get(k)); } } for (j=0; jname_list.size(); j++) { - Dmsg1(400, "F %s\n", (char *)incexe->name_list.get(j)); + Dmsg1(400, "F %s\n", (char *)incexe->name_list.get(j)); } } return ff->fileset->state != state_error; @@ -916,7 +916,7 @@ static void set_options(findFOPTS *fo, const char *opts) break; case 'V': /* verify options */ /* Copy Verify Options */ - for (j=0; *p && *p != ':'; p++) { + for (j=0; *p && *p != ':'; p++) { fo->VerifyOpts[j] = *p; if (j < (int)sizeof(fo->VerifyOpts) - 1) { j++; @@ -929,19 +929,19 @@ static void set_options(findFOPTS *fo, const char *opts) break; case 'Z': /* gzip compression */ fo->flags |= FO_GZIP; - fo->GZIP_level = *++p - '0'; - Dmsg1(200, "Compression level=%d\n", fo->GZIP_level); + fo->GZIP_level = *++p - '0'; + Dmsg1(200, "Compression level=%d\n", fo->GZIP_level); break; default: - Emsg1(M_ERROR, 0, "Unknown include/exclude option: %c\n", *p); + Emsg1(M_ERROR, 0, "Unknown include/exclude option: %c\n", *p); break; } } -} +} /* - * Director is passing his Fileset + * Director is passing his Fileset */ static int fileset_cmd(JCR *jcr) { @@ -998,7 +998,7 @@ static int bootstrap_cmd(JCR *jcr) bs = fopen(fname, "a+"); /* create file */ if (!bs) { berrno be; - /* + /* * Suck up what he is sending to us so that he will then * read our error message. */ @@ -1043,24 +1043,24 @@ static int level_cmd(JCR *jcr) /* Base backup requested? */ if (strcmp(level, "base") == 0) { jcr->JobLevel = L_BASE; - /* Full backup requested? */ + /* Full backup requested? */ } else if (strcmp(level, "full") == 0) { jcr->JobLevel = L_FULL; - /* + /* * Backup requested since