Subject: mmap and fsync
To: None <tech-kern@netbsd.org>
From: Nick Hudson <skrll@netbsd.org>
List: tech-kern
Date: 03/28/2001 18:03:52
The program below is taken from a configure script and "fails". Is this
correct?

#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);
}


$ uname -a
NetBSD go61923 1.5 NetBSD 1.5 (GO61923) #0: Tue Nov 21 16:17:23 GMT
2000    
nick@kenny:/dsk/NetBSD/NetBSD-1.5/src/sys/arch/i386/compile/GO61923 i386

Nick
-- 
aka skrll@netbsd.org, skrll@excite.co.uk