svn commit: samba r19701 - in branches/SAMBA_3_0_24/source/tdb: .
jra at samba.org
jra at samba.org
Mon Nov 13 21:24:53 GMT 2006
Author: jra
Date: 2006-11-13 21:24:52 +0000 (Mon, 13 Nov 2006)
New Revision: 19701
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=19701
Log:
Back-port Volker's fix to 3.0.24 code tree. Very useful
change.
Jeremy.
Modified:
branches/SAMBA_3_0_24/source/tdb/Makefile
branches/SAMBA_3_0_24/source/tdb/tdb.c
branches/SAMBA_3_0_24/source/tdb/tdbback.c
branches/SAMBA_3_0_24/source/tdb/tdbback.h
branches/SAMBA_3_0_24/source/tdb/tdbbackup.c
Changeset:
Modified: branches/SAMBA_3_0_24/source/tdb/Makefile
===================================================================
--- branches/SAMBA_3_0_24/source/tdb/Makefile 2006-11-13 19:53:15 UTC (rev 19700)
+++ branches/SAMBA_3_0_24/source/tdb/Makefile 2006-11-13 21:24:52 UTC (rev 19701)
@@ -2,13 +2,14 @@
# Makefile for tdb directory
#
-CFLAGS = -DSTANDALONE -DTDB_DEBUG -g -DHAVE_MMAP=1
+CFLAGS = -DSTANDALONE -DTDB_DEBUG -g -DHAVE_MMAP=1 -I../include
CC = gcc
ADMINPROGS = tdbdump tdbbackup
PROGS = tdbtest tdbtool tdbtorture
TDB_OBJ = tdb.o spinlock.o tdbback.o
+all: $(PROGS) $(ADMINPROGS)
default: $(PROGS)
admintools: $(ADMINPROGS)
Modified: branches/SAMBA_3_0_24/source/tdb/tdb.c
===================================================================
--- branches/SAMBA_3_0_24/source/tdb/tdb.c 2006-11-13 19:53:15 UTC (rev 19700)
+++ branches/SAMBA_3_0_24/source/tdb/tdb.c 2006-11-13 21:24:52 UTC (rev 19701)
@@ -531,7 +531,7 @@
&totalsize);
}
-static tdb_off tdb_dump_record(TDB_CONTEXT *tdb, tdb_off offset)
+static tdb_off tdb_dump_record(TDB_CONTEXT *tdb, int hash, tdb_off offset)
{
struct list_struct rec;
tdb_off tailer_ofs, tailer;
@@ -541,8 +541,8 @@
return 0;
}
- printf(" rec: offset=%u next=%d rec_len=%d key_len=%d data_len=%d full_hash=0x%x magic=0x%x\n",
- offset, rec.next, rec.rec_len, rec.key_len, rec.data_len, rec.full_hash, rec.magic);
+ printf(" rec: hash=%d, offset=%u next=%d rec_len=%d key_len=%d data_len=%d full_hash=0x%x magic=0x%x\n",
+ hash, offset, rec.next, rec.rec_len, rec.key_len, rec.data_len, rec.full_hash, rec.magic);
tailer_ofs = offset + sizeof(rec) + rec.rec_len - sizeof(tdb_off);
if (ofs_read(tdb, tailer_ofs, &tailer) == -1) {
@@ -574,7 +574,7 @@
printf("hash=%d\n", i);
while (rec_ptr) {
- rec_ptr = tdb_dump_record(tdb, rec_ptr);
+ rec_ptr = tdb_dump_record(tdb, i, rec_ptr);
hash_length += 1;
}
Modified: branches/SAMBA_3_0_24/source/tdb/tdbback.c
===================================================================
--- branches/SAMBA_3_0_24/source/tdb/tdbback.c 2006-11-13 19:53:15 UTC (rev 19700)
+++ branches/SAMBA_3_0_24/source/tdb/tdbback.c 2006-11-13 21:24:52 UTC (rev 19701)
@@ -95,7 +95,7 @@
only doing the backup if its OK
this function is also used for restore
*/
-int backup_tdb(const char *old_name, const char *new_name)
+int backup_tdb(const char *old_name, const char *new_name, int hash_size)
{
TDB_CONTEXT *tdb;
TDB_CONTEXT *tdb_new;
@@ -122,7 +122,7 @@
/* create the new tdb */
unlink(tmp_name);
- tdb_new = tdb_open(tmp_name, tdb->header.hash_size,
+ tdb_new = tdb_open(tmp_name, hash_size ? hash_size : tdb->header.hash_size,
TDB_DEFAULT, O_RDWR|O_CREAT|O_EXCL,
st.st_mode & 0777);
if (!tdb_new) {
@@ -217,7 +217,7 @@
/* count is < 0 means an error */
if (count < 0) {
printf("restoring %s\n", fname);
- return backup_tdb(bak_name, fname);
+ return backup_tdb(bak_name, fname, 0);
}
printf("%s : %d records\n", fname, count);
Modified: branches/SAMBA_3_0_24/source/tdb/tdbback.h
===================================================================
--- branches/SAMBA_3_0_24/source/tdb/tdbback.h 2006-11-13 19:53:15 UTC (rev 19700)
+++ branches/SAMBA_3_0_24/source/tdb/tdbback.h 2006-11-13 21:24:52 UTC (rev 19701)
@@ -19,5 +19,5 @@
*/
char *add_suffix(const char *name, const char *suffix);
-int backup_tdb(const char *old_name, const char *new_name);
+int backup_tdb(const char *old_name, const char *new_name, int hash_size);
int verify_tdb(const char *fname, const char *bak_name);
Modified: branches/SAMBA_3_0_24/source/tdb/tdbbackup.c
===================================================================
--- branches/SAMBA_3_0_24/source/tdb/tdbbackup.c 2006-11-13 19:53:15 UTC (rev 19700)
+++ branches/SAMBA_3_0_24/source/tdb/tdbbackup.c 2006-11-13 21:24:52 UTC (rev 19701)
@@ -93,6 +93,7 @@
printf(" -h this help message\n");
printf(" -s suffix set the backup suffix\n");
printf(" -v verify mode (restore if corrupt)\n");
+ printf(" -n hashsize set the new hash size for the backup\n");
}
@@ -102,9 +103,10 @@
int ret = 0;
int c;
int verify = 0;
+ int hashsize = 0;
const char *suffix = ".bak";
- while ((c = getopt(argc, argv, "vhs:")) != -1) {
+ while ((c = getopt(argc, argv, "vhs:n:")) != -1) {
switch (c) {
case 'h':
usage();
@@ -115,6 +117,9 @@
case 's':
suffix = optarg;
break;
+ case 'n':
+ hashsize = atoi(optarg);
+ break;
}
}
@@ -138,7 +143,7 @@
}
} else {
if (file_newer(fname, bak_name) &&
- backup_tdb(fname, bak_name) != 0) {
+ backup_tdb(fname, bak_name, hashsize) != 0) {
ret = 1;
}
}
More information about the samba-cvs
mailing list