3 // Used to test mmap writing (ie yaffs_writepage)
5 // Written by James McKenzie
16 main (int argc, char *argv[])
24 (void) unlink ("testfile");
26 fd = open ("testfile", O_RDWR | O_CREAT | O_TRUNC, 0666);
34 if (lseek (fd, size, SEEK_SET) != size)
40 if (write (fd, "", 1) != 1)
48 map = mmap (NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
49 if (map == MAP_FAILED)
55 memset (map, 1 + (*(unsigned char *) map), size);
59 printf ("msync(map,8536,MS_SYNC) returns %d (errno=%d [%s])\n",
60 msync (map, 8536, MS_SYNC), errno, strerror (errno));
62 (void) munmap (map, size);