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/m68k | |
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/m68k')
-rw-r--r-- | arch/m68k/kernel/ptrace.c | 47 |
1 files changed, 3 insertions, 44 deletions
diff --git a/arch/m68k/kernel/ptrace.c b/arch/m68k/kernel/ptrace.c index f7f1d2e5b90b..7e54422685cf 100644 --- a/arch/m68k/kernel/ptrace.c +++ b/arch/m68k/kernel/ptrace.c | |||
@@ -121,48 +121,11 @@ void ptrace_disable(struct task_struct *child) | |||
121 | child->thread.work.syscall_trace = 0; | 121 | child->thread.work.syscall_trace = 0; |
122 | } | 122 | } |
123 | 123 | ||
124 | asmlinkage long sys_ptrace(long request, long pid, long addr, long data) | 124 | long arch_ptrace(struct task_struct *child, long request, long addr, long data) |
125 | { | 125 | { |
126 | struct task_struct *child; | ||
127 | unsigned long tmp; | 126 | unsigned long tmp; |
128 | int i, ret = 0; | 127 | int i, ret = 0; |
129 | 128 | ||
130 | lock_kernel(); | ||
131 | if (request == PTRACE_TRACEME) { | ||
132 | /* are we already being traced? */ | ||
133 | if (current->ptrace & PT_PTRACED) { | ||
134 | ret = -EPERM; | ||
135 | goto out; | ||
136 | } | ||
137 | /* set the ptrace bit in the process flags. */ | ||
138 | current->ptrace |= PT_PTRACED; | ||
139 | goto out; | ||
140 | } | ||
141 | read_lock(&tasklist_lock); | ||
142 | child = find_task_by_pid(pid); | ||
143 | if (child) | ||
144 | get_task_struct(child); | ||
145 | read_unlock(&tasklist_lock); | ||
146 | if (unlikely(!child)) { | ||
147 | ret = -ESRCH; | ||
148 | goto out; | ||
149 | } | ||
150 | |||
151 | /* you may not mess with init */ | ||
152 | if (unlikely(pid == 1)) { | ||
153 | ret = -EPERM; | ||
154 | goto out_tsk; | ||
155 | } | ||
156 | |||
157 | if (request == PTRACE_ATTACH) { | ||
158 | ret = ptrace_attach(child); | ||
159 | goto out_tsk; | ||
160 | } | ||
161 | |||
162 | ret = ptrace_check_attach(child, request == PTRACE_KILL); | ||
163 | if (ret) | ||
164 | goto out_tsk; | ||
165 | |||
166 | switch (request) { | 129 | switch (request) { |
167 | /* when I and D space are separate, these will need to be fixed. */ | 130 | /* when I and D space are separate, these will need to be fixed. */ |
168 | case PTRACE_PEEKTEXT: /* read word at location addr. */ | 131 | case PTRACE_PEEKTEXT: /* read word at location addr. */ |
@@ -317,14 +280,10 @@ asmlinkage long sys_ptrace(long request, long pid, long addr, long data) | |||
317 | ret = ptrace_request(child, request, addr, data); | 280 | ret = ptrace_request(child, request, addr, data); |
318 | break; | 281 | break; |
319 | } | 282 | } |
320 | out_tsk: | 283 | |
321 | put_task_struct(child); | ||
322 | out: | ||
323 | unlock_kernel(); | ||
324 | return ret; | 284 | return ret; |
325 | out_eio: | 285 | out_eio: |
326 | ret = -EIO; | 286 | return -EIO; |
327 | goto out_tsk; | ||
328 | } | 287 | } |
329 | 288 | ||
330 | asmlinkage void syscall_trace(void) | 289 | asmlinkage void syscall_trace(void) |