patch-kernel_exmap_c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. $Id: update-patches 24 2008-08-31 14:56:13Z wbx $
  2. --- exmap-console-0.4.1.orig/kernel/exmap.c 2006-10-24 20:45:11.000000000 +0200
  3. +++ exmap-console-0.4.1/kernel/exmap.c 2013-10-30 14:01:03.000000000 +0100
  4. @@ -392,7 +392,11 @@ int setup_from_pid(pid_t pid)
  5. struct task_struct *tsk;
  6. int errcode = -EINVAL;
  7. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)
  8. + tsk = find_task_by_vpid(pid);
  9. +#else
  10. tsk = find_task_by_pid(pid);
  11. +#endif
  12. if (tsk == NULL) {
  13. printk (KERN_ALERT
  14. "/proc/%s: can't find task for pid %d\n",
  15. @@ -405,6 +409,9 @@ int setup_from_pid(pid_t pid)
  16. PROCFS_NAME, pid);
  17. goto Exit;
  18. }
  19. + printk (KERN_ALERT
  20. + "/proc/%s: DEBUG: pid of task is %d\n",
  21. + PROCFS_NAME, tsk->pid);
  22. mm = get_task_mm(tsk);
  23. if (mm == NULL) {
  24. @@ -497,40 +504,29 @@ static int procfile_read (char *buffer,
  25. return ret;
  26. }
  27. +static const struct file_operations proc_file_fops = {
  28. + .owner = THIS_MODULE,
  29. + .write = procfile_write,
  30. + .read = procfile_read,
  31. +};
  32. +
  33. +
  34. int init_module ()
  35. {
  36. struct proc_dir_entry *exmap_proc_file;
  37. printk (KERN_INFO "/proc/%s: insert\n", PROCFS_NAME);
  38. - exmap_proc_file = create_proc_entry (PROCFS_NAME,
  39. + exmap_proc_file = proc_create (PROCFS_NAME,
  40. 0644,
  41. - NULL);
  42. + NULL,
  43. + &proc_file_fops);
  44. if (exmap_proc_file == NULL) {
  45. - remove_proc_entry (PROCFS_NAME, &proc_root);
  46. printk (KERN_ALERT "/proc/%s: could not initialize\n",
  47. PROCFS_NAME);
  48. return -ENOMEM;
  49. }
  50. - exmap_proc_file->read_proc = procfile_read;
  51. - exmap_proc_file->write_proc = procfile_write;
  52. - exmap_proc_file->owner = THIS_MODULE;
  53. -
  54. - /* exmap_proc_file->mode = S_IFREG | S_IRUGO; */
  55. - /* TODO - this is quite probably a security problem */
  56. - exmap_proc_file->mode = 0666;
  57. -
  58. - exmap_proc_file->uid = 0;
  59. - exmap_proc_file->gid = 0;
  60. - exmap_proc_file->size = 0;
  61. -
  62. init_local_data();
  63. return 0;
  64. }
  65. -
  66. -void cleanup_module ()
  67. -{
  68. - printk (KERN_INFO "/proc/%s: remove\n", PROCFS_NAME);
  69. - remove_proc_entry (PROCFS_NAME, &proc_root);
  70. -}