Commit 91ec8aa9 authored by Andrew Morton's avatar Andrew Morton Committed by James Bottomley

[PATCH] Fix filesystems that cannot do mmap writeback

The writepage-removal patch broke filesystems which do not want to
support writeable mappings.

Fix that up by making those filesystems point their mmap vector at the
new generic_file_readonly_mmap().
parent 1ae41b20
......@@ -37,7 +37,7 @@ struct inode_operations afs_file_inode_operations = {
struct file_operations afs_file_file_operations = {
.read = generic_file_read,
.write = afs_file_write,
.mmap = generic_file_mmap,
.mmap = generic_file_readonly_mmap,
#if 0
.open = afs_file_open,
.release = afs_file_release,
......
......@@ -74,7 +74,7 @@ struct inode_operations befs_dir_inode_operations = {
struct file_operations befs_file_operations = {
.llseek = default_llseek,
.read = generic_file_read,
.mmap = generic_file_mmap,
.mmap = generic_file_readonly_mmap,
};
struct address_space_operations befs_aops = {
......
......@@ -1641,7 +1641,7 @@ static struct file_operations jffs_file_operations =
.read = generic_file_read,
.write = generic_file_write,
.ioctl = jffs_ioctl,
.mmap = generic_file_mmap,
.mmap = generic_file_readonly_mmap,
.fsync = jffs_fsync,
.sendfile = generic_file_sendfile,
};
......
......@@ -58,7 +58,7 @@ struct file_operations jffs2_file_operations =
.read = generic_file_read,
.write = generic_file_write,
.ioctl = jffs2_ioctl,
.mmap = generic_file_mmap,
.mmap = generic_file_readonly_mmap,
.fsync = jffs2_fsync,
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,29)
.sendfile = generic_file_sendfile
......
......@@ -19,7 +19,7 @@
struct file_operations generic_ro_fops = {
.llseek = generic_file_llseek,
.read = generic_file_read,
.mmap = generic_file_mmap,
.mmap = generic_file_readonly_mmap,
.sendfile = generic_file_sendfile,
};
......
......@@ -1233,6 +1233,7 @@ extern int sb_set_blocksize(struct super_block *, int);
extern int sb_min_blocksize(struct super_block *, int);
extern int generic_file_mmap(struct file *, struct vm_area_struct *);
extern int generic_file_readonly_mmap(struct file *, struct vm_area_struct *);
extern int file_read_actor(read_descriptor_t * desc, struct page *page, unsigned long offset, unsigned long size);
extern int file_send_actor(read_descriptor_t * desc, struct page *page, unsigned long offset, unsigned long size);
extern ssize_t generic_file_read(struct file *, char *, size_t, loff_t *);
......
......@@ -228,6 +228,7 @@ EXPORT_SYMBOL(file_ra_state_init);
EXPORT_SYMBOL(generic_file_write);
EXPORT_SYMBOL(generic_file_write_nolock);
EXPORT_SYMBOL(generic_file_mmap);
EXPORT_SYMBOL(generic_file_readonly_mmap);
EXPORT_SYMBOL(generic_ro_fops);
EXPORT_SYMBOL(file_lock_list);
EXPORT_SYMBOL(locks_init_lock);
......
......@@ -1293,6 +1293,14 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
vma->vm_ops = &generic_file_vm_ops;
return 0;
}
int generic_file_readonly_mmap(struct file *file, struct vm_area_struct *vma)
{
if ((vma->vm_flags & VM_SHARED) && (vma->vm_flags & VM_WRITE))
return -EINVAL;
vma->vm_flags &= ~VM_MAYWRITE;
return generic_file_mmap(file, vma);
}
#else
int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment