1139776Simp/*-
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 * 4. Neither the name of the University nor the names of its contributors
191541Srgrimes *    may be used to endorse or promote products derived from this software
201541Srgrimes *    without specific prior written permission.
211541Srgrimes *
221541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
231541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
241541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
251541Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
261541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
271541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
281541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
291541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
301541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
311541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
321541Srgrimes * SUCH DAMAGE.
331541Srgrimes *
3422521Sdyson *	@(#)procfs_mem.c	8.5 (Berkeley) 6/15/94
351541Srgrimes *
3650477Speter * $FreeBSD$
371541Srgrimes */
381541Srgrimes
391541Srgrimes#include <sys/param.h>
4076166Smarkm#include <sys/lock.h>
4176827Salfred#include <sys/mutex.h>
421541Srgrimes#include <sys/proc.h>
4376166Smarkm#include <sys/ptrace.h>
4495210Sbde#include <sys/systm.h>
4587321Sdes#include <sys/uio.h>
4676166Smarkm
4787321Sdes#include <fs/pseudofs/pseudofs.h>
4877031Sru#include <fs/procfs/procfs.h>
4976166Smarkm
501541Srgrimes/*
511541Srgrimes * Copy data in and out of the target process.
521541Srgrimes * We do this by mapping the process's page into
531541Srgrimes * the kernel and then doing a uiomove direct
541541Srgrimes * from the kernel address space.
551541Srgrimes */
561541Srgrimesint
5787321Sdesprocfs_doprocmem(PFS_FILL_ARGS)
581541Srgrimes{
5981107Srwatson	int error;
601541Srgrimes
611541Srgrimes	if (uio->uio_resid == 0)
621541Srgrimes		return (0);
631541Srgrimes
6494623Sjhb	PROC_LOCK(p);
6596886Sjhb	error = p_candebug(td, p);
6694623Sjhb	PROC_UNLOCK(p);
6794623Sjhb	if (error == 0)
6894623Sjhb		error = proc_rwmem(p, uio);
6928086Ssef
7087321Sdes	return (error);
711541Srgrimes}
72