From owner-svn-src-stable@freebsd.org Sat Jan 9 17:27:37 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 94CA0A69367; Sat, 9 Jan 2016 17:27:37 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::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 499221FEB; Sat, 9 Jan 2016 17:27:37 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u09HRaLZ058120; Sat, 9 Jan 2016 17:27:36 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u09HRa76058119; Sat, 9 Jan 2016 17:27:36 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201601091727.u09HRa76058119@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Sat, 9 Jan 2016 17:27:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r293574 - stable/10/sys/compat/linprocfs X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Jan 2016 17:27:37 -0000 Author: dchagin Date: Sat Jan 9 17:27:36 2016 New Revision: 293574 URL: https://svnweb.freebsd.org/changeset/base/293574 Log: MFC r283473: Add support for /proc//auxv. Modified: stable/10/sys/compat/linprocfs/linprocfs.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/compat/linprocfs/linprocfs.c ============================================================================== --- stable/10/sys/compat/linprocfs/linprocfs.c Sat Jan 9 17:23:57 2016 (r293573) +++ stable/10/sys/compat/linprocfs/linprocfs.c Sat Jan 9 17:27:36 2016 (r293574) @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -51,6 +52,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -1364,6 +1366,52 @@ linprocfs_douuid(PFS_FILL_ARGS) return(0); } +/* + * Filler function for proc/pid/auxv + */ +static int +linprocfs_doauxv(PFS_FILL_ARGS) +{ + struct sbuf *asb; + off_t buflen, resid; + int error; + + /* + * Mimic linux behavior and pass only processes with usermode + * address space as valid. Return zero silently otherwise. + */ + if (p->p_vmspace == &vmspace0) + return (0); + + if (uio->uio_resid == 0) + return (0); + if (uio->uio_offset < 0 || uio->uio_resid < 0) + return (EINVAL); + + asb = sbuf_new_auto(); + if (asb == NULL) + return (ENOMEM); + error = proc_getauxv(td, p, asb); + if (error == 0) + error = sbuf_finish(asb); + + resid = sbuf_len(asb) - uio->uio_offset; + if (resid > uio->uio_resid) + buflen = uio->uio_resid; + else + buflen = resid; + if (buflen > IOSIZE_MAX) + return (EINVAL); + if (buflen > MAXPHYS) + buflen = MAXPHYS; + if (resid <= 0) + return (0); + + if (error == 0) + error = uiomove(sbuf_data(asb) + uio->uio_offset, buflen, uio); + sbuf_delete(asb); + return (error); +} /* * Constructor @@ -1439,6 +1487,8 @@ linprocfs_init(PFS_INIT_ARGS) NULL, NULL, NULL, PFS_RD); pfs_create_link(dir, "fd", &linprocfs_dofdescfs, NULL, NULL, NULL, 0); + pfs_create_file(dir, "auxv", &linprocfs_doauxv, + NULL, &procfs_candebug, NULL, PFS_RD|PFS_RAWRD); /* /proc/scsi/... */ dir = pfs_create_dir(root, "scsi", NULL, NULL, NULL, 0);