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/powerpc | |
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/powerpc')
-rw-r--r-- | arch/powerpc/kernel/ptrace.c | 43 |
1 files changed, 2 insertions, 41 deletions
diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c index 568ea335d616..3d2abd95c7ae 100644 --- a/arch/powerpc/kernel/ptrace.c +++ b/arch/powerpc/kernel/ptrace.c | |||
@@ -248,46 +248,10 @@ void ptrace_disable(struct task_struct *child) | |||
248 | clear_single_step(child); | 248 | clear_single_step(child); |
249 | } | 249 | } |
250 | 250 | ||
251 | long sys_ptrace(long request, long pid, long addr, long data) | 251 | long arch_ptrace(struct task_struct *child, long request, long addr, long data) |
252 | { | 252 | { |
253 | struct task_struct *child; | ||
254 | int ret = -EPERM; | 253 | int ret = -EPERM; |
255 | 254 | ||
256 | lock_kernel(); | ||
257 | if (request == PTRACE_TRACEME) { | ||
258 | /* are we already being traced? */ | ||
259 | if (current->ptrace & PT_PTRACED) | ||
260 | goto out; | ||
261 | ret = security_ptrace(current->parent, current); | ||
262 | if (ret) | ||
263 | goto out; | ||
264 | /* set the ptrace bit in the process flags. */ | ||
265 | current->ptrace |= PT_PTRACED; | ||
266 | ret = 0; | ||
267 | goto out; | ||
268 | } | ||
269 | ret = -ESRCH; | ||
270 | read_lock(&tasklist_lock); | ||
271 | child = find_task_by_pid(pid); | ||
272 | if (child) | ||
273 | get_task_struct(child); | ||
274 | read_unlock(&tasklist_lock); | ||
275 | if (!child) | ||
276 | goto out; | ||
277 | |||
278 | ret = -EPERM; | ||
279 | if (pid == 1) /* you may not mess with init */ | ||
280 | goto out_tsk; | ||
281 | |||
282 | if (request == PTRACE_ATTACH) { | ||
283 | ret = ptrace_attach(child); | ||
284 | goto out_tsk; | ||
285 | } | ||
286 | |||
287 | ret = ptrace_check_attach(child, request == PTRACE_KILL); | ||
288 | if (ret < 0) | ||
289 | goto out_tsk; | ||
290 | |||
291 | switch (request) { | 255 | switch (request) { |
292 | /* when I and D space are separate, these will need to be fixed. */ | 256 | /* when I and D space are separate, these will need to be fixed. */ |
293 | case PTRACE_PEEKTEXT: /* read word at location addr. */ | 257 | case PTRACE_PEEKTEXT: /* read word at location addr. */ |
@@ -540,10 +504,7 @@ long sys_ptrace(long request, long pid, long addr, long data) | |||
540 | ret = ptrace_request(child, request, addr, data); | 504 | ret = ptrace_request(child, request, addr, data); |
541 | break; | 505 | break; |
542 | } | 506 | } |
543 | out_tsk: | 507 | |
544 | put_task_struct(child); | ||
545 | out: | ||
546 | unlock_kernel(); | ||
547 | return ret; | 508 | return ret; |
548 | } | 509 | } |
549 | 510 | ||