patch-2.1.108 linux/mm/mremap.c
Next file: linux/Documentation/Configure.help
Previous file: linux/mm/mmap.c
Back to the patch index
Back to the overall index
- Lines: 31
- Date:
Sat Jun 27 09:44:15 1998
- Orig file:
v2.1.107/linux/mm/mremap.c
- Orig date:
Tue Jun 23 10:01:30 1998
diff -u --recursive --new-file v2.1.107/linux/mm/mremap.c linux/mm/mremap.c
@@ -21,6 +21,8 @@
#include <asm/system.h>
#include <asm/pgtable.h>
+extern int vm_enough_memory(long pages);
+
static inline pte_t *get_one_pte(struct mm_struct *mm, unsigned long addr)
{
pgd_t * pgd;
@@ -179,7 +181,7 @@
* the unnecessary pages..
*/
ret = addr;
- if (old_len > new_len) {
+ if (old_len >= new_len) {
do_munmap(addr+new_len, old_len - new_len);
goto out;
}
@@ -204,6 +206,11 @@
ret = -ENOMEM;
if ((current->mm->total_vm << PAGE_SHIFT) + (new_len - old_len)
> current->rlim[RLIMIT_AS].rlim_cur)
+ goto out;
+ /* Private writable mapping? Check memory availability.. */
+ if ((vma->vm_flags & (VM_SHARED | VM_WRITE)) == VM_WRITE &&
+ !(flags & MAP_NORESERVE) &&
+ !vm_enough_memory((new_len - old_len) >> PAGE_SHIFT))
goto out;
/* old_len exactly to the end of the area.. */
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov