TDB on OpenBSD problem.

Jeremy Allison jeremy at valinux.com
Fri May 4 21:42:46 GMT 2001


Ok - please discard my earlier patch. I now have tdbtorure
running correctly on an OpenBSD box. Thanks to Chris on the
Team for giving me ssh access.

Please try the following patch against the 2.2.0 tdb/tdb.c
code. Essentially I changed tdb.c to ensure that any lseek/
write calls were done whilst the file was unmapped, and 
remapped the file before adding the new free space back in.

Please let me know if this fixes the problem on Open BSD and
HPUX 10.x.

Thanks,

		Jeremy Allison,
		Samba Team.


--- tdb.c	Fri Apr 13 17:36:46 2001
+++ /tmp/tdb.c	Fri May  4 14:35:34 2001
@@ -439,20 +439,24 @@
            the database up to a multiple of TDB_PAGE_SIZE */
 	size = TDB_ALIGN(tdb->map_size + size*10, TDB_PAGE_SIZE) - tdb->map_size;
 
-	/* expand the file itself */
-        if (!(tdb->flags & TDB_INTERNAL)) {
-		lseek(tdb->fd, tdb->map_size + size - 1, SEEK_SET);
-		if (write(tdb->fd, &b, 1) != 1) goto fail;
-        }
-
 	if (!(tdb->flags & TDB_INTERNAL) && tdb->map_ptr)
 		tdb->map_ptr = tdb_munmap(tdb->map_ptr, tdb->map_size);
 
+	/* expand the file itself */
+	if (!(tdb->flags & TDB_INTERNAL)) {
+		if (lseek(tdb->fd, tdb->map_size + size - 1, SEEK_SET)!=tdb->map_size + size - 1)
+			goto fail;
+		if (write(tdb->fd, &b, 1) != 1) goto fail;
+	}
+
 	tdb->map_size += size;
 
 	if (tdb->flags & TDB_INTERNAL)
 		tdb->map_ptr = realloc(tdb->map_ptr, tdb->map_size);
 
+	if (!(tdb->flags & TDB_NOMMAP))
+		tdb->map_ptr = tdb_mmap(tdb->map_size, 0, tdb->fd);
+
 	/* form a new freelist record */
 	memset(&rec,'\0',sizeof(rec));
 	rec.rec_len = size - sizeof(rec);
@@ -460,9 +464,6 @@
 	/* link it into the free list */
 	offset = tdb->map_size - size;
 	if (tdb_free(tdb, offset, &rec) == -1) goto fail;
-
-	if (!(tdb->flags & TDB_NOMMAP))
-		tdb->map_ptr = tdb_mmap(tdb->map_size, 0, tdb->fd);
 
 	tdb_unlock(tdb, -1, F_WRLCK);
 	return 0;
-- 
--------------------------------------------------------
Buying an operating system without source is like buying
a self-assembly Space Shuttle with no instructions.
--------------------------------------------------------




More information about the samba-technical mailing list