--- uml-2.4/arch/um/kernel/process_kern.c.orig 2004-04-15 23:26:49.000000000 +0300 +++ uml-2.4/arch/um/kernel/process_kern.c 2004-04-15 23:49:38.312250576 +0300 @@ -16,6 +16,7 @@ #include "linux/module.h" #include "linux/init.h" #include "linux/capability.h" +#include "linux/vmalloc.h" #include "asm/unistd.h" #include "asm/mman.h" #include "asm/segment.h" @@ -279,6 +280,11 @@ void *um_kmalloc(int size) return(kmalloc(size, GFP_KERNEL)); } +void *um_vmalloc(int size) +{ + return(vmalloc(size)); +} + void *um_kmalloc_atomic(int size) { return(kmalloc(size, GFP_ATOMIC)); --- uml-2.4/arch/um/main.c.orig 2004-04-15 23:58:28.786606216 +0300 +++ uml-2.4/arch/um/main.c 2004-04-16 00:35:35.074159064 +0300 @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -160,10 +161,16 @@ extern void *__real_malloc(int); void *__wrap_malloc(int size) { - if(CAN_KMALLOC()) - return(um_kmalloc(size)); - else + if(CAN_KMALLOC()) { + /* glibc people insist that if malloc fails, errno should be + set by malloc as well. So we do. */ + void *ret = um_vmalloc(size); + if (!ret) + errno = ENOMEM; + return(ret); + } else { return(__real_malloc(size)); + } } void *__wrap_calloc(int n, int size) @@ -179,7 +186,7 @@ extern void __real_free(void *); void __wrap_free(void *ptr) { - if(CAN_KMALLOC()) kfree(ptr); + if(CAN_KMALLOC()) vfree(ptr); else __real_free(ptr); } --- uml-2.4/arch/um/include/user.h.orig 2004-04-15 23:41:57.000000000 +0300 +++ uml-2.4/arch/um/include/user.h 2004-04-16 00:36:24.806598584 +0300 @@ -10,8 +10,10 @@ extern void panic(const char *fmt, ...); extern int printk(const char *fmt, ...); extern void schedule(void); extern void *um_kmalloc(int size); +extern void *um_vmalloc(int size); extern void *um_kmalloc_atomic(int size); extern void kfree(void *ptr); +extern void vfree(void *ptr); extern int in_aton(char *str); extern int open_gdb_chan(void);