squashfs: fix warn_on when root inode is corrupted
[safe/jmp/linux-2.6] / fs / ncpfs / mmap.c
index af48b79..56f5b3a 100644 (file)
@@ -9,12 +9,12 @@
 #include <linux/stat.h>
 #include <linux/time.h>
 #include <linux/kernel.h>
+#include <linux/gfp.h>
 #include <linux/mm.h>
 #include <linux/shm.h>
 #include <linux/errno.h>
 #include <linux/mman.h>
 #include <linux/string.h>
-#include <linux/slab.h>
 #include <linux/fcntl.h>
 #include <linux/ncp_fs.h>
 
 
 /*
  * Fill in the supplied page for mmap
+ * XXX: how are we excluding truncate/invalidate here? Maybe need to lock
+ * page?
  */
-static struct page* ncp_file_mmap_fault(struct vm_area_struct *area,
-                                               struct fault_data *fdata)
+static int ncp_file_mmap_fault(struct vm_area_struct *area,
+                                       struct vm_fault *vmf)
 {
        struct file *file = area->vm_file;
        struct dentry *dentry = file->f_path.dentry;
        struct inode *inode = dentry->d_inode;
-       struct page* page;
        char *pg_addr;
        unsigned int already_read;
        unsigned int count;
        int bufsize;
-       int pos;
+       int pos; /* XXX: loff_t ? */
 
-       page = alloc_page(GFP_HIGHUSER); /* ncpfs has nothing against high pages
-                  as long as recvmsg and memset works on it */
-       if (!page) {
-               fdata->type = VM_FAULT_OOM;
-               return NULL;
-       }
-       pg_addr = kmap(page);
-       pos = fdata->pgoff << PAGE_SHIFT;
+       /*
+        * ncpfs has nothing against high pages as long
+        * as recvmsg and memset works on it
+        */
+       vmf->page = alloc_page(GFP_HIGHUSER);
+       if (!vmf->page)
+               return VM_FAULT_OOM;
+       pg_addr = kmap(vmf->page);
+       pos = vmf->pgoff << PAGE_SHIFT;
 
        count = PAGE_SIZE;
-       if (fdata->address + PAGE_SIZE > area->vm_end) {
-               WARN_ON(1); /* shouldn't happen? */
-               count = area->vm_end - fdata->address;
-       }
        /* what we can read in one go */
        bufsize = NCP_SERVER(inode)->buffer_size;
 
@@ -85,20 +83,19 @@ static struct page* ncp_file_mmap_fault(struct vm_area_struct *area,
 
        if (already_read < PAGE_SIZE)
                memset(pg_addr + already_read, 0, PAGE_SIZE - already_read);
-       flush_dcache_page(page);
-       kunmap(page);
+       flush_dcache_page(vmf->page);
+       kunmap(vmf->page);
 
        /*
         * If I understand ncp_read_kernel() properly, the above always
         * fetches from the network, here the analogue of disk.
         * -- wli
         */
-       fdata->type = VM_FAULT_MAJOR;
        count_vm_event(PGMAJFAULT);
-       return page;
+       return VM_FAULT_MAJOR;
 }
 
-static struct vm_operations_struct ncp_file_mmap =
+static const struct vm_operations_struct ncp_file_mmap =
 {
        .fault = ncp_file_mmap_fault,
 };
@@ -124,7 +121,6 @@ int ncp_mmap(struct file *file, struct vm_area_struct *vma)
                return -EFBIG;
 
        vma->vm_ops = &ncp_file_mmap;
-       vma->vm_flags |= VM_CAN_INVALIDATE;
        file_accessed(file);
        return 0;
 }