From: <gi...@ba...> - 2011-06-04 18:53:53
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Bacula Community source". The branch, Branch-5.1 has been updated via 7e58c1e710df8f6504980b6603a0a573ebebc55e (commit) via 5970a2bb8904379d68aeea05e95712e0ca82f765 (commit) via 2387de8e29153bddd7f1a9161db428a8980c92aa (commit) via ffe853f6e0325ede3ef66b5ab3157dd90b3c2c85 (commit) via 87ddd59407933eebc3654d1559ef181735407374 (commit) via 348fe32002af64ee164bce518001e7f8b5bcee38 (commit) via 199a23208d36618d8b705e73b4fed358785a5d63 (commit) via e13ca67c023f30b603d72e7eb3b3562955d12f4e (commit) via 27084e2de2cd39636bdc353866d25a99086fba18 (commit) via 00eb3592cd917051f0fb3d17ce9994a9f9f01f28 (commit) via d81e32a49f8d2d533f61889018bd6188616f5ff8 (commit) via 932c49b125af866356f10856d595148a56ddf178 (commit) via f885cad60697406ff5af6b7aeccf6117d10e8f49 (commit) via aedd1c1a39c5e72b453bf468b4ace9e31770b26e (commit) via 21e7594813f2e7c9cc4ae3b260f9290754570adb (commit) via ffc8b93e0daf105276e595a2293cb079cd668df9 (commit) via b0683dffe5c2d2bcaa85ee2718f6ae3672afd048 (commit) from 53feb70edf05df1349a4b8fc9956135608d643df (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 7e58c1e710df8f6504980b6603a0a573ebebc55e Author: Kern Sibbald <ke...@si...> Date: Sat Jun 4 20:53:58 2011 +0200 Remove broken code commit 5970a2bb8904379d68aeea05e95712e0ca82f765 Author: Marco van Wieringen <mv...@pl...> Date: Fri Jun 3 22:03:43 2011 +0200 Fix small memory leak when job get canceled. commit 2387de8e29153bddd7f1a9161db428a8980c92aa Author: Marco van Wieringen <mv...@pl...> Date: Wed Jun 1 20:56:07 2011 +0200 Fix small memory leak in dbcheck not calling free_pool_memory for name variable. commit ffe853f6e0325ede3ef66b5ab3157dd90b3c2c85 Author: Marco van Wieringen <mv...@pl...> Date: Wed Jun 1 10:46:17 2011 +0200 Remove global variable shadowing by local variable. commit 87ddd59407933eebc3654d1559ef181735407374 Author: Marco van Wieringen <mv...@pl...> Date: Tue May 31 19:07:35 2011 +0200 Fix dbcheck to use the new runtime checks for mysql and not compile time. commit 348fe32002af64ee164bce518001e7f8b5bcee38 Author: Marco van Wieringen <mv...@pl...> Date: Tue May 31 19:00:08 2011 +0200 Tweak layout and redo comments. commit 199a23208d36618d8b705e73b4fed358785a5d63 Author: Marco van Wieringen <mv...@pl...> Date: Tue May 31 18:39:53 2011 +0200 Restore db_type printing to dbcheck -B commit e13ca67c023f30b603d72e7eb3b3562955d12f4e Author: Eric Bollengier <er...@eb...> Date: Mon May 30 20:34:40 2011 +0200 Fix unitialized DeltaSeq during Verify jobs commit 27084e2de2cd39636bdc353866d25a99086fba18 Author: Kern Sibbald <ke...@si...> Date: Mon May 30 12:14:17 2011 +0200 Make delta_seq same size as in other places commit 00eb3592cd917051f0fb3d17ce9994a9f9f01f28 Author: Kern Sibbald <ke...@si...> Date: Mon May 30 12:03:07 2011 +0200 Remove broken code commit d81e32a49f8d2d533f61889018bd6188616f5ff8 Author: Eric Bollengier <er...@eb...> Date: Mon May 16 18:53:25 2011 +0200 Add db_strtime_handler to get DATE fields from database commit 932c49b125af866356f10856d595148a56ddf178 Author: Marco van Wieringen <mv...@pl...> Date: Mon May 16 17:24:18 2011 +0200 Drop AFS detection. commit f885cad60697406ff5af6b7aeccf6117d10e8f49 Author: Marco van Wieringen <mv...@pl...> Date: Mon May 16 15:43:29 2011 +0200 AC_CHECK_DECL doesn't seem to work so lets do it somewhat differently. commit aedd1c1a39c5e72b453bf468b4ace9e31770b26e Author: Marco van Wieringen <mv...@pl...> Date: Sat May 14 17:16:28 2011 +0200 Fix typo commit 21e7594813f2e7c9cc4ae3b260f9290754570adb Author: Marco van Wieringen <mv...@pl...> Date: Fri May 13 23:06:10 2011 +0200 Cleanup code path for acl and count number of acl entries so we only save real acls. commit ffc8b93e0daf105276e595a2293cb079cd668df9 Author: Marco van Wieringen <mv...@pl...> Date: Fri May 13 19:55:53 2011 +0200 First attempt at fixing bug #1735 where acls on OSX doesn't seem to reach the backup. commit b0683dffe5c2d2bcaa85ee2718f6ae3672afd048 Author: Marco van Wieringen <mv...@pl...> Date: Tue May 10 13:59:35 2011 +0200 Drop old unused protypes from before backend refactoring. ----------------------------------------------------------------------- Summary of changes: diff --git a/bacula/autoconf/config.h.in b/bacula/autoconf/config.h.in index 2b4f018..caa6daa 100644 --- a/bacula/autoconf/config.h.in +++ b/bacula/autoconf/config.h.in @@ -114,12 +114,6 @@ /* Define if you have zlib */ #undef HAVE_LIBZ -/* Define if you have libacl */ -#undef HAVE_ACL - -/* Define if you have AFS acls */ -#undef HAVE_AFS_ACL - /* General libs */ #undef LIBS @@ -227,6 +221,18 @@ /* Normal acl support */ #undef HAVE_ACL +/* Defines if your system have the ACL_TYPE_DEFAULT_DIR acl type */ +#undef HAVE_ACL_TYPE_DEFAULT_DIR + +/* Defines if your system have the ACL_TYPE_EXTENDED acl type */ +#undef HAVE_ACL_TYPE_EXTENDED + +/* Defines if your system have the ACL_TYPE_NFS4 acl type */ +#undef HAVE_ACL_TYPE_NFS4 + +/* Define to 1 if you have the 'add_proplist_entry' function. */ +#undef HAVE_ADD_PROPLIST_ENTRY + /* Defines if your system has AFS support */ #undef HAVE_AFS diff --git a/bacula/autoconf/configure.in b/bacula/autoconf/configure.in index bbcd0e2..d84e6c4 100644 --- a/bacula/autoconf/configure.in +++ b/bacula/autoconf/configure.in @@ -2496,82 +2496,6 @@ fi AC_SUBST(ZLIBS) dnl -dnl Check if we have AFS on this system -dnl -AFS_CFLAGS="" -AFS_LIBS="" -support_afs=auto -AC_ARG_ENABLE(afs, - AC_HELP_STRING([--disable-afs], [disable afs support @<:@default=auto@:>@]), - [ - if test x$enableval = xyes; then - support_afs=yes - elif test x$enableval = xno; then - support_afs=no - fi - ] -) - -have_afs=no -if test x$support_afs = xyes -o x$support_afs = xauto; then - AC_ARG_WITH(afsdir, - AC_HELP_STRING([--with-afsdir@<:@=DIR@:>@], [Directory holding AFS includes/libs]), - with_afsdir=$withval - ) - - dnl - dnl Search in standard places, or --with-afsdir not specified - dnl - if test x$with_afsdir = x; then - for root in /usr /usr/local; do - if test -d ${root}/include/afs/ ; then - with_afsdir=${root} - break - fi - done - fi - - AFS_CFLAGS="-I${with_afsdir}/include" - - saved_CFLAGS="${CFLAGS}" - CFLAGS="${AFS_CFLAGS} ${saved_CFLAGS}" - - AC_CHECK_HEADERS(afs/stds.h) - - CFLAGS="${saved_CFLAGS}" - - dnl - dnl See if we can find a libsys with the pioctl symbol in there - dnl - for dir in ${with_afsdir}/lib ${with_afsdir}/lib/afs - do - for arch_type in .a .so - do - A=`test -f ${dir}/libsys${arch_type} && nm ${dir}/libsys${arch_type} | grep pioctl` - pkg=$? - if test $pkg = 0; then - have_afs=yes - AFS_LIBS="-L${dir} -lsys -lrx -llwp ${dir}/util.a" - break - fi - done - done - - if test x$support_afs = xyes -a $have_afs != yes; then - AC_MSG_ERROR([afs support explicitly enabled but no supported afs implementation found, - please either load the afs libraries or rerun configure without --enable-afs]) - else - if test $have_afs = yes; then - AC_DEFINE([HAVE_AFS],1,[Defines if your system has AFS support]) - AC_DEFINE([HAVE_AFS_ACL],1,[Andrew FileSystem ACL support]) - fi - fi -fi - -AC_SUBST(AFS_CFLAGS) -AC_SUBST(AFS_LIBS) - -dnl dnl Check for ACL support and libraries dnl support_acl=auto @@ -2625,14 +2549,55 @@ if test x$support_acl = xyes -o x$support_acl = xauto; then dnl dnl Check for acl_get_file in libpacl (OSF1) + dnl and if ACL_TYPE_DEFAULT_DIR is defined. dnl - if test $have_acl = no; then + if test $have_acl = no -a \ + x${HAVE_OSF1_OS_TRUE} = x; then AC_CHECK_LIB(pacl, acl_get_file, [ have_acl=yes FDLIBS="-lpacl $FDLIBS" ] ) + + AC_MSG_CHECKING(for ACL_TYPE_DEFAULT_DIR in acl.h include file) + grep ACL_TYPE_DEFAULT_DIR /usr/include/sys/acl.h > /dev/null 2>&1 + if test $? = 0; then + AC_DEFINE(HAVE_ACL_TYPE_DEFAULT_DIR,1,[Defines if your system have the ACL_TYPE_DEFAULT_DIR acl type]) + AC_MSG_RESULT(yes) + else + AC_MSG_RESULT(no) + fi + fi + + dnl + dnl On OSX check for availability of ACL_TYPE_EXTENDED + dnl + if test $have_acl = yes -a \ + x${HAVE_DARWIN_OS_TRUE} = x; then + AC_MSG_CHECKING(for ACL_TYPE_EXTENDED in acl.h include file) + grep ACL_TYPE_EXTENDED /usr/include/sys/acl.h > /dev/null 2>&1 + if test $? = 0; then + AC_DEFINE(HAVE_ACL_TYPE_EXTENDED,1,[Defines if your system have the ACL_TYPE_EXTENDED acl type]) + AC_MSG_RESULT(yes) + else + AC_MSG_RESULT(no) + fi + fi + + dnl + dnl On FreeBSD check for availability of ACL_TYPE_NFS4 + dnl + if test $have_acl = yes -a \ + x${HAVE_FREEBSD_OS_TRUE} = x; then + AC_MSG_CHECKING(for ACL_TYPE_NFS4 in acl.h include file) + grep ACL_TYPE_NFS4 /usr/include/sys/acl.h > /dev/null 2>&1 + if test $? = 0; then + AC_DEFINE(HAVE_ACL_TYPE_NFS4,1,[Defines if your system have the ACL_TYPE_NFS4 acl type]) + AC_MSG_RESULT(yes) + else + AC_MSG_RESULT(no) + fi fi dnl diff --git a/bacula/src/cats/protos.h b/bacula/src/cats/protos.h index 0c82468..a6777a4 100644 --- a/bacula/src/cats/protos.h +++ b/bacula/src/cats/protos.h @@ -44,6 +44,7 @@ bool db_open_batch_connexion(JCR *jcr, B_DB *mdb); char *db_strerror(B_DB *mdb); int db_int64_handler(void *ctx, int num_fields, char **row); +int db_strtime_handler(void *ctx, int num_fields, char **row); int db_list_handler(void *ctx, int num_fields, char **row); void db_debug_print(JCR *jcr, FILE *fp); int db_int_handler(void *ctx, int num_fields, char **row); @@ -63,9 +64,6 @@ bool db_create_device_record(JCR *jcr, B_DB *mdb, DEVICE_DBR *dr); bool db_create_storage_record(JCR *jcr, B_DB *mdb, STORAGE_DBR *sr); bool db_create_mediatype_record(JCR *jcr, B_DB *mdb, MEDIATYPE_DBR *mr); bool db_write_batch_file_records(JCR *jcr); -bool my_batch_start(JCR *jcr, B_DB *mdb); -bool my_batch_end(JCR *jcr, B_DB *mdb, const char *error); -bool my_batch_insert(JCR *jcr, B_DB *mdb, ATTR_DBR *ar); bool db_create_attributes_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar); bool db_create_restore_object_record(JCR *jcr, B_DB *mdb, ROBJECT_DBR *ar); bool db_create_base_file_attributes_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar); diff --git a/bacula/src/cats/sql.c b/bacula/src/cats/sql.c index 3bb8a9c..e4f88f6 100644 --- a/bacula/src/cats/sql.c +++ b/bacula/src/cats/sql.c @@ -100,6 +100,21 @@ int db_int64_handler(void *ctx, int num_fields, char **row) } /* + * Called here to retrieve a btime from the database. + * The returned integer will be extended to 64 bit. + */ +int db_strtime_handler(void *ctx, int num_fields, char **row) +{ + db_int64_ctx *lctx = (db_int64_ctx *)ctx; + + if (row[0]) { + lctx->value = str_to_utime(row[0]); + lctx->count++; + } + return 0; +} + +/* * Use to build a comma separated list of values from a query. "10,20,30" */ int db_list_handler(void *ctx, int num_fields, char **row) diff --git a/bacula/src/dird/backup.c b/bacula/src/dird/backup.c index cb7e917..d533cf2 100644 --- a/bacula/src/dird/backup.c +++ b/bacula/src/dird/backup.c @@ -246,7 +246,7 @@ bool send_accurate_current_files(JCR *jcr) if (jcr->is_canceled() || jcr->is_JobLevel(L_BASE)) { return true; } - if (!jcr->accurate && !jcr->rerunning) { + if (!jcr->accurate) { return true; } @@ -255,7 +255,7 @@ bool send_accurate_current_files(JCR *jcr) if (get_base_jobids(jcr, &jobids)) { jcr->HasBase = true; Jmsg(jcr, M_INFO, 0, _("Using BaseJobId(s): %s\n"), jobids.list); - } else if (!jcr->rerunning) { + } else { return true; } } else { @@ -269,12 +269,6 @@ bool send_accurate_current_files(JCR *jcr) } } - /* For incomplete Jobs, we add our own id */ - if (jcr->rerunning) { - edit_int64(jcr->JobId, ed1); - jobids.add(ed1); - } - /* Don't send and store the checksum if fileset doesn't require it */ jcr->use_accurate_chksum = is_checksum_needed_by_fileset(jcr); @@ -332,13 +326,8 @@ bool do_backup(JCR *jcr) } /* Print Job Start message */ - if (jcr->rerunning) { - Jmsg(jcr, M_INFO, 0, _("Restart Incomplete Backup JobId %s, Job=%s\n"), - edit_uint64(jcr->JobId, ed1), jcr->Job); - } else { - Jmsg(jcr, M_INFO, 0, _("Start Backup JobId %s, Job=%s\n"), - edit_uint64(jcr->JobId, ed1), jcr->Job); - } + Jmsg(jcr, M_INFO, 0, _("Start Backup JobId %s, Job=%s\n"), + edit_uint64(jcr->JobId, ed1), jcr->Job); jcr->setJobStatus(JS_Running); Dmsg2(100, "JobId=%d JobLevel=%c\n", jcr->jr.JobId, jcr->jr.JobLevel); @@ -347,35 +336,6 @@ bool do_backup(JCR *jcr) return false; } - /* For incomplete Jobs, we add our own id */ - if (jcr->rerunning) { - edit_int64(jcr->JobId, ed1); - Mmsg(buf, "SELECT max(FileIndex) FROM File WHERE JobId=%s", ed1); - if (db_sql_query(jcr->db, buf.c_str(), db_int64_handler, &job)) { - Jmsg(jcr, M_INFO, 0, _("Found %ld files from prior incomplete Job.\n"), - (int32_t)job.value); - } else { - Jmsg(jcr, M_FATAL, 0, "%s", db_strerror(jcr->db)); - return false; - } - jcr->JobFiles = job.value; - Dmsg1(100, "==== FI=%ld\n", jcr->JobFiles); - Mmsg(buf, "SELECT VolSessionId FROM Job WHERE JobId=%s", ed1); - if (!db_sql_query(jcr->db, buf.c_str(), db_int64_handler, &job)) { - Jmsg(jcr, M_FATAL, 0, "%s", db_strerror(jcr->db)); - return false; - } - jcr->VolSessionId = job.value; - Mmsg(buf, "SELECT VolSessionTime FROM Job WHERE JobId=%s", ed1); - if (!db_sql_query(jcr->db, buf.c_str(), db_int64_handler, &job)) { - Jmsg(jcr, M_FATAL, 0, "%s", db_strerror(jcr->db)); - return false; - } - jcr->VolSessionTime = job.value; - Dmsg4(100, "JobId=%s JobFiles=%ld VolSessionId=%ld VolSessionTime=%ld\n", ed1, - jcr->JobFiles, jcr->VolSessionId, jcr->VolSessionTime); - } - /* * Open a message channel connection with the Storage * daemon. This is to let him know that our client diff --git a/bacula/src/dird/dird_conf.c b/bacula/src/dird/dird_conf.c index b9505a0..c88fb88 100644 --- a/bacula/src/dird/dird_conf.c +++ b/bacula/src/dird/dird_conf.c @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2000-2010 Free Software Foundation Europe e.V. + Copyright (C) 2000-2011 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -328,7 +328,6 @@ RES_ITEM job_items[] = { {"clientrunafterjob", store_short_runscript, ITEM(res_job.RunScripts), 0, 0, 0}, {"maximumconcurrentjobs", store_pint32, ITEM(res_job.MaxConcurrentJobs), 0, ITEM_DEFAULT, 1}, {"rescheduleonerror", store_bool, ITEM(res_job.RescheduleOnError), 0, ITEM_DEFAULT, false}, - {"rescheduleincompletejobs", store_bool, ITEM(res_job.RescheduleIncompleteJobs), 0, ITEM_DEFAULT, true}, {"rescheduleinterval", store_time, ITEM(res_job.RescheduleInterval), 0, ITEM_DEFAULT, 60 * 30}, {"rescheduletimes", store_pint32, ITEM(res_job.RescheduleTimes), 0, 0, 5}, {"priority", store_pint32, ITEM(res_job.Priority), 0, ITEM_DEFAULT, 10}, diff --git a/bacula/src/dird/fd_cmds.c b/bacula/src/dird/fd_cmds.c index c192973..c11b0b3 100644 --- a/bacula/src/dird/fd_cmds.c +++ b/bacula/src/dird/fd_cmds.c @@ -845,6 +845,7 @@ int get_attributes_and_put_in_catalog(JCR *jcr) ar->FilenameId = 0; ar->Digest = NULL; ar->DigestType = CRYPTO_DIGEST_NONE; + ar->DeltaSeq = 0; jcr->cached_attribute = true; Dmsg2(dbglvl, "dird<filed: stream=%d %s\n", stream, jcr->fname); diff --git a/bacula/src/dird/jobq.c b/bacula/src/dird/jobq.c index 026b0f8..10a4ccd 100644 --- a/bacula/src/dird/jobq.c +++ b/bacula/src/dird/jobq.c @@ -637,7 +637,6 @@ static bool reschedule_job(JCR *jcr, jobq_t *jq, jobq_item_t *je) * Reschedule this job by cleaning it up, but * reuse the same JobId if possible. */ - jcr->rerunning = jcr->is_incomplete(); /* save incomplete status */ time_t now = time(NULL); jcr->reschedule_count++; jcr->sched_time = now + jcr->job->RescheduleInterval; @@ -656,7 +655,7 @@ static bool reschedule_job(JCR *jcr, jobq_t *jq, jobq_item_t *je) return false; } /* Only jobs with no output or Incomplete jobs can run on same JCR */ - if (jcr->JobBytes == 0 || jcr->rerunning) { + if (jcr->JobBytes == 0) { Dmsg2(2300, "Requeue job=%d use=%d\n", jcr->JobId, jcr->use_count()); V(jq->mutex); /* diff --git a/bacula/src/dird/verify.c b/bacula/src/dird/verify.c index e325c23..386fcb0 100644 --- a/bacula/src/dird/verify.c +++ b/bacula/src/dird/verify.c @@ -560,7 +560,7 @@ void get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId) char Opts_Digest[MAXSTRING]; /* Verify Opts or MD5/SHA1 digest */ if (job_canceled(jcr)) { - return; + goto bail_out; } fname = check_pool_memory_size(fname, fd->msglen); jcr->fname = check_pool_memory_size(jcr->fname, fd->msglen); @@ -569,7 +569,7 @@ void get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId) fname)) != 3) { Jmsg3(jcr, M_FATAL, 0, _("bird<filed: bad attributes, expected 3 fields got %d\n" " mslen=%d msg=%s\n"), len, fd->msglen, fd->msg); - return; + goto bail_out; } /* * We read the Options or Signature into fname @@ -740,7 +740,7 @@ void get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId) if (jcr->FileIndex != (uint32_t)file_index) { Jmsg2(jcr, M_FATAL, 0, _("MD5/SHA1 index %d not same as attributes %d\n"), file_index, jcr->FileIndex); - return; + goto bail_out; } if (do_Digest != CRYPTO_DIGEST_NONE) { db_escape_string(jcr, jcr->db, buf, Opts_Digest, strlen(Opts_Digest)); @@ -759,7 +759,7 @@ void get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId) berrno be; Jmsg2(jcr, M_FATAL, 0, _("bdird<filed: bad attributes from filed n=%d : %s\n"), n, be.bstrerror()); - return; + goto bail_out; } /* Now find all the files that are missing -- i.e. all files in @@ -777,6 +777,8 @@ void get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId) if (jcr->fn_printed) { jcr->setJobStatus(JS_Differences); } + +bail_out: free_pool_memory(fname); } diff --git a/bacula/src/filed/Makefile.in b/bacula/src/filed/Makefile.in index f96ce8d..8f0f10d 100644 --- a/bacula/src/filed/Makefile.in +++ b/bacula/src/filed/Makefile.in @@ -24,8 +24,6 @@ GETTEXT_LIBS = @LIBINTL@ PYTHON_LIBS = @PYTHON_LIBS@ PYTHON_INC = @PYTHON_INCDIR@ -AFS_CFLAGS = @AFS_CFLAGS@ -AFS_LIBS = @AFS_LIBS@ first_rule: all dummy: @@ -65,7 +63,7 @@ all: Makefile @WIN32@ bacula-fd @STATIC_FD@ acl.o: acl.c @echo "Compiling $<" - $(NO_ECHO)$(CXX) $(DEFS) $(DEBUG) -c $(WCFLAGS) $(CPPFLAGS) $(PYTHON_INC) -I$(srcdir) -I$(basedir) $(DINCLUDE) $(CFLAGS) $(AFS_CFLAGS) $< + $(NO_ECHO)$(CXX) $(DEFS) $(DEBUG) -c $(WCFLAGS) $(CPPFLAGS) $(PYTHON_INC) -I$(srcdir) -I$(basedir) $(DINCLUDE) $(CFLAGS) $< win32/winlib.a: @if test -f win32/Makefile -a "${GMAKE}" != "none"; then \ @@ -96,12 +94,12 @@ bacula-fd: Makefile $(SVROBJS) ../findlib/libbacfind$(DEFAULT_ARCHIVE_TYPE) ../ @echo "Linking $@ ..." $(LIBTOOL_LINK) $(CXX) $(WLDFLAGS) $(LDFLAGS) -L../lib -L../findlib -o $@ $(SVROBJS) \ $(WIN32LIBS) $(FDLIBS) $(ZLIBS) -lbacfind -lbacpy -lbaccfg -lbac -lm $(PYTHON_LIBS) $(LIBS) \ - $(DLIB) $(WRAPLIBS) $(GETTEXT_LIBS) $(OPENSSL_LIBS) $(CAP_LIBS) $(AFS_LIBS) + $(DLIB) $(WRAPLIBS) $(GETTEXT_LIBS) $(OPENSSL_LIBS) $(CAP_LIBS) static-bacula-fd: Makefile $(SVROBJS) ../findlib/libbacfind.a ../lib/libbacpy$(DEFAULT_ARCHIVE_TYPE) ../lib/libbaccfg$(DEFAULT_ARCHIVE_TYPE) ../lib/libbac$(DEFAULT_ARCHIVE_TYPE) @WIN32@ $(LIBTOOL_LINK) $(CXX) $(WLDFLAGS) $(LDFLAGS) -static -L../lib -L../findlib -o $@ $(SVROBJS) \ $(WIN32LIBS) $(FDLIBS) $(ZLIBS) -lbacfind -lbacpy -lbaccfg -lbac -lm $(PYTHON_LIBS) $(LIBS) \ - $(DLIB) $(WRAPLIBS) $(GETTEXT_LIBS) $(OPENSSL_LIBS) $(CAP_LIBS) $(AFS_LIBS) + $(DLIB) $(WRAPLIBS) $(GETTEXT_LIBS) $(OPENSSL_LIBS) $(CAP_LIBS) strip $@ Makefile: $(srcdir)/Makefile.in $(topdir)/config.status diff --git a/bacula/src/filed/accurate.c b/bacula/src/filed/accurate.c index 2c01bab..3a043a3 100644 --- a/bacula/src/filed/accurate.c +++ b/bacula/src/filed/accurate.c @@ -494,7 +494,7 @@ int accurate_cmd(JCR *jcr) BSOCK *dir = jcr->dir_bsock; int lstat_pos, chksum_pos; int32_t nb; - uint16_t delta_seq; + uint32_t delta_seq; if (job_canceled(jcr)) { return true; diff --git a/bacula/src/filed/acl.c b/bacula/src/filed/acl.c index 9e4f922..cfe2c64 100644 --- a/bacula/src/filed/acl.c +++ b/bacula/src/filed/acl.c @@ -38,8 +38,6 @@ * - Solaris (POSIX and NFSv4/ZFS acls) * - Tru64 * - * Next to OS specific acls we support AFS acls using the pioctl interface. - * * We handle two different types of ACLs: access and default ACLS. * On most systems that support default ACLs they only apply to directories. * @@ -64,7 +62,7 @@ #include "bacula.h" #include "filed.h" -#if !defined(HAVE_ACL) && !defined(HAVE_AFS_ACL) +#if !defined(HAVE_ACL) /** * Entry points when compiled without support for ACLs or on an unsupported platform. */ @@ -480,7 +478,7 @@ static acl_type_t bac_to_os_acltype(bacl_type acltype) case BACL_TYPE_DEFAULT: ostype = ACL_TYPE_DEFAULT; break; -#ifdef ACL_TYPE_NFS4 +#ifdef HAVE_ACL_TYPE_NFS4 /** * FreeBSD has an additional acl type named ACL_TYPE_NFS4. */ @@ -488,7 +486,7 @@ static acl_type_t bac_to_os_acltype(bacl_type acltype) ostype = ACL_TYPE_NFS4; break; #endif -#ifdef ACL_TYPE_DEFAULT_DIR +#ifdef HAVE_ACL_TYPE_DEFAULT_DIR case BACL_TYPE_DEFAULT_DIR: /** * TRU64 has an additional acl type named ACL_TYPE_DEFAULT_DIR. @@ -496,7 +494,7 @@ static acl_type_t bac_to_os_acltype(bacl_type acltype) ostype = ACL_TYPE_DEFAULT_DIR; break; #endif -#ifdef ACL_TYPE_EXTENDED +#ifdef HAVE_ACL_TYPE_EXTENDED case BACL_TYPE_EXTENDED: /** * MacOSX has an additional acl type named ACL_TYPE_EXTENDED. @@ -515,6 +513,36 @@ static acl_type_t bac_to_os_acltype(bacl_type acltype) return ostype; } +static int acl_count_entries(acl_t acl) +{ + int count = 0; +#if defined(HAVE_FREEBSD_OS) || \ + defined(HAVE_LINUX_OS) + acl_entry_t ace; + int entry_available; + + entry_available = acl_get_entry(acl, ACL_FIRST_ENTRY, &ace); + while (entry_available == 1) { + count++; + entry_available = acl_get_entry(acl, ACL_NEXT_ENTRY, &ace); + } +#elif defined(HAVE_IRIX_OS) + count = acl->acl_cnt; +#elif defined(HAVE_OSF1_OS) + count = acl->acl_num; +#elif defined(HAVE_DARWIN_OS) + acl_entry_t ace; + int entry_available; + + entry_available = acl_get_entry(acl, ACL_FIRST_ENTRY, &ace); + while (entry_available == 0) { + count++; + entry_available = acl_get_entry(acl, ACL_NEXT_ENTRY, &ace); + } +#endif + return count; +} + #if !defined(HAVE_DARWIN_OS) /** * See if an acl is a trivial one (e.g. just the stat bits encoded as acl.) @@ -606,30 +634,23 @@ static bacl_exit_code generic_get_acl_from_os(JCR *jcr, bacl_type acltype) acl_type_t ostype; char *acl_text; berrno be; + bacl_exit_code retval = bacl_exit_ok; ostype = bac_to_os_acltype(acltype); acl = acl_get_file(jcr->last_fname, ostype); if (acl) { -#if defined(HAVE_IRIX_OS) /** * From observation, IRIX's acl_get_file() seems to return a * non-NULL acl with a count field of -1 when a file has no ACL * defined, while IRIX's acl_to_text() returns NULL when presented * with such an ACL. * - * Checking the count in the acl structure before calling - * acl_to_text() lets us avoid error messages about files - * with no ACLs, without modifying the flow of the code used for - * other operating systems, and it saves making some calls - * to acl_to_text() besides. + * For all other implmentations we check if there are more then + * zero entries in the acl returned. */ - if (acl->acl_cnt <= 0) { - pm_strcpy(jcr->acl_data->content, ""); - jcr->acl_data->content_length = 0; - acl_free(acl); - return bacl_exit_ok; + if (acl_count_entries(acl) <= 0) { + goto bail_out; } -#endif /** * Make sure this is not just a trivial ACL. @@ -640,10 +661,7 @@ static bacl_exit_code generic_get_acl_from_os(JCR *jcr, bacl_type acltype) * The ACLs simply reflect the (already known) standard permissions * So we don't send an ACL stream to the SD. */ - pm_strcpy(jcr->acl_data->content, ""); - jcr->acl_data->content_length = 0; - acl_free(acl); - return bacl_exit_ok; + goto bail_out; } #endif #if defined(HAVE_FREEBSD_OS) && defined(_PC_ACL_NFS4) @@ -655,15 +673,15 @@ static bacl_exit_code generic_get_acl_from_os(JCR *jcr, bacl_type acltype) * The ACLs simply reflect the (already known) standard permissions * So we don't send an ACL stream to the SD. */ - pm_strcpy(jcr->acl_data->content, ""); - jcr->acl_data->content_length = 0; - acl_free(acl); - return bacl_exit_ok; + goto bail_out; } } } #endif + /** + * Convert the internal acl representation into a text representation. + */ if ((acl_text = acl_to_text(acl, NULL)) != NULL) { jcr->acl_data->content_length = pm_strcpy(jcr->acl_data->content, acl_text); acl_free(acl); @@ -676,16 +694,12 @@ static bacl_exit_code generic_get_acl_from_os(JCR *jcr, bacl_type acltype) Dmsg2(100, "acl_to_text error file=%s ERR=%s\n", jcr->last_fname, be.bstrerror()); - pm_strcpy(jcr->acl_data->content, ""); - jcr->acl_data->content_length = 0; - acl_free(acl); - return bacl_exit_error; - } - - /** - * Handle errors gracefully. - */ - if (acl == (acl_t)NULL) { + retval = bacl_exit_error; + goto bail_out; + } else { + /** + * Handle errors gracefully. + */ switch (errno) { #if defined(BACL_ENOTSUP) case BACL_ENOTSUP: @@ -696,12 +710,10 @@ static bacl_exit_code generic_get_acl_from_os(JCR *jcr, bacl_type acltype) * when we change from one filesystem to an other. */ jcr->acl_data->flags &= ~BACL_FLAG_SAVE_NATIVE; - break; /* not supported */ + goto bail_out; #endif case ENOENT: - pm_strcpy(jcr->acl_data->content, ""); - jcr->acl_data->content_length = 0; - return bacl_exit_ok; + goto bail_out; default: /* Some real error */ Mmsg2(jcr->errmsg, _("acl_get_file error on file \"%s\": ERR=%s\n"), @@ -709,18 +721,18 @@ static bacl_exit_code generic_get_acl_from_os(JCR *jcr, bacl_type acltype) Dmsg2(100, "acl_get_file error file=%s ERR=%s\n", jcr->last_fname, be.bstrerror()); - pm_strcpy(jcr->acl_data->content, ""); - jcr->acl_data->content_length = 0; - return bacl_exit_error; + retval = bacl_exit_error; + goto bail_out; } } - /** - * Not supported, just pretend there is nothing to see - */ +bail_out: + if (acl) { + acl_free(acl); + } pm_strcpy(jcr->acl_data->content, ""); jcr->acl_data->content_length = 0; - return bacl_exit_ok; + return retval; } /** @@ -810,7 +822,7 @@ static int os_default_acl_streams[1] = { -1 }; static bacl_exit_code darwin_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) { -#if defined(ACL_TYPE_EXTENDED) +#if defined(HAVE_ACL_TYPE_EXTENDED) /** * On MacOS X, acl_get_file (name, ACL_TYPE_ACCESS) * and acl_get_file (name, ACL_TYPE_DEFAULT) @@ -838,7 +850,7 @@ static bacl_exit_code darwin_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) static bacl_exit_code darwin_parse_acl_streams(JCR *jcr, int stream) { -#if defined(ACL_TYPE_EXTENDED) +#if defined(HAVE_ACL_TYPE_EXTENDED) return generic_set_acl_on_os(jcr, BACL_TYPE_EXTENDED); #else return generic_set_acl_on_os(jcr, BACL_TYPE_ACCESS); diff --git a/bacula/src/stored/append.c b/bacula/src/stored/append.c index 89c3716..1af03fb 100644 --- a/bacula/src/stored/append.c +++ b/bacula/src/stored/append.c @@ -43,24 +43,9 @@ static char OK_append[] = "3000 OK append data\n"; /* - * Check if we can mark this job incomplete - * */ void possible_incomplete_job(JCR *jcr, int32_t last_file_index) { - /* - * Note, here we decide if it is worthwhile to restart - * the Job at this point. For the moment, if at least - * 10 Files have been seen, which is good for testing, but - * for a production system, we probably want something like - * 100-1000 files, and some number of bytes of data. - * - * ****FIXME**** set last_file_index to something more - * reasonable, and maybe check JobBytes. - */ - if (jcr->spool_attributes && last_file_index > 10) { - jcr->setJobStatus(JS_Incomplete); - } } /* * Append Data sent from File daemon diff --git a/bacula/src/stored/askdir.c b/bacula/src/stored/askdir.c index 09eaf70..35200e0 100644 --- a/bacula/src/stored/askdir.c +++ b/bacula/src/stored/askdir.c @@ -479,11 +479,6 @@ bool dir_update_file_attributes(DCR *dcr, DEV_RECORD *rec) ser_bytes(rec->data, rec->data_len); dir->msglen = ser_length(dir->msg); Dmsg1(1800, ">dird %s\n", dir->msg); /* Attributes */ - if (rec->maskedStream == STREAM_UNIX_ATTRIBUTES || - rec->maskedStream == STREAM_UNIX_ATTRIBUTES_EX) { - Dmsg2(100, "==== set_data_end FI=%ld %s\n", rec->FileIndex, rec->data); - dir->set_data_end(rec->FileIndex); /* set offset of last valid data */ - } return dir->send(); } diff --git a/bacula/src/tools/dbcheck.c b/bacula/src/tools/dbcheck.c index 20a403b..a61b1c7 100644 --- a/bacula/src/tools/dbcheck.c +++ b/bacula/src/tools/dbcheck.c @@ -42,8 +42,10 @@ extern bool parse_dir_config(CONFIG *config, const char *configfile, int exit_code); -/* Dummy functions */ -int generate_daemon_event(JCR *jcr, const char *event) +/* + * Dummy functions + */ +int generate_daemon_event(JCR *jcr, const char *event) { return 1; } typedef struct s_id_ctx { @@ -62,7 +64,9 @@ typedef struct s_name_ctx { int tot_ids; /* total to process */ } NAME_LIST; -/* Global variables */ +/* + * Global variables + */ static bool fix = false; static bool batch = false; static B_DB *db; @@ -71,10 +75,14 @@ static NAME_LIST name_list; static char buf[20000]; static bool quit = false; static CONFIG *config; +static const char *idx_tmp_name; #define MAX_ID_LIST_LEN 10000000 -/* Forward referenced functions */ +/* + * Forward referenced functions + */ +static void print_catalog_details(CAT *catalog, const char *working_dir); static int make_id_list(const char *query, ID_LIST *id_list); static int delete_id_list(const char *query, ID_LIST *id_list); static int make_name_list(const char *query, NAME_LIST *name_list); @@ -97,16 +105,10 @@ static void repair_bad_filenames(); static void do_interactive_mode(); static bool yes_no(const char *prompt); static bool check_idx(const char *col_name); -static bool create_tmp_idx(const char *idx_name, const char *table_name, +static bool create_tmp_idx(const char *idx_name, const char *table_name, const char *col_name); static bool drop_tmp_idx(const char *idx_name, const char *table_name); -#ifdef HAVE_MYSQL static int check_idx_handler(void *ctx, int num_fields, char **row); -#endif - - -/* Global variables */ -static const char *idx_tmp_name; static void usage() { @@ -141,7 +143,7 @@ int main (int argc, char *argv[]) lmgr_init_thread(); my_name_is(argc, argv, "dbcheck"); - init_msg(NULL, NULL); /* setup message handler */ + init_msg(NULL, NULL); /* setup message handler */ memset(&id_list, 0, sizeof(id_list)); memset(&name_list, 0, sizeof(name_list)); @@ -151,19 +153,15 @@ int main (int argc, char *argv[]) case 'B': print_catalog = true; /* get catalog information from config */ break; - case 'b': /* batch */ batch = true; break; - case 'C': /* CatalogName */ catalogname = optarg; break; - case 'c': /* configfile */ configfile = optarg; break; - case 'd': /* debug level */ if (*optarg == 't') { dbg_timestamp = true; @@ -174,15 +172,12 @@ int main (int argc, char *argv[]) } } break; - case 'f': /* fix inconsistencies */ fix = true; break; - case 'v': verbose++; break; - case '?': default: usage(); @@ -230,12 +225,11 @@ int main (int argc, char *argv[]) } set_working_directory(director->working_directory); - /* Print catalog information and exit (-B) */ + /* + * Print catalog information and exit (-B) + */ if (print_catalog) { - POOLMEM *buf = get_pool_memory(PM_MESSAGE); - printf("%s\nworking_dir=%s\n", catalog->display(buf), - working_directory); - free_pool_memory(buf); + print_catalog_details(catalog, director->working_directory); exit(0); } @@ -259,7 +253,9 @@ int main (int argc, char *argv[]) usage(); } - /* This is needed by SQLite to find the db */ + /* + * This is needed by SQLite to find the db + */ working_directory = argv[0]; db_name = "bacula"; user = db_name; @@ -298,14 +294,18 @@ int main (int argc, char *argv[]) } } - /* Open database */ + /* + * Open database + */ db = db_init_database(NULL, NULL, db_name, user, password, dbhost, dbport, NULL, false, false); if (!db_open_database(NULL, db)) { Emsg1(M_FATAL, 0, "%s", db_strerror(db)); return 1; } - /* drop temporary index idx_tmp_name if it already exists */ + /* + * Drop temporary index idx_tmp_name if it already exists + */ drop_tmp_idx("idxPIchk", "File"); if (batch) { @@ -326,7 +326,9 @@ int main (int argc, char *argv[]) do_interactive_mode(); } - /* drop temporary index idx_tmp_name */ + /* + * Drop temporary index idx_tmp_name + */ drop_tmp_idx("idxPIchk", "File"); db_close_database(NULL, db); @@ -336,6 +338,26 @@ int main (int argc, char *argv[]) return 0; } +static void print_catalog_details(CAT *catalog, const char *working_dir) +{ + POOLMEM *catalog_details = get_pool_memory(PM_MESSAGE); + + /* + * Instantiate a B_DB class and see what db_type gets assigned to it. + */ + db = db_init_database(NULL, catalog->db_driver, catalog->db_name, catalog->db_user, + catalog->db_password, catalog->db_address, + catalog->db_port, catalog->db_socket, + catalog->mult_db_connections, + catalog->disable_batch_insert); + if (db) { + printf("%sdb_type=%s\nworking_dir=%s\n", catalog->display(catalog_details), + db->db_get_type(), working_directory); + db_close_database(NULL, db); + } + free_pool_memory(catalog_details); +} + static void do_interactive_mode() { const char *cmd; @@ -483,9 +505,10 @@ static int print_name_handler(void *ctx, int num_fields, char **row) static int get_name_handler(void *ctx, int num_fields, char **row) { - POOLMEM *buf = (POOLMEM *)ctx; + POOLMEM *name = (POOLMEM *)ctx; + if (row[0]) { - pm_strcpy(&buf, row[0]); + pm_strcpy(&name, row[0]); } return 0; } @@ -497,7 +520,6 @@ static int print_job_handler(void *ctx, int num_fields, char **row) return 0; } - static int print_jobmedia_handler(void *ctx, int num_fields, char **row) { printf(_("Orphaned JobMediaId=%s JobId=%s Volume=\"%s\"\n"), @@ -526,7 +548,6 @@ static int print_client_handler(void *ctx, int num_fields, char **row) return 0; } - /* * Called here with each id to be added to the list */ @@ -605,7 +626,6 @@ static int name_list_handler(void *ctx, int num_fields, char **row) return 0; } - /* * Construct name list */ @@ -632,7 +652,6 @@ static void print_name_list(NAME_LIST *name_list) } } - /* * Free names in the list */ @@ -651,7 +670,9 @@ static void eliminate_duplicate_filenames() printf(_("Checking for duplicate Filename entries.\n")); - /* Make list of duplicated names */ + /* + * Make list of duplicated names + */ query = "SELECT Name, count(Name) as Count FROM Filename GROUP BY Name " "HAVING count(Name) > 1"; @@ -666,9 +687,13 @@ static void eliminate_duplicate_filenames() return; } if (fix) { - /* Loop through list of duplicate names */ + /* + * Loop through list of duplicate names + */ for (int i=0; i<name_list.num_ids; i++) { - /* Get all the Ids of each name */ + /* + * Get all the Ids of each name + */ db_escape_string(NULL, db, esc_name, name_list.name[i], strlen(name_list.name[i])); bsnprintf(buf, sizeof(buf), "SELECT FilenameId FROM Filename WHERE Name='%s'", esc_name); if (verbose > 1) { @@ -680,7 +705,9 @@ static void eliminate_duplicate_filenames() if (verbose) { printf(_("Found %d for: %s\n"), id_list.num_ids, name_list.name[i]); } - /* Force all records to use the first id then delete the other ids */ + /* + * Force all records to use the first id then delete the other ids + */ for (int j=1; j<id_list.num_ids; j++) { char ed1[50], ed2[50]; bsnprintf(buf, sizeof(buf), "UPDATE File SET FilenameId=%s WHERE FilenameId=%s", @@ -708,8 +735,9 @@ static void eliminate_duplicate_paths() printf(_("Checking for duplicate Path entries.\n")); - /* Make list of duplicated names */ - + /* + * Make list of duplicated names + */ query = "SELECT Path, count(Path) as Count FROM Path " "GROUP BY Path HAVING count(Path) > 1"; @@ -724,9 +752,13 @@ static void eliminate_duplicate_paths() return; } if (fix) { - /* Loop through list of duplicate names */ + /* + * Loop through list of duplicate names + */ for (int i=0; i<name_list.num_ids; i++) { - /* Get all the Ids of each name */ + /* + * Get all the Ids of each name + */ db_escape_string(NULL, db, esc_name, name_list.name[i], strlen(name_list.name[i])); bsnprintf(buf, sizeof(buf), "SELECT PathId FROM Path WHERE Path='%s'", esc_name); if (verbose > 1) { @@ -738,7 +770,9 @@ static void eliminate_duplicate_paths() if (verbose) { printf(_("Found %d for: %s\n"), id_list.num_ids, name_list.name[i]); } - /* Force all records to use the first id then delete the other ids */ + /* + * Force all records to use the first id then delete the other ids + */ for (int j=1; j<id_list.num_ids; j++) { char ed1[50], ed2[50]; bsnprintf(buf, sizeof(buf), "UPDATE File SET PathId=%s WHERE PathId=%s", @@ -768,7 +802,9 @@ static void eliminate_orphaned_jobmedia_records() if (!make_id_list(query, &id_list)) { exit(1); } - /* Loop doing 300000 at a time */ + /* + * Loop doing 300000 at a time + */ while (id_list.num_ids != 0) { printf(_("Found %d orphaned JobMedia records.\n"), id_list.num_ids); if (id_list.num_ids && verbose && yes_no(_("Print them? (yes/no): "))) { @@ -776,7 +812,7 @@ static void eliminate_orphaned_jobmedia_records() char ed1[50]; bsnprintf(buf, sizeof(buf), "SELECT JobMedia.JobMediaId,JobMedia.JobId,Media.VolumeName FROM JobMedia,Media " -"WHERE JobMedia.JobMediaId=%s AND Media.MediaId=JobMedia.MediaId", +"WHERE JobMedia.JobMediaId=%s AND Media.MediaId=JobMedia.MediaId", edit_int64(id_list.Id[i], ed1)); if (!db_sql_query(db, buf, print_jobmedia_handler, NULL)) { printf("%s\n", db_strerror(db)); @@ -812,7 +848,9 @@ static void eliminate_orphaned_file_records() if (!make_id_list(query, &id_list)) { exit(1); } - /* Loop doing 300000 at a time */ + /* + * Loop doing 300000 at a time + */ while (id_list.num_ids != 0) { printf(_("Found %d orphaned File records.\n"), id_list.num_ids); if (name_list.num_ids && verbose && yes_no(_("Print them? (yes/no): "))) { @@ -820,7 +858,7 @@ static void eliminate_orphaned_file_records() char ed1[50]; bsnprintf(buf, sizeof(buf), "SELECT File.FileId,File.JobId,Filename.Name FROM File,Filename " -"WHERE File.FileId=%s AND File.FilenameId=Filename.FilenameId", +"WHERE File.FileId=%s AND File.FilenameId=Filename.FilenameId", edit_int64(id_list.Id[i], ed1)); if (!db_sql_query(db, buf, print_file_handler, NULL)) { printf("%s\n", db_strerror(db)); @@ -845,10 +883,14 @@ static void eliminate_orphaned_file_records() static void eliminate_orphaned_path_records() { idx_tmp_name = NULL; - /* check the existence of the required "one column" index */ + /* + * Check the existence of the required "one column" index + */ if (!check_idx("PathId")) { if (yes_no(_("Create temporary index? (yes/no): "))) { - /* create temporary index PathId */ + /* + * create temporary index PathId + */ create_tmp_idx("idxPIchk", "File", "PathId"); } } @@ -864,13 +906,15 @@ static void eliminate_orphaned_path_records() if (!make_id_list(query, &id_list)) { exit(1); } - /* Loop doing 300000 at a time */ + /* + * Loop doing 300000 at a time + */ while (id_list.num_ids != 0) { printf(_("Found %d orphaned Path records.\n"), id_list.num_ids); if (id_list.num_ids && verbose && yes_no(_("Print them? (yes/no): "))) { for (int i=0; i < id_list.num_ids; i++) { char ed1[50]; - bsnprintf(buf, sizeof(buf), "SELECT Path FROM Path WHERE PathId=%s", + bsnprintf(buf, sizeof(buf), "SELECT Path FROM Path WHERE PathId=%s", edit_int64(id_list.Id[i], ed1)); db_sql_query(db, buf, print_name_handler, NULL); } @@ -887,18 +931,24 @@ static void eliminate_orphaned_path_records() if (!make_id_list(query, &id_list)) { exit(1); } - } - /* drop temporary index idx_tmp_name */ + } + /* + * Drop temporary index idx_tmp_name + */ drop_tmp_idx("idxPIchk", "File"); } static void eliminate_orphaned_filename_records() { idx_tmp_name = NULL; - /* check the existence of the required "one column" index */ + /* + * Check the existence of the required "one column" index + */ if (!check_idx("FilenameId") ) { if (yes_no(_("Create temporary index? (yes/no): "))) { - /* create temporary index FilenameId */ + /* + * Create temporary index FilenameId + */ create_tmp_idx("idxFIchk", "File", "FilenameId"); } } @@ -914,13 +964,15 @@ static void eliminate_orphaned_filename_records() if (!make_id_list(query, &id_list)) { exit(1); } - /* Loop doing 300000 at a time */ + /* + * Loop doing 300000 at a time + */ while (id_list.num_ids != 0) { printf(_("Found %d orphaned Filename records.\n"), id_list.num_ids); if (id_list.num_ids && verbose && yes_no(_("Print them? (yes/no): "))) { for (int i=0; i < id_list.num_ids; i++) { char ed1[50]; - bsnprintf(buf, sizeof(buf), "SELECT Name FROM Filename WHERE FilenameId=%s", + bsnprintf(buf, sizeof(buf), "SELECT Name FROM Filename WHERE FilenameId=%s", edit_int64(id_list.Id[i], ed1)); db_sql_query(db, buf, print_name_handler, NULL); } @@ -938,7 +990,9 @@ static void eliminate_orphaned_filename_records() exit(1); } } - /* drop temporary index idx_tmp_name */ + /* + * Drop temporary index idx_tmp_name + */ drop_tmp_idx("idxFIchk", "File"); } @@ -982,7 +1036,8 @@ static void eliminate_orphaned_client_records() const char *query; printf(_("Checking for orphaned Client entries.\n")); - /* In English: + /* + * In English: * Wiffle through Client for every Client * joining with the Job table including every Client even if * there is not a match in Job (left outer join), then @@ -1023,7 +1078,8 @@ static void eliminate_orphaned_job_records() const char *query; printf(_("Checking for orphaned Job entries.\n")); - /* In English: + /* + * In English: * Wiffle through Job for every Job * joining with the Client table including every Job even if * there is not a match in Client (left outer join), then @@ -1063,7 +1119,6 @@ static void eliminate_orphaned_job_records() } } - static void eliminate_admin_records() { const char *query; @@ -1130,9 +1185,6 @@ static void eliminate_restore_records() } } - - - static void repair_bad_filenames() { const char *query; @@ -1152,7 +1204,7 @@ static void repair_bad_filenames() for (i=0; i < id_list.num_ids; i++) { char ed1[50]; bsnprintf(buf, sizeof(buf), - "SELECT Name FROM Filename WHERE FilenameId=%s", + "SELECT Name FROM Filename WHERE FilenameId=%s", edit_int64(id_list.Id[i], ed1)); if (!db_sql_query(db, buf, print_name_handler, NULL)) { printf("%s\n", db_strerror(db)); @@ -1170,12 +1222,14 @@ static void repair_bad_filenames() int len; char ed1[50]; bsnprintf(buf, sizeof(buf), - "SELECT Name FROM Filename WHERE FilenameId=%s", + "SELECT Name FROM Filename WHERE FilenameId=%s", edit_int64(id_list.Id[i], ed1)); if (!db_sql_query(db, buf, get_name_handler, name)) { printf("%s\n", db_strerror(db)); } - /* Strip trailing slash(es) */ + /* + * Strip trailing slash(es) + */ for (len=strlen(name); len > 0 && IsPathSeparator(name[len-1]); len--) { } if (len == 0) { @@ -1194,6 +1248,7 @@ static void repair_bad_filenames() } db_sql_query(db, buf, NULL, NULL); } + free_pool_memory(name); } } @@ -1237,11 +1292,15 @@ static void repair_bad_paths() if (!db_sql_query(db, buf, get_name_handler, name)) { printf("%s\n", db_strerror(db)); } - /* Strip trailing blanks */ + /* + * Strip trailing blanks + */ for (len=strlen(name); len > 0 && name[len-1]==' '; len--) { name[len-1] = 0; } - /* Add trailing slash */ + /* + * Add trailing slash + */ len = pm_strcat(&name, "/"); db_escape_string(NULL, db, esc_name, name, len); bsnprintf(buf, sizeof(buf), "UPDATE Path SET Path='%s' WHERE PathId=%s", @@ -1251,10 +1310,10 @@ static void repair_bad_paths() } db_sql_query(db, buf, NULL, NULL); } + free_pool_memory(name); } } - /* * Gen next input command from the terminal */ @@ -1285,13 +1344,11 @@ static bool yes_no(const char *prompt) bool python_set_prog(JCR*, char const*) { return false; } - /* * The code below to add indexes is needed only for MySQL, and * that to improve the performance. */ -#ifdef HAVE_MYSQL #define MAXIDX 100 typedef struct s_idx_list { char *key_name; @@ -1301,17 +1358,19 @@ typedef struct s_idx_list { static IDX_LIST idx_list[MAXIDX]; -/* +/* * Called here with each table index to be added to the list */ static int check_idx_handler(void *ctx, int num_fields, char **row) { - /* Table | Non_unique | Key_name | Seq_in_index | Column_name |... - * File | 0 | PRIMARY | 1 | FileId |... + /* + * Table | Non_unique | Key_name | Seq_in_index | Column_name |... + * File | 0 | PRIMARY | 1 | FileId |... */ char *name, *key_name, *col_name; int i, len; int found = false; + name = (char *)ctx; key_name = row[2]; col_name = row[4]; @@ -1325,7 +1384,9 @@ static int check_idx_handler(void *ctx, int num_fields, char **row) break; } } - /* if the new Key_name, add it to the list */ + /* + * If the new Key_name, add it to the list + */ if (!found) { len = strlen(key_name) + 1; idx_list[i].key_name = (char *)malloc(len); @@ -1339,53 +1400,55 @@ static int check_idx_handler(void *ctx, int num_fields, char **row) } return 0; } -#endif /* * Return TRUE if "one column" index over *col_name exists */ static bool check_idx(const char *col_name) { -#ifdef HAVE_MYSQL int i; int found = false; - - memset(&idx_list, 0, sizeof(idx_list)); const char *query = "SHOW INDEX FROM File"; - if (!db_sql_query(db, query, check_idx_handler, (void *)col_name)) { - printf("%s\n", db_strerror(db)); - } - for(i = 0; (idx_list[i].key_name != NULL) && (i < MAXIDX) ; i++) { - /* NOTE : if (idx_list[i].count_key > 1) then index idx_list[i].key_name is "multiple-column" index */ - if ((idx_list[i].count_key == 1) && (idx_list[i].count_col == 1)) { - /* "one column" index over *col_name found */ - found = true; + switch (db_get_type_index(db)) { + case SQL_TYPE_MYSQL: + memset(&idx_list, 0, sizeof(idx_list)); + if (!db_sql_query(db, query, check_idx_handler, (void *)col_name)) { + printf("%s\n", db_strerror(db)); } - } - if (found) { - if (verbose) { - printf(_("Ok. Index over the %s column already exists and dbcheck will work faster.\n"), col_name); + for (i = 0; (idx_list[i].key_name != NULL) && (i < MAXIDX) ; i++) { + /* + * NOTE : if (idx_list[i].count_key > 1) then index idx_list[i].key_name is "multiple-column" index + */ + if ((idx_list[i].count_key == 1) && (idx_list[i].count_col == 1)) { + /* + * "one column" index over *col_name found + */ + found = true; + } } - } else { - printf(_("Note. Index over the %s column not found, that can greatly slow down dbcheck.\n"), col_name); + if (found) { + if (verbose) { + printf(_("Ok. Index over the %s column already exists and dbcheck will work faster.\n"), col_name); + } + } else { + printf(_("Note. Index over the %s column not found, that can greatly slow down dbcheck.\n"), col_name); + } + return found; + default: + return true; } - - return found; -#else - return true; -#endif } /* * Create temporary one-column index */ -static bool create_tmp_idx(const char *idx_name, const char *table_name, - const char *col_name) +static bool create_tmp_idx(const char *idx_name, const char *table_name, + const char *col_name) { idx_tmp_name = NULL; printf(_("Create temporary index... This may take some time!\n")); - bsnprintf(buf, sizeof(buf), "CREATE INDEX %s ON %s (%s)", idx_name, table_name, col_name); + bsnprintf(buf, sizeof(buf), "CREATE INDEX %s ON %s (%s)", idx_name, table_name, col_name); if (verbose) { printf("%s\n", buf); } hooks/post-receive -- Bacula Community source |