public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* Problem with mmap
@ 2001-08-29 15:47 Kenneth Johansson
  2001-08-29 16:11 ` David Woodhouse
  0 siblings, 1 reply; 2+ messages in thread
From: Kenneth Johansson @ 2001-08-29 15:47 UTC (permalink / raw)
  To: mtd

[-- Attachment #1: Type: text/plain, Size: 258 bytes --]

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@inn.ericsson.se

[-- Attachment #2: fail1.c --]
[-- Type: text/plain, Size: 748 bytes --]

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-08-29 16:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-08-29 15:47 Problem with mmap Kenneth Johansson
2001-08-29 16:11 ` David Woodhouse

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox