Date: Thu, 22 Apr 2004 19:42:24 -0700 (PDT) From: Matthew Dillon <dillon@apollo.backplane.com> To: Stephan Uphoff <ups@tree.com> Cc: Julian Elischer <julian@elischer.org> Subject: Re: how to flush out cache.? Message-ID: <200404230242.i3N2gOMg004349@apollo.backplane.com> References: <200404230103.VAA18066@stups.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Ok... I've done some more testing.
Ahh! I finally was able to reproduce the problem with PROT_READ, and
I now see the code bit you were talking about. That's definitely a bug.
Here's the test program that reproduces the problem. This is definitely
a serious bug.
-Matt
/*
* y.c
*/
#include <sys/types.h>
#include <sys/mman.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
int
main(int ac, char **av)
{
int fd;
char *ptr1;
char *ptr2;
fd = open("test.dat", O_RDWR|O_CREAT|O_TRUNC, 0666);
ftruncate(fd, 4096);
ptr1 = mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
*ptr1 = 'A';
ptr2 = mmap(NULL, 4096, PROT_READ, MAP_SHARED, fd, 0);
if (msync(ptr2, 4096, MS_INVALIDATE | MS_SYNC) < 0)
perror("msync");
printf("contents of *ptr1 is %d\n", *ptr1);
printf("contents of *ptr2 is %d\n", *ptr2);
return(0);
}
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200404230242.i3N2gOMg004349>
