--- linux-2.4.22-5um.fm/arch/um/kernel/filemap.c Tue Oct 14 10:44:50 2003 +++ linux-2.4.22-5um.new/arch/um/kernel/filemap.c Tue Oct 14 13:56:37 2003 @@ -502,6 +502,11 @@ .entries = NULL, .ops = &fm_ops_pool, }, + { + .name = "mm", + .entries = NULL, + .ops = &fm_ops_pool, + }, }; static struct filemap_table* filemap_get_table(const char* table_name) --- linux-2.4.22-5um.fm/arch/um/kernel/skas/process.c Tue Oct 14 10:44:31 2003 +++ linux-2.4.22-5um.new/arch/um/kernel/skas/process.c Tue Oct 14 14:28:39 2003 @@ -27,6 +27,8 @@ #include "skas_ptrace.h" #include "chan_user.h" +#include "filemap.h" + int is_skas_winch(int pid, int fd, void *data) { if(pid != getpid()) @@ -340,12 +342,27 @@ int new_mm(int from) { struct proc_mm_op copy; - int n, fd = os_open_file("/proc/mm", + int n, fd; + + /* use the raw access since /proc/mm opens a new file every time */ + fd = filemap_access("mm", "/proc/mm"); + if(fd >= 0) { + printk("filemap aquire: fd=%d, file=%s\n", fd, "/proc/mm"); + goto handle_fd; + } + + /* if /proc/mm exists, the same fd would be returned over and over */ + if(filemap_access("file", "/proc/mm") >= 0) { + return(-1); + } + + fd = os_open_file("/proc/mm", of_cloexec(of_write(OPENFLAGS())), 0); if(fd < 0) return(fd); +handle_fd: if(from != -1){ copy = ((struct proc_mm_op) { .op = MM_COPY_SEGMENTS, .u = --- linux-2.4.22-5um.fm/arch/um/kernel/skas/mmu.c Tue Oct 14 10:44:31 2003 +++ linux-2.4.22-5um.new/arch/um/kernel/skas/mmu.c Tue Oct 14 16:48:36 2003 @@ -21,14 +21,23 @@ mm->context.skas.mm_fd = new_mm(from); if(mm->context.skas.mm_fd < 0) +#if 1 panic("init_new_context_skas - new_mm failed, errno = %d\n", mm->context.skas.mm_fd); +#else /* DON'T PANIC */ + return(mm->context.skas.mm_fd); +#endif return(0); } void destroy_context_skas(struct mm_struct *mm) { + /* filemapped files will return something other than -ENOENT */ + if(filemap_release("mm", mm->context.skas.mm_fd) != -ENOENT) { + return; + } + os_close_file(mm->context.skas.mm_fd); }