summaryrefslogtreecommitdiffstats
path: root/mm/mmap.c
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2000-01-29 01:41:54 +0000
committerRalf Baechle <ralf@linux-mips.org>2000-01-29 01:41:54 +0000
commitf969d69ba9f952e5bdd38278e25e26a3e4a61a70 (patch)
treeb3530d803df59d726afaabebc6626987dee1ca05 /mm/mmap.c
parenta10ce7ef2066b455d69187643ddf2073bfc4db24 (diff)
Merge with 2.3.27.
Diffstat (limited to 'mm/mmap.c')
-rw-r--r--mm/mmap.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/mm/mmap.c b/mm/mmap.c
index db47ad266..99e86653d 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -64,7 +64,7 @@ int vm_enough_memory(long pages)
free = atomic_read(&buffermem_pages);
free += atomic_read(&page_cache_size);
- free += nr_free_pages;
+ free += nr_free_pages();
free += nr_swap_pages;
return free > pages;
}
@@ -183,6 +183,8 @@ unsigned long do_mmap(struct file * file, unsigned long addr, unsigned long len,
if (off + len < off)
return -EINVAL;
+ off = off >> PAGE_SHIFT;
+
/* Too many mappings? */
if (mm->map_count > MAX_MAP_COUNT)
return -ENOMEM;
@@ -272,7 +274,7 @@ unsigned long do_mmap(struct file * file, unsigned long addr, unsigned long len,
vma->vm_flags |= VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
vma->vm_page_prot = protection_map[vma->vm_flags & 0x0f];
vma->vm_ops = NULL;
- vma->vm_offset = off;
+ vma->vm_pgoff = off;
vma->vm_file = NULL;
vma->vm_private_data = NULL;
@@ -533,7 +535,7 @@ static struct vm_area_struct * unmap_fixup(struct vm_area_struct *area,
area->vm_end = addr;
vmlist_modify_lock(current->mm);
} else if (addr == area->vm_start) {
- area->vm_offset += (end - area->vm_start);
+ area->vm_pgoff += (end - area->vm_start) >> PAGE_SHIFT;
area->vm_start = end;
vmlist_modify_lock(current->mm);
} else {
@@ -548,7 +550,8 @@ static struct vm_area_struct * unmap_fixup(struct vm_area_struct *area,
mpnt->vm_page_prot = area->vm_page_prot;
mpnt->vm_flags = area->vm_flags;
mpnt->vm_ops = area->vm_ops;
- mpnt->vm_offset = area->vm_offset + (end - area->vm_start);
+ mpnt->vm_pgoff = area->vm_pgoff;
+ area->vm_pgoff += (end - area->vm_start) >> PAGE_SHIFT;
mpnt->vm_file = area->vm_file;
mpnt->vm_private_data = area->vm_private_data;
if (mpnt->vm_file)
@@ -783,7 +786,7 @@ unsigned long do_brk(unsigned long addr, unsigned long len)
vma->vm_flags |= VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
vma->vm_page_prot = protection_map[vma->vm_flags & 0x0f];
vma->vm_ops = NULL;
- vma->vm_offset = 0;
+ vma->vm_pgoff = 0;
vma->vm_file = NULL;
vma->vm_private_data = NULL;
@@ -943,8 +946,9 @@ void merge_segments (struct mm_struct * mm, unsigned long start_addr, unsigned l
* the offsets must be contiguous..
*/
if ((mpnt->vm_file != NULL) || (mpnt->vm_flags & VM_SHM)) {
- unsigned long off = prev->vm_offset+prev->vm_end-prev->vm_start;
- if (off != mpnt->vm_offset)
+ unsigned long off = prev->vm_pgoff;
+ off += (prev->vm_end - prev->vm_start) >> PAGE_SHIFT;
+ if (off != mpnt->vm_pgoff)
continue;
}
@@ -957,7 +961,7 @@ void merge_segments (struct mm_struct * mm, unsigned long start_addr, unsigned l
prev->vm_end = mpnt->vm_end;
prev->vm_next = mpnt->vm_next;
if (mpnt->vm_ops && mpnt->vm_ops->close) {
- mpnt->vm_offset += mpnt->vm_end - mpnt->vm_start;
+ mpnt->vm_pgoff += (mpnt->vm_end - mpnt->vm_start) >> PAGE_SHIFT;
mpnt->vm_start = mpnt->vm_end;
vmlist_modify_unlock(mm);
mpnt->vm_ops->close(mpnt);