|
@@ -1,7 +1,40 @@
|
|
$Id: update-patches 24 2008-08-31 14:56:13Z wbx $
|
|
$Id: update-patches 24 2008-08-31 14:56:13Z wbx $
|
|
--- exmap-console-0.4.1.orig/kernel/exmap.c 2006-10-24 20:45:11.000000000 +0200
|
|
--- exmap-console-0.4.1.orig/kernel/exmap.c 2006-10-24 20:45:11.000000000 +0200
|
|
-+++ exmap-console-0.4.1/kernel/exmap.c 2013-10-30 14:01:03.000000000 +0100
|
|
++++ exmap-console-0.4.1/kernel/exmap.c 2013-11-02 18:56:21.000000000 +0100
|
|
-@@ -392,7 +392,11 @@ int setup_from_pid(pid_t pid)
|
|
+@@ -340,24 +340,22 @@ static int show_vma_start(struct exmap_v
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+-static int exmap_show_next(char *buffer, int length)
|
|
|
|
++static ssize_t exmap_show_next(char *buffer, size_t length)
|
|
|
|
+ {
|
|
|
|
+- int offset = 0;
|
|
|
|
++ ssize_t offset = 0;
|
|
|
|
+ struct exmap_vma_data *vma_data;
|
|
|
|
+ pte_t pte;
|
|
|
|
+ int line_len;
|
|
|
|
+
|
|
|
|
+ while (local_data.vma_cursor < local_data.num_vmas) {
|
|
|
|
+ vma_data = local_data.vma_data + local_data.vma_cursor;
|
|
|
|
+-// printk (KERN_INFO
|
|
|
|
+-// "exmap: examining vma %08lx [%d/%d] %d\n",
|
|
|
|
+-// vma_data->vm_start,
|
|
|
|
+-// local_data.vma_cursor,
|
|
|
|
+-// local_data.num_vmas,
|
|
|
|
+-// vma_data->start_shown);
|
|
|
|
++ printk (KERN_INFO
|
|
|
|
++ "exmap: examining vma %08lx [%d/%d] %d\n",
|
|
|
|
++ vma_data->vm_start,
|
|
|
|
++ local_data.vma_cursor,
|
|
|
|
++ local_data.num_vmas,
|
|
|
|
++ vma_data->start_shown);
|
|
|
|
+ if (!vma_data->start_shown) {
|
|
|
|
+-// printk (KERN_INFO
|
|
|
|
+-// "exmap: svs\n");
|
|
|
|
+ line_len = show_vma_start(vma_data,
|
|
|
|
+ buffer + offset,
|
|
|
|
+ length - offset);
|
|
|
|
+@@ -392,7 +390,11 @@ int setup_from_pid(pid_t pid)
|
|
struct task_struct *tsk;
|
|
struct task_struct *tsk;
|
|
int errcode = -EINVAL;
|
|
int errcode = -EINVAL;
|
|
|
|
|
|
@@ -13,20 +46,52 @@ $Id: update-patches 24 2008-08-31 14:56:13Z wbx $
|
|
if (tsk == NULL) {
|
|
if (tsk == NULL) {
|
|
printk (KERN_ALERT
|
|
printk (KERN_ALERT
|
|
"/proc/%s: can't find task for pid %d\n",
|
|
"/proc/%s: can't find task for pid %d\n",
|
|
-@@ -405,6 +409,9 @@ int setup_from_pid(pid_t pid)
|
|
+@@ -445,10 +447,10 @@ Exit:
|
|
- PROCFS_NAME, pid);
|
|
+ * where deadbeef is the hex addr of the vma to examine
|
|
- goto Exit;
|
|
+ * and pid is the (decimal) pid of the process to examine
|
|
|
|
+ */
|
|
|
|
+-static int procfile_write (struct file *file,
|
|
|
|
++static ssize_t procfile_write (struct file *file,
|
|
|
|
+ const char __user *buffer,
|
|
|
|
+- unsigned long count,
|
|
|
|
+- void *data)
|
|
|
|
++ size_t count,
|
|
|
|
++ loff_t *off)
|
|
|
|
+ {
|
|
|
|
+ pid_t pid;
|
|
|
|
+ int errcode = -EINVAL;
|
|
|
|
+@@ -475,14 +477,11 @@ static int procfile_write (struct file *
|
|
|
|
+ * Only support sequential reading of file from start to finish
|
|
|
|
+ * (following a write() to set the pid to examine
|
|
|
|
+ */
|
|
|
|
+-static int procfile_read (char *buffer,
|
|
|
|
+- char **buffer_location,
|
|
|
|
+- off_t offset,
|
|
|
|
+- int buffer_length,
|
|
|
|
+- int *eof,
|
|
|
|
+- void *data)
|
|
|
|
++static ssize_t procfile_read (struct file *filp,
|
|
|
|
++ char __user *buf,
|
|
|
|
++ size_t len,
|
|
|
|
++ loff_t *ppos)
|
|
|
|
+ {
|
|
|
|
+- int ret;
|
|
|
|
+
|
|
|
|
+ if (local_data.vma_data == NULL) {
|
|
|
|
+ printk (KERN_ALERT "/proc/%s: vma data not set\n",
|
|
|
|
+@@ -490,47 +489,40 @@ static int procfile_read (char *buffer,
|
|
|
|
+ return -EINVAL;
|
|
}
|
|
}
|
|
-+ printk (KERN_ALERT
|
|
|
|
-+ "/proc/%s: DEBUG: pid of task is %d\n",
|
|
|
|
-+ PROCFS_NAME, tsk->pid);
|
|
|
|
|
|
|
|
- mm = get_task_mm(tsk);
|
|
+- ret = exmap_show_next(buffer, buffer_length);
|
|
- if (mm == NULL) {
|
|
+- if (ret > 0) {
|
|
-@@ -497,40 +504,29 @@ static int procfile_read (char *buffer,
|
|
+- *buffer_location = buffer;
|
|
- return ret;
|
|
+- }
|
|
|
|
+- return ret;
|
|
|
|
++ return exmap_show_next(buf, len);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+-int init_module ()
|
|
+static const struct file_operations proc_file_fops = {
|
|
+static const struct file_operations proc_file_fops = {
|
|
+ .owner = THIS_MODULE,
|
|
+ .owner = THIS_MODULE,
|
|
+ .write = procfile_write,
|
|
+ .write = procfile_write,
|
|
@@ -34,7 +99,7 @@ $Id: update-patches 24 2008-08-31 14:56:13Z wbx $
|
|
+};
|
|
+};
|
|
+
|
|
+
|
|
+
|
|
+
|
|
- int init_module ()
|
|
++static int __init exmap_init(void)
|
|
{
|
|
{
|
|
struct proc_dir_entry *exmap_proc_file;
|
|
struct proc_dir_entry *exmap_proc_file;
|
|
printk (KERN_INFO "/proc/%s: insert\n", PROCFS_NAME);
|
|
printk (KERN_INFO "/proc/%s: insert\n", PROCFS_NAME);
|
|
@@ -68,9 +133,14 @@ $Id: update-patches 24 2008-08-31 14:56:13Z wbx $
|
|
init_local_data();
|
|
init_local_data();
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
--
|
|
+
|
|
-void cleanup_module ()
|
|
-void cleanup_module ()
|
|
--{
|
|
++static void __exit exmap_exit(void)
|
|
|
|
+ {
|
|
- printk (KERN_INFO "/proc/%s: remove\n", PROCFS_NAME);
|
|
- printk (KERN_INFO "/proc/%s: remove\n", PROCFS_NAME);
|
|
- remove_proc_entry (PROCFS_NAME, &proc_root);
|
|
- remove_proc_entry (PROCFS_NAME, &proc_root);
|
|
--}
|
|
++ remove_proc_entry(PROCFS_NAME, NULL);
|
|
|
|
+ }
|
|
|
|
++
|
|
|
|
++module_init(exmap_init);
|
|
|
|
++module_exit(exmap_exit);
|