patch-2.1.97 linux/arch/sparc64/mm/modutil.c
Next file: linux/arch/sparc64/prom/bootstr.c
Previous file: linux/arch/sparc64/mm/init.c
Back to the patch index
Back to the overall index
- Lines: 52
- Date:
Tue Apr 14 17:44:21 1998
- Orig file:
v2.1.96/linux/arch/sparc64/mm/modutil.c
- Orig date:
Mon Jul 7 08:18:55 1997
diff -u --recursive --new-file v2.1.96/linux/arch/sparc64/mm/modutil.c linux/arch/sparc64/mm/modutil.c
@@ -1,7 +1,7 @@
-/* $Id: modutil.c,v 1.1 1997/06/27 14:53:35 jj Exp $
+/* $Id: modutil.c,v 1.3 1998/01/16 16:35:02 jj Exp $
* arch/sparc64/mm/modutil.c
*
- * Copyright (C) 1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
+ * Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
* Based upon code written by Linus Torvalds and others.
*/
@@ -21,7 +21,7 @@
if (!addr)
return;
if ((PAGE_SIZE-1) & (unsigned long) addr) {
- printk("Trying to vfree() bad address (%p)\n", addr);
+ printk("Trying to unmap module with bad address (%p)\n", addr);
return;
}
for (p = &modvmlist ; (tmp = *p) ; p = &tmp->next) {
@@ -33,6 +33,32 @@
}
}
printk("Trying to unmap nonexistent module vm area (%p)\n", addr);
+}
+
+void module_shrink(void * addr, unsigned long size)
+{
+ struct vm_struct *tmp;
+
+ if (!addr)
+ return;
+ if ((PAGE_SIZE-1) & (unsigned long) addr) {
+ printk("Trying to shrink module with bad address (%p)\n", addr);
+ return;
+ }
+ size = PAGE_ALIGN(size);
+ if (!size)
+ module_unmap(addr);
+ for (tmp = modvmlist; tmp; tmp = tmp->next) {
+ if (tmp->addr == addr) {
+ if (size > tmp->size - PAGE_SIZE) {
+ printk("Trying to expand module with module_shrink()\n");
+ return;
+ }
+ vmfree_area_pages(VMALLOC_VMADDR(tmp->addr)+size, tmp->size-size);
+ return;
+ }
+ }
+ printk("Trying to shrink nonexistent module vm area (%p)\n", addr);
}
void * module_map (unsigned long size)
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov