]> git.sur5r.net Git - bacula/bacula/commitdiff
- Update some very old licenses in src/cats.
authorKern Sibbald <kern@sibbald.com>
Thu, 22 Jun 2006 09:55:43 +0000 (09:55 +0000)
committerKern Sibbald <kern@sibbald.com>
Thu, 22 Jun 2006 09:55:43 +0000 (09:55 +0000)
- Modify the database format for handling Migration jobs:
   Add PriorJobId, RealEndTime to Job table
   Delete MAC table
   Remove Stripe from JobMedia record (not used, wasting space)
   Add ScratchPoolId, RecyclePoolId, Enabled to Media record
   Add Cost to Location table.
- Delete mac_record subroutines.
- Add new table values to create/update/get routines as appropriate.
- Update the update_tables and make_tables scripts.
- Make a first cut in using a union where multiple pointers (actually
  pointers to pointers) are stored.
- Make some changes to base64.c suggested by Robert and others and add
  a small amount of documentation.
- Add some changes suggested by Peter for Solaris (bregex...)
- Make runscript.h always built because it needs to be pulled into
  more places.  In particular its RES was left out of a union.
- Renumber the enum{} list in runscript.h to avoid starting from zero.
  This makes it slightly easier to detect uninitialized variables.

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

39 files changed:
bacula/kes-1.39
bacula/src/cats/bdb.c
bacula/src/cats/bdb_create.c
bacula/src/cats/bdb_delete.c
bacula/src/cats/bdb_find.c
bacula/src/cats/bdb_get.c
bacula/src/cats/bdb_list.c
bacula/src/cats/bdb_update.c
bacula/src/cats/cats.h
bacula/src/cats/make_mysql_tables.in
bacula/src/cats/make_postgresql_tables.in
bacula/src/cats/make_sqlite3_tables.in
bacula/src/cats/make_sqlite_tables.in
bacula/src/cats/protos.h
bacula/src/cats/sql.c
bacula/src/cats/sql_create.c
bacula/src/cats/sql_delete.c
bacula/src/cats/sql_get.c
bacula/src/cats/sql_list.c
bacula/src/cats/sql_update.c
bacula/src/cats/update_mysql_tables.in
bacula/src/cats/update_postgresql_tables.in
bacula/src/cats/update_sqlite3_tables.in
bacula/src/cats/update_sqlite_tables.in
bacula/src/dird/catreq.c
bacula/src/dird/dird.h
bacula/src/dird/dird_conf.c
bacula/src/dird/dird_conf.h
bacula/src/dird/inc_conf.c
bacula/src/lib/base64.c
bacula/src/lib/base64.h
bacula/src/lib/bregex.c
bacula/src/lib/bregex.h
bacula/src/lib/bsys.c
bacula/src/lib/parse_conf.c
bacula/src/lib/parse_conf.h
bacula/src/lib/runscript.h
bacula/src/tools/dbcheck.c
bacula/src/version.h

index d01f665beb23fb71c2042e2d29c99dbd84708376..8570c3da75bd53bd6f9a9f6e0562c43556825071 100644 (file)
@@ -2,6 +2,26 @@
                         Kern Sibbald
 
 General:
+22Jun06
+- Update some very old licenses in src/cats.
+- Modify the database format for handling Migration jobs:
+   Add PriorJobId, RealEndTime to Job table
+   Delete MAC table
+   Remove Stripe from JobMedia record (not used, wasting space)
+   Add ScratchPoolId, RecyclePoolId, Enabled to Media record
+   Add Cost to Location table.
+- Delete mac_record subroutines.
+- Add new table values to create/update/get routines as appropriate.
+- Update the update_tables and make_tables scripts.
+- Make a first cut in using a union where multiple pointers (actually
+  pointers to pointers) are stored.
+- Make some changes to base64.c suggested by Robert and others and add
+  a small amount of documentation.
+- Add some changes suggested by Peter for Solaris (bregex...)
+- Make runscript.h always built because it needs to be pulled into
+  more places.  In particular its RES was left out of a union.
+- Renumber the enum{} list in runscript.h to avoid starting from zero.
+  This makes it slightly easier to detect uninitialized variables.
 14Jun06
 - Remove xpg4 lib from FreeBSD build as it is no longer needed and
   sometimes creates install problems.
index 69aaac86be671c8be50c674cc0872d19e47f3415..a0836efc9f7c35b1f9017d83864a338642653c55 100644 (file)
@@ -12,7 +12,7 @@
  *
  */
 /*
-   Copyright (C) 2000-2005 Kern Sibbald
+   Copyright (C) 2000-2006 Kern Sibbald
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
index c9d9d9bbc76bb0f087f9653c1c94cf325d465640..3228d42e08e11e0d487ec2d87370ceeea1a5af8f 100644 (file)
  */
 
 /*
-   Copyright (C) 2001-2003 Kern Sibbald and John Walker
+   Copyright (C) 2001-2006 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.
+   modify it under the terms of the GNU General Public License
+   version 2 as amended with additional clauses defined in the
+   file LICENSE in the main source directory.
 
    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.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
+   the file LICENSE for additional details.
 
  */
 
@@ -37,7 +32,7 @@
 /* The following is necessary so that we do not include
  * the dummy external definition of DB.
  */
-#define __SQL_C                      /* indicate that this is sql.c */
+#define __SQL_C                       /* indicate that this is sql.c */
 
 #include "bacula.h"
 #include "cats.h"
@@ -74,7 +69,7 @@ int db_create_file_item(JCR *jcr, B_DB *mdb, ATTR_DBR *ar)
  *   it is updated in bdb_update.c when the Job terminates.
  *
  * Returns: 0 on failure
- *         1 on success
+ *          1 on success
  */
 int db_create_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
 {
@@ -103,7 +98,7 @@ int db_create_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
 
 /* Create a JobMedia record for Volume used this job
  * Returns: 0 on failure
- *         record-id on success
+ *          record-id on success
  */
 bool db_create_jobmedia_record(JCR *jcr, B_DB *mdb, JOBMEDIA_DBR *jm)
 {
@@ -135,7 +130,7 @@ bool db_create_jobmedia_record(JCR *jcr, B_DB *mdb, JOBMEDIA_DBR *jm)
 /*
  *  Create a unique Pool record
  * Returns: 0 on failure
- *         1 on success
+ *          1 on success
  */
 bool db_create_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr)
 {
@@ -182,12 +177,12 @@ bool db_create_mediatype_record(JCR *jcr, B_DB *mdb, MEDIATYPE_DBR *dr)
 
 
 /*
- * Create Unique Media record. This record
+ * Create Unique Media record.  This record
  *   contains all the data pertaining to a specific
  *   Volume.
  *
  * Returns: 0 on failure
- *         1 on success
+ *          1 on success
  */
 int db_create_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
 {
@@ -224,7 +219,7 @@ int db_create_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
 /*
  *  Create a unique Client record or return existing record
  * Returns: 0 on failure
- *         1 on success
+ *          1 on success
  */
 int db_create_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cr)
 {
@@ -266,7 +261,7 @@ int db_create_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cr)
  *   Note, here we write the FILESET_DBR structure
  *
  * Returns: 0 on failure
- *         1 on success
+ *          1 on success
  */
 bool db_create_fileset_record(JCR *jcr, B_DB *mdb, FILESET_DBR *fsr)
 {
index 3e3915a8d3dcd6766c535c007254ecfc5ff133bf..125a777c588d094d8c711b88e1961d16e7e33126 100644 (file)
  */
 
 /*
-   Copyright (C) 2001-2003 Kern Sibbald and John Walker
+   Copyright (C) 2001-2006 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.
+   modify it under the terms of the GNU General Public License
+   version 2 as amended with additional clauses defined in the
+   file LICENSE in the main source directory.
 
    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.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
+   the file LICENSE for additional details.
 
  */
 
@@ -37,7 +32,7 @@
 /* The following is necessary so that we do not include
  * the dummy external definition of DB.
  */
-#define __SQL_C                      /* indicate that this is sql.c */
+#define __SQL_C                       /* indicate that this is sql.c */
 
 #include "bacula.h"
 #include "cats.h"
@@ -59,7 +54,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)
 {
@@ -67,7 +62,7 @@ int db_delete_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr)
    POOL_DBR opr;
 
    db_lock(mdb);
-   pr->PoolId = 0;                   /* Search on Pool Name */
+   pr->PoolId = 0;                    /* Search on Pool Name */
    if (!db_get_pool_record(jcr, mdb, pr)) {
       Mmsg1(&mdb->errmsg, "No pool record %s exists\n", pr->Name);
       db_unlock(mdb);
index e79b6ad95c335c3c0b60d40de70d3d5c87a15280..6c5bd3b11740c812634b5c42e3389dbcda53a19c 100644 (file)
  *
  *    Version $Id$
  */
-
 /*
-   Copyright (C) 2001-2003 Kern Sibbald and John Walker
+   Copyright (C) 2001-2006 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.
+   modify it under the terms of the GNU General Public License
+   version 2 as amended with additional clauses defined in the
+   file LICENSE in the main source directory.
 
    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.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
+   the file LICENSE for additional details.
 
  */
 
index 0e27befdef287e44c24765a20033f4584e2de6a9..8fd20b0fa3898753ac50a06b9d6b43a0abfbcb60 100644 (file)
  *
  *    Version $Id$
  */
-
 /*
-   Copyright (C) 2001-2003 Kern Sibbald and John Walker
+   Copyright (C) 2001-2006 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.
+   modify it under the terms of the GNU General Public License
+   version 2 as amended with additional clauses defined in the
+   file LICENSE in the main source directory.
 
    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.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
+   the file LICENSE for additional details.
 
  */
 
index 82238c77da482d45c3d9511e9efb90b466d49f53..902739c7a30a1294ba1c1fd87a562440cf4401e3 100644 (file)
  */
 
 /*
-   Copyright (C) 2001-2003 Kern Sibbald and John Walker
+   Copyright (C) 2001-2006 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.
+   modify it under the terms of the GNU General Public License
+   version 2 as amended with additional clauses defined in the
+   file LICENSE in the main source directory.
 
    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.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
+   the file LICENSE for additional details.
 
  */
 
@@ -37,7 +32,7 @@
 /* The following is necessary so that we do not include
  * the dummy external definition of DB.
  */
-#define __SQL_C                      /* indicate that this is sql.c */
+#define __SQL_C                       /* indicate that this is sql.c */
 
 #include "bacula.h"
 #include "cats.h"
@@ -58,7 +53,7 @@
  * Submit general SQL query
  */
 int db_list_sql_query(JCR *jcr, B_DB *mdb, char *query, DB_LIST_HANDLER *sendit,
-                     void *ctx, int verbose)
+                      void *ctx, int verbose)
 {
    sendit(ctx, "SQL Queries not implemented with internal database.\n");
    return 0;
@@ -84,9 +79,9 @@ 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",
-           pr.PoolId, pr.NumVols, pr.MaxVols, pr.PoolType, pr.Name);
-        sendit(ctx, mdb->cmd);
+         Mmsg(mdb->cmd, " %7d  %6d  %6d  %-10s %s\n",
+            pr.PoolId, pr.NumVols, pr.MaxVols, pr.PoolType, pr.Name);
+         sendit(ctx, mdb->cmd);
    }
    sendit(ctx, "===================================================\n");
    db_unlock(mdb);
@@ -99,7 +94,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,
-                          DB_LIST_HANDLER *sendit, void *ctx)
+                           DB_LIST_HANDLER *sendit, void *ctx)
 {
    char ewc[30];
    int len;
@@ -112,13 +107,13 @@ void db_list_media_records(JCR *jcr, B_DB *mdb, MEDIA_DBR *mdbr,
    }
    sendit(ctx, "  Status           VolBytes  MediaType        VolumeName\n");
    sendit(ctx, "=============================================================\n");
-   fseek(mdb->mediafd, 0L, SEEK_SET);  /* rewind file */
+   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",
-           mr.VolStatus, edit_uint64_with_commas(mr.VolBytes, ewc),
-           mr.MediaType, mr.VolumeName);
-        sendit(ctx, mdb->cmd);
+         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);
    }
    sendit(ctx, "====================================================================\n");
    db_unlock(mdb);
@@ -126,7 +121,7 @@ void db_list_media_records(JCR *jcr, B_DB *mdb, MEDIA_DBR *mdbr,
 }
 
 void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, uint32_t JobId,
