From owner-svn-src-user@FreeBSD.ORG Sat Feb 21 09:17:32 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 9774372A; Sat, 21 Feb 2015 09:17:32 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6984CBDE; Sat, 21 Feb 2015 09:17:32 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1L9HWN3033556; Sat, 21 Feb 2015 09:17:32 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1L9HWG0033555; Sat, 21 Feb 2015 09:17:32 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201502210917.t1L9HWG0033555@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Sat, 21 Feb 2015 09:17:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r279100 - user/dchagin/lemul/sys/compat/linprocfs X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Feb 2015 09:17:32 -0000 Author: dchagin Date: Sat Feb 21 09:17:31 2015 New Revision: 279100 URL: https://svnweb.freebsd.org/changeset/base/279100 Log: Reimplement /proc//auxv using RAW pfs method. Modified: user/dchagin/lemul/sys/compat/linprocfs/linprocfs.c Modified: user/dchagin/lemul/sys/compat/linprocfs/linprocfs.c ============================================================================== --- user/dchagin/lemul/sys/compat/linprocfs/linprocfs.c Sat Feb 21 09:13:32 2015 (r279099) +++ user/dchagin/lemul/sys/compat/linprocfs/linprocfs.c Sat Feb 21 09:17:31 2015 (r279100) @@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -1403,31 +1404,37 @@ linprocfs_douuid(PFS_FILL_ARGS) static int linprocfs_doauxv(PFS_FILL_ARGS) { - int ret; - - PROC_LOCK(p); - if ((ret = p_candebug(td, p)) != 0) { - PROC_UNLOCK(p); - return (ret); - } + struct sbuf *asb; + off_t buflen; + int error; /* * Mimic linux behavior and pass only processes with usermode * address space as valid. Return zero silently otherwize. */ - if (p->p_vmspace == &vmspace0) { - PROC_UNLOCK(p); + if (p->p_vmspace == &vmspace0) return (0); - } - if ((p->p_flag & P_SYSTEM) != 0) { - PROC_UNLOCK(p); + if (uio->uio_resid == 0) return (0); - } - - PROC_UNLOCK(p); - - return (proc_getauxv(td, p, sb)); + if (uio->uio_offset < 0 || uio->uio_resid < 0) + return (EINVAL); + buflen = uio->uio_resid; + if (buflen > IOSIZE_MAX) + return (EINVAL); + if (buflen > MAXPHYS) + buflen = MAXPHYS; + + asb = sbuf_new_auto(); + if (asb == NULL) + return (ENOMEM); + error = proc_getauxv(td, p, asb); + if (error == 0) + error = sbuf_finish(asb); + if (error == 0) + error = uiomove(sbuf_data(asb) + uio->uio_offset, buflen, uio); + sbuf_delete(asb); + return (error); } /* @@ -1505,7 +1512,7 @@ linprocfs_init(PFS_INIT_ARGS) pfs_create_link(dir, "fd", &linprocfs_dofdescfs, NULL, NULL, NULL, 0); pfs_create_file(dir, "auxv", &linprocfs_doauxv, - NULL, NULL, NULL, PFS_RD); + NULL, &procfs_candebug, NULL, PFS_RD|PFS_RAWRD); /* /proc/scsi/... */ dir = pfs_create_dir(root, "scsi", NULL, NULL, NULL, 0);