diff -urNp 2.4.19rc1aa3/fs/proc/base.c mapped-base/fs/proc/base.c --- 2.4.19rc1aa3/fs/proc/base.c Mon Jul 15 18:47:44 2002 +++ mapped-base/fs/proc/base.c Wed Jul 17 00:49:49 2002 @@ -444,6 +444,57 @@ static struct file_operations proc_mem_o open: mem_open, }; +static ssize_t mapbase_read(struct file * file, char * buf, + size_t count, loff_t *ppos) +{ + struct task_struct *task = file->f_dentry->d_inode->u.proc_i.task; + char buffer[64]; + int len; + unsigned long newbase; + + sprintf(buffer, "%li", task->map_base); + len=strlen(buffer)+1; + *ppos += len; + if (copy_to_user(buf, buffer, len)) + len = -EFAULT; + + return (len<*ppos)?0:len; +} + +static ssize_t mapbase_write(struct file * file, const char * buf, + size_t count, loff_t *ppos) +{ + struct task_struct *task = file->f_dentry->d_inode->u.proc_i.task; + char buffer[64]; + int len; + unsigned long newbase; + if (!capable(CAP_SYS_ADMIN)) return -EPERM; + memset(buffer, 0, 64); + len = count; + if (len>63) + len = 63; + if (copy_from_user(buffer, buf, len)) + return -EFAULT; + + for (len = 0; len < 64; len++) + if (!buffer[len]) + break; + if (len>60) + return -EFAULT; + + newbase = simple_strtoul(buffer, NULL, 0); + + if (newbase > 0) + task->map_base = newbase; + + return len; +} + +static struct file_operations proc_mapbase_operations = { + read: mapbase_read, + write: mapbase_write, +}; + static struct inode_operations proc_mem_inode_operations = { permission: proc_permission, }; @@ -540,6 +591,7 @@ enum pid_directory_inos { PROC_PID_MAPS, PROC_PID_CPU, PROC_PID_MOUNTS, + PROC_PID_MAPBASE, PROC_PID_FD_DIR = 0x8000, /* 0x8000-0xffff */ }; @@ -560,6 +612,7 @@ static struct pid_entry base_stuff[] = { E(PROC_PID_ROOT, "root", S_IFLNK|S_IRWXUGO), E(PROC_PID_EXE, "exe", S_IFLNK|S_IRWXUGO), E(PROC_PID_MOUNTS, "mounts", S_IFREG|S_IRUGO), + E(PROC_PID_MAPBASE, "mapped_base", S_IFREG|S_IRUSR|S_IWUSR), {0,0,NULL,0} }; #undef E @@ -912,6 +965,9 @@ static struct dentry *proc_base_lookup(s inode->i_fop = &proc_info_file_operations; inode->u.proc_i.op.proc_read = proc_pid_statm; break; + case PROC_PID_MAPBASE: + inode->i_fop = &proc_mapbase_operations; + break; case PROC_PID_MAPS: inode->i_fop = &proc_maps_operations; break; diff -urNp 2.4.19rc1aa3/include/asm-i386/processor.h mapped-base/include/asm-i386/processor.h --- 2.4.19rc1aa3/include/asm-i386/processor.h Wed Jul 17 00:43:06 2002 +++ mapped-base/include/asm-i386/processor.h Wed Jul 17 00:46:53 2002 @@ -275,11 +275,7 @@ extern unsigned int mca_pentium_flag; /* This decides where the kernel will search for a free chunk of vm * space during mmap's. */ -#ifndef CONFIG_05GB -#define TASK_UNMAPPED_BASE (TASK_SIZE / 3) -#else -#define TASK_UNMAPPED_BASE (TASK_SIZE / 16) -#endif +#define TASK_UNMAPPED_BASE (current->map_base) /* * Size of io_bitmap in longwords: 32 is ports 0-0x3ff. diff -urNp 2.4.19rc1aa3/include/linux/sched.h mapped-base/include/linux/sched.h --- 2.4.19rc1aa3/include/linux/sched.h Wed Jul 17 00:43:07 2002 +++ mapped-base/include/linux/sched.h Wed Jul 17 00:59:44 2002 @@ -441,6 +441,9 @@ struct task_struct { /* Protection of (de-)allocation: mm, files, fs, tty */ spinlock_t alloc_lock; +/* TASK_UNMAPPED_BASE value */ + unsigned long map_base; + /* journalling filesystem info */ void *journal_info; }; @@ -494,6 +497,12 @@ asmlinkage long sys_sched_yield(void); */ extern struct exec_domain default_exec_domain; +#ifndef CONFIG_05GB +#define __TASK_UNMAPPED_BASE (TASK_SIZE / 3) +#else +#define __TASK_UNMAPPED_BASE (TASK_SIZE / 16) +#endif + /* * INIT_TASK is used to set up the first task table, touch at * your own risk!. Base=0, limit=0x1fffff (=2MB) @@ -539,6 +548,7 @@ extern struct exec_domain default_exec_d blocked: {{0}}, \ alloc_lock: SPIN_LOCK_UNLOCKED, \ journal_info: NULL, \ + map_base: __TASK_UNMAPPED_BASE, \ }