how to flush out cache.?

Matthew Dillon dillon at apollo.backplane.com
Thu Apr 22 19:42:26 PDT 2004


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



More information about the freebsd-hackers mailing list