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/sh | |
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/sh')
-rw-r--r-- | arch/sh/kernel/ptrace.c | 44 |
1 files changed, 2 insertions, 42 deletions
diff --git a/arch/sh/kernel/ptrace.c b/arch/sh/kernel/ptrace.c index 1fbe5a428e31..1a8be06519ec 100644 --- a/arch/sh/kernel/ptrace.c +++ b/arch/sh/kernel/ptrace.c | |||
@@ -80,48 +80,11 @@ void ptrace_disable(struct task_struct *child) | |||
80 | /* nothing to do.. */ | 80 | /* nothing to do.. */ |
81 | } | 81 | } |
82 | 82 | ||
83 | asmlinkage long sys_ptrace(long request, long pid, long addr, long data) | 83 | long arch_ptrace(struct task_struct *child, long request, long addr, long data) |
84 | { | 84 | { |
85 | struct task_struct *child; | ||
86 | struct user * dummy = NULL; | 85 | struct user * dummy = NULL; |
87 | int ret; | 86 | int ret; |
88 | 87 | ||
89 | lock_kernel(); | ||
90 | ret = -EPERM; | ||
91 | if (request == PTRACE_TRACEME) { | ||
92 | /* are we already being traced? */ | ||
93 | if (current->ptrace & PT_PTRACED) | ||
94 | goto out; | ||
95 | ret = security_ptrace(current->parent, current); | ||
96 | if (ret) | ||
97 | goto out; | ||
98 | /* set the ptrace bit in the process flags. */ | ||
99 | current->ptrace |= PT_PTRACED; | ||
100 | ret = 0; | ||
101 | goto out; | ||
102 | } | ||
103 | ret = -ESRCH; | ||
104 | read_lock(&tasklist_lock); | ||
105 | child = find_task_by_pid(pid); | ||
106 | if (child) | ||
107 | get_task_struct(child); | ||
108 | read_unlock(&tasklist_lock); | ||
109 | if (!child) | ||
110 | goto out; | ||
111 | |||
112 | ret = -EPERM; | ||
113 | if (pid == 1) /* you may not mess with init */ | ||
114 | goto out_tsk; | ||
115 | |||
116 | if (request == PTRACE_ATTACH) { | ||
117 | ret = ptrace_attach(child); | ||
118 | goto out_tsk; | ||
119 | } | ||
120 | |||
121 | ret = ptrace_check_attach(child, request == PTRACE_KILL); | ||
122 | if (ret < 0) | ||
123 | goto out_tsk; | ||
124 | |||
125 | switch (request) { | 88 | switch (request) { |
126 | /* when I and D space are separate, these will need to be fixed. */ | 89 | /* when I and D space are separate, these will need to be fixed. */ |
127 | case PTRACE_PEEKTEXT: /* read word at location addr. */ | 90 | case PTRACE_PEEKTEXT: /* read word at location addr. */ |
@@ -289,10 +252,7 @@ asmlinkage long sys_ptrace(long request, long pid, long addr, long data) | |||
289 | ret = ptrace_request(child, request, addr, data); | 252 | ret = ptrace_request(child, request, addr, data); |
290 | break; | 253 | break; |
291 | } | 254 | } |
292 | out_tsk: | 255 | |
293 | put_task_struct(child); | ||
294 | out: | ||
295 | unlock_kernel(); | ||
296 | return ret; | 256 | return ret; |
297 | } | 257 | } |
298 | 258 | ||