[PATCH] New version of mmid patch, against 2.3.12

cd_smith@ou.edu
Thu, 29 Jul 1999 20:34:01 -0500 (CDT)


Hey,

Here's my mmid patch against 2.3.12. I took the suggestion of Martijn van
Oosterhout to use current->mm as the mm_id. I thought about it, and I've
convinced myself there are no security issues with that. So it's actually
substantially smaller than the old one. And there's really no extra
memory required besides a tiny amount of additional code in the proc
filesystem. That worked out very nicely. (Thanks Martijn!)

If anyone has any comments or complaints, let me know. If not, Linus
please consider this for 2.3.13.

Chris Smith <cd_smith@ou.edu>

diff -Nru linux-save/fs/proc/array.c linux/fs/proc/array.c
--- linux-save/fs/proc/array.c Thu Jul 29 08:55:55 1999
+++ linux/fs/proc/array.c Thu Jul 29 15:31:46 1999
@@ -1079,6 +1079,23 @@
size, resident, share, trs, lrs, drs, dt);
}

+static int get_mm_id(int pid, char * buffer)
+{
+ struct task_struct *tsk;
+ int mm_id = 0;
+
+ read_lock(&tasklist_lock);
+ tsk = find_task_by_pid(pid);
+ read_unlock(&tasklist_lock);
+
+ if (!tsk)
+ return 0;
+ if (tsk->mm && tsk->mm != &init_mm)
+ mm_id = (unsigned long) tsk->mm;
+
+ return sprintf(buffer,"%lu\n", mm_id);
+}
+
/*
* The way we support synthetic files > 4K
* - without storing their contents in some buffer and
@@ -1441,6 +1458,8 @@
return get_stat(pid, page);
case PROC_PID_STATM:
return get_statm(pid, page);
+ case PROC_PID_MM_ID:
+ return get_mm_id(pid, page);
#ifdef __SMP__
case PROC_PID_CPU:
return get_pidcpu(pid, page);
diff -Nru linux-save/fs/proc/base.c linux/fs/proc/base.c
--- linux-save/fs/proc/base.c Sat Jun 26 14:04:39 1999
+++ linux/fs/proc/base.c Thu Jul 29 09:12:08 1999
@@ -159,6 +159,12 @@
0, &proc_arraylong_inode_operations,
NULL, proc_pid_fill_inode,
};
+static struct proc_dir_entry proc_pid_mm_id = {
+ PROC_PID_MM_ID, 5, "mm_id",
+ S_IFREG | S_IRUGO, 1, 0, 0,
+ 0, &proc_array_inode_operations,
+ NULL, proc_pid_fill_inode,
+};

#if CONFIG_AP1000
static struct proc_dir_entry proc_pid_ringbuf = {
@@ -194,6 +200,7 @@
proc_register(&proc_pid, &proc_pid_stat);
proc_register(&proc_pid, &proc_pid_statm);
proc_register(&proc_pid, &proc_pid_maps);
+ proc_register(&proc_pid, &proc_pid_mm_id);
#ifdef __SMP__
proc_register(&proc_pid, &proc_pid_cpu);
#endif
diff -Nru linux-save/include/linux/proc_fs.h linux/include/linux/proc_fs.h
--- linux-save/include/linux/proc_fs.h Wed Jul 7 11:21:05 1999
+++ linux/include/linux/proc_fs.h Thu Jul 29 15:31:55 1999
@@ -70,6 +70,7 @@
PROC_PID_STAT,
PROC_PID_STATM,
PROC_PID_MAPS,
+ PROC_PID_MM_ID,
#if CONFIG_AP1000
PROC_PID_RINGBUF,
#endif

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/