--- mm/mincore.c.old 2007-03-24 19:55:01.000000000 -0500 +++ mm/mincore.c 2007-03-24 20:13:43.000000000 -0500 @@ -43,7 +43,8 @@ * all the arguments, we hold the mmap semaphore: we should * just return the amount of info we're asked for. */ -static long do_mincore(unsigned long addr, unsigned char *vec, unsigned long pages) +static long do_mincore(unsigned long addr, unsigned char *vec, unsigned long pages, + struct file** file_struct) { unsigned long i, nr, pgoff; struct vm_area_struct *vma = find_vma(current->mm, addr); @@ -64,7 +65,19 @@ * this is what we've traditionally done, so we'll just * continue doing it. */ - if (!vma->vm_file) + + /* + * Initialize file pointer to the value in the first vma structure + */ + + if ( *file_struct == NULL && vma->vm_file ) + *file_struct = vma->vm_file; + + /* + * Return an error if the is no file mapped of the file is different + */ + + if (!vma->vm_file || vma->vm_file != *file_struct) return -ENOMEM; /* @@ -115,6 +128,7 @@ long retval; unsigned long pages; unsigned char *tmp; + static struct file* file = NULL; /* Check the start address: needs to be page-aligned.. */ if (start & ~PAGE_CACHE_MASK) @@ -142,7 +156,7 @@ * the temporary buffer size. */ down_read(¤t->mm->mmap_sem); - retval = do_mincore(start, tmp, min(pages, PAGE_SIZE)); + retval = do_mincore(start, tmp, min(pages, PAGE_SIZE), &file); up_read(¤t->mm->mmap_sem); if (retval <= 0)