diff options
author | Christoph Hellwig <hch@lst.de> | 2005-11-07 03:59:47 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-11-07 10:53:42 -0500 |
commit | 481bed454247538e9f57d4ea37b153ccba24ba7b (patch) | |
tree | bb4198296962c08dbf52e8f377dc27206f621640 /arch/mips | |
parent | db73e9aa99bf093427b79877f9475392724fd5e5 (diff) |
[PATCH] consolidate sys_ptrace()
The sys_ptrace boilerplate code (everything outside the big switch
statement for the arch-specific requests) is shared by most architectures.
This patch moves it to kernel/ptrace.c and leaves the arch-specific code as
arch_ptrace.
Some architectures have a too different ptrace so we have to exclude them.
They continue to keep their implementations. For sh64 I had to add a
sh64_ptrace wrapper because it does some initialization on the first call.
For um I removed an ifdefed SUBARCH_PTRACE_SPECIAL block, but
SUBARCH_PTRACE_SPECIAL isn't defined anywhere in the tree.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Paul Mackerras <paulus@samba.org>
Acked-by: Ralf Baechle <ralf@linux-mips.org>
Acked-By: David Howells <dhowells@redhat.com>
Acked-by: Russell King <rmk+kernel@arm.linux.org.uk>
Acked-by: Paul Mundt <lethal@linux-sh.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/mips')
-rw-r--r-- | arch/mips/kernel/ptrace.c | 55 |
1 files changed, 5 insertions, 50 deletions
diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c index f1b0f3e1f95b..510da5fda567 100644 --- a/arch/mips/kernel/ptrace.c +++ b/arch/mips/kernel/ptrace.c | |||
@@ -174,51 +174,10 @@ int ptrace_setfpregs (struct task_struct *child, __u32 __user *data) | |||
174 | return 0; | 174 | return 0; |
175 | } | 175 | } |
176 | 176 | ||
177 | asmlinkage long sys_ptrace(long request, long pid, long addr, long data) | 177 | long arch_ptrace(struct task_struct *child, long request, long addr, long data) |
178 | { | 178 | { |
179 | struct task_struct *child; | ||
180 | int ret; | 179 | int ret; |
181 | 180 | ||
182 | #if 0 | ||
183 | printk("ptrace(r=%d,pid=%d,addr=%08lx,data=%08lx)\n", | ||
184 | (int) request, (int) pid, (unsigned long) addr, | ||
185 | (unsigned long) data); | ||
186 | #endif | ||
187 | lock_kernel(); | ||
188 | ret = -EPERM; | ||
189 | if (request == PTRACE_TRACEME) { | ||
190 | /* are we already being traced? */ | ||
191 | if (current->ptrace & PT_PTRACED) | ||
192 | goto out; | ||
193 | if ((ret = security_ptrace(current->parent, current))) | ||
194 | goto out; | ||
195 | /* set the ptrace bit in the process flags. */ | ||
196 | current->ptrace |= PT_PTRACED; | ||
197 | ret = 0; | ||
198 | goto out; | ||
199 | } | ||
200 | ret = -ESRCH; | ||
201 | read_lock(&tasklist_lock); | ||
202 | child = find_task_by_pid(pid); | ||
203 | if (child) | ||
204 | get_task_struct(child); | ||
205 | read_unlock(&tasklist_lock); | ||
206 | if (!child) | ||
207 | goto out; | ||
208 | |||
209 | ret = -EPERM; | ||
210 | if (pid == 1) /* you may not mess with init */ | ||
211 | goto out_tsk; | ||
212 | |||
213 | if (request == PTRACE_ATTACH) { | ||
214 | ret = ptrace_attach(child); | ||
215 | goto out_tsk; | ||
216 | } | ||
217 | |||
218 | ret = ptrace_check_attach(child, request == PTRACE_KILL); | ||
219 | if (ret < 0) | ||
220 | goto out_tsk; | ||
221 | |||
222 | switch (request) { | 181 | switch (request) { |
223 | /* when I and D space are separate, these will need to be fixed. */ | 182 | /* when I and D space are separate, these will need to be fixed. */ |
224 | case PTRACE_PEEKTEXT: /* read word at location addr. */ | 183 | case PTRACE_PEEKTEXT: /* read word at location addr. */ |
@@ -319,7 +278,7 @@ asmlinkage long sys_ptrace(long request, long pid, long addr, long data) | |||
319 | if (!cpu_has_dsp) { | 278 | if (!cpu_has_dsp) { |
320 | tmp = 0; | 279 | tmp = 0; |
321 | ret = -EIO; | 280 | ret = -EIO; |
322 | goto out_tsk; | 281 | goto out; |
323 | } | 282 | } |
324 | if (child->thread.dsp.used_dsp) { | 283 | if (child->thread.dsp.used_dsp) { |
325 | dregs = __get_dsp_regs(child); | 284 | dregs = __get_dsp_regs(child); |
@@ -333,14 +292,14 @@ asmlinkage long sys_ptrace(long request, long pid, long addr, long data) | |||
333 | if (!cpu_has_dsp) { | 292 | if (!cpu_has_dsp) { |
334 | tmp = 0; | 293 | tmp = 0; |
335 | ret = -EIO; | 294 | ret = -EIO; |
336 | goto out_tsk; | 295 | goto out; |
337 | } | 296 | } |
338 | tmp = child->thread.dsp.dspcontrol; | 297 | tmp = child->thread.dsp.dspcontrol; |
339 | break; | 298 | break; |
340 | default: | 299 | default: |
341 | tmp = 0; | 300 | tmp = 0; |
342 | ret = -EIO; | 301 | ret = -EIO; |
343 | goto out_tsk; | 302 | goto out; |
344 | } | 303 | } |
345 | ret = put_user(tmp, (unsigned long __user *) data); | 304 | ret = put_user(tmp, (unsigned long __user *) data); |
346 | break; | 305 | break; |
@@ -495,11 +454,7 @@ asmlinkage long sys_ptrace(long request, long pid, long addr, long data) | |||
495 | ret = ptrace_request(child, request, addr, data); | 454 | ret = ptrace_request(child, request, addr, data); |
496 | break; | 455 | break; |
497 | } | 456 | } |
498 | 457 | out: | |
499 | out_tsk: | ||
500 | put_task_struct(child); | ||
501 | out: | ||
502 | unlock_kernel(); | ||
503 | return ret; | 458 | return ret; |
504 | } | 459 | } |
505 | 460 | ||