public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Woodhouse <dwmw2@infradead.org>
To: linux-kernel@vger.kernel.org
Subject: RFC: mmap(PROT_READ, MAP_SHARED) fails if !writepage.
Date: Fri, 08 Nov 2002 22:49:02 +0000	[thread overview]
Message-ID: <24305.1036795742@passion.cambridge.redhat.com> (raw)

Why does a _readonly_ mapping fail if the file system has no writepage 
method? 

do_mmap_pgoff() sets VM_MAYWRITE on the vma and then generic_file_mmap() 
refuses to allow it. 

Suggested patch below.... or should I just hack fsx-linux to use 
MAP_PRIVATE for its readonly mappings and ignore it?

--- 1.157/mm/filemap.c  Sun Nov  3 02:55:27 2002
+++ edited/mm/filemap.c Fri Nov  8 22:08:22 2002
@@ -1311,9 +1311,12 @@
        struct address_space *mapping = file->f_dentry->d_inode->i_mapping;
        struct inode *inode = mapping->host;

-       if ((vma->vm_flags & VM_SHARED) && (vma->vm_flags & VM_MAYWRITE)) {
-               if (!mapping->a_ops->writepage)
+       if ((vma->vm_flags & VM_SHARED) && (vma->vm_flags & VM_MAYWRITE) &&
+           !mapping->a_ops->writepage) {
+               if (vma->vm_flags & VM_WRITE)
                        return -EINVAL;
+               else
+                       vma->vm_flags &= ~VM_MAYWRITE;
        }
        if (!mapping->a_ops->readpage)
                return -ENOEXEC;


--
dwmw2



             reply	other threads:[~2002-11-08 22:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-08 22:49 David Woodhouse [this message]
2002-11-08 23:31 ` RFC: mmap(PROT_READ, MAP_SHARED) fails if !writepage Linus Torvalds
2002-11-08 23:50   ` David Woodhouse
2002-11-09  2:46     ` Linus Torvalds
2002-11-09 16:36       ` David Woodhouse

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=24305.1036795742@passion.cambridge.redhat.com \
    --to=dwmw2@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox