From: Kern Sibbald Date: Mon, 14 Jul 2003 21:38:34 +0000 (+0000) Subject: Move host.h from filed to src + add Project to home page X-Git-Tag: Release-1.31~22 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=9d83c5d582869fb2f34f429e66921ff7446d0d3f;p=bacula%2Fbacula Move host.h from filed to src + add Project to home page git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@634 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/ChangeLog b/bacula/ChangeLog index 57f5d1acc2..3f0f48720c 100644 --- a/bacula/ChangeLog +++ b/bacula/ChangeLog @@ -1,4 +1,11 @@ +2003-07-12 Version 1.31 Beta 14Jul03 +- Marc Brueckner reported a crash during restore (a missing tree->) +- Moved host.h.in file from filed to src. +- Update btraceback to include host os, distname, distver in output. +- Split list (in lib) into alist and dlist both with .h and .c. +- Update home page to include Project status page. + 2003-07-12 Version 1.31 Beta 10Jul03 - Manual updates. - Clean up some unused variables detected by the IRIX compiler. diff --git a/bacula/autoconf/acconfig.h b/bacula/autoconf/acconfig.h index 38157a5115..a6fe066c74 100644 --- a/bacula/autoconf/acconfig.h +++ b/bacula/autoconf/acconfig.h @@ -204,3 +204,4 @@ #undef HAVE_OLD_SOCKOPT #undef HAVE_BIGENDIAN + diff --git a/bacula/autoconf/configure.in b/bacula/autoconf/configure.in index bda0b6f72b..02aadbe93c 100644 --- a/bacula/autoconf/configure.in +++ b/bacula/autoconf/configure.in @@ -1422,6 +1422,7 @@ AC_OUTPUT([autoconf/Make.common \ scripts/mtx-changer \ doc/Makefile \ src/Makefile \ + src/host.h \ src/console/Makefile \ src/console/console.conf \ src/gnome-console/Makefile \ @@ -1435,7 +1436,6 @@ AC_OUTPUT([autoconf/Make.common \ src/stored/Makefile \ src/stored/bacula-sd.conf \ src/filed/Makefile \ - src/filed/host.h \ src/filed/bacula-fd.conf \ src/filed/win32/Makefile \ src/cats/Makefile \ diff --git a/bacula/configure b/bacula/configure index 9926b4ebfd..aff11347a5 100755 --- a/bacula/configure +++ b/bacula/configure @@ -9932,6 +9932,7 @@ trap 'rm -fr `echo "autoconf/Make.common \ scripts/mtx-changer \ doc/Makefile \ src/Makefile \ + src/host.h \ src/console/Makefile \ src/console/console.conf \ src/gnome-console/Makefile \ @@ -9945,7 +9946,6 @@ trap 'rm -fr `echo "autoconf/Make.common \ src/stored/Makefile \ src/stored/bacula-sd.conf \ src/filed/Makefile \ - src/filed/host.h \ src/filed/bacula-fd.conf \ src/filed/win32/Makefile \ src/cats/Makefile \ @@ -10207,6 +10207,7 @@ CONFIG_FILES=\${CONFIG_FILES-"autoconf/Make.common \ scripts/mtx-changer \ doc/Makefile \ src/Makefile \ + src/host.h \ src/console/Makefile \ src/console/console.conf \ src/gnome-console/Makefile \ @@ -10220,7 +10221,6 @@ CONFIG_FILES=\${CONFIG_FILES-"autoconf/Make.common \ src/stored/Makefile \ src/stored/bacula-sd.conf \ src/filed/Makefile \ - src/filed/host.h \ src/filed/bacula-fd.conf \ src/filed/win32/Makefile \ src/cats/Makefile \ diff --git a/bacula/kernstodo b/bacula/kernstodo index 86495102e2..ae110d00ce 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -1,5 +1,5 @@ Kern's ToDo List - 10 July 2003 + 14 July 2003 Documentation to do: (any release a little bit at a time) - Document running a test version. @@ -17,6 +17,7 @@ Documentation to do: (any release a little bit at a time) - Document need to add "-u root" to most of MySQL script calls (./create_mys... ./make_my...). - Document all the status codes JobLevel, JobType, JobStatus. +- Document dynamic DNS Testing to do: (painful) @@ -71,7 +72,8 @@ For 1.31 release: For 1.32: -- Figure out how to handle DHCP IP addresses. +- Implement a Recycle or Prune Current Volume (as from Nic Bellamy), + possibly implement Prune Oldest Volume. - Allow multiple Storage specifications (or multiple names on a single Storage specification) in the Job record. Thus a job can be backed up to a number of storage devices. @@ -1043,3 +1045,6 @@ Done: (see kernsdone for more) - Document update volume: jobid, current, before, all - Document that bscan does not work with multiple simultaneous jobs. - Update Automatic Volume Labeling in disk.wml +- Figure out how to handle DHCP IP addresses -- use dynamic DNS. +- Add OS, GCC version to traceback output. + diff --git a/bacula/scripts/btraceback.gdb b/bacula/scripts/btraceback.gdb index 387430a57c..416f70f3e6 100644 --- a/bacula/scripts/btraceback.gdb +++ b/bacula/scripts/btraceback.gdb @@ -3,6 +3,9 @@ print exename print exepath print catalog_db print version +print host_os +print distname +print distver bt thread apply all bt f 0 diff --git a/bacula/src/.cvsignore b/bacula/src/.cvsignore index ee4c5144e1..018076a9be 100644 --- a/bacula/src/.cvsignore +++ b/bacula/src/.cvsignore @@ -4,3 +4,4 @@ Makefile config.h testprogs +host.h diff --git a/bacula/src/Makefile.in b/bacula/src/Makefile.in index 1a3d0f9817..1f32ee5812 100644 --- a/bacula/src/Makefile.in +++ b/bacula/src/Makefile.in @@ -47,7 +47,7 @@ realclean: clean distclean: realclean if test $(srcdir) = .; then $(MAKE) realclean; fi @(cd $(srcdir); $(RMF) Makefile) - @$(RMF) config.h + @$(RMF) config.h host.h @$(RMF) -r CVS install: diff --git a/bacula/src/bacula.h b/bacula/src/bacula.h index 6814485c05..80d6eba43c 100644 --- a/bacula/src/bacula.h +++ b/bacula/src/bacula.h @@ -28,6 +28,7 @@ #define _BACULA_H 1 #include "config.h" +#include "host.h" #define _REENTRANT 1 #define _THREAD_SAFE 1 diff --git a/bacula/src/dird/ua_tree.c b/bacula/src/dird/ua_tree.c index 6331200e1a..6c95803dec 100644 --- a/bacula/src/dird/ua_tree.c +++ b/bacula/src/dird/ua_tree.c @@ -75,7 +75,7 @@ void user_select_files_from_tree(TREE_CTX *tree) { char cwd[2000]; /* Get a new context so we don't destroy restore command args */ - UAContext *ua = new_ua_context(ua->jcr); + UAContext *ua = new_ua_context(tree->ua->jcr); ua->UA_sock = tree->ua->UA_sock; /* patch in UA socket */ bsendmsg(tree->ua, _( diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index 186252429d..9a7165cba5 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -28,7 +28,6 @@ #include "bacula.h" #include "filed.h" -#include "host.h" extern char my_name[]; extern CLIENT *me; /* our client resource */ @@ -108,7 +107,7 @@ static char OKverify[] = "2000 OK verify\n"; static char OKrestore[] = "2000 OK restore\n"; static char OKsession[] = "2000 OK session\n"; static char OKstore[] = "2000 OK storage\n"; -static char OKjob[] = "2000 OK Job " FDHOST "," DISTNAME "," DISTVER; +static char OKjob[] = "2000 OK Job " HOST_OS "," DISTNAME "," DISTVER; static char OKsetdebug[] = "2000 OK setdebug=%d\n"; static char BADjob[] = "2901 Bad Job\n"; static char EndJob[] = "2800 End Job TermCode=%d JobFiles=%u ReadBytes=%s JobBytes=%s Errors=%u\n"; diff --git a/bacula/src/host.h.in b/bacula/src/host.h.in new file mode 100644 index 0000000000..e9c2cd00f4 --- /dev/null +++ b/bacula/src/host.h.in @@ -0,0 +1,29 @@ +/* + * Define Host machine + * + * Version $Id$ + * + */ +/* + Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the Free + Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, + MA 02111-1307, USA. + + */ + +#define HOST_OS "@host@" +#define DISTNAME "@DISTNAME@" +#define DISTVER "@DISTVER@" diff --git a/bacula/src/lib/Makefile.in b/bacula/src/lib/Makefile.in index 5ef2096bec..dcdb32ab33 100644 --- a/bacula/src/lib/Makefile.in +++ b/bacula/src/lib/Makefile.in @@ -35,7 +35,7 @@ LIBSRCS = alloc.c attr.c base64.c bsys.c bget_msg.c \ bnet.c bnet_server.c \ bpipe.c bshm.c btime.c \ cram-md5.c crc32.c daemon.c edit.c fnmatch.c \ - hmac.c idcache.c jcr.c lex.c list.c \ + hmac.c idcache.c jcr.c lex.c alist.c dlist.c \ md5.c message.c mem_pool.c parse_conf.c \ queue.c rwlock.c scan.c serial.c sha1.c \ semlock.c signal.c smartall.c tree.c \ @@ -46,7 +46,7 @@ LIBOBJS = alloc.o attr.o base64.o bsys.o bget_msg.o \ bnet.o bnet_server.o \ bpipe.o bshm.o btime.o \ cram-md5.o crc32.o daemon.o edit.o fnmatch.o \ - hmac.o idcache.o jcr.o lex.o list.o \ + hmac.o idcache.o jcr.o lex.o alist.o dlist.o \ md5.o message.o mem_pool.o parse_conf.o \ queue.o rwlock.o scan.o serial.o sha1.o \ semlock.o signal.o smartall.o tree.o \ diff --git a/bacula/src/lib/alist.c b/bacula/src/lib/alist.c new file mode 100644 index 0000000000..e5eafaf933 --- /dev/null +++ b/bacula/src/lib/alist.c @@ -0,0 +1,118 @@ +/* + * Bacula array list routines + * + * alist is a simple malloc'ed array of pointers. For the moment, + * it simply malloc's a bigger array controlled by num_grow. + * Default is to realloc the pointer array for each new member. + * + * Kern Sibbald, June MMIII + * + * Version $Id$ + * + */ +/* + Copyright (C) 2000-2003 Kern Sibbald and John Walker + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the Free + Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, + MA 02111-1307, USA. + + */ + +#include "bacula.h" + +/* + * Append an item to the list + */ +void alist::append(void *item) { + if (num_items == 0) { + if (num_grow == 0) { + num_grow = 1; /* default if not initialized */ + } + items = (void **)malloc(num_grow * sizeof(void *)); + max_items = num_grow; + } else if (num_items == max_items) { + max_items += num_grow; + items = (void **)realloc(items, max_items * sizeof(void *)); + } + items[num_items++] = item; +} + +/* Get the index item -- we should probably allow real indexing here */ +void * alist::get(int index) +{ + if (index < 0 || index >= num_items) { + return NULL; + } + return items[index]; +} + +/* Destroy the list and its contents */ +void alist::destroy() +{ + if (items) { + for (int i=0; imylist.init(); + + printf("Manual allocation/destruction of list:\n"); + + for (int i=0; i<20; i++) { + sprintf(buf, "This is item %d", i); + fileset->mylist.append(bstrdup(buf)); + } + for (int i=0; imylist.size(); i++) { + printf("Item %d = %s\n", i, (char *)fileset->mylist[i]); + } + fileset->mylist.destroy(); + free(fileset); + + printf("Allocation/destruction using new delete\n"); + mlist = new alist(10); + + for (int i=0; i<20; i++) { + sprintf(buf, "This is item %d", i); + mlist->append(bstrdup(buf)); + } + for (int i=0; isize(); i++) { + printf("Item %d = %s\n", i, (char *)mlist->get(i)); + } + + delete mlist; + + + sm_dump(False); + +} +#endif diff --git a/bacula/src/lib/alist.h b/bacula/src/lib/alist.h new file mode 100644 index 0000000000..81d603c6f0 --- /dev/null +++ b/bacula/src/lib/alist.h @@ -0,0 +1,94 @@ +/* + * Version $Id$ + */ + +/* + Copyright (C) 2000-2003 Kern Sibbald and John Walker + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the Free + Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, + MA 02111-1307, USA. + + */ + +/* + * Array list -- much like a simplified STL vector + * array of pointers to inserted items + */ +class alist { + void **items; + int num_items; + int max_items; + int num_grow; +public: + alist(int num = 1); + void init(int num = 1); + void append(void *item); + void *get(int index); + void * operator [](int index) const; + int size(); + void destroy(); + void grow(int num); + void * operator new(size_t); + void operator delete(void *); +}; + +inline void * alist::operator [](int index) const { + if (index < 0 || index >= num_items) { + return NULL; + } + return items[index]; +} + +/* + * This allows us to do explicit initialization, + * allowing us to mix C++ classes inside malloc'ed + * C structures. Define before called in constructor. + */ +inline void alist::init(int num) { + items = NULL; + num_items = 0; + max_items = 0; + num_grow = num; +} + +/* Constructor */ +inline alist::alist(int num) { + this->init(num); +} + + + +/* Current size of list */ +inline int alist::size() +{ + return num_items; +} + +/* How much to grow by each time */ +inline void alist::grow(int num) +{ + num_grow = num; +} + +inline void * alist::operator new(size_t) +{ + return malloc(sizeof(alist)); +} + +inline void alist::operator delete(void *item) +{ + ((alist *)item)->destroy(); + free(item); +} diff --git a/bacula/src/lib/dlist.c b/bacula/src/lib/dlist.c new file mode 100644 index 0000000000..cd905e6d19 --- /dev/null +++ b/bacula/src/lib/dlist.c @@ -0,0 +1,151 @@ +/* + * Bacula doubly linked list routines. + * + * dlist is a doubly linked list with the links being in the + * list data item. + * + * Kern Sibbald, July MMIII + * + * Version $Id$ + * + */ +/* + Copyright (C) 2000-2003 Kern Sibbald and John Walker + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the Free + Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, + MA 02111-1307, USA. + + */ + +#include "bacula.h" + +/* =================================================================== + * dlist + */ +/* + * Append an item to the list + */ +void dlist::append(void *item) +{ + ((dlink *)((char *)item+loffset))->next = NULL; + ((dlink *)((char *)item+loffset))->prev = tail; + if (tail) { + ((dlink *)((char *)tail+loffset))->next = item; + } + tail = item; + if (head == NULL) { /* if empty list, */ + head = item; /* item is head as well */ + } +} + +/* + * Append an item to the list + */ +void dlist::prepend(void *item) +{ + ((dlink *)((char *)item+loffset))->next = head; + ((dlink *)((char *)item+loffset))->prev = NULL; + if (head) { + ((dlink *)((char *)head+loffset))->prev = item; + } + head = item; + if (tail == NULL) { /* if empty list, */ + tail = item; /* item is tail too */ + } +} + +void dlist::remove(void *item) +{ + void *xitem; + dlink *ilink = (dlink *)((char *)item+loffset); /* item's link */ + if (item == head) { + head = ilink->next; + ((dlink *)((char *)head+loffset))->prev = NULL; + } else if (item == tail) { + tail = ilink->prev; + ((dlink *)((char *)tail+loffset))->next = NULL; + } else { + xitem = ilink->next; + ((dlink *)((char *)xitem+loffset))->prev = ilink->prev; + xitem = ilink->prev; + ((dlink *)((char *)xitem+loffset))->next = ilink->next; + } + free(item); +} + +void * dlist::next(void *item) +{ + if (item == NULL) { + return head; + } + return ((dlink *)((char *)item+loffset))->next; +} + +/* Destroy the list and its contents */ +void dlist::destroy() +{ + for (void *n=head; n; ) { + void *ni = ((dlink *)((char *)n+loffset))->next; + free(n); + n = ni; + } +} + + + +#ifdef TEST_PROGRAM + +struct MYJCR { + char *buf; + dlist link; +}; + +int main() +{ + char buf[30]; + dlist *jcr_chain; + MYJCR *save_jcr = NULL; + + jcr_chain = (dlist *)malloc(sizeof(dlist)); + jcr_chain->init((int)&MYJCR::link); + + printf("Prepend 20 items 0-19\n"); + for (int i=0; i<20; i++) { + MYJCR *jcr; + sprintf(buf, "This is dlist item %d", i); + jcr = (MYJCR *)malloc(sizeof(MYJCR)); + jcr->buf = bstrdup(buf); + jcr_chain->prepend(jcr); + if (i == 10) { + save_jcr = jcr; + } + } + + printf("Remove 10th item\n"); + free(save_jcr->buf); + jcr_chain->remove(save_jcr); + + printf("Print remaining list.\n"); + for (MYJCR *jcr=NULL; (jcr=(MYJCR *)jcr_chain->next(jcr)); ) { + printf("Dlist item = %s\n", jcr->buf); + free(jcr->buf); + } + jcr_chain->destroy(); + free(jcr_chain); + + sm_dump(False); + +} +#endif diff --git a/bacula/src/lib/dlist.h b/bacula/src/lib/dlist.h new file mode 100644 index 0000000000..b698256d69 --- /dev/null +++ b/bacula/src/lib/dlist.h @@ -0,0 +1,91 @@ +/* + * Version $Id$ + */ + +/* + Copyright (C) 2000-2003 Kern Sibbald and John Walker + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the Free + Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, + MA 02111-1307, USA. + + */ + +/* ======================================================================== + * + * Doubly linked list -- dlist + * + */ + +#define OFFSET(item,link) ((char *)link - (char *)item) + +struct dlink { + void *next; + void *prev; +}; + +class dlist { + void *head; + void *tail; + int loffset; +public: + dlist(int offset); + void init(int offset); + void prepend(void *item); + void append(void *item); + void remove(void *item); + void *next(void *item); + void destroy(); + void *first(); + void *last(); + void * operator new(size_t); + void operator delete(void *); +}; + +/* + * This allows us to do explicit initialization, + * allowing us to mix C++ classes inside malloc'ed + * C structures. Define before called in constructor. + */ +inline void dlist::init(int offset) { + head = tail = NULL; + loffset = (int)offset; +} + +/* Constructor */ +inline dlist::dlist(int offset) { + this->init(offset); +} + +inline void * dlist::operator new(size_t) +{ + return malloc(sizeof(dlist)); +} + +inline void dlist::operator delete(void *item) +{ + ((dlist *)item)->destroy(); + free(item); +} + + +inline void * dlist::first() +{ + return head; +} + +inline void * dlist::last() +{ + return tail; +} diff --git a/bacula/src/lib/lib.h b/bacula/src/lib/lib.h index a9afae76db..dd6f07c265 100644 --- a/bacula/src/lib/lib.h +++ b/bacula/src/lib/lib.h @@ -28,7 +28,8 @@ */ -#include "list.h" +#include "alist.h" +#include "dlist.h" #include "bits.h" #include "btime.h" #include "smartall.h" diff --git a/bacula/src/lib/message.c b/bacula/src/lib/message.c index 3ceb904022..4fc1447aac 100755 --- a/bacula/src/lib/message.c +++ b/bacula/src/lib/message.c @@ -61,6 +61,9 @@ char catalog_db[] = "Internal"; #endif #endif +char *host_os = HOST_OS; +char *distname = DISTNAME; +char *distver = DISTVER; /* Forward referenced functions */ diff --git a/bacula/src/version.h b/bacula/src/version.h index 7c67104845..551a570df5 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -1,8 +1,8 @@ /* */ #define VERSION "1.31" #define VSTRING "1" -#define BDATE "10 Jul 2003" -#define LSMDATE "10Jul03" +#define BDATE "14 Jul 2003" +#define LSMDATE "14Jul03" /* Debug flags */ #define DEBUG 1