Muli Ben-Yehuda wrote:
On Mon, Jan 31, 2005 at 12:36:44PM +0200, Shachar Shemesh wrote:
Now here's the strange bit. If I open the file as "O_RDWR|O_CREAT, this
scheme works. The man page for mmap says that the prot argument "must
not conflict with the open mode of the file", but surely there is no
conflict between "O_WRONLY" and "PROT_WRITE".
Or is there?
do_mmap_pgoff():
case MAP_PRIVATE:
if (!(file->f_mode & FMODE_READ))
return -EACCES;
Are you trying to map it MAP_PRIVATE?
I find the combination "MAP_PRIVATE" and "PROT_WRITE" alone the most
non-sensical one there is. It's fairly easy to implement as far as the
kernel is concerned, though. Just dump whatever is written into it - the
user will never know the difference.
what is errno?
EPERM
Thinking about it logically, it makes sense to fail the mapping if you
don't have O_READ on the file, because with mmap we have no easy way
of making sure you only write to the pointer you get back, and not
read from it...
Huh? The CPU can enforce that, can't it? If a page is marked write only,
I cannot read from it. Just tried it - trying to read from memory
successfully mapped as "PROT_WRITE" produces a segmentation fault.
Cheers,
Muli
Shachar
--
Shachar Shemesh
Lingnu Open Source Consulting ltd.
http://www.lingnu.com/
=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]