From a8e1c11c4c977216f7eae556a688107f3797faa3 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Thu, 22 Jun 2006 09:55:43 +0000 Subject: [PATCH] - 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. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@3064 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/kes-1.39 | 20 ++++ bacula/src/cats/bdb.c | 2 +- bacula/src/cats/bdb_create.c | 33 +++--- bacula/src/cats/bdb_delete.c | 23 ++-- bacula/src/cats/bdb_find.c | 18 +-- bacula/src/cats/bdb_get.c | 18 +-- bacula/src/cats/bdb_list.c | 121 ++++++++++---------- bacula/src/cats/bdb_update.c | 21 ++-- bacula/src/cats/cats.h | 39 ++----- bacula/src/cats/make_mysql_tables.in | 21 ++-- bacula/src/cats/make_postgresql_tables.in | 17 +-- bacula/src/cats/make_sqlite3_tables.in | 24 ++-- bacula/src/cats/make_sqlite_tables.in | 23 ++-- bacula/src/cats/protos.h | 2 - bacula/src/cats/sql.c | 17 +-- bacula/src/cats/sql_create.c | 75 +++--------- bacula/src/cats/sql_delete.c | 53 ++++----- bacula/src/cats/sql_get.c | 48 +------- bacula/src/cats/sql_list.c | 4 +- bacula/src/cats/sql_update.c | 28 ++++- bacula/src/cats/update_mysql_tables.in | 17 +-- bacula/src/cats/update_postgresql_tables.in | 21 ++-- bacula/src/cats/update_sqlite3_tables.in | 81 +++++++++++-- bacula/src/cats/update_sqlite_tables.in | 81 +++++++++++-- bacula/src/dird/catreq.c | 3 +- bacula/src/dird/dird.h | 2 +- bacula/src/dird/dird_conf.c | 97 ++++++++-------- bacula/src/dird/dird_conf.h | 3 +- bacula/src/dird/inc_conf.c | 62 +++++----- bacula/src/lib/base64.c | 13 ++- bacula/src/lib/base64.h | 6 +- bacula/src/lib/bregex.c | 4 +- bacula/src/lib/bregex.h | 2 +- bacula/src/lib/bsys.c | 2 +- bacula/src/lib/parse_conf.c | 2 +- bacula/src/lib/parse_conf.h | 16 ++- bacula/src/lib/runscript.h | 26 ++--- bacula/src/tools/dbcheck.c | 3 +- bacula/src/version.h | 6 +- 39 files changed, 529 insertions(+), 525 deletions(-) diff --git a/bacula/kes-1.39 b/bacula/kes-1.39 index d01f665beb..8570c3da75 100644 --- a/bacula/kes-1.39 +++ b/bacula/kes-1.39 @@ -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. diff --git a/bacula/src/cats/bdb.c b/bacula/src/cats/bdb.c index 69aaac86be..a0836efc9f 100644 --- a/bacula/src/cats/bdb.c +++ b/bacula/src/cats/bdb.c @@ -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 diff --git a/bacula/src/cats/bdb_create.c b/bacula/src/cats/bdb_create.c index c9d9d9bbc7..3228d42e08 100644 --- a/bacula/src/cats/bdb_create.c +++ b/bacula/src/cats/bdb_create.c @@ -14,22 +14,17 @@ */ /* - 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) { diff --git a/bacula/src/cats/bdb_delete.c b/bacula/src/cats/bdb_delete.c index 3e3915a8d3..125a777c58 100644 --- a/bacula/src/cats/bdb_delete.c +++ b/bacula/src/cats/bdb_delete.c @@ -14,22 +14,17 @@ */ /* - 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); diff --git a/bacula/src/cats/bdb_find.c b/bacula/src/cats/bdb_find.c index e79b6ad95c..6c5bd3b117 100644 --- a/bacula/src/cats/bdb_find.c +++ b/bacula/src/cats/bdb_find.c @@ -16,24 +16,18 @@ * * 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. */ diff --git a/bacula/src/cats/bdb_get.c b/bacula/src/cats/bdb_get.c index 0e27befdef..8fd20b0fa3 100644 --- a/bacula/src/cats/bdb_get.c +++ b/bacula/src/cats/bdb_get.c @@ -15,24 +15,18 @@ * * 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. */ diff --git a/bacula/src/cats/bdb_list.c b/bacula/src/cats/bdb_list.c index 82238c77da..902739c7a3 100644 --- a/bacula/src/cats/bdb_list.c +++ b/bacula/src/cats/bdb_list.c @@ -14,22 +14,17 @@ */ /* - 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 diff --git a/bacula/src/cats/bdb_update.c b/bacula/src/cats/bdb_update.c index 7b1f054f8d..35fa610a89 100755 --- a/bacula/src/cats/bdb_update.c +++ b/bacula/src/cats/bdb_update.c @@ -15,22 +15,17 @@ */ /* - 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); diff --git a/bacula/src/cats/cats.h b/bacula/src/cats/cats.h index 25d5b53ea4..598d514a05 100644 --- a/bacula/src/cats/cats.h +++ b/bacula/src/cats/cats.h @@ -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 diff --git a/bacula/src/cats/make_mysql_tables.in b/bacula/src/cats/make_mysql_tables.in index 549282b4ce..1baf407e19 100644 --- a/bacula/src/cats/make_mysql_tables.in +++ b/bacula/src/cats/make_mysql_tables.in @@ -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, diff --git a/bacula/src/cats/make_postgresql_tables.in b/bacula/src/cats/make_postgresql_tables.in index c169ebf280..13d14d4255 100644 --- a/bacula/src/cats/make_postgresql_tables.in +++ b/bacula/src/cats/make_postgresql_tables.in @@ -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, diff --git a/bacula/src/cats/make_sqlite3_tables.in b/bacula/src/cats/make_sqlite3_tables.in index da180cf7dc..a70a8fcc95 100644 --- a/bacula/src/cats/make_sqlite3_tables.in +++ b/bacula/src/cats/make_sqlite3_tables.in @@ -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, diff --git a/bacula/src/cats/make_sqlite_tables.in b/bacula/src/cats/make_sqlite_tables.in index 431447d052..a70a8fcc95 100644 --- a/bacula/src/cats/make_sqlite_tables.in +++ b/bacula/src/cats/make_sqlite_tables.in @@ -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, diff --git a/bacula/src/cats/protos.h b/bacula/src/cats/protos.h index 464af82d1b..fd3aa6d818 100644 --- a/bacula/src/cats/protos.h +++ b/bacula/src/cats/protos.h @@ -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); diff --git a/bacula/src/cats/sql.c b/bacula/src/cats/sql.c index 933c96663a..9844f1458f 100644 --- a/bacula/src/cats/sql.c +++ b/bacula/src/cats/sql.c @@ -10,22 +10,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. */ diff --git a/bacula/src/cats/sql_create.c b/bacula/src/cats/sql_create.c index d8cca379fe..f42f2cd3d3 100644 --- a/bacula/src/cats/sql_create.c +++ b/bacula/src/cats/sql_create.c @@ -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 ); diff --git a/bacula/src/cats/sql_delete.c b/bacula/src/cats/sql_delete.c index e03cf5cdaf..c4641ff4f6 100644 --- a/bacula/src/cats/sql_delete.c +++ b/bacula/src/cats/sql_delete.c @@ -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"); diff --git a/bacula/src/cats/sql_get.c b/bacula/src/cats/sql_get.c index f2bd3d9dd9..567a18cd13 100644 --- a/bacula/src/cats/sql_get.c +++ b/bacula/src/cats/sql_get.c @@ -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; } diff --git a/bacula/src/cats/sql_list.c b/bacula/src/cats/sql_list.c index c1b451e319..f61e751e30 100644 --- a/bacula/src/cats/sql_list.c +++ b/bacula/src/cats/sql_list.c @@ -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"); } diff --git a/bacula/src/cats/sql_update.c b/bacula/src/cats/sql_update.c index e757bdcdaa..c7cd9c80ed 100644 --- a/bacula/src/cats/sql_update.c +++ b/bacula/src/cats/sql_update.c @@ -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); diff --git a/bacula/src/cats/update_mysql_tables.in b/bacula/src/cats/update_mysql_tables.in index b43dd28aed..a892e392d0 100755 --- a/bacula/src/cats/update_mysql_tables.in +++ b/bacula/src/cats/update_mysql_tables.in @@ -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) ); diff --git a/bacula/src/cats/update_postgresql_tables.in b/bacula/src/cats/update_postgresql_tables.in index 92fd0c1be4..b99f1fa056 100755 --- a/bacula/src/cats/update_postgresql_tables.in +++ b/bacula/src/cats/update_postgresql_tables.in @@ -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) ); diff --git a/bacula/src/cats/update_sqlite3_tables.in b/bacula/src/cats/update_sqlite3_tables.in index f09d226bc0..802a6b5f49 100755 --- a/bacula/src/cats/update_sqlite3_tables.in +++ b/bacula/src/cats/update_sqlite3_tables.in @@ -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) ); diff --git a/bacula/src/cats/update_sqlite_tables.in b/bacula/src/cats/update_sqlite_tables.in index f09d226bc0..802a6b5f49 100755 --- a/bacula/src/cats/update_sqlite_tables.in +++ b/bacula/src/cats/update_sqlite_tables.in @@ -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) ); diff --git a/bacula/src/dird/catreq.c b/bacula/src/dird/catreq.c index 8477d8bbc8..06ed35937b 100644 --- a/bacula/src/dird/catreq.c +++ b/bacula/src/dird/catreq.c @@ -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; diff --git a/bacula/src/dird/dird.h b/bacula/src/dird/dird.h index ce83228b70..ab6995306e 100644 --- a/bacula/src/dird/dird.h +++ b/bacula/src/dird/dird.h @@ -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 */ diff --git a/bacula/src/dird/dird_conf.c b/bacula/src/dird/dird_conf.c index b67f780962..77f59a8853 100644 --- a/bacula/src/dird/dird_conf.c +++ b/bacula/src/dird/dird_conf.c @@ -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(); diff --git a/bacula/src/dird/dird_conf.h b/bacula/src/dird/dird_conf.h index 3b67dbb06e..0108c6a997 100644 --- a/bacula/src/dird/dird_conf.h +++ b/bacula/src/dird/dird_conf.h @@ -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; }; diff --git a/bacula/src/dird/inc_conf.c b/bacula/src/dird/inc_conf.c index cff0e26884..dff8eae194 100644 --- a/bacula/src/dird/inc_conf.c +++ b/bacula/src/dird/inc_conf.c @@ -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} }; diff --git a/bacula/src/lib/base64.c b/bacula/src/lib/base64.c index 08b95d4851..d81b00cd18 100644 --- a/bacula/src/lib/base64.c +++ b/bacula/src/lib/base64.c @@ -23,6 +23,11 @@ #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; ierrmsg=(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; diff --git a/bacula/src/lib/bregex.h b/bacula/src/lib/bregex.h index b2f3fabe36..cfda3f0680 100644 --- a/bacula/src/lib/bregex.h +++ b/bacula/src/lib/bregex.h @@ -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 diff --git a/bacula/src/lib/bsys.c b/bacula/src/lib/bsys.c index 548ab97b2a..5f4775fddb 100644 --- a/bacula/src/lib/bsys.c +++ b/bacula/src/lib/bsys.c @@ -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)); diff --git a/bacula/src/lib/parse_conf.c b/bacula/src/lib/parse_conf.c index 204a5b937d..8e53477325 100755 --- a/bacula/src/lib/parse_conf.c +++ b/bacula/src/lib/parse_conf.c @@ -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 { diff --git a/bacula/src/lib/parse_conf.h b/bacula/src/lib/parse_conf.h index eca7aaa35b..181d55343d 100644 --- a/bacula/src/lib/parse_conf.h +++ b/bacula/src/lib/parse_conf.h @@ -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 */ diff --git a/bacula/src/lib/runscript.h b/bacula/src/lib/runscript.h index 3d43608505..85538059d8 100644 --- a/bacula/src/lib/runscript.h +++ b/bacula/src/lib/runscript.h @@ -22,12 +22,6 @@ #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 @@ -46,10 +40,10 @@ * 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_ */ diff --git a/bacula/src/tools/dbcheck.c b/bacula/src/tools/dbcheck.c index b8890a26f1..c7eaa5a0f6 100644 --- a/bacula/src/tools/dbcheck.c +++ b/bacula/src/tools/dbcheck.c @@ -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 */ diff --git a/bacula/src/version.h b/bacula/src/version.h index d1d427ed80..8a5db7555e 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -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 -- 2.39.5