RFC: mmap(PROT_READ, MAP_SHARED) fails if !writepage.

From: David Woodhouse (dwmw2@infradead.org)
Date: Fri Nov 08 2002 - 17:49:02 EST


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

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Fri Nov 15 2002 - 22:00:16 EST