Author: jerry
Date: 2007-02-06 21:10:08 +0000 (Tue, 06 Feb 2007)
New Revision: 21193

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=21193

Log:
sync tdb code from SAMBA_3_0
Added:
   branches/SAMBA_3_0_25/source/tdb/common/freelistcheck.c
Modified:
   branches/SAMBA_3_0_25/source/tdb/Makefile.in
   branches/SAMBA_3_0_25/source/tdb/autogen.sh
   branches/SAMBA_3_0_25/source/tdb/common/freelist.c
   branches/SAMBA_3_0_25/source/tdb/common/tdb_private.h
   branches/SAMBA_3_0_25/source/tdb/config.m4
   branches/SAMBA_3_0_25/source/tdb/include/tdb.h
   branches/SAMBA_3_0_25/source/tdb/tools/tdbtest.c


Changeset:
Modified: branches/SAMBA_3_0_25/source/tdb/Makefile.in
===================================================================
--- branches/SAMBA_3_0_25/source/tdb/Makefile.in        2007-02-06 21:08:35 UTC 
(rev 21192)
+++ branches/SAMBA_3_0_25/source/tdb/Makefile.in        2007-02-06 21:10:08 UTC 
(rev 21193)
@@ -12,13 +12,19 @@
 VPATH = @srcdir@:@libreplacedir@
 srcdir = @srcdir@
 builddir = @builddir@
-CFLAGS = -I$(srcdir)/include -Iinclude [EMAIL PROTECTED]@ @CFLAGS@
+CPPFLAGS = @CPPFLAGS@ -I$(srcdir)/include -Iinclude -I../include [EMAIL 
PROTECTED]@
+CFLAGS = $(CPPFLAGS) @CFLAGS@
+LDFLAGS = @LDFLAGS@
+EXEEXT = @EXEEXT@
 
 .PHONY: test
 
-PROGS = bin/tdbtool bin/tdbtorture
-TDB_OBJ = @TDBOBJ@ @LIBREPLACEOBJ@
+PROGS = bin/tdbtool$(EXEEXT) bin/tdbtorture$(EXEEXT)
+PROGS_NOINSTALL = bin/tdbtest$(EXEEXT) bin/tdbdump$(EXEEXT) 
bin/tdbbackup$(EXEEXT)
+ALL_PROGS = $(PROGS) $(PROGS_NOINSTALL)
 
+TDB_OBJ = @TDBOBJ@
+
 DIRS = bin common tools
 
 all: showflags dirs $(PROGS)
@@ -26,6 +32,8 @@
 showflags:
        @echo 'tdb will be compiled with flags:'
        @echo '  CFLAGS = $(CFLAGS)'
+       @echo '  CPPFLAGS = $(CPPFLAGS)'
+       @echo '  LDFLAGS = $(LDFLAGS)'
        @echo '  LIBS = $(LIBS)'
 
 .c.o:
@@ -48,28 +56,28 @@
 libtdb.a: $(TDB_OBJ)
        ar -rv libtdb.a $(TDB_OBJ)
 
-bin/tdbtest: tools/tdbtest.o libtdb.a
-       $(CC) $(CFLAGS) -o bin/tdbtest tools/tdbtest.o -L. -ltdb -lgdbm
+bin/tdbtest$(EXEEXT): tools/tdbtest.o libtdb.a
+       $(CC) $(CFLAGS) $(LDFLAGS) -o bin/tdbtest tools/tdbtest.o -L. -ltdb 
-lgdbm
 
-bin/tdbtool: tools/tdbtool.o libtdb.a
-       $(CC) $(CFLAGS) -o bin/tdbtool tools/tdbtool.o -L. -ltdb
+bin/tdbtool$(EXEEXT): tools/tdbtool.o libtdb.a
+       $(CC) $(CFLAGS) $(LDFLAGS) -o bin/tdbtool tools/tdbtool.o -L. -ltdb
 
