Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754142AbZFOLCt (ORCPT ); Mon, 15 Jun 2009 07:02:49 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751826AbZFOLCk (ORCPT ); Mon, 15 Jun 2009 07:02:40 -0400 Received: from bombadil.infradead.org ([18.85.46.34]:39676 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750964AbZFOLCj (ORCPT ); Mon, 15 Jun 2009 07:02:39 -0400 Date: Mon, 15 Jun 2009 07:02:40 -0400 From: Christoph Hellwig To: liqin.chen@sunplusct.com Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, Arnd Bergmann , Andrew Morton , torvalds@linux-foundation.org Subject: Re: [PATCH 21/27] score: create kernel files ptrace.c setup.c Message-ID: <20090615110240.GA16735@infradead.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.18 (2008-05-17) X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1897 Lines: 61 On Tue, Jun 09, 2009 at 02:35:45PM +0800, liqin.chen@sunplusct.com wrote: > +long > +arch_ptrace(struct task_struct *child, long request, long addr, long > data) > +{ > + int ret; > + > + if (request == PTRACE_TRACEME) { > + /* are we already being traced? */ > + if (current->ptrace & PT_PTRACED) > + return -EPERM; > + > + /* set the ptrace bit in the process flags. */ > + current->ptrace |= PT_PTRACED; > + return 0; > + } > + > + ret = -ESRCH; > + if (!child) > + return ret; > + > + ret = -EPERM; > + > + if (request == PTRACE_ATTACH) { > + ret = ptrace_attach(child); > + return ret; > + } > + > + ret = ptrace_check_attach(child, request == PTRACE_KILL); > + if (ret < 0) > + return ret; > + All this stuff has been done by generic ptrace code for a long time and is not needed at all. > + switch (request) { > + case PTRACE_PEEKTEXT: /* read word at location addr. */ > + case PTRACE_PEEKDATA: { > + unsigned long tmp; > + int copied; > + > + copied = access_process_vm(child, addr, &tmp, sizeof(tmp), > 0); > + ret = -EIO; > + if (copied != sizeof(tmp)) > + break; > + > + ret = put_user(tmp, (unsigned long *) data); > + return ret; > + } > + This also has a generic implementation. Please take a look at a modern ptrace implementation like sh, powerpc or x86 to model yours after. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/