procfs_mem.c revision 96886
11541Srgrimes/*
21541Srgrimes * Copyright (c) 1993 Jan-Simon Pendry
31541Srgrimes * Copyright (c) 1993 Sean Eric Fagan
41541Srgrimes * Copyright (c) 1993
51541Srgrimes *	The Regents of the University of California.  All rights reserved.
61541Srgrimes *
71541Srgrimes * This code is derived from software contributed to Berkeley by
81541Srgrimes * Jan-Simon Pendry and Sean Eric Fagan.
91541Srgrimes *
101541Srgrimes * Redistribution and use in source and binary forms, with or without
111541Srgrimes * modification, are permitted provided that the following conditions
121541Srgrimes * are met:
131541Srgrimes * 1. Redistributions of source code must retain the above copyright
141541Srgrimes *    notice, this list of conditions and the following disclaimer.
151541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
161541Srgrimes *    notice, this list of conditions and the following disclaimer in the
171541Srgrimes *    documentation and/or other materials provided with the distribution.
181541Srgrimes * 3. All advertising materials mentioning features or use of this software
191541Srgrimes *    must display the following acknowledgement:
201541Srgrimes *	This product includes software developed by the University of
211541Srgrimes *	California, Berkeley and its contributors.
221541Srgrimes * 4. Neither the name of the University nor the names of its contributors
231541Srgrimes *    may be used to endorse or promote products derived from this software
241541Srgrimes *    without specific prior written permission.
251541Srgrimes *
261541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
271541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
281541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
291541Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
301541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
311541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
321541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
331541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
341541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
351541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
361541Srgrimes * SUCH DAMAGE.
371541Srgrimes *
3822521Sdyson *	@(#)procfs_mem.c	8.5 (Berkeley) 6/15/94
391541Srgrimes *
4050477Speter * $FreeBSD: head/sys/fs/procfs/procfs_mem.c 96886 2002-05-19 00:14:50Z jhb $
411541Srgrimes */
421541Srgrimes
431541Srgrimes#include <sys/param.h>
4476166Smarkm#include <sys/lock.h>
4576827Salfred#include <sys/mutex.h>
461541Srgrimes#include <sys/proc.h>
4776166Smarkm#include <sys/ptrace.h>
4895210Sbde#include <sys/systm.h>
4987321Sdes#include <sys/uio.h>
5076166Smarkm
5187321Sdes#include <fs/pseudofs/pseudofs.h>
5277031Sru#include <fs/procfs/procfs.h>
5376166Smarkm
541541Srgrimes/*
551541Srgrimes * Copy data in and out of the target process.
561541Srgrimes * We do this by mapping the process's page into
571541Srgrimes * the kernel and then doing a uiomove direct
581541Srgrimes * from the kernel address space.
591541Srgrimes */
601541Srgrimesint
6187321Sdesprocfs_doprocmem(PFS_FILL_ARGS)
621541Srgrimes{
6381107Srwatson	int error;
641541Srgrimes
651541Srgrimes	if (uio->uio_resid == 0)
661541Srgrimes		return (0);
671541Srgrimes
6894623Sjhb	PROC_LOCK(p);
6996886Sjhb	error = p_candebug(td, p);
7094623Sjhb	PROC_UNLOCK(p);
7194623Sjhb	if (error == 0)
7294623Sjhb		error = proc_rwmem(p, uio);
7328086Ssef
7487321Sdes	return (error);
751541Srgrimes}
76