-bin/tdbtorture: tools/tdbtorture.o libtdb.a
-       $(CC) $(CFLAGS) -o bin/tdbtorture tools/tdbtorture.o -L. -ltdb
+bin/tdbtorture$(EXEEXT): tools/tdbtorture.o libtdb.a
+       $(CC) $(CFLAGS) $(LDFLAGS) -o bin/tdbtorture tools/tdbtorture.o -L. 
-ltdb
 
-bin/tdbdump: tools/tdbdump.o libtdb.a
-       $(CC) $(CFLAGS) -o bin/tdbdump tools/tdbdump.o -L. -ltdb
+bin/tdbdump$(EXEEXT): tools/tdbdump.o libtdb.a
+       $(CC) $(CFLAGS) $(LDFLAGS) -o bin/tdbdump tools/tdbdump.o -L. -ltdb
 
-bin/tdbbackup: tools/tdbbackup.o libtdb.a
-       $(CC) $(CFLAGS) -o bin/tdbbackup tools/tdbbackup.o -L. -ltdb
+bin/tdbbackup$(EXEEXT): tools/tdbbackup.o libtdb.a
+       $(CC) $(CFLAGS) $(LDFLAGS) -o bin/tdbbackup tools/tdbbackup.o -L. -ltdb
 
-test: bin/tdbtorture
-       bin/tdbtorture
+test: bin/tdbtorture$(EXEEXT)
+       bin/tdbtorture$(EXEEXT)
 
 installcheck: test install
 
 clean:
-       rm -f $(PROGS) *.o *.a common/*.o tools/*.o tdb.pc
+       rm -f $(ALL_PROGS) *.o *.a common/*.o tools/*.o tdb.pc
        rm -f test.db test.tdb torture.tdb test.gdbm
 
 distclean: clean

Modified: branches/SAMBA_3_0_25/source/tdb/autogen.sh
===================================================================
--- branches/SAMBA_3_0_25/source/tdb/autogen.sh 2007-02-06 21:08:35 UTC (rev 
21192)
+++ branches/SAMBA_3_0_25/source/tdb/autogen.sh 2007-02-06 21:10:08 UTC (rev 
21193)
@@ -3,7 +3,7 @@
 rm -rf autom4te.cache
 rm -f configure config.h.in
 
-IPATHS="-I libreplace -I lib/replace -I ../libreplace -I ../replace"
+IPATHS="-I libreplace -I lib/replace -I ../libreplace -I ../replace -I 
../lib/replace"
 autoconf $IPATHS || exit 1
 autoheader $IPATHS || exit 1
 

Modified: branches/SAMBA_3_0_25/source/tdb/common/freelist.c
===================================================================
--- branches/SAMBA_3_0_25/source/tdb/common/freelist.c  2007-02-06 21:08:35 UTC 
(rev 21192)
+++ branches/SAMBA_3_0_25/source/tdb/common/freelist.c  2007-02-06 21:10:08 UTC 
(rev 21193)
@@ -29,7 +29,7 @@
 #include "tdb_private.h"
 
 /* read a freelist record and check for simple errors */
-static int rec_free_read(struct tdb_context *tdb, tdb_off_t off, struct 
list_struct *rec)
+int rec_free_read(struct tdb_context *tdb, tdb_off_t off, struct list_struct 
*rec)
 {
        if (tdb->methods->tdb_read(tdb, off, rec, sizeof(*rec),DOCONV()) == -1)
                return -1;

Copied: branches/SAMBA_3_0_25/source/tdb/common/freelistcheck.c (from rev 
21182, branches/SAMBA_3_0/source/tdb/common/freelistcheck.c)

Modified: branches/SAMBA_3_0_25/source/tdb/common/tdb_private.h
===================================================================
--- branches/SAMBA_3_0_25/source/tdb/common/tdb_private.h       2007-02-06 
21:08:35 UTC (rev 21192)
+++ branches/SAMBA_3_0_25/source/tdb/common/tdb_private.h       2007-02-06 
21:10:08 UTC (rev 21193)
@@ -198,5 +198,7 @@
                           struct list_struct *rec);
 void tdb_io_init(struct tdb_context *tdb);
 int tdb_expand(struct tdb_context *tdb, tdb_off_t size);
+int rec_free_read(struct tdb_context *tdb, tdb_off_t off,
+                 struct list_struct *rec);
 
 

Modified: branches/SAMBA_3_0_25/source/tdb/config.m4
===================================================================
--- branches/SAMBA_3_0_25/source/tdb/config.m4  2007-02-06 21:08:35 UTC (rev 
21192)
+++ branches/SAMBA_3_0_25/source/tdb/config.m4  2007-02-06 21:10:08 UTC (rev 
21193)
@@ -1,3 +1,24 @@
+dnl find the tdb sources. This is meant to work both for
+dnl tdb standalone builds, and builds of packages using tdb
+tdbdir=""
+tdbpaths="$srcdir $srcdir/lib/tdb $srcdir/tdb $srcdir/../tdb"
+for d in $tdbpaths; do
+        if test -f "$d/common/tdb.c"; then
+                tdbdir="$d"
+                AC_SUBST(tdbdir)
+                break;
+        fi
+done
+if test x"$tdbdir" = "x"; then
+   AC_MSG_ERROR([cannot find tdb source in $tdbpaths])
+fi
+TDBOBJ="common/tdb.o common/dump.o common/transaction.o common/error.o 
common/traverse.o"
+TDBOBJ="$TDBOBJ common/freelist.o common/freelistcheck.o common/io.o 
common/lock.o common/open.o"
+AC_SUBST(TDBOBJ)
+
+libreplacedir=../lib/replace
+AC_SUBST(libreplacedir)
+
 AC_CHECK_FUNCS(mmap pread pwrite getpagesize utime)
 AC_CHECK_HEADERS(getopt.h sys/select.h sys/time.h)
 

Modified: branches/SAMBA_3_0_25/source/tdb/include/tdb.h
===================================================================
--- branches/SAMBA_3_0_25/source/tdb/include/tdb.h      2007-02-06 21:08:35 UTC 
(rev 21192)
+++ branches/SAMBA_3_0_25/source/tdb/include/tdb.h      2007-02-06 21:10:08 UTC 
(rev 21193)
@@ -136,6 +136,7 @@
 /* Debug functions. Not used in production. */
 void tdb_dump_all(struct tdb_context *tdb);
 int tdb_printfreelist(struct tdb_context *tdb);
+int tdb_validate_freelist(struct tdb_context *tdb, int *pnum_entries);
 
 extern TDB_DATA tdb_null;
 

Modified: branches/SAMBA_3_0_25/source/tdb/tools/tdbtest.c
===================================================================
--- branches/SAMBA_3_0_25/source/tdb/tools/tdbtest.c    2007-02-06 21:08:35 UTC 
(rev 21192)
+++ branches/SAMBA_3_0_25/source/tdb/tools/tdbtest.c    2007-02-06 21:10:08 UTC 
(rev 21193)
@@ -219,6 +219,7 @@
 {
        int i, seed=0;
        int loops = 10000;
+       int num_entries;
        char test_gdbm[] = "test.gdbm";
 
        unlink("test.gdbm");
@@ -232,8 +233,6 @@
                fatal("db open failed");
        }
 
-       tdb_logging_function(db, tdb_log);
-       
 #if 1
        srand(seed);
        _start_timer();
@@ -248,6 +247,12 @@
        for (i=0;i<loops;i++) addrec_db();
        printf("tdb got %.2f ops/sec\n", i/_end_timer());
 
+       if (tdb_validate_freelist(db, &num_entries) == -1) {
+               printf("tdb freelist is corrupt\n");
+       } else {
+               printf("tdb freelist is good (%d entries)\n", num_entries);
+       }
+
        compare_db();
 
        printf("traversed %d records\n", tdb_traverse(db, traverse_fn, NULL));

Reply via email to