X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fsrc%2Fcats%2Fbdb_update.c;h=bd891eba896db58b7e0e19f886456e1aafa55d64;hb=8e81c40b1346cdbfd0bbb5f7557e7cdb804a553f;hp=8b0f0ea2f503489f4838b80587f7423067a24d2e;hpb=f7fb2261ab648bfc02a32773b7a5a2201783e189;p=bacula%2Fbacula diff --git a/bacula/src/cats/bdb_update.c b/bacula/src/cats/bdb_update.c index 8b0f0ea2f5..bd891eba89 100755 --- a/bacula/src/cats/bdb_update.c +++ b/bacula/src/cats/bdb_update.c @@ -7,38 +7,45 @@ * The purpose of these routines is to ensure that Bacula * can limp along if no real database is loaded on the * system. - * - * Kern Sibbald, January MMI + * + * Kern Sibbald, January MMI * * * Version $Id$ */ - /* - Copyright (C) 2001, 2002 Kern Sibbald and John Walker + Bacula® - The Network Backup Solution + + Copyright (C) 2001-2006 Free Software Foundation Europe e.V. - 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. + The main author of Bacula is Kern Sibbald, with contributions from + many others, a complete list can be found in the file AUTHORS. + This program is Free Software; you can redistribute it and/or + modify it under the terms of version two of the GNU General Public + License as published by the Free Software Foundation plus additions + that are listed in the file LICENSE. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of + 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. + 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., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. - */ + Bacula® is a registered trademark of John Walker. + The licensor of Bacula is the Free Software Foundation Europe + (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, + Switzerland, email:ftf@fsfeurope.org. +*/ /* 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" @@ -46,8 +53,6 @@ #ifdef HAVE_BACULA_DB -/* Forward referenced functions */ - /* ----------------------------------------------------------------------- * * Bacula specific defines and subroutines @@ -61,24 +66,26 @@ * most current start fields to the job record. * It is assumed that you did a db_create_job_record() already. */ -int db_update_job_start_record(B_DB *mdb, JOB_DBR *jr) +bool db_update_job_start_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr) { - int len, stat; + int len, stat = 1; JOB_DBR ojr; + db_lock(mdb); + Dmsg0(200, "In db_update_job_start_record\n"); len = sizeof(ojr); memcpy(&ojr, jr, len); - if (!db_get_job_record(mdb, &ojr)) { + if (!db_get_job_record(jcr, mdb, &ojr)) { + db_unlock(mdb); return 0; } - db_lock(mdb); fseek(mdb->jobfd, ojr.rec_addr, SEEK_SET); if (fwrite(jr, len, 1, mdb->jobfd) != 1) { - Mmsg1(&mdb->errmsg, _("Error updating DB Job file. ERR=%s\n"), strerror(errno)); + Mmsg1(mdb->errmsg, _("Error updating DB Job file. ERR=%s\n"), strerror(errno)); stat = 0; } fflush(mdb->jobfd); @@ -91,21 +98,22 @@ int db_update_job_start_record(B_DB *mdb, JOB_DBR *jr) * This is called at Job termination time to add all the * other fields to the job record. */ -int db_update_job_end_record(B_DB *mdb, JOB_DBR *jr) +int db_update_job_end_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr) { - int len, stat; + int len, stat = 1; JOB_DBR ojr; + db_lock(mdb); + Dmsg0(200, "In db_update_job_start_record\n"); len = sizeof(ojr); memcpy(&ojr, jr, len); - if (!db_get_job_record(mdb, &ojr)) { + if (!db_get_job_record(jcr, mdb, &ojr)) { + db_unlock(mdb); return 0; } - db_lock(mdb); - fseek(mdb->jobfd, ojr.rec_addr, SEEK_SET); if (fwrite(jr, len, 1, mdb->jobfd) != 1) { Mmsg1(&mdb->errmsg, _("Error updating DB Job file. ERR=%s\n"), strerror(errno)); @@ -118,35 +126,36 @@ int db_update_job_end_record(B_DB *mdb, JOB_DBR *jr) } -int db_update_media_record(B_DB *mdb, MEDIA_DBR *mr) -{ +int db_update_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) +{ int stat = 1; MEDIA_DBR omr; int len; - + + db_lock(mdb); Dmsg0(200, "In db_update_media_record\n"); mr->MediaId = 0; len = sizeof(omr); memcpy(&omr, mr, len); - if (!db_get_media_record(mdb, &omr)) { + if (!db_get_media_record(jcr, mdb, &omr)) { + db_unlock(mdb); return 0; } - db_lock(mdb); /* Don't allow some fields to change by copying from master record */ strcpy(mr->VolumeName, omr.VolumeName); strcpy(mr->MediaType, omr.MediaType); mr->MediaId = omr.MediaId; mr->PoolId = omr.PoolId; - mr->VolMaxBytes = omr.VolMaxBytes; + mr->MaxVolBytes = omr.MaxVolBytes; mr->VolCapacityBytes = omr.VolCapacityBytes; mr->Recycle = omr.Recycle; fseek(mdb->mediafd, omr.rec_addr, SEEK_SET); if (fwrite(mr, len, 1, mdb->mediafd) != 1) { - Mmsg1(&mdb->errmsg, _("Error updating DB Media file. ERR=%s\n"), strerror(errno)); + Mmsg1(mdb->errmsg, _("Error updating DB Media file. ERR=%s\n"), strerror(errno)); stat = 0; } fflush(mdb->mediafd); @@ -155,25 +164,26 @@ int db_update_media_record(B_DB *mdb, MEDIA_DBR *mr) return stat; } -int db_update_pool_record(B_DB *mdb, POOL_DBR *pr) -{ +int db_update_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr) +{ int stat = 1; POOL_DBR opr; int len; - + + db_lock(mdb); Dmsg0(200, "In db_update_pool_record\n"); len = sizeof(opr); memcpy(&opr, pr, len); - if (!db_get_pool_record(mdb, &opr)) { + if (!db_get_pool_record(jcr, mdb, &opr)) { + db_unlock(mdb); return 0; } - db_lock(mdb); /* Update specific fields */ opr.NumVols = pr->NumVols; - opr.MaxVols = pr->MaxVols; + opr.MaxVols = pr->MaxVols; opr.UseOnce = pr->UseOnce; opr.UseCatalog = pr->UseCatalog; opr.AcceptAnyVolume = pr->AcceptAnyVolume; @@ -181,10 +191,10 @@ int db_update_pool_record(B_DB *mdb, POOL_DBR *pr) fseek(mdb->poolfd, opr.rec_addr, SEEK_SET); if (fwrite(&opr, len, 1, mdb->poolfd) != 1) { - Mmsg1(&mdb->errmsg, _("Error updating DB Media file. ERR=%s\n"), strerror(errno)); + 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); @@ -192,15 +202,34 @@ int db_update_pool_record(B_DB *mdb, POOL_DBR *pr) return stat; } -int db_add_MD5_to_file_record(B_DB *mdb, FileId_t FileId, char *MD5) +int db_add_digest_to_file_record(JCR *jcr, B_DB *mdb, FileId_t FileId, char *digest, int type) { return 1; } -int db_mark_file_record(B_DB *mdb, FileId_t FileId, int JobId) -{ +int db_mark_file_record(JCR *jcr, B_DB *mdb, FileId_t FileId, JobId_t JobId) +{ return 1; } +int db_update_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cr) +{ + return 1; +} + +int db_update_counter_record(JCR *jcr, B_DB *mdb, COUNTER_DBR *cr) +{ + return 0; +} + +int db_update_media_defaults(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) +{ + return 1; +} + +void db_make_inchanger_unique(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) +{ + return; +} #endif /* HAVE_BACULA_DB */