[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: oBSD as mailserver



I got a lot of answers on my question and decided
to do some digging myself.
This is the code that the cyrus configure uses to check memory
mapping support.


#include <sys/types.h>
#include <sys/mman.h>
#include <fcntl.h>

main() {

  char *base;
  int fd = open("conftestmmap", O_RDWR|O_CREAT|O_TRUNC, 0666);
  if (fd == -1) exit(1);
  if (write(fd, "test", 4) != 4) exit(1);
  fsync(fd);
  base = mmap((caddr_t)0, 100, PROT_READ, MAP_SHARED | MAP_FILE, fd, 0L);
  if (base == (caddr_t)-1) exit(1);
  if (strncmp(base, "test", 4) != 0) exit(1);
  if (write(fd, "test", 4) != 4) exit(1);
  fsync(fd);
  if (strncmp(base+4, "test", 4) != 0) exit(1);
  exit(0);
}

I compile and run this through gdb and it doesn't look good.
After the last fsync I checked the file, and compared it
with what was in memory at base, and the last write isn't there,
so of course the last strncmp fails.
I compiled and run it throught gdb on a FreeBSD2.2.8, and here it
looks OK.

Any comments on this ?

BTW, my system is OpenBSD2.4.

Tony Sarendal



Visit your host, monkey.org