From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,eeac0fcac5e55248,start X-Google-Attributes: gidfee84,public From: Frederick Ros Subject: mmap problems Date: 1999/07/01 Message-ID: <377B0D0B.FD37DD2@compaq.com>#1/1 X-Deja-AN: 496404914 Content-Transfer-Encoding: 7bit Organization: Digital X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 Newsgroups: comp.unix.osf.osf1 Hi, Im'm trying to map a file in memory using mmap. Currently I'm using Digital Unix 4.0 ( u'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 #include #include #include #include #include #include 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.