-                             DB_LIST_HANDLER *sendit, void *ctx)
+                              DB_LIST_HANDLER *sendit, void *ctx)
 {
    JOBMEDIA_DBR jm;
    MEDIA_DBR mr;
@@ -149,29 +144,29 @@ void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, uint32_t JobId,
    while (fread(&jm, jmlen, 1, mdb->jobmediafd) > 0) {
       /* List by JobId */
       if (JobId != 0) {
-        if (jm.JobId == JobId) {
-           /* Now find VolumeName in corresponding Media record */
-           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",
-                      jm.JobId, mr.VolumeName, jm.FirstIndex, jm.LastIndex);
-                 sendit(ctx, mdb->cmd);
-                 break;
-              }
-           }
-        }
+         if (jm.JobId == JobId) {
+            /* Now find VolumeName in corresponding Media record */
+            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",
+                       jm.JobId, mr.VolumeName, jm.FirstIndex, jm.LastIndex);
+                  sendit(ctx, mdb->cmd);
+                  break;
+               }
+            }
+         }
       } else {
-        /* List all records */
-        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",
-                   jm.JobId, mr.VolumeName, jm.FirstIndex, jm.LastIndex);
-              sendit(ctx, mdb->cmd);
-              break;
-           }
-        }
+         /* List all records */
+         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",
+                    jm.JobId, mr.VolumeName, jm.FirstIndex, jm.LastIndex);
+               sendit(ctx, mdb->cmd);
+               break;
+            }
+         }
       }
    }
 
@@ -185,7 +180,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,
-                        DB_LIST_HANDLER *sendit, void *ctx)
+                         DB_LIST_HANDLER *sendit, void *ctx)
 {
    int jrlen;
    JOB_DBR ojr;
@@ -208,19 +203,19 @@ void db_list_job_records(JCR *jcr, B_DB *mdb, JOB_DBR *jr,
    jrlen = sizeof(ojr);
    while (!done && fread(&ojr, jrlen, 1, mdb->jobfd) > 0) {
       if (jr->JobId != 0) {
-        if (jr->JobId == ojr.JobId) {
-           done = 1;
-        } else {
-           continue;
-        }
+         if (jr->JobId == ojr.JobId) {
+            done = 1;
+         } else {
+            continue;
+         }
       }
       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),
-               edit_uint64_with_commas(ojr.JobFiles, ewc2),
-               (char)ojr.JobStatus, ojr.Name);
+                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);
    }
    sendit(ctx, "============================================================================\n");
@@ -233,7 +228,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,
-                       DB_LIST_HANDLER *sendit, void *ctx)
+                        DB_LIST_HANDLER *sendit, void *ctx)
 {
    char ewc1[30], ewc2[30], ewc3[30];
    int jrlen;
@@ -260,9 +255,9 @@ void db_list_job_totals(JCR *jcr, B_DB *mdb, JOB_DBR *jr,
       total_jobs++;
    }
    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_bytes, ewc3));
+             edit_uint64_with_commas(total_jobs, ewc1),
+             edit_uint64_with_commas(total_files, ewc2),
+             edit_uint64_with_commas(total_bytes, ewc3));
    sendit(ctx, mdb->cmd);
    sendit(ctx, "=======================================\n");
    db_unlock(mdb);
@@ -278,7 +273,7 @@ void db_list_client_records(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *
 { }
 
 int db_list_sql_query(JCR *jcr, B_DB *mdb, char *query, DB_LIST_HANDLER *sendit,
-                     void *ctx, int verbose, e_list_type type)
+                      void *ctx, int verbose, e_list_type type)
 {
    return 0;
 }
@@ -289,16 +284,16 @@ db_list_pool_records(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ctx, e_
 
 void
 db_list_media_records(JCR *jcr, B_DB *mdb, MEDIA_DBR *mdbr,
-                     DB_LIST_HANDLER *sendit, void *ctx, e_list_type type)
+                      DB_LIST_HANDLER *sendit, void *ctx, e_list_type type)
 { }
 
 void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, uint32_t JobId,
-                             DB_LIST_HANDLER *sendit, void *ctx, e_list_type type)
+                              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,
-                   void *ctx, e_list_type type)
+                    void *ctx, e_list_type type)
 { }
 
 void
index 7b1f054f8d88e41f8ed1abb8a5759498e9554ea1..35fa610a89bfa3b6d9a5c38fdbc76c70835fa5a3 100755 (executable)
  */
 
 /*
-   Copyright (C) 2001-2003 Kern Sibbald and John Walker
+   Copyright (C) 2001-2006 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.
+   modify it under the terms of the GNU General Public License
+   version 2 as amended with additional clauses defined in the
+   file LICENSE in the main source directory.
 
    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.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
+   the file LICENSE for additional details.
 
  */
 
@@ -38,7 +33,7 @@
 /* The following is necessary so that we do not include
  * the dummy external definition of DB.
  */
-#define __SQL_C                      /* indicate that this is sql.c */
+#define __SQL_C                       /* indicate that this is sql.c */
 
 #include "bacula.h"
 #include "cats.h"
@@ -189,7 +184,7 @@ int db_update_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr)
       Mmsg1(mdb->errmsg, _("Error updating DB Media file. ERR=%s\n"), strerror(errno));
       stat = 0;
    } else {
-      memcpy(pr, &opr, len);         /* return record written */
+      memcpy(pr, &opr, len);          /* return record written */
    }
    fflush(mdb->poolfd);
 
index 25d5b53ea4b8e7d38067ca7865f7a21fcfb3f273..598d514a057aebabe79806e8b4d44d3a715f7e36 100644 (file)
@@ -536,9 +536,11 @@ struct JOB_DBR {
    DBId_t ClientId;                   /* Id of client */
    DBId_t PoolId;                     /* Id of pool */
    DBId_t FileSetId;                  /* Id of FileSet */
+   DBId_t PriorJobId;                 /* Id of migrated (prior) job */
    time_t SchedTime;                  /* Time job scheduled */
    time_t StartTime;                  /* Job start time */
-   time_t EndTime;                    /* Job termination time */
+   time_t EndTime;                    /* Job termination time of orig job */
+   time_t RealEndTime;                /* Job termination time of this job */
    utime_t JobTDate;                  /* Backup time/date in seconds */
    uint32_t VolSessionId;
    uint32_t VolSessionTime;
@@ -567,33 +569,6 @@ struct JOB_DBR {
    faddr_t rec_addr;
 };
 
-/* 
- * Suplementary record for Migration, archive, copy jobs
- */
-/* MAC record */
-struct MAC_DBR {
-   JobId_t JobId;                     /* Id of this job */
-   JobId_t OriginalJobId;             /* Id of job migrated, copied or archived */
-   /* 
-    * The following are the actual values for this job. This
-    *  is needed because the values in the corresponding Job
-    *  record were set to the values of the original backup job.
-    */
-   int JobType;                       /* Actual job type */
-   int JobLevel;                      /* Actual job level */
-   time_t SchedTime;                  /* Actual time job scheduled */
-   time_t StartTime;                  /* Actual Job start time */
-   time_t EndTime;                    /* Actual Job termination time */
-   utime_t JobTDate;                  /* Actual Backup time/date in seconds */
-
-   char cSchedTime[MAX_TIME_LENGTH];
-   char cStartTime[MAX_TIME_LENGTH];
-   char cEndTime[MAX_TIME_LENGTH];
-
-};
-
-
-
 /* Job Media information used to create the media records
  * for each Volume used for the job.
  */
@@ -609,7 +584,6 @@ struct JOBMEDIA_DBR {
    uint32_t StartBlock;               /* start block on tape */
    uint32_t EndBlock;                 /* last block */
    uint32_t Copy;                     /* identical copy */
-   uint32_t Stripe;                   /* RAIT strip number */
 };
 
 
@@ -756,7 +730,12 @@ struct MEDIA_DBR {
    DBId_t   StorageId;                /* Storage record Id */
    uint32_t EndFile;                  /* Last file on volume */
    uint32_t EndBlock;                 /* Last block on volume */
-   char VolStatus[20];                /* Volume status */
+   char     VolStatus[20];            /* Volume status */
+   DBId_t   DeviceId;                 /* Device where Vol last written */
+   DBId_t   LocationId;               /* Where Volume is -- user defined */
+   DBId_t   ScratchPoolId;            /* Where to move if scratch */
+   DBId_t   RecyclePoolId;            /* Where to move when recycled */
+   int32_t  Enabled;                  /* disabled=0, enabled=1, archived=2 */
    /* Extra stuff not in DB */
    faddr_t rec_addr;                  /* found record address */
    /* Since the database returns times as strings, this is how we pass
index 549282b4ce0e628804126b1c7381b247ca68cb32..1baf407e1944734e0f6b6a58de9f4858df85db67 100644 (file)
@@ -97,6 +97,7 @@ CREATE TABLE Job (
    SchedTime DATETIME NOT NULL,
    StartTime DATETIME NOT NULL,
    EndTime DATETIME NOT NULL,
+   RealEndTime DATETIME NOT NULL,
    JobTDate BIGINT UNSIGNED NOT NULL,
    VolSessionId INTEGER UNSIGNED NOT NULL DEFAULT 0,
    VolSessionTime INTEGER UNSIGNED NOT NULL DEFAULT 0,
@@ -106,27 +107,18 @@ CREATE TABLE Job (
    JobMissingFiles INTEGER UNSIGNED NOT NULL DEFAULT 0,
    PoolId INTEGER UNSIGNED NOT NULL REFERENCES Pool,
    FileSetId INTEGER UNSIGNED NOT NULL REFERENCES FileSet,
+   PriorJobId INTEGER UNSIGNED DEFAULT 0 REFERENCES Job,
    PurgedFiles TINYINT NOT NULL DEFAULT 0,
    HasBase TINYINT NOT NULL DEFAULT 0,
    PRIMARY KEY(JobId),
    INDEX (Name(128))
    );
 
-CREATE TABLE MAC (
-   JobId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
-   OriginalJobId INTEGER UNSIGNED NOT NULL,
-   JobType BINARY(1) NOT NULL,
-   JobLevel BINARY(1) NOT NULL,
-   SchedTime DATETIME NOT NULL,
-   StartTime DATETIME NOT NULL,
-   EndTime DATETIME NOT NULL,
-   JobTDate BIGINT UNSIGNED NOT NULL,
-   PRIMARY KEY(JobId)
-   );
 
 CREATE TABLE Location (
    LocationId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
    Location TINYBLOB NOT NULL,
+   Cost INTEGER NOT NULL DEFAULT 0,
    PRIMARY KEY(LocationId)
    );
 
@@ -179,6 +171,7 @@ CREATE TABLE Media (
    VolCapacityBytes BIGINT UNSIGNED NOT NULL,
    VolStatus ENUM('Full', 'Archive', 'Append', 'Recycle', 'Purged',
     'Read-Only', 'Disabled', 'Error', 'Busy', 'Used', 'Cleaning') NOT NULL,
+   Enabled TINYINT DEFAULT 1,
    Recycle TINYINT NOT NULL DEFAULT 0,
    VolRetention BIGINT UNSIGNED NOT NULL DEFAULT 0,
    VolUseDuration BIGINT UNSIGNED NOT NULL DEFAULT 0,
@@ -186,14 +179,14 @@ CREATE TABLE Media (
    MaxVolFiles INTEGER UNSIGNED NOT NULL DEFAULT 0,
    MaxVolBytes BIGINT UNSIGNED NOT NULL DEFAULT 0,
    InChanger TINYINT NOT NULL DEFAULT 0,
-   StorageId INTEGER UNSIGNED NOT NULL REFERENCES Storage,
-   DeviceId INTEGER UNSIGNED NOT NULL REFERENCES Device,
+   StorageId INTEGER UNSIGNED DEFAULT 0 REFERENCES Storage,
+   DeviceId INTEGER UNSIGNED DEFAULT 0 REFERENCES Device,
    MediaAddressing TINYINT NOT NULL DEFAULT 0,
    VolReadTime BIGINT UNSIGNED NOT NULL DEFAULT 0,
    VolWriteTime BIGINT UNSIGNED NOT NULL DEFAULT 0,
    EndFile INTEGER UNSIGNED NOT NULL DEFAULT 0,
    EndBlock INTEGER UNSIGNED NOT NULL DEFAULT 0,
-   LocationId INTEGER UNSIGNED NOT NULL REFERENCES Location,
+   LocationId INTEGER UNSIGNED DEFAULT 0 REFERENCES Location,
    RecycleCount INTEGER UNSIGNED DEFAULT 0,
    InitialWrite DATETIME NOT NULL,
    ScratchPoolId INTEGER UNSIGNED DEFAULT 0 REFERENCES Pool,
index c169ebf28009ae20668dfe3bfaa6178e881b5b4e..13d14d425515a73d825edbb5aa0ca739fe0d3a26 100644 (file)
@@ -60,6 +60,7 @@ CREATE TABLE job
     schedtime        timestamp   without time zone not null,
     starttime        timestamp   without time zone,
     endtime          timestamp   without time zone,
+    realendtime       timestamp   without time zone,
     jobtdate         bigint      not null,
     volsessionid      integer    not null default 0,
     volsessiontime    integer    not null default 0,
@@ -71,26 +72,16 @@ CREATE TABLE job
     filesetid        integer,
     purgedfiles       smallint   not null default 0,
     hasbase          smallint    not null default 0,
+    priorjobid       integer     not null default 0,
     primary key (jobid)
 );
 
 CREATE INDEX job_name_idx on job (name);
 
-CREATE TABLE MAC (
-    JobId            serial      not null,
-    OriginalJobId     serial     not null,
-    JobType          char(1)     not null,
-    JobLevel         char(1)     not null,
-    schedtime        timestamp   without time zone not null,
-    starttime        timestamp   without time zone,
-    endtime          timestamp   without time zone,
-    jobtdate         bigint      not null,
-    primary key (jobid)
-);
-
 CREATE TABLE Location (
    LocationId        serial      not null,
    Location          text        not null,
+   Cost              integer     not null default 0,
    primary key (LocationId)
 );
 
@@ -119,7 +110,6 @@ CREATE TABLE jobmedia
     endblock         bigint      not null default 0,
     volindex         integer     not null default 0,
     copy             integer     not null default 0,
-    stripe           integer     not null default 0,
     primary key (jobmediaid)
 );
 
@@ -150,6 +140,7 @@ CREATE TABLE media
        check (volstatus in ('Full','Archive','Append',
              'Recycle','Purged','Read-Only','Disabled',
              'Error','Busy','Used','Cleaning','Scratch')),
+    enabled          smallint    not null default 1,
     recycle          smallint    not null default 0,
     volretention      bigint     not null default 0,
     voluseduration    bigint     not null default 0,
index da180cf7dc699c57a7bb6c44618fe90b71b64bf7..a70a8fcc95d74108cc16233340e3208bf49f2589 100644 (file)
@@ -57,6 +57,7 @@ CREATE TABLE Job (
    SchedTime DATETIME NOT NULL,
    StartTime DATETIME DEFAULT 0,
    EndTime DATETIME DEFAULT 0,
+   RealEndTime DATETIME DEFAULT 0,
    JobTDate BIGINT UNSIGNED DEFAULT 0,
    VolSessionId INTEGER UNSIGNED DEFAULT 0,
    VolSessionTime INTEGER UNSIGNED DEFAULT 0,
@@ -66,6 +67,7 @@ CREATE TABLE Job (
    JobMissingFiles INTEGER UNSIGNED DEFAULT 0,
    PoolId INTEGER UNSIGNED REFERENCES Pool DEFAULT 0,
    FileSetId INTEGER UNSIGNED REFERENCES FileSet DEFAULT 0,
+   PriorJobId INTEGER UNSIGNED REFERENCES Job DEFAULT 0,
    PurgedFiles TINYINT DEFAULT 0,
    HasBase TINYINT DEFAULT 0,
    PRIMARY KEY(JobId) 
@@ -73,24 +75,14 @@ CREATE TABLE Job (
 
 CREATE INDEX inx6 ON Job (Name);
 
-CREATE TABLE MAC (
-   JobId INTEGER,
-   OriginalJobId INTEGER,
-   JobType CHAR NOT NULL,
-   JobLevel CHAR NOT NULL,
-   SchedTime DATETIME NOT NULL,
-   StartTime DATETIME DEFAULT 0,
-   EndTime DATETIME DEFAULT 0,
-   JobTDate BIGINT UNSIGNED DEFAULT 0,
-   PRIMARY KEY(JobId)
-   );
-
 CREATE TABLE Location (
    LocationId INTEGER,
    Location TINYBLOB NOT NULL,
+   Cost INTEGER,
    PRIMARY KEY(LocationId)
    );
 
+
 CREATE TABLE FileSet (
    FileSetId INTEGER,
    FileSet VARCHAR(128) NOT NULL,
@@ -111,7 +103,6 @@ CREATE TABLE JobMedia (
    EndBlock INTEGER UNSIGNED DEFAULT 0,
    VolIndex INTEGER UNSIGNED DEFAULT 0,
    Copy     INTEGER UNSIGNED DEFAULT 0,
-   Stripe   INTEGER UNSIGNED DEFAULT 0,
    PRIMARY KEY(JobMediaId) 
    );
 
@@ -139,6 +130,7 @@ CREATE TABLE Media (
    VolWrites INTEGER UNSIGNED DEFAULT 0,
    VolCapacityBytes BIGINT UNSIGNED DEFAULT 0,
    VolStatus VARCHAR(20) NOT NULL,
+   Enabled TINYINT DEFAULT 1,
    Recycle TINYINT DEFAULT 0,
    VolRetention BIGINT UNSIGNED DEFAULT 0,
    VolUseDuration BIGINT UNSIGNED DEFAULT 0,
@@ -146,14 +138,14 @@ CREATE TABLE Media (
    MaxVolFiles INTEGER UNSIGNED DEFAULT 0,
    MaxVolBytes BIGINT UNSIGNED DEFAULT 0,
    InChanger TINYINT DEFAULT 0,
-   StorageId INTEGER UNSIGNED REFERENCES Storage,        
-   DeviceId INTEGER UNSIGNED REFERENCES Device,
+   StorageId INTEGER UNSIGNED REFERENCES Storage DEFAULT 0,
+   DeviceId INTEGER UNSIGNED REFERENCES Device DEFAULT 0,
    MediaAddressing TINYINT DEFAULT 0,
    VolReadTime BIGINT UNSIGNED DEFAULT 0,
    VolWriteTime BIGINT UNSIGNED DEFAULT 0,
    EndFile INTEGER UNSIGNED DEFAULT 0,
    EndBlock INTEGER UNSIGNED DEFAULT 0,
-   LocationId INTEGER UNSIGNED REFERENCES Location,
+   LocationId INTEGER UNSIGNED REFERENCES Location DEFAULT 0,
    RecycleCount INTEGER UNSIGNED DEFAULT 0,
    InitialWrite DATETIME DEFAULT 0,
    ScratchPoolId INTEGER UNSIGNED REFERENCES Pool DEFAULT 0,
index 431447d052a9722c00085fcba262918a5db338e4..a70a8fcc95d74108cc16233340e3208bf49f2589 100644 (file)
@@ -57,6 +57,7 @@ CREATE TABLE Job (
    SchedTime DATETIME NOT NULL,
    StartTime DATETIME DEFAULT 0,
    EndTime DATETIME DEFAULT 0,
+   RealEndTime DATETIME DEFAULT 0,
    JobTDate BIGINT UNSIGNED DEFAULT 0,
    VolSessionId INTEGER UNSIGNED DEFAULT 0,
    VolSessionTime INTEGER UNSIGNED DEFAULT 0,
@@ -66,6 +67,7 @@ CREATE TABLE Job (
    JobMissingFiles INTEGER UNSIGNED DEFAULT 0,
    PoolId INTEGER UNSIGNED REFERENCES Pool DEFAULT 0,
    FileSetId INTEGER UNSIGNED REFERENCES FileSet DEFAULT 0,
+   PriorJobId INTEGER UNSIGNED REFERENCES Job DEFAULT 0,
    PurgedFiles TINYINT DEFAULT 0,
    HasBase TINYINT DEFAULT 0,
    PRIMARY KEY(JobId) 
@@ -73,21 +75,10 @@ CREATE TABLE Job (
 
 CREATE INDEX inx6 ON Job (Name);
 
-CREATE TABLE MAC (
-   JobId INTEGER,
-   OriginalJobId INTEGER,
-   JobType CHAR NOT NULL,
-   JobLevel CHAR NOT NULL,
-   SchedTime DATETIME NOT NULL,
-   StartTime DATETIME DEFAULT 0,
-   EndTime DATETIME DEFAULT 0,
-   JobTDate BIGINT UNSIGNED DEFAULT 0,
-   PRIMARY KEY(JobId)
-   );
-
 CREATE TABLE Location (
    LocationId INTEGER,
    Location TINYBLOB NOT NULL,
+   Cost INTEGER,
    PRIMARY KEY(LocationId)
    );
 
@@ -112,7 +103,6 @@ CREATE TABLE JobMedia (
    EndBlock INTEGER UNSIGNED DEFAULT 0,
    VolIndex INTEGER UNSIGNED DEFAULT 0,
    Copy     INTEGER UNSIGNED DEFAULT 0,
-   Stripe   INTEGER UNSIGNED DEFAULT 0,
    PRIMARY KEY(JobMediaId) 
    );
 
@@ -140,6 +130,7 @@ CREATE TABLE Media (
    VolWrites INTEGER UNSIGNED DEFAULT 0,
    VolCapacityBytes BIGINT UNSIGNED DEFAULT 0,
    VolStatus VARCHAR(20) NOT NULL,
+   Enabled TINYINT DEFAULT 1,
    Recycle TINYINT DEFAULT 0,
    VolRetention BIGINT UNSIGNED DEFAULT 0,
    VolUseDuration BIGINT UNSIGNED DEFAULT 0,
@@ -147,14 +138,14 @@ CREATE TABLE Media (
    MaxVolFiles INTEGER UNSIGNED DEFAULT 0,
    MaxVolBytes BIGINT UNSIGNED DEFAULT 0,
    InChanger TINYINT DEFAULT 0,
-   StorageId INTEGER UNSIGNED REFERENCES Storage,        
-   DeviceId INTEGER UNSIGNED REFERENCES Device,
+   StorageId INTEGER UNSIGNED REFERENCES Storage DEFAULT 0,
+   DeviceId INTEGER UNSIGNED REFERENCES Device DEFAULT 0,
    MediaAddressing TINYINT DEFAULT 0,
    VolReadTime BIGINT UNSIGNED DEFAULT 0,
    VolWriteTime BIGINT UNSIGNED DEFAULT 0,
    EndFile INTEGER UNSIGNED DEFAULT 0,
    EndBlock INTEGER UNSIGNED DEFAULT 0,
-   LocationId INTEGER UNSIGNED REFERENCES Location,
+   LocationId INTEGER UNSIGNED REFERENCES Location DEFAULT 0,
    RecycleCount INTEGER UNSIGNED DEFAULT 0,
    InitialWrite DATETIME DEFAULT 0,
    ScratchPoolId INTEGER UNSIGNED REFERENCES Pool DEFAULT 0,
index 464af82d1b69b2663315754041b204a3ee1a2fa2..fd3aa6d8183c8fc837d9a76f5e115778a28765f9 100644 (file)
@@ -44,7 +44,6 @@ void db_end_transaction(JCR *jcr, B_DB *mdb);
 /* create.c */
 int db_create_file_attributes_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar);
 bool db_create_job_record(JCR *jcr, B_DB *db, JOB_DBR *jr);
-bool db_create_mac_record(JCR *jcr, B_DB *db, MAC_DBR *mr);
 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);
 bool db_create_fileset_record(JCR *jcr, B_DB *db, FILESET_DBR *fsr);
@@ -69,7 +68,6 @@ bool db_find_failed_job_since(JCR *jcr, B_DB *mdb, JOB_DBR *jr, POOLMEM *stime,
 bool db_get_pool_record(JCR *jcr, B_DB *db, POOL_DBR *pdbr);
 int db_get_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cr);
 bool db_get_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr);
-bool db_get_mac_record(JCR *jcr, B_DB *mdb, MAC_DBR *mr);
 int db_get_job_volume_names(JCR *jcr, B_DB *mdb, JobId_t JobId, POOLMEM **VolumeNames);
 int db_get_file_attributes_record(JCR *jcr, B_DB *mdb, char *fname, JOB_DBR *jr, FILE_DBR *fdbr);
 int db_get_fileset_record(JCR *jcr, B_DB *mdb, FILESET_DBR *fsr);
