From 7503a438c87931cf1748bd0fda3bb932e2af3346 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Mon, 14 Mar 2005 13:00:42 +0000 Subject: [PATCH] - Fix ANSI labels to put EOF1 and EOF2 after each file mark. - Add Python to SD and FD. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1886 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/cats/make_mysql_tables.in | 6 +- bacula/src/filed/Makefile.in | 10 +- bacula/src/filed/python.c | 130 +++++++++++++++++ bacula/src/stored/acquire.c | 2 +- bacula/src/stored/ansi_label.c | 10 -- bacula/src/stored/block.c | 11 +- bacula/src/stored/dev.c | 8 -- bacula/src/stored/label.c | 1 + bacula/src/stored/stored.c | 3 + bacula/src/stored/stored_conf.c | 208 ++++++++++++++------------- bacula/src/stored/stored_conf.h | 97 ++++++------- bacula/src/version.h | 4 +- 12 files changed, 306 insertions(+), 184 deletions(-) create mode 100644 bacula/src/filed/python.c diff --git a/bacula/src/cats/make_mysql_tables.in b/bacula/src/cats/make_mysql_tables.in index e1ce1ad9d4..677b65d198 100644 --- a/bacula/src/cats/make_mysql_tables.in +++ b/bacula/src/cats/make_mysql_tables.in @@ -32,8 +32,7 @@ CREATE TABLE File ( LStat TINYBLOB NOT NULL, MD5 TINYBLOB NOT NULL, PRIMARY KEY(FileId), - INDEX (JobId), - INDEX (FilenameId, PathId) + INDEX (JobId, PathId, FilenameId) ); # @@ -43,7 +42,8 @@ CREATE TABLE File ( # # INDEX (PathId), # INDEX (FilenameId), -# INDEX (JobId, PathId, FilenameId) +# INDEX (FilenameId, PathId) +# INDEX (JobId), # CREATE TABLE MediaType ( diff --git a/bacula/src/filed/Makefile.in b/bacula/src/filed/Makefile.in index e5c05e2e3e..3b0efbb5b9 100755 --- a/bacula/src/filed/Makefile.in +++ b/bacula/src/filed/Makefile.in @@ -24,10 +24,10 @@ dummy: # SVRSRCS = filed.c authenticate.c acl.c backup.c chksum.c estimate.c \ - filed_conf.c heartbeat.c job.c \ + filed_conf.c heartbeat.c job.c python.c \ restore.c status.c verify.c verify_vol.c SVROBJS = filed.o authenticate.o acl.o backup.o chksum.o estimate.o \ - filed_conf.o heartbeat.o job.o \ + filed_conf.o heartbeat.o job.o python.o \ restore.o status.o verify.o verify_vol.o # these are the objects that are changed by the .configure process @@ -47,7 +47,7 @@ WIN32LIBS = $(@WIN32@) # inference rules .c.o: - $(CXX) $(DEFS) $(DEBUG) -c $(WCFLAGS) $(CPPFLAGS) -I$(srcdir) -I$(basedir) $(DINCLUDE) $(CFLAGS) $< + $(CXX) $(DEFS) $(DEBUG) -c $(WCFLAGS) $(CPPFLAGS) $(PYTHON_INC) -I$(srcdir) -I$(basedir) $(DINCLUDE) $(CFLAGS) $< #------------------------------------------------------------------------- all: Makefile @WIN32@ bacula-fd @STATIC_FD@ @echo "==== Make of filed is good ====" @@ -72,11 +72,11 @@ win32: $(WIN32OBJS) bacula-fd: $(SVROBJS) ../findlib/libfind.a ../lib/libbac.a @WIN32@ $(CXX) $(WLDFLAGS) $(LDFLAGS) -L../lib -L../findlib -o $@ $(SVROBJS) \ - $(WIN32LIBS) $(FDLIBS) -lfind -lbac -lm $(LIBS) $(DLIB) + $(WIN32LIBS) $(FDLIBS) -lfind -lbac -lm $(PYTHON_LIBS) $(LIBS) $(DLIB) static-bacula-fd: $(SVROBJS) ../findlib/libfind.a ../lib/libbac.a @WIN32@ $(CXX) $(WLDFLAGS) $(LDFLAGS) -static -L../lib -L../findlib -o $@ $(SVROBJS) \ - $(WIN32LIBS) $(FDLIBS) -lfind -lbac -lm $(LIBS) $(DLIB) + $(WIN32LIBS) $(FDLIBS) -lfind -lbac -lm $(PYTHON_LIBS) $(LIBS) $(DLIB) strip $@ diff --git a/bacula/src/filed/python.c b/bacula/src/filed/python.c new file mode 100644 index 0000000000..91e5a67501 --- /dev/null +++ b/bacula/src/filed/python.c @@ -0,0 +1,130 @@ +/* + * + * Bacula interface to Python for the File Daemon + * + * Kern Sibbald, March MMV + * + * Version $Id$ + * + */ + +/* + Copyright (C) 2005 Kern Sibbald + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + 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, + MA 02111-1307, USA. + + */ + +#include "bacula.h" +#include "filed.h" + +#ifdef HAVE_PYTHON +#undef _POSIX_C_SOURCE +#include + +PyObject *bacula_get(PyObject *self, PyObject *args); +PyObject *bacula_set(PyObject *self, PyObject *args, PyObject *keyw); + +/* Define Bacula entry points */ +PyMethodDef BaculaMethods[] = { + {"get", bacula_get, METH_VARARGS, "Get Bacula FD variables."}, + {"set", (PyCFunction)bacula_set, METH_VARARGS|METH_KEYWORDS, + "Set FD Bacula variables."}, + {NULL, NULL, 0, NULL} /* last item */ +}; + + +struct s_vars { + const char *name; + char *fmt; +}; + +static struct s_vars vars[] = { + { N_("FDName"), "s"}, /* 0 */ + { N_("Level"), "s"}, /* 1 */ + { N_("Type"), "s"}, /* 2 */ + { N_("JobId"), "i"}, /* 3 */ + { N_("Client"), "s"}, /* 4 */ + { N_("JobName"), "s"}, /* 5 */ + { N_("JobStatus"), "s"}, /* 6 */ + + { NULL, NULL} +}; + +/* Return Bacula variables */ +PyObject *bacula_get(PyObject *self, PyObject *args) +{ + PyObject *CObject; + JCR *jcr; + char *item; + bool found = false; + int i; + char buf[10]; + + if (!PyArg_ParseTuple(args, "Os:get", &CObject, &item)) { + return NULL; + } + jcr = (JCR *)PyCObject_AsVoidPtr(CObject); + for (i=0; vars[i].name; i++) { + if (strcmp(vars[i].name, item) == 0) { + found = true; + break; + } + } + if (!found) { + return NULL; + } + switch (i) { + case 0: /* FD's name */ + return Py_BuildValue(vars[i].fmt, my_name); + case 1: /* level */ + return Py_BuildValue(vars[i].fmt, job_level_to_str(jcr->JobLevel)); + case 2: /* type */ + return Py_BuildValue(vars[i].fmt, job_type_to_str(jcr->JobType)); + case 3: /* JobId */ + return Py_BuildValue(vars[i].fmt, jcr->JobId); + case 4: /* Client */ + return Py_BuildValue(vars[i].fmt, jcr->client_name); + case 5: /* JobName */ + return Py_BuildValue(vars[i].fmt, jcr->Job); + case 6: /* JobStatus */ + buf[1] = 0; + buf[0] = jcr->JobStatus; + return Py_BuildValue(vars[i].fmt, buf); + } + return NULL; +} + +/* Set Bacula variables */ +PyObject *bacula_set(PyObject *self, PyObject *args, PyObject *keyw) +{ + PyObject *CObject; + JCR *jcr; + char *msg = NULL; + static char *kwlist[] = {"jcr", "JobReport", NULL}; + if (!PyArg_ParseTupleAndKeywords(args, keyw, "O|ss:set", kwlist, + &CObject, &msg)) { + return NULL; + } + jcr = (JCR *)PyCObject_AsVoidPtr(CObject); + + if (msg) { + Jmsg(jcr, M_INFO, 0, "%s", msg); + } + return Py_BuildValue("i", 1); +} + +#endif /* HAVE_PYTHON */ diff --git a/bacula/src/stored/acquire.c b/bacula/src/stored/acquire.c index f8c9e1679d..c751aa887a 100644 --- a/bacula/src/stored/acquire.c +++ b/bacula/src/stored/acquire.c @@ -595,6 +595,7 @@ bool release_device(DCR *dcr) /* If no more writers, write an EOF */ if (!dev->num_writers && dev_can_write(dev)) { weof_dev(dev, 1); + write_ansi_ibm_labels(dcr, ANSI_EOF_LABEL, dev->VolHdr.VolName); } dev->VolCatInfo.VolCatFiles = dev->file; /* set number of files */ dev->VolCatInfo.VolCatJobs++; /* increment number of jobs */ @@ -602,7 +603,6 @@ bool release_device(DCR *dcr) Dmsg0(100, "dir_update_vol_info. Release0\n"); dir_update_volume_info(dcr, false); /* send Volume info to Director */ Dmsg0(100, "==== write ansi eof label \n"); - write_ansi_ibm_labels(dcr, ANSI_EOF_LABEL, dev->VolHdr.VolName); } /* If no writers, close if file or !CAP_ALWAYS_OPEN */ diff --git a/bacula/src/stored/ansi_label.c b/bacula/src/stored/ansi_label.c index 0257a43500..46bb03f05a 100644 --- a/bacula/src/stored/ansi_label.c +++ b/bacula/src/stored/ansi_label.c @@ -352,16 +352,6 @@ bool write_ansi_ibm_labels(DCR *dcr, int type, const char *VolName) Jmsg(jcr, M_FATAL, 0, _("Error writing EOF to tape. ERR=%s"), dev->errmsg); return false; } - /* If this is an EOF label, we must reposition to before it - as Bacula does not support these on read. - */ - if (type == ANSI_EOF_LABEL) { - if (!bsf_dev(dev, 2) || !fsf_dev(dev, 1)) { - Jmsg(jcr, M_FATAL, 0, _("Error repositiong after writing ANSI/IBM EOF labels to tape. ERR=%s"), - dev->errmsg); - return false; - } - } return true; default: Jmsg0(jcr, M_ABORT, 0, _("write_ansi_ibm_label called for non-ANSI/IBM type\n")); diff --git a/bacula/src/stored/block.c b/bacula/src/stored/block.c index 14d29d3bf5..a5e96da7b9 100644 --- a/bacula/src/stored/block.c +++ b/bacula/src/stored/block.c @@ -487,6 +487,9 @@ bool write_block_to_dev(DCR *dcr) dev->dev_errno = ENOSPC; return false; } + if (!write_ansi_ibm_labels(dcr, ANSI_EOF_LABEL, dev->VolHdr.VolName)) { + return false; + } if (!do_new_file_bookkeeping(dcr)) { /* Error message already sent */ @@ -662,6 +665,9 @@ static bool terminate_writing_volume(DCR *dcr) ok = false; Dmsg0(100, "WEOF error.\n"); } + if (ok) { + ok = write_ansi_ibm_labels(dcr, ANSI_EOV_LABEL, dev->VolHdr.VolName); + } dev->VolCatInfo.VolCatFiles = dev->file; if (dev->is_dvd()) { /* Write the current (and last) part. */ @@ -673,7 +679,6 @@ static bool terminate_writing_volume(DCR *dcr) } Dmsg1(100, "dir_update_volume_info terminate writing -- %s\n", ok?"OK":"ERROR"); - /* * Walk through all attached dcrs setting flag to call * set_new_file_parameters() when that dcr is next used. @@ -688,10 +693,6 @@ static bool terminate_writing_volume(DCR *dcr) /* Set new file/block parameters for current dcr */ set_new_file_parameters(dcr); - if (ok) { - ok = write_ansi_ibm_labels(dcr, ANSI_EOV_LABEL, dev->VolHdr.VolName); - } - if (ok && dev_cap(dev, CAP_TWOEOF) && weof_dev(dev, 1) != 0) { /* end the tape */ dev->VolCatInfo.VolCatErrors++; /* This may not be fatal since we already wrote an EOF */ diff --git a/bacula/src/stored/dev.c b/bacula/src/stored/dev.c index 5d8d4c6a8b..9261bb1f9b 100644 --- a/bacula/src/stored/dev.c +++ b/bacula/src/stored/dev.c @@ -664,14 +664,6 @@ eod_dev(DEVICE *dev) } else { update_pos_dev(dev); /* update position */ } - /* If this is an ANSI or IBM labeled tape we must - * backspace over EOF label - */ - if (dev->label_type != B_BACULA_LABEL) { - if (!bsf_dev(dev, 2) || !fsf_dev(dev, 1)) { - ok = false; - } - } Dmsg1(200, "EOD dev->file=%d\n", dev->file); return ok; } diff --git a/bacula/src/stored/label.c b/bacula/src/stored/label.c index fa5dafffb9..ff4c801e35 100644 --- a/bacula/src/stored/label.c +++ b/bacula/src/stored/label.c @@ -417,6 +417,7 @@ bool write_new_volume_label_to_dev(DCR *dcr, const char *VolName, const char *Po if (weof_dev(dev, 1) == 0) { dev->state |= ST_LABEL; + write_ansi_ibm_labels(dcr, ANSI_EOF_LABEL, dev->VolHdr.VolName); } if (debug_level >= 20) { diff --git a/bacula/src/stored/stored.c b/bacula/src/stored/stored.c index 3bd86b0fbf..206a8c8207 100644 --- a/bacula/src/stored/stored.c +++ b/bacula/src/stored/stored.c @@ -208,6 +208,9 @@ int main (int argc, char *argv[]) Jmsg0(NULL, M_ABORT, 0, _("Volume Session Time is ZERO!\n")); } + init_python_interpreter(me->hdr.name, me->scripts_directory ? + me->scripts_directory : "."); + /* Make sure on Solaris we can run concurrent, watch dog + servers + misc */ set_thread_concurrency(me->max_concurrent_jobs * 2 + 4); diff --git a/bacula/src/stored/stored_conf.c b/bacula/src/stored/stored_conf.c index a1c3d00dc8..8dd020a597 100644 --- a/bacula/src/stored/stored_conf.c +++ b/bacula/src/stored/stored_conf.c @@ -62,6 +62,7 @@ static RES_ITEM store_items[] = { {"workingdirectory", store_dir, ITEM(res_store.working_directory), 0, ITEM_REQUIRED, 0}, {"piddirectory", store_dir, ITEM(res_store.pid_directory), 0, ITEM_REQUIRED, 0}, {"subsysdirectory", store_dir, ITEM(res_store.subsys_directory), 0, 0, 0}, + {"scriptsdirectory", store_dir, ITEM(res_store.scripts_directory), 0, 0, 0}, {"requiressl", store_yesno,ITEM(res_store.require_ssl), 1, ITEM_DEFAULT, 0}, {"maximumconcurrentjobs", store_pint, ITEM(res_store.max_concurrent_jobs), 0, ITEM_DEFAULT, 10}, {"heartbeatinterval", store_time, ITEM(res_store.heartbeat_interval), 0, ITEM_DEFAULT, 0}, @@ -160,7 +161,7 @@ RES_TABLE resources[] = { {"device", dev_items, R_DEVICE}, {"messages", msgs_items, R_MSGS}, {"autochanger", changer_items, R_AUTOCHANGER}, - {NULL, NULL, 0} + {NULL, NULL, 0} }; @@ -178,7 +179,7 @@ void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fm return; } sendit(sock, "dump_resource type=%d\n", type); - if (type < 0) { /* no recursion */ + if (type < 0) { /* no recursion */ type = - type; recurse = 0; } @@ -188,40 +189,40 @@ void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fm break; case R_STORAGE: sendit(sock, "Storage: name=%s SDaddr=%s SDport=%d SDDport=%d HB=%s\n", - res->res_store.hdr.name, - NPRT(get_first_address(res->res_store.sdaddrs, buf, sizeof(buf))), - get_first_port_host_order(res->res_store.sdaddrs), - get_first_port_host_order(res->res_store.sddaddrs), - edit_utime(res->res_store.heartbeat_interval, buf, sizeof(buf))); + res->res_store.hdr.name, + NPRT(get_first_address(res->res_store.sdaddrs, buf, sizeof(buf))), + get_first_port_host_order(res->res_store.sdaddrs), + get_first_port_host_order(res->res_store.sddaddrs), + edit_utime(res->res_store.heartbeat_interval, buf, sizeof(buf))); if (res->res_store.sdaddrs) { - foreach_dlist(p, res->res_store.sdaddrs) { + foreach_dlist(p, res->res_store.sdaddrs) { sendit(sock, " SDaddr=%s SDport=%d\n", - p->get_address(buf, sizeof(buf)), p->get_port_host_order()); - } + p->get_address(buf, sizeof(buf)), p->get_port_host_order()); + } } if (res->res_store.sddaddrs) { - foreach_dlist(p, res->res_store.sddaddrs) { + foreach_dlist(p, res->res_store.sddaddrs) { sendit(sock, " SDDaddr=%s SDDport=%d\n", - p->get_address(buf, sizeof(buf)), p->get_port_host_order()); - } + p->get_address(buf, sizeof(buf)), p->get_port_host_order()); + } } break; case R_DEVICE: sendit(sock, "Device: name=%s MediaType=%s Device=%s LabelType=%d\n", - res->res_dev.hdr.name, - res->res_dev.media_type, res->res_dev.device_name, - res->res_dev.label_type); + res->res_dev.hdr.name, + res->res_dev.media_type, res->res_dev.device_name, + res->res_dev.label_type); sendit(sock, " rew_wait=%d min_bs=%d max_bs=%d\n", - res->res_dev.max_rewind_wait, res->res_dev.min_block_size, - res->res_dev.max_block_size); + res->res_dev.max_rewind_wait, res->res_dev.min_block_size, + res->res_dev.max_block_size); sendit(sock, " max_jobs=%d max_files=%" lld " max_size=%" lld "\n", - res->res_dev.max_volume_jobs, res->res_dev.max_volume_files, - res->res_dev.max_volume_size); + res->res_dev.max_volume_jobs, res->res_dev.max_volume_files, + res->res_dev.max_volume_size); sendit(sock, " max_file_size=%" lld " capacity=%" lld "\n", - res->res_dev.max_file_size, res->res_dev.volume_capacity); + res->res_dev.max_file_size, res->res_dev.volume_capacity); sendit(sock, " spool_directory=%s\n", NPRT(res->res_dev.spool_directory)); sendit(sock, " max_spool_size=%" lld " max_job_spool_size=%" lld "\n", - res->res_dev.max_spool_size, res->res_dev.max_job_spool_size); + res->res_dev.max_spool_size, res->res_dev.max_job_spool_size); if (res->res_dev.changer_res) { sendit(sock, " changer=%p\n", res->res_dev.changer_res); } @@ -271,8 +272,8 @@ void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fm case R_AUTOCHANGER: DEVRES *dev; sendit(sock, "Changer: name=%s Changer_devname=%s\n Changer_cmd=%s\n", - res->res_changer.hdr.name, - res->res_changer.changer_name, res->res_changer.changer_command); + res->res_changer.hdr.name, + res->res_changer.changer_name, res->res_changer.changer_command); foreach_alist(dev, res->res_changer.device) { sendit(sock, " --->Device: name=%s\n", dev->hdr.name); } @@ -322,81 +323,84 @@ void free_resource(RES *sres, int type) switch (type) { case R_DIRECTOR: if (res->res_dir.password) { - free(res->res_dir.password); + free(res->res_dir.password); } if (res->res_dir.address) { - free(res->res_dir.address); + free(res->res_dir.address); } break; case R_AUTOCHANGER: if (res->res_changer.changer_name) { - free(res->res_changer.changer_name); + free(res->res_changer.changer_name); } if (res->res_changer.changer_command) { - free(res->res_changer.changer_command); + free(res->res_changer.changer_command); } if (res->res_changer.device) { - delete res->res_changer.device; + delete res->res_changer.device; } break; case R_STORAGE: if (res->res_store.sdaddrs) { - free_addresses(res->res_store.sdaddrs); + free_addresses(res->res_store.sdaddrs); } if (res->res_store.sddaddrs) { - free_addresses(res->res_store.sddaddrs); + free_addresses(res->res_store.sddaddrs); } if (res->res_store.working_directory) { - free(res->res_store.working_directory); + free(res->res_store.working_directory); } if (res->res_store.pid_directory) { - free(res->res_store.pid_directory); + free(res->res_store.pid_directory); } if (res->res_store.subsys_directory) { - free(res->res_store.subsys_directory); + free(res->res_store.subsys_directory); + } + if (res->res_store.scripts_directory) { + free(res->res_store.scripts_directory); } break; case R_DEVICE: if (res->res_dev.media_type) { - free(res->res_dev.media_type); + free(res->res_dev.media_type); } if (res->res_dev.device_name) { - free(res->res_dev.device_name); + free(res->res_dev.device_name); } if (res->res_dev.changer_name) { - free(res->res_dev.changer_name); + free(res->res_dev.changer_name); } if (res->res_dev.changer_command) { - free(res->res_dev.changer_command); + free(res->res_dev.changer_command); } if (res->res_dev.alert_command) { - free(res->res_dev.alert_command); + free(res->res_dev.alert_command); } if (res->res_dev.spool_directory) { - free(res->res_dev.spool_directory); + free(res->res_dev.spool_directory); } if (res->res_dev.mount_point) { - free(res->res_dev.mount_point); + free(res->res_dev.mount_point); } if (res->res_dev.mount_command) { - free(res->res_dev.mount_command); + free(res->res_dev.mount_command); } if (res->res_dev.unmount_command) { - free(res->res_dev.unmount_command); + free(res->res_dev.unmount_command); } if (res->res_dev.write_part_command) { - free(res->res_dev.write_part_command); + free(res->res_dev.write_part_command); } if (res->res_dev.free_space_command) { - free(res->res_dev.free_space_command); + free(res->res_dev.free_space_command); } break; case R_MSGS: if (res->res_msgs.mail_cmd) { - free(res->res_msgs.mail_cmd); + free(res->res_msgs.mail_cmd); } if (res->res_msgs.operator_cmd) { - free(res->res_msgs.operator_cmd); + free(res->res_msgs.operator_cmd); } free_msgs_res((MSGS *)res); /* free message resource */ res = NULL; @@ -430,10 +434,10 @@ void save_resource(int type, RES_ITEM *items, int pass) */ 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)) { + 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]); - } + items[i].name, resources[rindex]); + } } /* If this triggers, take a look at lib/parse_conf.h */ if (i >= MAX_RES_ITEMS) { @@ -454,49 +458,49 @@ void save_resource(int type, RES_ITEM *items, int pass) case R_DIRECTOR: case R_DEVICE: case R_MSGS: - break; + break; /* Resources containing a resource or an alist */ case R_STORAGE: - if ((res = (URES *)GetResWithName(R_STORAGE, res_all.res_dir.hdr.name)) == NULL) { + if ((res = (URES *)GetResWithName(R_STORAGE, res_all.res_dir.hdr.name)) == NULL) { Emsg1(M_ERROR_TERM, 0, "Cannot find Storage resource \"%s\"\n", res_all.res_dir.hdr.name); - } - res->res_store.messages = res_all.res_store.messages; - break; + } + res->res_store.messages = res_all.res_store.messages; + break; case R_AUTOCHANGER: - if ((res = (URES *)GetResWithName(type, res_all.res_changer.hdr.name)) == NULL) { + if ((res = (URES *)GetResWithName(type, res_all.res_changer.hdr.name)) == NULL) { Emsg1(M_ERROR_TERM, 0, "Cannot find AutoChanger resource %s\n", - res_all.res_changer.hdr.name); - } - /* we must explicitly copy the device alist pointer */ - res->res_changer.device = res_all.res_changer.device; - /* - * Now update each device in this resource to point back - * to the changer resource. - */ - foreach_alist(dev, res->res_changer.device) { - dev->changer_res = (AUTOCHANGER *)&res->res_changer; - } - if ((errstat = pthread_mutex_init(&res->res_changer.changer_mutex, NULL)) != 0) { - berrno be; + res_all.res_changer.hdr.name); + } + /* we must explicitly copy the device alist pointer */ + res->res_changer.device = res_all.res_changer.device; + /* + * Now update each device in this resource to point back + * to the changer resource. + */ + foreach_alist(dev, res->res_changer.device) { + dev->changer_res = (AUTOCHANGER *)&res->res_changer; + } + if ((errstat = pthread_mutex_init(&res->res_changer.changer_mutex, NULL)) != 0) { + berrno be; Jmsg1(NULL, M_ERROR_TERM, 0, _("Unable to init mutex: ERR=%s\n"), - be.strerror(errstat)); - } - break; + be.strerror(errstat)); + } + break; default: printf("Unknown resource type %d\n", type); - error = 1; - break; + error = 1; + break; } if (res_all.res_dir.hdr.name) { - free(res_all.res_dir.hdr.name); - res_all.res_dir.hdr.name = NULL; + free(res_all.res_dir.hdr.name); + res_all.res_dir.hdr.name = NULL; } if (res_all.res_dir.hdr.desc) { - free(res_all.res_dir.hdr.desc); - res_all.res_dir.hdr.desc = NULL; + free(res_all.res_dir.hdr.desc); + res_all.res_dir.hdr.desc = NULL; } return; } @@ -504,45 +508,45 @@ void save_resource(int type, RES_ITEM *items, int pass) /* The following code is only executed on pass 1 */ switch (type) { case R_DIRECTOR: - size = sizeof(DIRRES); - break; + size = sizeof(DIRRES); + break; case R_STORAGE: - size = sizeof(STORES); - break; + size = sizeof(STORES); + break; case R_DEVICE: - size = sizeof(DEVRES); - break; + size = sizeof(DEVRES); + break; case R_MSGS: - size = sizeof(MSGS); - break; + size = sizeof(MSGS); + break; case R_AUTOCHANGER: - size = sizeof(AUTOCHANGER); - break; + size = sizeof(AUTOCHANGER); + break; default: printf("Unknown resource type %d\n", type); - error = 1; - size = 1; - break; + error = 1; + size = 1; + break; } /* Common */ if (!error) { res = (URES *)malloc(size); memcpy(res, &res_all, size); if (!res_head[rindex]) { - res_head[rindex] = (RES *)res; /* store first entry */ + res_head[rindex] = (RES *)res; /* store first entry */ } else { - RES *next; - /* Add new res to end of chain */ - 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, + RES *next; + /* Add new res to end of chain */ + 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"), - resources[rindex].name, res->res_dir.hdr.name); - } - } - next->next = (RES *)res; + resources[rindex].name, res->res_dir.hdr.name); + } + } + next->next = (RES *)res; Dmsg2(90, "Inserting %s res: %s\n", res_to_str(type), - res->res_dir.hdr.name); + res->res_dir.hdr.name); } } } diff --git a/bacula/src/stored/stored_conf.h b/bacula/src/stored/stored_conf.h index 9ea5d71bad..881bdcdd7b 100644 --- a/bacula/src/stored/stored_conf.h +++ b/bacula/src/stored/stored_conf.h @@ -30,7 +30,7 @@ enum { R_MSGS, R_AUTOCHANGER, R_FIRST = R_DIRECTOR, - R_LAST = R_AUTOCHANGER /* keep this updated */ + R_LAST = R_AUTOCHANGER /* keep this updated */ }; enum { @@ -45,29 +45,30 @@ enum { /* Definition of the contents of each Resource */ class DIRRES { public: - RES hdr; + RES hdr; - char *password; /* Director password */ - char *address; /* Director IP address or zero */ - int enable_ssl; /* Use SSL with this Director */ - int monitor; /* Have only access to status and .status functions */ + char *password; /* Director password */ + char *address; /* Director IP address or zero */ + int enable_ssl; /* Use SSL with this Director */ + int monitor; /* Have only access to status and .status functions */ }; /* Storage daemon "global" definitions */ class s_res_store { public: - RES hdr; + RES hdr; dlist *sdaddrs; dlist *sddaddrs; - char *working_directory; /* working directory for checkpoints */ + char *working_directory; /* working directory for checkpoints */ char *pid_directory; char *subsys_directory; - int require_ssl; /* Require SSL on all connections */ + char *scripts_directory; + int require_ssl; /* Require SSL on all connections */ uint32_t max_concurrent_jobs; /* maximum concurrent jobs to run */ - MSGS *messages; /* Daemon message handler */ - utime_t heartbeat_interval; /* Interval to send hb to FD */ + MSGS *messages; /* Daemon message handler */ + utime_t heartbeat_interval; /* Interval to send hb to FD */ }; typedef struct s_res_store STORES; @@ -75,52 +76,52 @@ class AUTOCHANGER { public: RES hdr; alist *device; - char *changer_name; /* Changer device name */ - char *changer_command; /* Changer command -- external program */ + char *changer_name; /* Changer device name */ + char *changer_command; /* Changer command -- external program */ pthread_mutex_t changer_mutex; /* One changer operation at a time */ }; /* Device specific definitions */ class DEVRES { public: - RES hdr; - - char *media_type; /* User assigned media type */ - char *device_name; /* Archive device name */ - char *changer_name; /* Changer device name */ - char *changer_command; /* Changer command -- external program */ - char *alert_command; /* Alert command -- external program */ - char *spool_directory; /* Spool file directory */ - int label_type; /* label type */ - int autoselect; /* Automatically select from AutoChanger */ - uint32_t drive_index; /* Autochanger drive index */ - uint32_t cap_bits; /* Capabilities of this device */ - uint32_t max_changer_wait; /* Changer timeout */ - uint32_t max_rewind_wait; /* maximum secs to wait for rewind */ - uint32_t max_open_wait; /* maximum secs to wait for open */ - uint32_t max_open_vols; /* maximum simultaneous open volumes */ - uint32_t min_block_size; /* min block size */ - uint32_t max_block_size; /* max block size */ - uint32_t max_volume_jobs; /* max jobs to put on one volume */ + RES hdr; + + char *media_type; /* User assigned media type */ + char *device_name; /* Archive device name */ + char *changer_name; /* Changer device name */ + char *changer_command; /* Changer command -- external program */ + char *alert_command; /* Alert command -- external program */ + char *spool_directory; /* Spool file directory */ + int label_type; /* label type */ + int autoselect; /* Automatically select from AutoChanger */ + uint32_t drive_index; /* Autochanger drive index */ + uint32_t cap_bits; /* Capabilities of this device */ + uint32_t max_changer_wait; /* Changer timeout */ + uint32_t max_rewind_wait; /* maximum secs to wait for rewind */ + uint32_t max_open_wait; /* maximum secs to wait for open */ + uint32_t max_open_vols; /* maximum simultaneous open volumes */ + uint32_t min_block_size; /* min block size */ + uint32_t max_block_size; /* max block size */ + uint32_t max_volume_jobs; /* max jobs to put on one volume */ uint32_t max_network_buffer_size; /* max network buf size */ - utime_t vol_poll_interval; /* interval between polling volume during mount */ - int64_t max_volume_files; /* max files to put on one volume */ - int64_t max_volume_size; /* max bytes to put on one volume */ - int64_t max_file_size; /* max file size in bytes */ - int64_t volume_capacity; /* advisory capacity */ - int64_t max_spool_size; /* Max spool size for all jobs */ - int64_t max_job_spool_size; /* Max spool size for any single job */ + utime_t vol_poll_interval; /* interval between polling volume during mount */ + int64_t max_volume_files; /* max files to put on one volume */ + int64_t max_volume_size; /* max bytes to put on one volume */ + int64_t max_file_size; /* max file size in bytes */ + int64_t volume_capacity; /* advisory capacity */ + int64_t max_spool_size; /* Max spool size for all jobs */ + int64_t max_job_spool_size; /* Max spool size for any single job */ - int64_t max_part_size; /* Max part size */ - char *mount_point; /* Mount point for require mount devices */ - char *mount_command; /* Mount command */ - char *unmount_command; /* Unmount command */ - char *write_part_command; /* Write part command */ - char *free_space_command; /* Free space command */ + int64_t max_part_size; /* Max part size */ + char *mount_point; /* Mount point for require mount devices */ + char *mount_command; /* Mount command */ + char *unmount_command; /* Unmount command */ + char *write_part_command; /* Write part command */ + char *free_space_command; /* Free space command */ /* The following are set at runtime */ - DEVICE *dev; /* Pointer to phyical dev -- set at runtime */ - AUTOCHANGER *changer_res; /* pointer to changer res if any */ + DEVICE *dev; /* Pointer to phyical dev -- set at runtime */ + AUTOCHANGER *changer_res; /* pointer to changer res if any */ }; @@ -130,5 +131,5 @@ union URES { DEVRES res_dev; MSGS res_msgs; AUTOCHANGER res_changer; - RES hdr; + RES hdr; }; diff --git a/bacula/src/version.h b/bacula/src/version.h index 254b637364..04cff472ce 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -1,8 +1,8 @@ /* */ #undef VERSION #define VERSION "1.37.7" -#define BDATE "12 March 2005" -#define LSMDATE "12Mar05" +#define BDATE "14 March 2005" +#define LSMDATE "14Mar05" /* Debug flags */ #undef DEBUG -- 2.39.5