lkml.org 
[lkml]   [2002]   [Nov]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
SubjectRFC: mmap(PROT_READ, MAP_SHARED) fails if !writepage.
Date
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/

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