aboutsummaryrefslogtreecommitdiffstats
path: root/arch/h8300/kernel/ptrace.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2005-11-07 03:59:47 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2005-11-07 10:53:42 -0500
commit481bed454247538e9f57d4ea37b153ccba24ba7b (patch)
treebb4198296962c08dbf52e8f377dc27206f621640 /arch/h8300/kernel/ptrace.c
parentdb73e9aa99bf093427b79877f9475392724fd5e5 (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/h8300/kernel/ptrace.c')
-rw-r--r--arch/h8300/kernel/ptrace.c39
1 files changed, 1 insertions, 38 deletions
diff --git a/arch/h8300/kernel/ptrace.c b/arch/h8300/kernel/ptrace.c
index a569fe4aa284..0ff6f79b0fed 100644
--- a/arch/h8300/kernel/ptrace.c
+++ b/arch/h8300/kernel/ptrace.c
@@ -57,43 +57,10 @@ void ptrace_disable(struct task_struct *child)
57 h8300_disable_trace(child); 57 h8300_disable_trace(child);
58} 58}
59 59
60asmlinkage long sys_ptrace(long request, long pid, long addr, long data) 60long arch_ptrace(struct task_struct *child, long request, long addr, long data)
61{ 61{
62 struct task_struct *child;
63 int ret; 62 int ret;
64 63
65 lock_kernel();
66 ret = -EPERM;
67 if (request == PTRACE_TRACEME) {
68 /* are we already being traced? */
69 if (current->ptrace & PT_PTRACED)
70 goto out;
71 /* set the ptrace bit in the process flags. */
72 current->ptrace |= PT_PTRACED;
73 ret = 0;
74 goto out;
75 }
76 ret = -ESRCH;
77 read_lock(&tasklist_lock);
78 child = find_task_by_pid(pid);
79 if (child)
80 get_task_struct(child);
81 read_unlock(&tasklist_lock);
82 if (!child)
83 goto out;
84
85 ret = -EPERM;
86 if (pid == 1) /* you may not mess with init */
87 goto out_tsk;
88
89 if (request == PTRACE_ATTACH) {
90 ret = ptrace_attach(child);
91 goto out_tsk;
92 }
93 ret = ptrace_check_attach(child, request == PTRACE_KILL);
94 if (ret < 0)
95 goto out_tsk;
96
97 switch (request) { 64 switch (request) {
98 case PTRACE_PEEKTEXT: /* read word at location addr. */ 65 case PTRACE_PEEKTEXT: /* read word at location addr. */
99 case PTRACE_PEEKDATA: { 66 case PTRACE_PEEKDATA: {
@@ -251,10 +218,6 @@ asmlinkage long sys_ptrace(long request, long pid, long addr, long data)
251 ret = -EIO; 218 ret = -EIO;
252 break; 219 break;
253 } 220 }
254out_tsk:
255 put_task_struct(child);
256out:
257 unlock_kernel();
258 return ret; 221 return ret;
259} 222}
260 223