diff options
author | Steven Whitehouse <swhiteho@redhat.com> | 2006-09-28 08:29:59 -0400 |
---|---|---|
committer | Steven Whitehouse <swhiteho@redhat.com> | 2006-09-28 08:29:59 -0400 |
commit | 185a257f2f73bcd89050ad02da5bedbc28fc43fa (patch) | |
tree | 5e32586114534ed3f2165614cba3d578f5d87307 /fs/proc/task_nommu.c | |
parent | 3f1a9aaeffd8d1cbc5ab9776c45cbd66af1c9699 (diff) | |
parent | a77c64c1a641950626181b4857abb701d8f38ccc (diff) |
Merge branch 'master' into gfs2
Diffstat (limited to 'fs/proc/task_nommu.c')
-rw-r--r-- | fs/proc/task_nommu.c | 74 |
1 files changed, 60 insertions, 14 deletions
diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c index 4616ed50ffcd..091aa8e48e02 100644 --- a/fs/proc/task_nommu.c +++ b/fs/proc/task_nommu.c | |||
@@ -138,25 +138,63 @@ out: | |||
138 | } | 138 | } |
139 | 139 | ||
140 | /* | 140 | /* |
141 | * Albert D. Cahalan suggested to fake entries for the traditional | 141 | * display mapping lines for a particular process's /proc/pid/maps |
142 | * sections here. This might be worth investigating. | ||
143 | */ | 142 | */ |
144 | static int show_map(struct seq_file *m, void *v) | 143 | static int show_map(struct seq_file *m, void *_vml) |
145 | { | 144 | { |
146 | return 0; | 145 | struct vm_list_struct *vml = _vml; |
146 | return nommu_vma_show(m, vml->vma); | ||
147 | } | 147 | } |
148 | |||
148 | static void *m_start(struct seq_file *m, loff_t *pos) | 149 | static void *m_start(struct seq_file *m, loff_t *pos) |
149 | { | 150 | { |
151 | struct proc_maps_private *priv = m->private; | ||
152 | struct vm_list_struct *vml; | ||
153 | struct mm_struct *mm; | ||
154 | loff_t n = *pos; | ||
155 | |||
156 | /* pin the task and mm whilst we play with them */ | ||
157 | priv->task = get_pid_task(priv->pid, PIDTYPE_PID); | ||
158 | if (!priv->task) | ||
159 | return NULL; | ||
160 | |||
161 | mm = get_task_mm(priv->task); | ||
162 | if (!mm) { | ||
163 | put_task_struct(priv->task); | ||
164 | priv->task = NULL; | ||
165 | return NULL; | ||
166 | } | ||
167 | |||
168 | down_read(&mm->mmap_sem); | ||
169 | |||
170 | /* start from the Nth VMA */ | ||
171 | for (vml = mm->context.vmlist; vml; vml = vml->next) | ||
172 | if (n-- == 0) | ||
173 | return vml; | ||
150 | return NULL; | 174 | return NULL; |
151 | } | 175 | } |
152 | static void m_stop(struct seq_file *m, void *v) | 176 | |
177 | static void m_stop(struct seq_file *m, void *_vml) | ||
153 | { | 178 | { |
179 | struct proc_maps_private *priv = m->private; | ||
180 | |||
181 | if (priv->task) { | ||
182 | struct mm_struct *mm = priv->task->mm; | ||
183 | up_read(&mm->mmap_sem); | ||
184 | mmput(mm); | ||
185 | put_task_struct(priv->task); | ||
186 | } | ||
154 | } | 187 | } |
155 | static void *m_next(struct seq_file *m, void *v, loff_t *pos) | 188 | |
189 | static void *m_next(struct seq_file *m, void *_vml, loff_t *pos) | ||
156 | { | 190 | { |
157 | return NULL; | 191 | struct vm_list_struct *vml = _vml; |
192 | |||
193 | (*pos)++; | ||
194 | return vml ? vml->next : NULL; | ||
158 | } | 195 | } |
159 | static struct seq_operations proc_pid_maps_op = { | 196 | |
197 | static struct seq_operations proc_pid_maps_ops = { | ||
160 | .start = m_start, | 198 | .start = m_start, |
161 | .next = m_next, | 199 | .next = m_next, |
162 | .stop = m_stop, | 200 | .stop = m_stop, |
@@ -165,11 +203,19 @@ static struct seq_operations proc_pid_maps_op = { | |||
165 | 203 | ||
166 | static int maps_open(struct inode *inode, struct file *file) | 204 | static int maps_open(struct inode *inode, struct file *file) |
167 | { | 205 | { |
168 | int ret; | 206 | struct proc_maps_private *priv; |
169 | ret = seq_open(file, &proc_pid_maps_op); | 207 | int ret = -ENOMEM; |
170 | if (!ret) { | 208 | |
171 | struct seq_file *m = file->private_data; | 209 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); |
172 | m->private = NULL; | 210 | if (priv) { |
211 | priv->pid = proc_pid(inode); | ||
212 | ret = seq_open(file, &proc_pid_maps_ops); | ||
213 | if (!ret) { | ||
214 | struct seq_file *m = file->private_data; | ||
215 | m->private = priv; | ||
216 | } else { | ||
217 | kfree(priv); | ||
218 | } | ||
173 | } | 219 | } |
174 | return ret; | 220 | return ret; |
175 | } | 221 | } |
@@ -178,6 +224,6 @@ struct file_operations proc_maps_operations = { | |||
178 | .open = maps_open, | 224 | .open = maps_open, |
179 | .read = seq_read, | 225 | .read = seq_read, |
180 | .llseek = seq_lseek, | 226 | .llseek = seq_lseek, |
181 | .release = seq_release, | 227 | .release = seq_release_private, |
182 | }; | 228 | }; |
183 | 229 | ||