index 933c96663a7219c4a9b0b162e2494a22f0bec0ed..9844f1458f10441af4ebf24766b8dcbfa3f8b7a4 100644 (file)
  */
 
 /*
-   Copyright (C) 2000-2005 Kern Sibbald
+   Copyright (C) 2000-2006 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.
+   modify it under the terms of the GNU General Public License
+   version 2 as amended with additional clauses defined in the
+   file LICENSE in the main source directory.
 
    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.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
+   the file LICENSE for additional details.
 
  */
 
index d8cca379fe4fac0b1a8172ffbe4b3a2dbbec692f..f42f2cd3d31fc99c09badf422cd8800af053787c 100644 (file)
@@ -6,7 +6,7 @@
  *    Version $Id$
  */
 /*
-   Copyright (C) 2000-2005 Kern Sibbald
+   Copyright (C) 2000-2006 Kern Sibbald
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
@@ -95,55 +95,6 @@ db_create_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
    return ok;
 }
 
-/* Create a new migration, archive, copy
- * Returns: false on failure
- *          true  on success
- */
-bool
-db_create_mac_record(JCR *jcr, B_DB *mdb, MAC_DBR *mr)
-{
-   char schedt[MAX_TIME_LENGTH], sdt[MAX_TIME_LENGTH], edt[MAX_TIME_LENGTH];
-   time_t stime;
-   struct tm tm;
-   bool ok;
-   utime_t JobTDate;
-   char ed1[30], ed2[30];
-
-   db_lock(mdb);
-
-   stime = mr->SchedTime;
-   ASSERT(stime != 0);
-
-   localtime_r(&stime, &tm);
-   strftime(schedt, sizeof(schedt), "%Y-%m-%d %T", &tm);
-   JobTDate = (utime_t)stime;
-   localtime_r(&mr->StartTime, &tm);
-   strftime(sdt, sizeof(sdt), "%Y-%m-%d %T", &tm);
-   localtime_r(&mr->EndTime, &tm);
-   strftime(edt, sizeof(edt), "%Y-%m-%d %T", &tm);
-
-   /* Must create it */
-   Mmsg(mdb->cmd,
-"INSERT INTO MAC (OriginaJobId,JobType,JobLevel,SchedTime,"
-"StartTime,EndTime,JobTDate) VALUES "
-"('%s','%c','%c','%s','%s','%s',%s)",
-           edit_int64(mr->OriginalJobId, ed1),
-           (char)(mr->JobType), (char)(mr->JobLevel),
-           schedt, sdt, edt, edit_uint64(JobTDate, ed2));
-
-   if (!INSERT_DB(jcr, mdb, mdb->cmd)) {
-      Mmsg2(&mdb->errmsg, _("Create DB MAC record %s failed. ERR=%s\n"),
-            mdb->cmd, sql_strerror(mdb));
-      mr->JobId = 0;
-      ok = false;
-   } else {
-      mr->JobId = sql_insert_id(mdb, NT_("Job"));
-      ok = true;
-   }
-   db_unlock(mdb);
-   return ok;
-}
-
 
 /* Create a JobMedia record for medium used this job
  * Returns: false on failure
@@ -167,15 +118,19 @@ db_create_jobmedia_record(JCR *jcr, B_DB *mdb, JOBMEDIA_DBR *jm)
    }
    count++;
 
+   /* Note, jm->Strip is not used and is not likely to be used
+    * in the near future, so I have removed it from the insert
+    * to save space in the DB. KES June 2006.
+    */
    Mmsg(mdb->cmd,
         "INSERT INTO JobMedia (JobId,MediaId,FirstIndex,LastIndex,"
-        "StartFile,EndFile,StartBlock,EndBlock,VolIndex,Copy,Stripe) "
-        "VALUES (%s,%s,%u,%u,%u,%u,%u,%u,%u,%u,%u)",
+        "StartFile,EndFile,StartBlock,EndBlock,VolIndex,Copy) "
+        "VALUES (%s,%s,%u,%u,%u,%u,%u,%u,%u,%u)",
         edit_int64(jm->JobId, ed1),
         edit_int64(jm->MediaId, ed2),
         jm->FirstIndex, jm->LastIndex,
         jm->StartFile, jm->EndFile, jm->StartBlock, jm->EndBlock,count,
-        jm->Copy, jm->Stripe);
+        jm->Copy);
 
    Dmsg0(300, mdb->cmd);
    if (!INSERT_DB(jcr, mdb, mdb->cmd)) {
@@ -421,6 +376,7 @@ db_create_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
 {
    int stat;
    char ed1[50], ed2[50], ed3[50], ed4[50], ed5[50], ed6[50], ed7[50], ed8[50];
+   char ed9[50], ed10[50], ed11[50], ed12[50];
    struct tm tm;
 
    db_lock(mdb);
@@ -444,8 +400,10 @@ db_create_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
 "INSERT INTO Media (VolumeName,MediaType,MediaTypeId,PoolId,MaxVolBytes,"
 "VolCapacityBytes,Recycle,VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles,"
 "VolStatus,Slot,VolBytes,InChanger,VolReadTime,VolWriteTime,VolParts,"
-"EndFile,EndBlock,LabelType,StorageId,DeviceId,LocationId) "
-"VALUES ('%s','%s',0,%u,%s,%s,%d,%s,%s,%u,%u,'%s',%d,%s,%d,%s,%s,%d,0,0,%d,%s,0,0)",
+"EndFile,EndBlock,LabelType,StorageId,DeviceId,LocationId,"
+"ScratchPoolId,RecyclePoolId,Enabled)"
+"VALUES ('%s','%s',0,%u,%s,%s,%d,%s,%s,%u,%u,'%s',%d,%s,%d,%s,%s,%d,0,0,%d,%s,"
+"%s,%s,%s,%s,%d)",
           mr->VolumeName,
           mr->MediaType, mr->PoolId,
           edit_uint64(mr->MaxVolBytes,ed1),
@@ -463,7 +421,12 @@ db_create_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
           edit_uint64(mr->VolWriteTime, ed7),
           mr->VolParts,
           mr->LabelType,
-          edit_int64(mr->StorageId, ed8) 
+          edit_int64(mr->StorageId, ed8), 
+          edit_int64(mr->DeviceId, ed9), 
+          edit_int64(mr->LocationId, ed10), 
+          edit_int64(mr->ScratchPoolId, ed11), 
+          edit_int64(mr->RecyclePoolId, ed12), 
+          mr->Enabled
           );
 
 
index e03cf5cdaf0c670502a140aa6c15d312c4a5a5fc..c4641ff4f665f922a928c5bd7492fca79c83d0a3 100644 (file)
@@ -7,22 +7,17 @@
  */
 
 /*
-   Copyright (C) 2000-2005 Kern Sibbald
+   Copyright (C) 2000-2006 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.
+   modify it under the terms of the GNU General Public License
+   version 2 as amended with additional clauses defined in the
+   file LICENSE in the main source directory.
 
    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.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
+   the file LICENSE for additional details.
 
  */
 
@@ -31,7 +26,7 @@
 /* The following is necessary so that we do not include
  * the dummy external definition of DB.
  */
-#define __SQL_C                      /* indicate that this is sql.c */
+#define __SQL_C                       /* indicate that this is sql.c */
 
 #include "bacula.h"
 #include "cats.h"
@@ -56,9 +51,9 @@ extern int DeleteDB(const char *file, int line, JCR *jcr, B_DB *db, char *delete
  *  Media records.
  *
  *  Returns: 0 on error
- *          1 on success
- *          PoolId = number of Pools deleted (should be 1)
- *          NumVols = number of Media records deleted
+ *           1 on success
+ *           PoolId = number of Pools deleted (should be 1)
+ *           NumVols = number of Media records deleted
  */
 int
 db_delete_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr)
@@ -77,19 +72,19 @@ db_delete_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr)
 
       if (mdb->num_rows == 0) {
          Mmsg(mdb->errmsg, _("No pool record %s exists\n"), pr->Name);
-        sql_free_result(mdb);
-        db_unlock(mdb);
-        return 0;
+         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);
-        sql_free_result(mdb);
-        db_unlock(mdb);
-        return 0;
+         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));
-        db_unlock(mdb);
-        return 0;
+         db_unlock(mdb);
+         return 0;
       }
       pr->PoolId = str_to_int64(row[0]);
       sql_free_result(mdb);
@@ -116,10 +111,10 @@ db_delete_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr)
 
 struct s_del_ctx {
    JobId_t *JobId;
-   int num_ids;                      /* ids stored */
-   int max_ids;                      /* size of array */
-   int num_del;                      /* number deleted */
-   int tot_ids;                      /* total to process */
+   int num_ids;                       /* ids stored */
+   int max_ids;                       /* size of array */
+   int num_del;                       /* number deleted */
+   int tot_ids;                       /* total to process */
 };
 
 /*
@@ -139,7 +134,7 @@ static int delete_handler(void *ctx, int num_fields, char **row)
    if (del->num_ids == del->max_ids) {
       del->max_ids = (del->max_ids * 3) / 2;
       del->JobId = (JobId_t *)brealloc(del->JobId, sizeof(JobId_t) *
-        del->max_ids);
+         del->max_ids);
    }
    del->JobId[del->num_ids++] = (JobId_t)str_to_int64(row[0]);
    return 0;
@@ -222,7 +217,7 @@ int db_purge_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
       return 0;
    }
    /* Delete associated records */
-   do_media_purge(mdb, mr);          /* Note, always purge */
+   do_media_purge(mdb, mr);           /* Note, always purge */
 
    /* Mark Volume as purged */
    strcpy(mr->VolStatus, "Purged");
index f2bd3d9dd9152b40984d4f870c7ea44a0b507049..567a18cd131c03dc81f80ec0228117d74e63e68c 100644 (file)
@@ -310,47 +310,6 @@ bool db_get_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
    return true;
 }
 
-/*
- * Get MAC record for given JobId
- * Returns: false on failure
- *          true  on success
- */
-bool db_get_mac_record(JCR *jcr, B_DB *mdb, MAC_DBR *mr)
-{
-   SQL_ROW row;
-   char ed1[50];
-
-   db_lock(mdb);
-   Mmsg(mdb->cmd, "SELECT OriginalJobId,JobType,JobLevel,"
-"SchedTime,StartTime,EndTime,JobTDate"
-"FROM MAC WHERE JobId=%s", 
-      edit_int64(mr->JobId, ed1));
-
-   if (!QUERY_DB(jcr, mdb, mdb->cmd)) {
-      db_unlock(mdb);
-      return 0;                       /* failed */
-   }
-   if ((row = sql_fetch_row(mdb)) == NULL) {
-      Mmsg1(mdb->errmsg, _("No MAC record found for JobId %s\n"), ed1);
-      sql_free_result(mdb);
-      db_unlock(mdb);
-      return false;                   /* failed */
-   }
-
-   mr->OriginalJobId = str_to_int64(row[0]);
-   mr->JobType = (int)*row[1];
-   mr->JobLevel = (int)*row[2];
-   bstrncpy(mr->cSchedTime, row[3]!=NULL?row[3]:"", sizeof(mr->cSchedTime));
-   bstrncpy(mr->cStartTime, row[4]!=NULL?row[4]:"", sizeof(mr->cStartTime));
-   bstrncpy(mr->cEndTime, row[5]!=NULL?row[5]:"", sizeof(mr->cEndTime));
-   mr->JobTDate = str_to_int64(row[6]);
-   sql_free_result(mdb);
-
-   db_unlock(mdb);
-   return 1;
-}
-
-
 /*
  * Find VolumeNames for a given JobId
  *  Returns: 0 on error or no Volumes found
@@ -427,7 +386,7 @@ int db_get_job_volume_parameters(JCR *jcr, B_DB *mdb, JobId_t JobId, VOL_PARAMS
    db_lock(mdb);
    Mmsg(mdb->cmd,
 "SELECT VolumeName,MediaType,FirstIndex,LastIndex,StartFile,"
-"JobMedia.EndFile,StartBlock,JobMedia.EndBlock,Copy,Stripe,"
+"JobMedia.EndFile,StartBlock,JobMedia.EndBlock,Copy,"
 "Slot,StorageId"
 " FROM JobMedia,Media WHERE JobMedia.JobId=%s"
 " AND JobMedia.MediaId=Media.MediaId ORDER BY VolIndex,JobMediaId",
@@ -464,9 +423,8 @@ int db_get_job_volume_parameters(JCR *jcr, B_DB *mdb, JobId_t JobId, VOL_PARAMS
                Vols[i].StartBlock = str_to_uint64(row[6]);
                Vols[i].EndBlock = str_to_uint64(row[7]);
 //             Vols[i].Copy = str_to_uint64(row[8]);
-//             Vols[i].Stripe = str_to_uint64(row[9]);
-               Vols[i].Slot = str_to_uint64(row[10]);
-               StorageId = str_to_uint64(row[11]);
+               Vols[i].Slot = str_to_uint64(row[9]);
+               StorageId = str_to_uint64(row[10]);
                Vols[i].Storage[0] = 0;
                SId[i] = StorageId;
             }
index c1b451e3196176b742e921400909f64b322b905d..f61e751e309efd84086869b96a82489e93238aaf 100644 (file)
@@ -195,13 +195,13 @@ void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, uint32_t JobId,
       if (JobId > 0) {                   /* do by JobId */
          Mmsg(mdb->cmd, "SELECT JobMediaId,JobId,Media.MediaId,Media.VolumeName,"
             "FirstIndex,LastIndex,StartFile,JobMedia.EndFile,StartBlock,"
-            "JobMedia.EndBlock,Copy,Stripe "
+            "JobMedia.EndBlock,Copy "
             "FROM JobMedia,Media WHERE Media.MediaId=JobMedia.MediaId "
             "AND JobMedia.JobId=%s", edit_int64(JobId, ed1));
       } else {
          Mmsg(mdb->cmd, "SELECT JobMediaId,JobId,Media.MediaId,Media.VolumeName,"
             "FirstIndex,LastIndex,StartFile,JobMedia.EndFile,StartBlock,"
-            "JobMedia.EndBlock,Copy,Stripe "
+            "JobMedia.EndBlock,Copy "
             "FROM JobMedia,Media WHERE Media.MediaId=JobMedia.MediaId");
       }
 
