lkml.org 
[lkml]   [1997]   [Jul]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: mmap() on write only files
Jim Nance writes:

> The following program makes a call to mmap() which fails under
> Linux 2.0.27 2.0.29 and Digital Unix 4.0B. I have not tested it
> under other operating systems. If the file descriptor is opened
> with O_RDWR the mmap() call works. Is this a bug or a feature?

I think it behaves correctly. Also an Ultrix and IRIX Version of this
code fails. The problem is more likely an old Linux man page which
specifies

ERRORS
For mmap:

EACCES The flag PROT_READ was specified as part of the
prot parameter and fd was not open for reading.
The flags PROT_WRITE, MAP_SHARED and MAP_WRITE
were specified as part of the flags and prot
parameters and fd was not open for writing.

or another later version of the man page:

EACCES MAP_PRIVATE was asked, but fd is not open for read­
ing. Or MAP_SHARED was asked and PROT_WRITE is set,
fd is not open for writing.


Instead mmaped files are always required to be open for reading
(compare mm/mmap.c - do_mmap()) - the code is more correct than the
man page...

OSF:

[EACCES] The file referred to by filedes is not open for read access, or
the file is not open for write access and PROT_WRITE was set for
a MAP_SHARED mapping operation.

IRIX:
EACCES fd is not open for read, regardless of the protection specified,
or fd is not open for write and PROT_WRITE was specified for a
MAP_SHARED type mapping.

HPUX:
[EACCESS] The file referred to by fildes is not open for
read access, or the file is not open for write
access and PROT_WRITE was set for a MAP_SHARED
mapping operation, or PROT_EXECUTE was set for a
MAP_SHARED mapping operation and the underlying
file does not have execute permission.



Wolfgang
--
_/ _/ _/ _/ _/_/_/ . Wolfgang Wander
_/ _/ _/ _/ _/ . MIT-LNS Email: wwc@ralph2.mit.edu
_/_/_/ _/_/_/ _/ . 77 Mass Ave 24-006 Tel: (617) 253 5222 - Fax: 258 6591
_/_/_/ _/_/_/ _/_/_/ . Cambridge, MA 02139-4307




\
 
 \ /
  Last update: 2005-03-22 13:39    [W:0.053 / U:0.160 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site