DragonFly BSD
DragonFly bugs List (threaded) for 2005-07
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

mmap and msdos


From: Richard Nyberg <rnyberg@xxxxxxxxxxxxx>
Date: Sun, 31 Jul 2005 13:32:39 +0200

Set FILEPATH to a path in a msdos fs, run the program  and watch it crash
in the assert. It won't crash if the msync call is removed. I guess this
is a bug in our msdos code.

Happy hacking!
        -Richard

Start of program:
#include <sys/types.h>
#include <sys/mman.h>

#include <assert.h>
#include <err.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>

#define FILEPATH "/mnt/foo"

int
main(void)
{
    int i;
    int fd;
    char *m;

    fd = open(FILEPATH, O_CREAT|O_RDWR, 0660);
    if (fd < 0)
	err(1, "open");

    if (ftruncate(fd, 200) != 0)
	err(1, "ftruncate");

    m = mmap(0, 200, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
    if (m == MAP_FAILED)
	err(1, "mmap");

    if (close(fd) == -1)
	err(1, "close");

    for (i = 0; i < 200; i++)
	m[i] = 'b';

    if (msync(m, 200, MS_SYNC) != 0)
	err(1, "msync");

    for (i = 0; i < 200; i++)
	assert(m[i] == 'b');

    if (munmap(m, 200) != 0)
	err(1, "munmap");

    return 0;
}




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