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/xtensa | |
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/xtensa')
-rw-r--r-- | arch/xtensa/kernel/ptrace.c | 55 |
1 files changed, 2 insertions, 53 deletions
diff --git a/arch/xtensa/kernel/ptrace.c b/arch/xtensa/kernel/ptrace.c index 14460743de07..ab5c4c65b5c4 100644 --- a/arch/xtensa/kernel/ptrace.c +++ b/arch/xtensa/kernel/ptrace.c | |||
@@ -45,58 +45,10 @@ void ptrace_disable(struct task_struct *child) | |||
45 | /* Nothing to do.. */ | 45 | /* Nothing to do.. */ |
46 | } | 46 | } |
47 | 47 | ||
48 | long sys_ptrace(long request, long pid, long addr, long data) | 48 | long arch_ptrace(struct task_struct *child, long request, long addr, long data) |
49 | { | 49 | { |
50 | struct task_struct *child; | ||
51 | int ret = -EPERM; | 50 | int ret = -EPERM; |
52 | 51 | ||
53 | lock_kernel(); | ||
54 | |||
55 | #if 0 | ||
56 | if ((int)request != 1) | ||
57 | printk("ptrace(r=%d,pid=%d,addr=%08lx,data=%08lx)\n", | ||
58 | (int) request, (int) pid, (unsigned long) addr, | ||
59 | (unsigned long) data); | ||
60 | #endif | ||
61 | |||
62 | if (request == PTRACE_TRACEME) { | ||
63 | |||
64 | /* Are we already being traced? */ | ||
65 | |||
66 | if (current->ptrace & PT_PTRACED) | ||
67 | goto out; | ||
68 | |||
69 | if ((ret = security_ptrace(current->parent, current))) | ||
70 | goto out; | ||
71 | |||
72 | /* Set the ptrace bit in the process flags. */ | ||
73 | |||
74 | current->ptrace |= PT_PTRACED; | ||
75 | ret = 0; | ||
76 | goto out; | ||
77 | } | ||
78 | |||
79 | ret = -ESRCH; | ||
80 | read_lock(&tasklist_lock); | ||
81 | child = find_task_by_pid(pid); | ||
82 | if (child) | ||
83 | get_task_struct(child); | ||
84 | read_unlock(&tasklist_lock); | ||
85 | if (!child) | ||
86 | goto out; | ||
87 | |||
88 | ret = -EPERM; | ||
89 | if (pid == 1) /* you may not mess with init */ | ||
90 | goto out; | ||
91 | |||
92 | if (request == PTRACE_ATTACH) { | ||
93 | ret = ptrace_attach(child); | ||
94 | goto out_tsk; | ||
95 | } | ||
96 | |||
97 | if ((ret = ptrace_check_attach(child, request == PTRACE_KILL)) < 0) | ||
98 | goto out_tsk; | ||
99 | |||
100 | switch (request) { | 52 | switch (request) { |
101 | case PTRACE_PEEKTEXT: /* read word at location addr. */ | 53 | case PTRACE_PEEKTEXT: /* read word at location addr. */ |
102 | case PTRACE_PEEKDATA: | 54 | case PTRACE_PEEKDATA: |
@@ -375,10 +327,7 @@ long sys_ptrace(long request, long pid, long addr, long data) | |||
375 | ret = ptrace_request(child, request, addr, data); | 327 | ret = ptrace_request(child, request, addr, data); |
376 | goto out; | 328 | goto out; |
377 | } | 329 | } |
378 | out_tsk: | 330 | out: |
379 | put_task_struct(child); | ||
380 | out: | ||
381 | unlock_kernel(); | ||
382 | return ret; | 331 | return ret; |
383 | } | 332 | } |
384 | 333 | ||