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