index e757bdcdaa523b806d8d17229affab0cd1fc9b88..c7cd9c80edf3f31004988aae8f93a2790181705d 100644 (file)
@@ -136,14 +136,13 @@ int
 db_update_job_end_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
 {
    char dt[MAX_TIME_LENGTH];
+   char rdt[MAX_TIME_LENGTH];
    time_t ttime;
    struct tm tm;
    int stat;
    char ed1[30], ed2[30], ed3[50];
    btime_t JobTDate;
-   char PoolId    [50];
-   char FileSetId [50];
-   char ClientId  [50];
+   char PoolId[50], FileSetId[50], ClientId[50], PriorJobId[50];
 
 
    /* some values are set to zero, which translates to NULL in SQL */
@@ -151,19 +150,36 @@ db_update_job_end_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
    edit_num_or_null(FileSetId, sizeof(FileSetId), jr->FileSetId);
    edit_num_or_null(ClientId,  sizeof(ClientId),  jr->ClientId);
 
+   if (jr->PriorJobId) {
+      bstrncpy(PriorJobId, edit_int64(jr->PriorJobId, ed1), sizeof(PriorJobId));
+   } else {
+      bstrncpy(PriorJobId, "0", sizeof(PriorJobId));
+   }
+
    ttime = jr->EndTime;
    localtime_r(&ttime, &tm);
    strftime(dt, sizeof(dt), "%Y-%m-%d %H:%M:%S", &tm);
+
+   if (jr->RealEndTime == 0) {
+      jr->RealEndTime = jr->EndTime;
+   }
+   ttime = jr->RealEndTime;
+   localtime_r(&ttime, &tm);
+   strftime(rdt, sizeof(rdt), "%Y-%m-%d %H:%M:%S", &tm);
+
    JobTDate = ttime;
 
    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=%s",
+      "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,"
+"RealEndTime='%s',PriorJobId=%s WHERE JobId=%s",
       (char)(jr->JobStatus), dt, ClientId, edit_uint64(jr->JobBytes, ed1),
       jr->JobFiles, jr->JobErrors, jr->VolSessionId, jr->VolSessionTime,
       PoolId, FileSetId, edit_uint64(JobTDate, ed2), 
+      rdt, 
+      PriorJobId,
       edit_int64(jr->JobId, ed3));
 
    stat = UPDATE_DB(jcr, mdb, mdb->cmd);
index b43dd28aedb5a9a4db5c15dc5d21cfe026394b0f..a892e392d07704c131cec36d9f43cbd15ade89ce 100755 (executable)
@@ -19,23 +19,18 @@ ALTER TABLE Media ADD COLUMN RecycleCount INTEGER UNSIGNED DEFAULT 0;
 ALTER TABLE Media ADD COLUMN InitialWrite DATETIME DEFAULT 0;
 ALTER TABLE Media ADD COLUMN ScratchPoolId INTEGER UNSIGNED DEFAULT 0 REFERENCES Pool;
 ALTER TABLE Media ADD COLUMN RecyclePoolId INTEGER UNSIGNED DEFAULT 0 REFERENCES Pool;
+ALTER TABLE Media ADD COLUMN Enabled TINYINT DEFAULT 1;
 
+ALTER TABLE JobMedia DROP ADD COLUMN Stripe;
+
+ALTER TABLE Job ADD COLUMN PriorJobId INTEGER UNSIGNED DEFAULT 0 REFERENCES Job;
+ALTER TABLE Job ADD COLUMN RealEndTime DATETIME DEFAULT 0;
 
-CREATE TABLE MAC (
-   JobId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
-   OriginalJobId INTEGER UNSIGNED NOT NULL,
-   JobType BINARY(1) NOT NULL,
-   JobLevel BINARY(1) NOT NULL,
-   SchedTime DATETIME NOT NULL,
-   StartTime DATETIME NOT NULL,
-   EndTime DATETIME NOT NULL,
-   JobTDate BIGINT UNSIGNED NOT NULL,
-   PRIMARY KEY(JobId)
-   );
 
 CREATE TABLE Location (
    LocationId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
    Location TINYBLOB NOT NULL,
+   Cost INTEGER DEFAULT 0,
    PRIMARY KEY(LocationId)
    );
 
index 92fd0c1be452591783a35d046ed32c11a6774c11..b99f1fa05651cf6c18fc9853c82279153e5e90ac 100755 (executable)
@@ -25,23 +25,22 @@ ALTER TABLE media ADD COLUMN scratchpoolid integer;
 UPDATE media SET scratchpoolid=0;
 ALTER TABLE media ADD COLUMN recyclepoolid integer;
 UPDATE media SET recyclepoolid=0;
+ALTER TABLE media ADD COLUMN enabled integer;
+UPDATE media SET enabled=1;
+
+ALTER TABLE job ADD COLUMN RealEndTime timestamp without time zone;
+UPDATE job SET RealEndTime=0;
+ALTER TABLE job ADD COLUMN PriorJobId integer;
+UPDATE job SET PriorJobId=0;
+
+ALTER TABLE jobmedia DROP COLUMN Stripe;
 
 
-CREATE TABLE MAC (
-    JobId            serial      not null,
-    OriginalJobId     serial     not null,
-    JobType          char(1)     not null,
-    JobLevel         char(1)     not null,
-    SchedTime        timestamp   without time zone not null,
-    StartTime        timestamp   without time zone,
-    EndTime          timestamp   without time zone,
-    JobTDate         bigint      not null,
-    primary key (JobId)
-);
 
 CREATE TABLE Location (
    LocationId SERIAL NOT NULL,
    Location TEXT NOT NULL,
+   Cost integer not null default 0,
    PRIMARY KEY (LocationId)
 );
 
