]> git.sur5r.net Git - bacula/bacula/commitdiff
- Fix ANSI labels to put EOF1 and EOF2 after each file mark.
authorKern Sibbald <kern@sibbald.com>
Mon, 14 Mar 2005 13:00:42 +0000 (13:00 +0000)
committerKern Sibbald <kern@sibbald.com>
Mon, 14 Mar 2005 13:00:42 +0000 (13:00 +0000)
- Add Python to SD and FD.

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1886 91ce42f0-d328-0410-95d8-f526ca767f89

12 files changed:
bacula/src/cats/make_mysql_tables.in
bacula/src/filed/Makefile.in
bacula/src/filed/python.c [new file with mode: 0644]
bacula/src/stored/acquire.c
bacula/src/stored/ansi_label.c
bacula/src/stored/block.c
bacula/src/stored/dev.c
bacula/src/stored/label.c
bacula/src/stored/stored.c
bacula/src/stored/stored_conf.c
bacula/src/stored/stored_conf.h
bacula/src/version.h

index e1ce1ad9d4f0201aa2fc623345e14b96d1c94def..677b65d198cb4eccc7459c81916f084c481d16d2 100644 (file)
@@ -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 (
index e5c05e2e3eac5a43b18db912b89f09f7ea270561..3b0efbb5b9d1b1a950e728dd4c2494397cf659c6 100755 (executable)
@@ -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 (file)
index 0000000..91e5a67
--- /dev/null
@@ -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 <Python.h>
+
+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 */
index f8c9e1679daa523878184cf8702111178bea561f..c751aa887ab2c6b5d8d5811bd5d5a0909039e73a 100644 (file)
@@ -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 */
index 0257a43500af22557ad2bd8e8b0a1cf2fcf70b8f..46bb03f05a36f6f4c94d568e7796eb12c6ed1c72 100644 (file)
@@ -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"));
index 14d29d3bf5e8829a8e75c5a54016cd8025326b86..a5e96da7b9756e9b365b0c776a2578b1f992ffc7 100644 (file)
@@ -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 */
index 5d8d4c6a8b706957f7f833b2d91eb8f558b2c4a8..9261bb1f9b4933813e6c2b2dff922894ab6979c9 100644 (file)
@@ -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;
 }
index fa5dafffb965f9609acc44ecc63e98b080411a82..ff4c801e35f21e4db72e10ae6f8d725228d82275 100644 (file)
@@ -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)  {
index 3bd86b0fbfaf04017d20b070dbe0f396be0667cd..206a8c82072384751e054f5f4ed8995913100a24 100644 (file)
@@ -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);
 
index a1c3d00dc83054f8f9ec4ec2cd1f4534dc4bd240..8dd020a59734dd629e97f4461876d985837fb805 100644 (file)
@@ -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);
       }
    }
 }
index 9ea5d71bad4fd65f4bc80c554951a281d7a0a3bc..881bdcdd7be3d3f116b5b1ba4b5b1b9b51ac10dc 100644 (file)
@@ -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;
 };
index 254b637364bb2d054458a711fc7130c20048eb62..04cff472ce3ae432ae09d6252e4dd9d63653e086 100644 (file)
@@ -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