TDB on OpenBSD problem.

MCCALL,DON (HP-USA,ex1) don_mccall at
Fri May 4 18:01:51 GMT 2001

I also changed fsync() to fdatasync() during some of my playing around - but

no effect; I should have changed this back before I sent you the modified
Also didn't instrument the write test, as I was not experiencing the error
that operation...

Hope this helps,
 "Reason, not volume, is the primary
differentiator between a discussion, and an

-----Original Message-----
From: tridge at [mailto:tridge at]
Sent: Friday, May 04, 2001 9:39 AM
To: jeremy at; vmn at; samba-technical at
Subject: Re: TDB on OpenBSD problem.

> I think I've just reproduced it using tdbtorture on a OpenBSD vmware
> session. I'm looking into it.

I now have a tiny test program that shows the basic problem. It seems
that on OpenBSD mmap and read are not coherent. I've written to Theo
to ask him about it.

Can those of you seeing the tdb expansion bug please try the following
test program and see if it reports an error.

btw, I think we could make tdb not rely on mmap/read coherence, but
I'd rather first understand whats going on. 

Cheers, Tridge

  trivial test program to see if file IO and mmap are coherent. 
  tridge at, May 2001

#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/mman.h>
#include <sys/stat.h>

#define SIZE 20000

static void test(char *map, int fd, int line)
	unsigned char buf1[SIZE], buf2[SIZE];

	memcpy(buf1, map, SIZE);
	lseek(fd, 0, SEEK_SET);
	read(fd, buf2, SIZE);
	if (memcmp(buf1, buf2, SIZE) != 0) {
		int i;
		for (i=0;i<SIZE;i++) {
			if (buf1[i] != buf2[i]) {
				printf("mismatch at %d (%d %d)\n",
				       i, buf1[i], buf2[i]);
		printf("not equal on line %d!\n", line);

#ifndef MAP_FILE
#define MAP_FILE 0

int main(void)
	int fd;
	char *map;
	char b = 0;

	fd = open("test.dat", O_RDWR|O_CREAT|O_TRUNC, 0600);

	lseek(fd, SIZE-1, SEEK_SET);
	write(fd, &b, 1);


	map[3000] = 17;
	test(map, fd, __LINE__);

	lseek(fd, 76, SEEK_SET);
	write(fd, &fd, sizeof(fd));
	test(map, fd, __LINE__);
	return 0;

More information about the samba-technical mailing list