index f09d226bc06c2706c9c588515759d4892c4d8752..802a6b5f492cfe5a28775405d738e767c7c91bbc 100755 (executable)
@@ -36,6 +36,7 @@ CREATE TEMPORARY TABLE Media_backup (
    VolWrites INTEGER UNSIGNED DEFAULT 0,
    VolCapacityBytes BIGINT UNSIGNED DEFAULT 0,
    VolStatus VARCHAR(20) NOT NULL,
+   Enabled TINYINT DEFAULT 1,
    Recycle TINYINT DEFAULT 0,
    VolRetention BIGINT UNSIGNED DEFAULT 0,
    VolUseDuration BIGINT UNSIGNED DEFAULT 0,
@@ -63,7 +64,7 @@ INSERT INTO Media_backup SELECT
    MediaType, LabelType, 0, FirstWritten, LastWritten,
    LabelDate, VolJobs, VolFiles, VolBlocks,
    VolMounts, VolBytes, VolParts, VolErrors, VolWrites,
-   VolCapacityBytes, VolStatus, Recycle,
+   VolCapacityBytes, VolStatus, 1, Recycle,
    VolRetention, VolUseDuration, MaxVolJobs,
    MaxVolFiles, MaxVolBytes, InChanger, 
    StorageId, 0, MediaAddressing,
@@ -94,6 +95,7 @@ CREATE TABLE Media (
    VolWrites INTEGER UNSIGNED DEFAULT 0,
    VolCapacityBytes BIGINT UNSIGNED DEFAULT 0,
    VolStatus VARCHAR(20) NOT NULL,
+   Enabled TINYINT DEFAULT 1,
    Recycle TINYINT DEFAULT 0,
    VolRetention BIGINT UNSIGNED DEFAULT 0,
    VolUseDuration BIGINT UNSIGNED DEFAULT 0,
@@ -121,7 +123,7 @@ INSERT INTO Media (
    MediaType, MediaTypeId, LabelType, FirstWritten, LastWritten,
    LabelDate, VolJobs, VolFiles, VolBlocks,
    VolMounts, VolBytes, VolParts, VolErrors, VolWrites,
-   VolCapacityBytes, VolStatus, Recycle,
+   VolCapacityBytes, VolStatus, Enabled, Recycle,
    VolRetention, VolUseDuration, MaxVolJobs,
    MaxVolFiles, MaxVolBytes,
    InChanger, StorageId, DeviceId, MediaAddressing,
@@ -134,22 +136,87 @@ INSERT INTO Media (
 DROP TABLE Media_backup;
 CREATE INDEX inx8 ON Media (PoolId);
 
+CREATE TEMPORARY TABLE job_backup
+{
+   JobId INTEGER,
+   Job VARCHAR(128) NOT NULL,
+   Name VARCHAR(128) NOT NULL,
+   Type CHAR NOT NULL,
+   Level CHAR NOT NULL,
+   ClientId INTEGER REFERENCES Client DEFAULT 0,
+   JobStatus CHAR NOT NULL,
+   SchedTime DATETIME NOT NULL,
+   StartTime DATETIME DEFAULT 0,
+   EndTime DATETIME DEFAULT 0,
+   RealEndTime DATETIME DEFAULT 0,
+   JobTDate BIGINT UNSIGNED DEFAULT 0,
+   VolSessionId INTEGER UNSIGNED DEFAULT 0,
+   VolSessionTime INTEGER UNSIGNED DEFAULT 0,
+   JobFiles INTEGER UNSIGNED DEFAULT 0,
+   JobBytes BIGINT UNSIGNED DEFAULT 0,
+   JobErrors INTEGER UNSIGNED DEFAULT 0,
+   JobMissingFiles INTEGER UNSIGNED DEFAULT 0,
+   PoolId INTEGER UNSIGNED REFERENCES Pool DEFAULT 0,
+   FileSetId INTEGER UNSIGNED REFERENCES FileSet DEFAULT 0,
+   PriorJobId INTEGER UNSIGNED REFERENCES Job DEFAULT 0,
+   PurgedFiles TINYINT DEFAULT 0,
+   HasBase TINYINT DEFAULT 0,
+   PRIMARY KEY(JobId) 
+   );
+
+INSERT INTO Job_backup SELECT 
+   JobId, Job, Name, Type, Level, ClientId, JobStatus,
+   SchedTime, StartTime, EndTime, 0,
+   JobTDate, VolSessionId, VolSessionTime, 
+   JobFiles, JobBytes, JobErrors, JobMissingFiles, 
+   PoolId, FileSetId, 0, PurgedFiles, HasBase,
+   PRIMARY KEY(JobId) 
+   );
+   FROM Job;
 
-CREATE TABLE MAC (
+DROP TABLE Job;
+CREATE TEMPORARY TABLE Job
+{
    JobId INTEGER,
-   OriginalJobId INTEGER,
-   JobType CHAR NOT NULL,
-   JobLevel CHAR NOT NULL,
+   Job VARCHAR(128) NOT NULL,
+   Name VARCHAR(128) NOT NULL,
+   Type CHAR NOT NULL,
+   Level CHAR NOT NULL,
+   ClientId INTEGER REFERENCES Client DEFAULT 0,
+   JobStatus CHAR NOT NULL,
    SchedTime DATETIME NOT NULL,
    StartTime DATETIME DEFAULT 0,
    EndTime DATETIME DEFAULT 0,
+   RealEndTime DATETIME DEFAULT 0,
    JobTDate BIGINT UNSIGNED DEFAULT 0,
-   PRIMARY KEY(JobId)
+   VolSessionId INTEGER UNSIGNED DEFAULT 0,
+   VolSessionTime INTEGER UNSIGNED DEFAULT 0,
+   JobFiles INTEGER UNSIGNED DEFAULT 0,
+   JobBytes BIGINT UNSIGNED DEFAULT 0,
+   JobErrors INTEGER UNSIGNED DEFAULT 0,
+   JobMissingFiles INTEGER UNSIGNED DEFAULT 0,
+   PoolId INTEGER UNSIGNED REFERENCES Pool DEFAULT 0,
+   FileSetId INTEGER UNSIGNED REFERENCES FileSet DEFAULT 0,
+   PriorJobId INTEGER UNSIGNED REFERENCES Job DEFAULT 0,
+   PurgedFiles TINYINT DEFAULT 0,
+   HasBase TINYINT DEFAULT 0,
+   PRIMARY KEY(JobId) 
    );
 
+INSERT INTO Job SELECT 
+   JobId, Job, Name, Type, Level, ClientId, JobStatus,
+   SchedTime, StartTime, EndTime, RealEndTime,
+   JobTDate, VolSessionId, VolSessionTime, 
+   JobFiles, JobBytes, JobErrors, JobMissingFiles, 
+   PoolId, FileSetId, PriorJobId, PurgedFiles, HasBase
+   FROM Job_backup;
+
+DROP TABLE Job_backup;
+
 CREATE TABLE Location (
    LocationId INTEGER,
    Location VARCHAR(128) NOT NULL,
+   Counter INTEGER DEFAULT 0,
    PRIMARY KEY(LocationId)
    );
  
index f09d226bc06c2706c9c588515759d4892c4d8752..802a6b5f492cfe5a28775405d738e767c7c91bbc 100755 (executable)
@@ -36,6 +36,7 @@ CREATE TEMPORARY TABLE Media_backup (
    VolWrites INTEGER UNSIGNED DEFAULT 0,
    VolCapacityBytes BIGINT UNSIGNED DEFAULT 0,
    VolStatus VARCHAR(20) NOT NULL,
+   Enabled TINYINT DEFAULT 1,
    Recycle TINYINT DEFAULT 0,
    VolRetention BIGINT UNSIGNED DEFAULT 0,
    VolUseDuration BIGINT UNSIGNED DEFAULT 0,
@@ -63,7 +64,7 @@ INSERT INTO Media_backup SELECT
    MediaType, LabelType, 0, FirstWritten, LastWritten,
    LabelDate, VolJobs, VolFiles, VolBlocks,
    VolMounts, VolBytes, VolParts, VolErrors, VolWrites,
-   VolCapacityBytes, VolStatus, Recycle,
+   VolCapacityBytes, VolStatus, 1, Recycle,
    VolRetention, VolUseDuration, MaxVolJobs,
    MaxVolFiles, MaxVolBytes, InChanger, 
    StorageId, 0, MediaAddressing,
@@ -94,6 +95,7 @@ CREATE TABLE Media (
    VolWrites INTEGER UNSIGNED DEFAULT 0,
    VolCapacityBytes BIGINT UNSIGNED DEFAULT 0,
    VolStatus VARCHAR(20) NOT NULL,
+   Enabled TINYINT DEFAULT 1,
    Recycle TINYINT DEFAULT 0,
    VolRetention BIGINT UNSIGNED DEFAULT 0,
    VolUseDuration BIGINT UNSIGNED DEFAULT 0,
@@ -121,7 +123,7 @@ INSERT INTO Media (
    MediaType, MediaTypeId, LabelType, FirstWritten, LastWritten,
    LabelDate, VolJobs, VolFiles, VolBlocks,
    VolMounts, VolBytes, VolParts, VolErrors, VolWrites,
-   VolCapacityBytes, VolStatus, Recycle,
+   VolCapacityBytes, VolStatus, Enabled, Recycle,
    VolRetention, VolUseDuration, MaxVolJobs,
    MaxVolFiles, MaxVolBytes,
    InChanger, StorageId, DeviceId, MediaAddressing,
@@ -134,22 +136,87 @@ INSERT INTO Media (
 DROP TABLE Media_backup;
 CREATE INDEX inx8 ON Media (PoolId);
 
+CREATE TEMPORARY TABLE job_backup
+{
+   JobId INTEGER,
+   Job VARCHAR(128) NOT NULL,
+   Name VARCHAR(128) NOT NULL,
+   Type CHAR NOT NULL,
+   Level CHAR NOT NULL,
+   ClientId INTEGER REFERENCES Client DEFAULT 0,
+   JobStatus CHAR NOT NULL,
+   SchedTime DATETIME NOT NULL,
+   StartTime DATETIME DEFAULT 0,
+   EndTime DATETIME DEFAULT 0,
+   RealEndTime DATETIME DEFAULT 0,
+   JobTDate BIGINT UNSIGNED DEFAULT 0,
+   VolSessionId INTEGER UNSIGNED DEFAULT 0,
+   VolSessionTime INTEGER UNSIGNED DEFAULT 0,
+   JobFiles INTEGER UNSIGNED DEFAULT 0,
+   JobBytes BIGINT UNSIGNED DEFAULT 0,
+   JobErrors INTEGER UNSIGNED DEFAULT 0,
+   JobMissingFiles INTEGER UNSIGNED DEFAULT 0,
+   PoolId INTEGER UNSIGNED REFERENCES Pool DEFAULT 0,
+   FileSetId INTEGER UNSIGNED REFERENCES FileSet DEFAULT 0,
+   PriorJobId INTEGER UNSIGNED REFERENCES Job DEFAULT 0,
+   PurgedFiles TINYINT DEFAULT 0,
+   HasBase TINYINT DEFAULT 0,
+   PRIMARY KEY(JobId) 
+   );
+
+INSERT INTO Job_backup SELECT 
+   JobId, Job, Name, Type, Level, ClientId, JobStatus,
+   SchedTime, StartTime, EndTime, 0,
+   JobTDate, VolSessionId, VolSessionTime, 
+   JobFiles, JobBytes, JobErrors, JobMissingFiles, 
+   PoolId, FileSetId, 0, PurgedFiles, HasBase,
+   PRIMARY KEY(JobId) 
+   );
+   FROM Job;
 
-CREATE TABLE MAC (
+DROP TABLE Job;
+CREATE TEMPORARY TABLE Job
+{
    JobId INTEGER,
-   OriginalJobId INTEGER,
-   JobType CHAR NOT NULL,
-   JobLevel CHAR NOT NULL,
+   Job VARCHAR(128) NOT NULL,
+   Name VARCHAR(128) NOT NULL,
+   Type CHAR NOT NULL,
+   Level CHAR NOT NULL,
+   ClientId INTEGER REFERENCES Client DEFAULT 0,
+   JobStatus CHAR NOT NULL,
    SchedTime DATETIME NOT NULL,
    StartTime DATETIME DEFAULT 0,
    EndTime DATETIME DEFAULT 0,
+   RealEndTime DATETIME DEFAULT 0,
    JobTDate BIGINT UNSIGNED DEFAULT 0,
-   PRIMARY KEY(JobId)
+   VolSessionId INTEGER UNSIGNED DEFAULT 0,
+   VolSessionTime INTEGER UNSIGNED DEFAULT 0,
+   JobFiles INTEGER UNSIGNED DEFAULT 0,
+   JobBytes BIGINT UNSIGNED DEFAULT 0,
+   JobErrors INTEGER UNSIGNED DEFAULT 0,
+   JobMissingFiles INTEGER UNSIGNED DEFAULT 0,
+   PoolId INTEGER UNSIGNED REFERENCES Pool DEFAULT 0,
+   FileSetId INTEGER UNSIGNED REFERENCES FileSet DEFAULT 0,
+   PriorJobId INTEGER UNSIGNED REFERENCES Job DEFAULT 0,
+   PurgedFiles TINYINT DEFAULT 0,
+   HasBase TINYINT DEFAULT 0,
+   PRIMARY KEY(JobId) 
    );
 
+INSERT INTO Job SELECT 
+   JobId, Job, Name, Type, Level, ClientId, JobStatus,
+   SchedTime, StartTime, EndTime, RealEndTime,
+   JobTDate, VolSessionId, VolSessionTime, 
+   JobFiles, JobBytes, JobErrors, JobMissingFiles, 
+   PoolId, FileSetId, PriorJobId, PurgedFiles, HasBase
+   FROM Job_backup;
+
+DROP TABLE Job_backup;
+
 CREATE TABLE Location (
    LocationId INTEGER,
    Location VARCHAR(128) NOT NULL,
+   Counter INTEGER DEFAULT 0,
    PRIMARY KEY(LocationId)
    );
  
index 8477d8bbc854ee076e5e91a843fa662aae3eece5..06ed35937b67a571390dbbfaaf11dbc71315a811 100644 (file)
@@ -95,6 +95,7 @@ void catalog_request(JCR *jcr, BSOCK *bs)
    int index, ok, label, writing;
    POOLMEM *omsg;
    POOL_DBR pr;
+   uint32_t Stripe;
 
    memset(&mr, 0, sizeof(mr));
    memset(&sdmr, 0, sizeof(sdmr));
@@ -276,7 +277,7 @@ void catalog_request(JCR *jcr, BSOCK *bs)
     */
    } else if (sscanf(bs->msg, Create_job_media, &Job,
       &jm.FirstIndex, &jm.LastIndex, &jm.StartFile, &jm.EndFile,
-      &jm.StartBlock, &jm.EndBlock, &jm.Copy, &jm.Stripe) == 9) {
+      &jm.StartBlock, &jm.EndBlock, &jm.Copy, &Stripe) == 9) {
 
       if (jcr->previous_jcr) {
          jm.JobId = jcr->previous_jcr->JobId;
index ce83228b701ee2985dfe7a8ade3df2082b3283ec..ab6995306efaaddb0f6c3defda42a123cf8e774e 100644 (file)
@@ -25,6 +25,7 @@
 
  */
 
+#include "lib/runscript.h"
 #include "dird_conf.h"
 
 #define DIRECTOR_DAEMON 1
@@ -37,7 +38,6 @@
 #include "protos.h"
 
 #include "jobq.h"
-#include "lib/runscript.h"
 
 /* Globals that dird.c exports */
 extern DIRRES *director;                     /* Director resource */
index b67f780962d29362ad9c99d6596b36f45e1ce3fd..77f59a8853d57c3f1428cbeed749a16831d43e45 100644 (file)
@@ -110,7 +110,7 @@ static RES_ITEM dir_items[] = {
    {"tlskey",               store_dir,       ITEM(res_dir.tls_keyfile), 0, 0, 0},
    {"tlsdhfile",            store_dir,       ITEM(res_dir.tls_dhfile), 0, 0, 0},
    {"tlsallowedcn",         store_alist_str, ITEM(res_dir.tls_allowed_cns), 0, 0, 0},
-   {NULL, NULL, NULL, 0, 0, 0}
+   {NULL, NULL, {0}, 0, 0, 0}
 };
 
 /*
@@ -140,7 +140,7 @@ static RES_ITEM con_items[] = {
    {"tlskey",               store_dir,       ITEM(res_con.tls_keyfile), 0, 0, 0},
    {"tlsdhfile",            store_dir,       ITEM(res_con.tls_dhfile), 0, 0, 0},
    {"tlsallowedcn",         store_alist_str, ITEM(res_con.tls_allowed_cns), 0, 0, 0},
-   {NULL, NULL, NULL, 0, 0, 0}
+   {NULL, NULL, {0}, 0, 0, 0}
 };
 
 
@@ -169,7 +169,7 @@ static RES_ITEM cli_items[] = {
    {"tlscacertificatedir",  store_dir,       ITEM(res_client.tls_ca_certdir), 0, 0, 0},
    {"tlscertificate",       store_dir,       ITEM(res_client.tls_certfile), 0, 0, 0},
    {"tlskey",               store_dir,       ITEM(res_client.tls_keyfile), 0, 0, 0},
-   {NULL, NULL, NULL, 0, 0, 0}
+   {NULL, NULL, {0}, 0, 0, 0}
 };
 
 /* Storage daemon resource
@@ -196,7 +196,7 @@ static RES_ITEM store_items[] = {
    {"tlscacertificatedir",  store_dir,       ITEM(res_store.tls_ca_certdir), 0, 0, 0},
    {"tlscertificate",       store_dir,       ITEM(res_store.tls_certfile), 0, 0, 0},
    {"tlskey",               store_dir,       ITEM(res_store.tls_keyfile), 0, 0, 0},
-   {NULL, NULL, NULL, 0, 0, 0}
+   {NULL, NULL, {0}, 0, 0, 0}
 };
 
 /*
@@ -218,7 +218,7 @@ static RES_ITEM cat_items[] = {
    {"dbsocket", store_str,      ITEM(res_cat.db_socket),   0, 0, 0},
    /* Turned off for the moment */
    {"multipleconnections", store_bit, ITEM(res_cat.mult_db_connections), 0, 0, 0},
-   {NULL, NULL, NULL, 0, 0, 0}
+   {NULL, NULL, {0}, 0, 0, 0}
 };
 
 /*
@@ -283,7 +283,7 @@ RES_ITEM job_items[] = {
    {"selectionpattern", store_str, ITEM(res_job.selection_pattern), 0, 0, 0},
    {"selectiontype", store_migtype, ITEM(res_job.selection_type), 0, 0, 0},
    {"runscript", store_runscript, ITEM(res_job.RunScripts), 0, ITEM_NO_EQUALS, 0},
-   {NULL, NULL, NULL, 0, 0, 0}
+   {NULL, NULL, {0}, 0, 0, 0}
 };
 
 /* FileSet resource
@@ -293,11 +293,11 @@ RES_ITEM job_items[] = {
 static RES_ITEM fs_items[] = {
    {"name",        store_name, ITEM(res_fs.hdr.name), 0, ITEM_REQUIRED, 0},
    {"description", store_str,  ITEM(res_fs.hdr.desc), 0, 0, 0},
-   {"include",     store_inc,  NULL,                  0, ITEM_NO_EQUALS, 0},
-   {"exclude",     store_inc,  NULL,                  1, ITEM_NO_EQUALS, 0},
+   {"include",     store_inc,  {0},                   0, ITEM_NO_EQUALS, 0},
+   {"exclude",     store_inc,  {0},                   1, ITEM_NO_EQUALS, 0},
    {"ignorefilesetchanges", store_bool, ITEM(res_fs.ignore_fs_changes), 0, ITEM_DEFAULT, false},
    {"enablevss",   store_bool, ITEM(res_fs.enable_vss), 0, ITEM_DEFAULT, false},
-   {NULL,          NULL,       NULL,                  0, 0, 0}
+   {NULL,          NULL,       {0},                  0, 0, 0}
 };
 
 /* Schedule -- see run_conf.c */
@@ -309,7 +309,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, {0}, 0, 0, 0}
 };
 
 /* Pool resource
@@ -343,7 +343,7 @@ static RES_ITEM pool_items[] = {
    {"storage",       store_alist_res, ITEM(res_pool.storage),  R_STORAGE, 0, 0},
    {"autoprune",       store_bool,    ITEM(res_pool.AutoPrune), 0, ITEM_DEFAULT, true},
    {"recycle",         store_bool,    ITEM(res_pool.Recycle),   0, ITEM_DEFAULT, true},
-   {NULL, NULL, NULL, 0, 0, 0}
+   {NULL, NULL, {0}, 0, 0, 0}
 };
 
 /*
@@ -357,7 +357,7 @@ 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, {0}, 0, 0, 0}
 };
 
 
@@ -1569,19 +1569,19 @@ static void store_runscript_target(LEX *lc, RES_ITEM *item, int index, int pass)
 
    if (pass == 2) {
       if (strcmp(lc->str, "%c") == 0) {
-        ((RUNSCRIPT*) item->value)->set_target(lc->str);
+         ((RUNSCRIPT*) item->value)->set_target(lc->str);
       } else if (strcmp(lc->str, "yes") == 0) {
-        ((RUNSCRIPT*) item->value)->set_target("%c");
+         ((RUNSCRIPT*) item->value)->set_target("%c");
       } else if (strcmp(lc->str, "no") == 0) {
-        /* store nothing, run on director */
+         /* store nothing, run on director */
       } else {
-        RES *res = GetResWithName(R_CLIENT, lc->str);
-        if (res == NULL) {
-           scan_err3(lc, _("Could not find config Resource %s referenced on line %d : %s\n"),
-                     lc->str, lc->line_no, lc->line);
-        }
+         RES *res = GetResWithName(R_CLIENT, lc->str);
+         if (res == NULL) {
+            scan_err3(lc, _("Could not find config Resource %s referenced on line %d : %s\n"),
+                      lc->str, lc->line_no, lc->line);
+         }
 
-        ((RUNSCRIPT*) item->value)->set_target(lc->str);
+         ((RUNSCRIPT*) item->value)->set_target(lc->str);
       }
    }
    scan_to_eol(lc);
@@ -1611,29 +1611,29 @@ static void store_short_runscript(LEX *lc, RES_ITEM *item, int index, int pass)
       script->set_command(lc->str);
 
       if (strcmp(item->name, "runbeforejob") == 0) {
-        script->when = SCRIPT_Before;
-        script->abort_on_error = true;
+         script->when = SCRIPT_Before;
+         script->abort_on_error = true;
 
       } else if (strcmp(item->name, "runafterjob") == 0) {
-        script->when = SCRIPT_After;
-        script->on_success = true;
-        script->on_failure = false;
-        
+         script->when = SCRIPT_After;
+         script->on_success = true;
+         script->on_failure = false;
+         
       } else if (strcmp(item->name, "clientrunafterjob") == 0) {
-        script->when = SCRIPT_After;
-        script->set_target("%c");
-        script->on_success = true;
-        script->on_failure = false;
+         script->when = SCRIPT_After;
+         script->set_target("%c");
+         script->on_success = true;
+         script->on_failure = false;
 
       } else if (strcmp(item->name, "clientrunbeforejob") == 0) {
-        script->when = SCRIPT_Before;
-        script->set_target("%c");
-        script->abort_on_error = true;
+         script->when = SCRIPT_Before;
+         script->set_target("%c");
+         script->abort_on_error = true;
 
       } else if (strcmp(item->name, "runafterfailedjob") == 0) {
-        script->when = SCRIPT_After;
-        script->on_failure = true;
-        script->on_success = false;
+         script->when = SCRIPT_After;
+         script->on_failure = true;
+         script->on_success = false;
       }
 
       if (*runscripts == NULL) {
@@ -1654,15 +1654,14 @@ static RUNSCRIPT  res_runscript;
  *   name             handler         value                                code flags default_value
  */
 static RES_ITEM runscript_items[] = {
-   {"command", store_runscript_cmd,   (char **)&res_runscript,            0,  ITEM_REQUIRED, 0}, 
-   {"target", store_runscript_target, (char **)&res_runscript,            0,  0, 0}, 
-   {"runsonsuccess",    store_bool,   (char **)&res_runscript.on_success, 0,  0, 0},
-   {"runsonfailure",    store_bool,   (char **)&res_runscript.on_failure, 0,  0, 0},
-   {"abortjobonerror", store_bool,    (char **)&res_runscript.abort_on_error, 0, 0,   0},
-   {"runswhen", store_runscript_when, (char **)&res_runscript.when,       0,  0, 0},
-   {"runsonclient", store_runscript_target, (char **)&res_runscript,       0,  0, 0}, /* TODO */
-
-   {NULL, NULL, NULL, 0, 0, 0}
+   {"command", store_runscript_cmd,   ITEM(res_runscript),           0,  ITEM_REQUIRED, 0}, 
+   {"target", store_runscript_target, ITEM(res_runscript),            0,  0, 0}, 
+   {"runsonsuccess",    store_bool,   ITEM(res_runscript.on_success), 0,  0, 0},
+   {"runsonfailure",    store_bool,   ITEM(res_runscript.on_failure), 0,  0, 0},
+   {"abortjobonerror", store_bool,    ITEM(res_runscript.abort_on_error), 0, 0,   0},
+   {"runswhen", store_runscript_when, ITEM(res_runscript.when),       0,  0, 0},
+   {"runsonclient", store_runscript_target, ITEM(res_runscript),       0,  0, 0}, /* TODO */
+   {NULL, NULL, {0}, 0, 0, 0}
 };
 
 /*
@@ -1715,13 +1714,13 @@ static void store_runscript(LEX *lc, RES_ITEM *item, int index, int pass)
 
    if (pass == 2) {
       if (res_runscript.command == NULL) {
-        scan_err2(lc, _("%s item is required in %s resource, but not found.\n"),
-                  "command", "runscript");
+         scan_err2(lc, _("%s item is required in %s resource, but not found.\n"),
+                   "command", "runscript");
       }
 
       /* run on client by default */
       if (res_runscript.target == NULL) {
-        res_runscript.set_target("%c");
+         res_runscript.set_target("%c");
       }
 
       RUNSCRIPT *script = new_runscript();
index 3b67dbb06e292702e1003cd4222af316fef73634..0108c6a997687ab76117f38b56256e65ac49f72a 100644 (file)
@@ -414,7 +414,7 @@ public:
    char *pool_type;                   /* Pool type */
    char *label_format;                /* Label format string */
    char *cleaning_prefix;             /* Cleaning label prefix */
-   int   LabelType;                   /* Bacula/ANSI/IBM label type */
+   int32_t LabelType;                 /* Bacula/ANSI/IBM label type */
    uint32_t max_volumes;              /* max number of volumes */
    utime_t VolRetention;              /* volume retention period in seconds */
    utime_t VolUseDuration;            /* duration volume can be used */
@@ -457,6 +457,7 @@ union URES {
    COUNTER    res_counter;
    DEVICE     res_dev;
    RES        hdr;
+   RUNSCRIPT  res_runscript;
 };
 
 
index cff0e26884eb6dc41e558608490734314014f0b1..dff8eae194fd225dfb09cbc4795fcf649fac98a7 100644 (file)
@@ -62,43 +62,43 @@ static INCEXE res_incexe;
  *   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}
+   {"file",            store_fname,   {0},      0, 0, 0},
+   {"options",         options_res,   {0},      0, 0, 0},
+   {NULL, NULL, {0}, 0, 0, 0}
 };
 
 /*
  * Items that are valid in an Options resource
  */
 static RES_ITEM options_items[] = {
-   {"compression",     store_opts,    NULL,     0, 0, 0},
-   {"signature",       store_opts,    NULL,     0, 0, 0},
-   {"verify",          store_opts,    NULL,     0, 0, 0},
-   {"onefs",           store_opts,    NULL,     0, 0, 0},
-   {"recurse",         store_opts,    NULL,     0, 0, 0},
-   {"sparse",          store_opts,    NULL,     0, 0, 0},
-   {"hardlinks",       store_opts,    NULL,     0, 0, 0},
-   {"readfifo",        store_opts,    NULL,     0, 0, 0},
-   {"replace",         store_opts,    NULL,     0, 0, 0},
-   {"portable",        store_opts,    NULL,     0, 0, 0},
-   {"mtimeonly",       store_opts,    NULL,     0, 0, 0},
-   {"keepatime",       store_opts,    NULL,     0, 0, 0},
-   {"regex",           store_regex,   NULL,     0, 0, 0},
-   {"regexdir",        store_regex,   NULL,     1, 0, 0},
-   {"regexfile",       store_regex,   NULL,     2, 0, 0},
-   {"base",            store_base,    NULL,     0, 0, 0},
-   {"wild",            store_wild,    NULL,     0, 0, 0},
-   {"wilddir",         store_wild,    NULL,     1, 0, 0},
-   {"wildfile",        store_wild,    NULL,     2, 0, 0},
-   {"exclude",         store_opts,    NULL,     0, 0, 0},
-   {"aclsupport",      store_opts,    NULL,     0, 0, 0},
-   {"reader",          store_reader,  NULL,     0, 0, 0},
-   {"writer",          store_writer,  NULL,     0, 0, 0},
-   {"ignorecase",      store_opts,    NULL,     0, 0, 0},
-   {"fstype",          store_fstype,  NULL,     0, 0, 0},
-   {"hfsplussupport",  store_opts,    NULL,     0, 0, 0},
-   {"noatime",         store_opts,    NULL,     0, 0, 0},
-   {NULL, NULL, NULL, 0, 0, 0}
+   {"compression",     store_opts,    {0},     0, 0, 0},
+   {"signature",       store_opts,    {0},     0, 0, 0},
+   {"verify",          store_opts,    {0},     0, 0, 0},
+   {"onefs",           store_opts,    {0},     0, 0, 0},
+   {"recurse",         store_opts,    {0},     0, 0, 0},
+   {"sparse",          store_opts,    {0},     0, 0, 0},
+   {"hardlinks",       store_opts,    {0},     0, 0, 0},
+   {"readfifo",        store_opts,    {0},     0, 0, 0},
+   {"replace",         store_opts,    {0},     0, 0, 0},
+   {"portable",        store_opts,    {0},     0, 0, 0},
+   {"mtimeonly",       store_opts,    {0},     0, 0, 0},
+   {"keepatime",       store_opts,    {0},     0, 0, 0},
+   {"regex",           store_regex,   {0},     0, 0, 0},
+   {"regexdir",        store_regex,   {0},     1, 0, 0},
+   {"regexfile",       store_regex,   {0},     2, 0, 0},
+   {"base",            store_base,    {0},     0, 0, 0},
+   {"wild",            store_wild,    {0},     0, 0, 0},
+   {"wilddir",         store_wild,    {0},     1, 0, 0},
+   {"wildfile",        store_wild,    {0},     2, 0, 0},
+   {"exclude",         store_opts,    {0},     0, 0, 0},
+   {"aclsupport",      store_opts,    {0},     0, 0, 0},
+   {"reader",          store_reader,  {0},     0, 0, 0},
+   {"writer",          store_writer,  {0},     0, 0, 0},
+   {"ignorecase",      store_opts,    {0},     0, 0, 0},
+   {"fstype",          store_fstype,  {0},     0, 0, 0},
+   {"hfsplussupport",  store_opts,    {0},     0, 0, 0},
+   {"noatime",         store_opts,    {0},     0, 0, 0},
+   {NULL, NULL, {0}, 0, 0, 0}
 };
 
 
index 08b95d485194dd35d49b4f7afe0e1e16035a7611..d81b00cd187a4c498f6a494078767bde565fa670 100644 (file)
 
 #include "bacula.h"
 
+/*
+ * If compatible is true, the bin_to_base64 routine will be compatible
+ * with what the rest of the world uses.  However, this would destroy
+ * existing database compatibility.
+ */
 const bool compatible = false;
 
 #ifdef TEST_MODE
@@ -144,9 +149,9 @@ bin_to_base64(char *buf, char *bin, int len)
       if (rem < 6) {
          reg <<= 8;
          if (compatible) {
-            reg |= (int8_t)bin[i++] & 0xFF;
+            reg |= (uint8_t)bin[i++];
          } else {
-           reg |= (int8_t)bin[i++];
+            reg |= (int8_t)bin[i++];
          }
          rem += 8;
       }
@@ -157,10 +162,14 @@ bin_to_base64(char *buf, char *bin, int len)
       rem -= 6;
    }
    if (rem) {
+#ifdef OLDxxxx
       mask = 1;
       for (i=1; i<rem; i++) {
          mask = (mask << 1) | 1;
       }
+#else 
+      mask = (1 << rem) - 1;
+#endif
       if (compatible) {
          buf[j++] = base64_digits[(reg & mask) << 6 - rem];
       } else {
index d17f76d16da6d6088bea28c53d61f8ec7b0ff175..17deac9d08f9d91e22bab12ab9d86c5c86d1af90 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 /*
-   Copyright (C) 2000-2005 Kern Sibbald
+   Copyright (C) 2000-2006 Kern Sibbald
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
@@ -22,4 +22,6 @@
  */
 
 /* Maximum size of len bytes after base64 encoding */
-#define BASE64_SIZE(len) (((len + 3 - (len % 3)) / 3) * 4)
+#define BASE64_SIZE(len) ((4 * len + 2) / 3 + 1)
+
+// #define BASE64_SIZE(len) (((len + 3 - (len % 3)) / 3) * 4)
index cf800e012faf6f90c4eb86c5809bf66cdce246c1..cc981403043b71ba077c78951013008da60914ab 100644 (file)
@@ -35,7 +35,7 @@
 #include "bacula.h"
 #include "bregex.h"
 
-#define set_error(x) bufp->errmsg=(x)
+#define set_error(x) bufp->errmsg=((char *)(x))
 #define got_error bufp->errmsg!=NULL
 
 /* The original code blithely assumed that sizeof(short) == 2.  Not
@@ -1037,7 +1037,7 @@ else \
    } \
 }
 
-char *re_compile_pattern(regex_t * bufp, unsigned char *regex)
+const char *re_compile_pattern(regex_t * bufp, unsigned char *regex)
 {
    int a;
    int pos;
index b2f3fabe36887ce54c7d1de74383ad9510f5574a..cfda3f0680e69757c24c626ea62c344a642bb2ef 100644 (file)
@@ -125,7 +125,7 @@ int re_set_syntax(int syntax);
 /* This sets the syntax to use and returns the previous syntax.  The
  * syntax is specified by a bit mask of the above defined bits. */
 
-char *re_compile_pattern(regex_t *compiled, unsigned char *regex);
+const char *re_compile_pattern(regex_t *compiled, unsigned char *regex);
 /* This compiles the regexp (given in regex and length in regex_size).
  * This returns NULL if the regexp compiled successfully, and an error
  * message if an error was encountered.  The buffer field must be
index 548ab97b2a6fbdb4ba562230f641f709ada893cd..5f4775fddbfe49ef3d045018a8e516a2d0a1d4d2 100644 (file)
@@ -367,7 +367,7 @@ void _v(char *file, int line, pthread_mutex_t *m)
 {
    int errstat;
 
-   if ((errstat=pthread_mutex_trylock(m)) == 0) {
+   if ((errstat=pthread_mutex_tryunlock(m)) == 0) {
       berrno be;
       e_msg(file, line, M_ERROR, 0, _("Mutex unlock not locked. ERR=%s\n"),
            be.strerror(errstat));
index 204a5b937d9aafc345d8418eb3d6f3e86596ff17..8e53477325662afbb9055fbbd7320c3f33b3973a 100755 (executable)
@@ -98,7 +98,7 @@ RES_ITEM msgs_items[] = {
    {"director",    store_msgs, ITEM(res_msgs), MD_DIRECTOR, 0, 0},
    {"console",     store_msgs, ITEM(res_msgs), MD_CONSOLE,  0, 0},
    {"operator",    store_msgs, ITEM(res_msgs), MD_OPERATOR, 0, 0},
-   {NULL, NULL,    NULL,       0,              0}
+   {NULL,          NULL,       {0},       0, 0, 0}
 };
 
 struct s_mtypes {
index eca7aaa35b23d4352831bb0e74e3f4c3200c4549..181d55343d0a0adc51cb65fdc252c15338507aaf 100644 (file)
@@ -17,6 +17,7 @@
  */
 
 struct RES_ITEM;                    /* Declare forward referenced structure */
+struct RES;                         /* Declare forware referenced structure */
 typedef void (MSG_RES_HANDLER)(LEX *lc, RES_ITEM *item, int index, int pass);
 
 /* This is the structure that defines
@@ -27,14 +28,25 @@ typedef void (MSG_RES_HANDLER)(LEX *lc, RES_ITEM *item, int index, int pass);
 struct RES_ITEM {
    const char *name;                  /* Resource name i.e. Director, ... */
    MSG_RES_HANDLER *handler;          /* Routine storing the resource item */
-   char **value;                      /* Where to store the item */
+   union {
+      char **value;                   /* Where to store the item */
+      char **charvalue;
+      uint32_t ui32value;
+      int32_t i32value;
+      uint64_t ui64value;
+      int64_t i64value;
+      bool boolvalue;
+      utime_t utimevalue;
+      RES *resvalue;
+      RES **presvalue;
+   };
    int  code;                         /* item code/additional info */
    int  flags;                        /* flags: default, required, ... */
    int  default_value;                /* default value */
 };
 
 /* For storing name_addr items in res_items table */
-#define ITEM(x) ((char **)&res_all.x)
+#define ITEM(x) {(char **)&res_all.x}
 
 #define MAX_RES_ITEMS 70              /* maximum resource items per RES */
 
index 3d4360850568af3fc9ac0ee3a08cf439dca09a5b..85538059d8c8aac45cbf07a40e0d09e57f396971 100644 (file)
 #ifndef __RUNSCRIPT_H_
 #define __RUNSCRIPT_H_ 1
 
-#if defined(FILE_DAEMON) || defined(DIRECTOR_DAEMON)
-# define USE_RUNSCRIPT
-#endif
-
-#ifdef USE_RUNSCRIPT
-
 /* Usage:
  *
  * #define USE_RUNSCRIPT
  * RUNSCRIPT->when can take following value : 
  */
 enum {
-   SCRIPT_Never  = 0,
-   SCRIPT_After  = 1,          /* AfterJob */
-   SCRIPT_Before = 2,          /* BeforeJob */
-   SCRIPT_Any    = 3                   /* Before and After */
+   SCRIPT_Never  = 1,
+   SCRIPT_After  = 2,           /* AfterJob */
+   SCRIPT_Before = 3,           /* BeforeJob */
+   SCRIPT_Any    = 4            /* Before and After */
 };
 
 /*
@@ -57,10 +51,10 @@ enum {
  */
 class RUNSCRIPT {
 public:
-   POOLMEM *command;           /* command string */
-   POOLMEM *target;            /* host target */
-   char level;                 /* Base|Full|Incr...|All (NYI) */
-   bool on_success;            /* executre command on job success (After) */
+   POOLMEM *command;            /* command string */
+   POOLMEM *target;             /* host target */
+   char level;                  /* Base|Full|Incr...|All (NYI) */
+   bool on_success;             /* executre command on job success (After) */
    bool on_failure;             /* executre command on job failure (After) */
    bool abort_on_error;         /* abort job on error (Before) */
    int  when;                   /* SCRIPT_Before|Script_After BEFORE/AFTER JOB*/
@@ -70,7 +64,7 @@ public:
    void set_command(const POOLMEM *cmd);
    void set_target(const POOLMEM *client_name);
    void reset_default(bool free_string = false);
-   bool is_local();            /* true if running on local host */
+   bool is_local();             /* true if running on local host */
    void debug();
 };
 
@@ -89,6 +83,4 @@ void free_runscript(RUNSCRIPT *script);
 /* foreach_alist free RUNSCRIPT */
 void free_runscripts(alist *runscripts); /* you have to free alist */
 
-#endif /* USE_RUNSCRIPT */
-
 #endif /* __RUNSCRIPT_H_ */
index b8890a26f143522c69136e4c4d8df065be031222..c7eaa5a0f6cd9b320dd956b960009e500ef6ad15 100644 (file)
@@ -9,7 +9,7 @@
  *
  */
 /*
-   Copyright (C) 2002-2005 Kern Sibbald
+   Copyright (C) 2002-2006 Kern Sibbald
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
@@ -25,6 +25,7 @@
 
 #include "bacula.h"
 #include "cats/cats.h"
+#include "lib/runscript.h"
 #include "dird/dird_conf.h"
 
 /* Dummy functions */
index d1d427ed80ee4a1750fa34f82c1c2b3fe73f94c9..8a5db7555edff59a542f16d21d7b642df28e281d 100644 (file)
@@ -3,9 +3,9 @@
  */
 
 #undef  VERSION
-#define VERSION "1.39.12"
-#define BDATE   "01 June 2006"
-#define LSMDATE "01Jun06"
+#define VERSION "1.39.14"
+#define BDATE   "22 June 2006"
+#define LSMDATE "22Jun06"
 
 /* Debug flags */
 #undef  DEBUG