public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* RFC: mmap(PROT_READ, MAP_SHARED) fails if !writepage.
@ 2002-11-08 22:49 David Woodhouse
  2002-11-08 23:31 ` Linus Torvalds
  0 siblings, 1 reply; 5+ messages in thread
From: David Woodhouse @ 2002-11-08 22:49 UTC (permalink / raw)
  To: linux-kernel

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



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2002-11-09 16:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-11-08 22:49 RFC: mmap(PROT_READ, MAP_SHARED) fails if !writepage David Woodhouse
2002-11-08 23:31 ` Linus Torvalds
2002-11-08 23:50   ` David Woodhouse
2002-11-09  2:46     ` Linus Torvalds
2002-11-09 16:36       ` David Woodhouse

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox