Return to BSD News archive
Xref: sserve comp.unix.bsd:15269 comp.unix.internals:7964 Newsgroups: comp.unix.bsd,comp.unix.internals Path: sserve!newshost.anu.edu.au!munnari.oz.au!news.Hawaii.Edu!ames!hookup!news.mathworks.com!udel!gatech!howland.reston.ans.net!EU.net!uunet!clsi!shankha From: shankha@tibu (Shankha S. Mitra) Subject: Re: mmap() returns errno = 5. Any Clues?? In-Reply-To: leo@krabat.marco.de's message of 26 Oct 94 09:34:34 GMT Message-ID: <SHANKHA.94Nov2164334@canopus.tibu> Followup-To: comp.unix.bsd,comp.unix.internals Sender: usenet@clsi.COM Organization: COMPASS Design Automation References: <38gb37$4d6@speedy.inri.com> <3895@krabat.marco.de> Date: 02 Nov 1994 21:43:34 GMT Lines: 71 In article <3895@krabat.marco.de> leo@krabat.marco.de (Matthias Pfaller) writes: Xref: clsi comp.unix.bsd:16206 comp.unix.internals:4014 Path: clsi!uunet!news.mathworks.com!news.duke.edu!convex!cs.utexas.edu!howland.reston.ans.net!EU.net!Germany.EU.net!b.marco.de!krabat!leo From: leo@krabat.marco.de (Matthias Pfaller) Newsgroups: comp.unix.bsd,comp.unix.internals Date: 26 Oct 94 09:34:34 GMT References: <38gb37$4d6@speedy.inri.com> Followup-To: comp.unix.bsd,comp.unix.internals Distribution: world Organization: marco GmbH, D-85221 Dachau Lines: 17 X-Newsreader: TIN [version 1.2 PL2] Anthony D Alston (ada@grumpy.mnfep.nn.inri.com) wrote: > The following line fails when trying to memory map a file thats > on a NFS mount directory. mmap() returns 0xffffff and errno = 5. > This line works fine when the file is on a local file system. > addr = mmap(0, map_size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0l); > I'm running SunOS 4.1.1 I had problems with mmap, nfs and SunOS 4.x.x too. It turned out that if you have locked the file in question you can't mmap it for an unknown period of time even if the lock is removed... So in case your mixing mmap and nfs locking you may have the same problem I had (Solution: Don't use mmap). Matthias Anthony: I tried an example out: #ifdef READ_WRITE fd = open(file, O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO); #else fd = open(file, O_RDONLY, S_IRWXU | S_IRWXG | S_IRWXO); #endif /* find the length of the file */ lseek(fd, (off_t)0, SEEK_END); len = lseek(fd, (off_t)0, SEEK_CUR); lseek(fd, (off_t)0, SEEK_SET); /* position back to beginning */ /* map file into memory */ #ifdef READ_WRITE /* ada@grumpy.mnfep.nn.inri.com (Anthony D Alston) reports this doesn't work on SunOS 4.1.1 if file is on an NFS mount directory */ *pa = mmap(0, len, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); #else *pa = mmap(0, len, PROT_READ, MAP_SHARED, fd, 0); #endif Both ifdef's work on files in both local and NFS-mounted disks. I running on SunOS 4.1.3 though. I was getting an EACCES because I was opening the file with O_RDONLY and trying to map it with PROT_READ|PROT_WRITE. You're not doing somthing similar are you? Shankha -- ------------------------------------------------------------------------------ Shankha S. Mitra shankha@compass-da.com COMPASS Design Automation 410.992.5700 x1227 ------------------------------------------------------------------------------