Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: Frederick Ros <Frederic.Ros@compaq.com>
Subject: mmap problems
Date: 1999/07/01	[thread overview]
Message-ID: <377B0D0B.FD37DD2@compaq.com> (raw)

Hi,

Im\b'm trying to map a file in memory using mmap. Currently I'm using
Digital
Unix 4.0 ( u\b'uname -a' says : OSF1 tobago.vbe.dec.com V4.0 878 alpha)
with the
DEC C Compiler DEC C V5.6-075 on Digital UNIX V4.0 (Rev. 878)

I've the following program:


/*=================================================================*/
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <errno.h>


int main(void) 
{
  
  int fd, pagesize,i;
  char *data;

  fd = open("/tmp/mapdemofile",O_RDWR| O_CREAT, 0666);


  data = mmap(NULL, 10, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
  
  if ( data == (caddr_t)-1) 
  {
    fprintf(stderr,"%i - %s\n",errno,strerror(errno));
    exit(1);
  }
  
  
  for (i =0 ; i< 10; i++)
    data[i] = '0';
  
  
}
/*======================================================*/



When I compile this example ( cc -o shared -g shared.c), and run it, I
get a:

Segmentation fault (core dumped)

If I replace the filename with mapdemofile instead of /tmp/mapdemofile,
evrything works fine.
In fact, if I try to map /tmp/mapdemofile, the mmap call returns an
adress ( no
error), but I can't neither read nor write to this address.
If the file is in my personnal directory. there's no problem.

In fact my HOME is on another computer, and is link via NFS on my
computer
(tobago).

Does this problem come from the fact that my personnal account is on an
NFS
partition, and that I'm trying to mmap on another partition ??

If I create a new directory on the same partition as /tmp , the problem
still
occurs...

Is this normal, and if so why isn't it specified in the mmap man page ??

Best Regards.

Frederick Ros.



             reply	other threads:[~1999-07-01  4:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-07-01  4:00 Frederick Ros [this message]
1999-07-02  4:00 ` mmap problems Joe Mario
read-only archive

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