Linux Headquarters
[ Register ]
[ About us ] [ Home Page ]

[ Kernel ] [ Documentation ] [ Links ] [ Books ]

Kernel v2.4.13-pre3 /mm/filemap.c

Filename:/mm/filemap.c
Lines Added:14
Lines Deleted:11
Also changed in: (Previous) 2.4.13-pre2  2.4.13-pre1  2.4.12-ac2  2.4.12-ac1  2.4.11  2.4.11-pre6 
(Following) 2.4.13-pre4  2.4.13-pre5  2.4.13-pre6  2.4.13  2.4.13-ac1  2.4.13-ac2 

Location
[  2.4.13-pre3
  [  mm
     o  filemap.c

Patch

diff -u --recursive --new-file v2.4.12/linux/mm/filemap.c linux/mm/filemap.c
--- v2.4.12/linux/mm/filemap.c   Tue Oct  9 17:06:53 2001
+++ linux/mm/filemap.c   Mon Oct 15 15:34:49 2001
@@ -667,8 +667,7 @@
 static int FASTCALL(page_cache_read(struct file * file, unsigned long offset));
 static int page_cache_read(struct file * file, unsigned long offset)
 {
-   struct inode *inode = file->f_dentry->d_inode;
-   struct address_space *mapping = inode->i_mapping;
+   struct address_space *mapping = file->f_dentry->d_inode->i_mapping;
    struct page **hash = page_hash(mapping, offset);
    struct page *page; 
 
@@ -1589,12 +1588,13 @@
 {
    int error;
    struct file *file = area->vm_file;
-   struct inode *inode = file->f_dentry->d_inode;
-   struct address_space *mapping = inode->i_mapping;
+   struct address_space *mapping = file->f_dentry->d_inode->i_mapping;
+   struct inode *inode = mapping->host;
    struct page *page, **hash, *old_page;
-   unsigned long size, pgoff;
+   unsigned long size, pgoff, endoff;
 
    pgoff = ((address - area->vm_start) >> PAGE_CACHE_SHIFT) + area->vm_pgoff;
+   endoff = ((area->vm_end - area->vm_start) >> PAGE_CACHE_SHIFT) + area->vm_pgoff;
 
 retry_all:
    /*
@@ -1605,6 +1605,10 @@
    if ((pgoff >= size) && (area->vm_mm == current->mm))
       return NULL;
 
+   /* The "size" of the file, as far as mmap is concerned, isn't bigger than the mapping */
+   if (size > endoff)
+      size = endoff;
+
    /*
     * Do we have something in the page cache already?
     */
@@ -1851,15 +1855,14 @@
 
 int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
 {
-   struct inode *inode = file->f_dentry->d_inode;
+   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 (!inode->i_mapping->a_ops->writepage)
+      if (!mapping->a_ops->writepage)
          return -EINVAL;
    }
-   if (!inode->i_sb || !S_ISREG(inode->i_mode))
-      return -EACCES;
-   if (!inode->i_mapping->a_ops->readpage)
+   if (!mapping->a_ops->readpage)
       return -ENOEXEC;
    UPDATE_ATIME(inode);
    vma->vm_ops = &generic_file_vm_ops;
@@ -2309,7 +2312,7 @@
    unsigned long pgoff)
 {
    unsigned char present = 0;
-   struct address_space * as = &vma->vm_file->f_dentry->d_inode->i_data;
+   struct address_space * as = &vma->vm_file->f_dentry->d_inode->i_mapping;
    struct page * page, ** hash = page_hash(as, pgoff);
 
    spin_lock(&pagecache_lock);


Comments: webmaster (at) linuxhq.com.
Advertising: banners (at) linuxhq.com.
Compilation ©1998-2008 Linux Headquarters, Inc.