patch-kernel_exmap_c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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-11-02 18:56:21.000000000 +0100
  4. @@ -340,24 +340,22 @@ static int show_vma_start(struct exmap_v
  5. }
  6. -static int exmap_show_next(char *buffer, int length)
  7. +static ssize_t exmap_show_next(char *buffer, size_t length)
  8. {
  9. - int offset = 0;
  10. + ssize_t offset = 0;
  11. struct exmap_vma_data *vma_data;
  12. pte_t pte;
  13. int line_len;
  14. while (local_data.vma_cursor < local_data.num_vmas) {
  15. vma_data = local_data.vma_data + local_data.vma_cursor;
  16. -// printk (KERN_INFO
  17. -// "exmap: examining vma %08lx [%d/%d] %d\n",
  18. -// vma_data->vm_start,
  19. -// local_data.vma_cursor,
  20. -// local_data.num_vmas,
  21. -// vma_data->start_shown);
  22. + printk (KERN_INFO
  23. + "exmap: examining vma %08lx [%d/%d] %d\n",
  24. + vma_data->vm_start,
  25. + local_data.vma_cursor,
  26. + local_data.num_vmas,
  27. + vma_data->start_shown);
  28. if (!vma_data->start_shown) {
  29. -// printk (KERN_INFO
  30. -// "exmap: svs\n");
  31. line_len = show_vma_start(vma_data,
  32. buffer + offset,
  33. length - offset);
  34. @@ -392,7 +390,11 @@ int setup_from_pid(pid_t pid)
  35. struct task_struct *tsk;
  36. int errcode = -EINVAL;
  37. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)
  38. + tsk = find_task_by_vpid(pid);
  39. +#else
  40. tsk = find_task_by_pid(pid);
  41. +#endif
  42. if (tsk == NULL) {
  43. printk (KERN_ALERT
  44. "/proc/%s: can't find task for pid %d\n",
  45. @@ -445,10 +447,10 @@ Exit:
  46. * where deadbeef is the hex addr of the vma to examine
  47. * and pid is the (decimal) pid of the process to examine
  48. */
  49. -static int procfile_write (struct file *file,
  50. +static ssize_t procfile_write (struct file *file,
  51. const char __user *buffer,
  52. - unsigned long count,
  53. - void *data)
  54. + size_t count,
  55. + loff_t *off)
  56. {
  57. pid_t pid;
  58. int errcode = -EINVAL;
  59. @@ -475,14 +477,11 @@ static int procfile_write (struct file *
  60. * Only support sequential reading of file from start to finish
  61. * (following a write() to set the pid to examine
  62. */
  63. -static int procfile_read (char *buffer,
  64. - char **buffer_location,
  65. - off_t offset,
  66. - int buffer_length,
  67. - int *eof,
  68. - void *data)
  69. +static ssize_t procfile_read (struct file *filp,
  70. + char __user *buf,
  71. + size_t len,
  72. + loff_t *ppos)
  73. {
  74. - int ret;
  75. if (local_data.vma_data == NULL) {
  76. printk (KERN_ALERT "/proc/%s: vma data not set\n",
  77. @@ -490,47 +489,40 @@ static int procfile_read (char *buffer,
  78. return -EINVAL;
  79. }
  80. - ret = exmap_show_next(buffer, buffer_length);
  81. - if (ret > 0) {
  82. - *buffer_location = buffer;
  83. - }
  84. - return ret;
  85. + return exmap_show_next(buf, len);
  86. }
  87. -int init_module ()
  88. +static const struct file_operations proc_file_fops = {
  89. + .owner = THIS_MODULE,
  90. + .write = procfile_write,
  91. + .read = procfile_read,
  92. +};
  93. +
  94. +
  95. +static int __init exmap_init(void)
  96. {
  97. struct proc_dir_entry *exmap_proc_file;
  98. printk (KERN_INFO "/proc/%s: insert\n", PROCFS_NAME);
  99. - exmap_proc_file = create_proc_entry (PROCFS_NAME,
  100. + exmap_proc_file = proc_create (PROCFS_NAME,
  101. 0644,
  102. - NULL);
  103. + NULL,
  104. + &proc_file_fops);
  105. if (exmap_proc_file == NULL) {
  106. - remove_proc_entry (PROCFS_NAME, &proc_root);
  107. printk (KERN_ALERT "/proc/%s: could not initialize\n",
  108. PROCFS_NAME);
  109. return -ENOMEM;
  110. }
  111. - exmap_proc_file->read_proc = procfile_read;
  112. - exmap_proc_file->write_proc = procfile_write;
  113. - exmap_proc_file->owner = THIS_MODULE;
  114. -
  115. - /* exmap_proc_file->mode = S_IFREG | S_IRUGO; */
  116. - /* TODO - this is quite probably a security problem */
  117. - exmap_proc_file->mode = 0666;
  118. -
  119. - exmap_proc_file->uid = 0;
  120. - exmap_proc_file->gid = 0;
  121. - exmap_proc_file->size = 0;
  122. -
  123. init_local_data();
  124. return 0;
  125. }
  126. -void cleanup_module ()
  127. +static void __exit exmap_exit(void)
  128. {
  129. - printk (KERN_INFO "/proc/%s: remove\n", PROCFS_NAME);
  130. - remove_proc_entry (PROCFS_NAME, &proc_root);
  131. + remove_proc_entry(PROCFS_NAME, NULL);
  132. }
  133. +
  134. +module_init(exmap_init);
  135. +module_exit(exmap_exit);