Problem with mmap
Kenneth Johansson
kenneth.johansson at inn.ericsson.se
Wed Aug 29 11:47:33 EDT 2001
Here is a program that works on ext2 but not on jffs2.
--
Kenneth Johansson
Ericsson Business Innovation AB Tel: +46 8 404 71 83
Viderögatan 3 Fax: +46 8 404 72 72
164 80 Stockholm kenneth.johansson at inn.ericsson.se
-------------- next part --------------
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
#include <stdio.h>
#include <string.h>
static const char *file = "mmap_file";
#define FILE_SIZE 8192
int main ()
{
int i,fd;
unsigned char *map;
if ((fd = open ("mmap_file",O_RDWR|O_CREAT)) < 0) {
printf("Could not open file %s\n",file);
perror (NULL);
exit (1);
}
map = mmap (NULL,
FILE_SIZE,
PROT_READ | PROT_WRITE,
MAP_SHARED,
fd,
0);
if (map == MAP_FAILED){
printf("Could not mmap file %s\n",file);
perror (NULL);
exit (1);
}
printf("mmap of file %s OK\n",file);
munmap (map,FILE_SIZE);
close (fd);
exit (0);
}
More information about the linux-mtd
mailing list