diff options
-rw-r--r-- | usr/src/man/man4/proc.4 | 12 | ||||
-rw-r--r-- | usr/src/uts/common/fs/proc/prvnops.c | 49 |
2 files changed, 59 insertions, 2 deletions
diff --git a/usr/src/man/man4/proc.4 b/usr/src/man/man4/proc.4 index 20f2089f5e..453ea3319f 100644 --- a/usr/src/man/man4/proc.4 +++ b/usr/src/man/man4/proc.4 @@ -1,11 +1,11 @@ '\" te .\" Copyright 1989 AT&T .\" Copyright (c) 2006, Sun Microsystems, Inc. All Rights Reserved. -.\" Copyright (c) 2013, Joyent, Inc. All rights reserved. +.\" Copyright (c) 2014, Joyent, Inc. All rights reserved. .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] -.TH PROC 4 "Mar 31, 2013" +.TH PROC 4 "May 19, 2014" .SH NAME proc \- /proc, the process file system .SH DESCRIPTION @@ -930,6 +930,14 @@ migrate to checking \fBPR_ISSYS\fR in the \fBpstatus\fR structure's 0x8000). \fBpr_pctcpu\fR is the summation over all lwps in the process. .sp .LP +The \fBpr_fname\fR is writable by the owner of the process. To write to it, +the \fBpsinfo\fR file should be open for writing and the desired value for +\fBpr_fname\fR should be written at the file offset that corresponds to the +\fBpr_fname\fR member of the structure. No other entry may be written to; if +a write is attempted to any other offset, or if the size of the write is not +exactly \fBPRFNSZ\fR bytes, no bytes will be written. +.sp +.LP \fBpr_lwp\fR contains the \fBps\fR(1) information for the representative lwp. If the process is a \fIzombie\fR, \fBpr_nlwp\fR, \fBpr_nzomb\fR, and \fBpr_lwp.pr_lwpid\fR are zero and the other fields of \fBpr_lwp\fR are diff --git a/usr/src/uts/common/fs/proc/prvnops.c b/usr/src/uts/common/fs/proc/prvnops.c index 84a8ae4d31..787e7619b4 100644 --- a/usr/src/uts/common/fs/proc/prvnops.c +++ b/usr/src/uts/common/fs/proc/prvnops.c @@ -2686,6 +2686,49 @@ prread(vnode_t *vp, uio_t *uiop, int ioflag, cred_t *cr, caller_context_t *ct) #endif } +/* + * We make pr_write_psinfo() somewhat simpler by asserting at compile time + * that PRFNSZ has the same definition as MAXCOMLEN. + */ +#if PRFNSZ != MAXCOMLEN +#error PRFNSZ/MAXCOMLEN mismatch +#endif + +int +pr_write_psinfo(prnode_t *pnp, uio_t *uiop) +{ + char fname[PRFNSZ]; + int offset = offsetof(psinfo_t, pr_fname), error; + + ASSERT(pnp->pr_type == PR_PSINFO); + +#ifdef _SYSCALL32_IMPL + if (curproc->p_model != DATAMODEL_LP64) + offset = offsetof(psinfo32_t, pr_fname); +#endif + + /* + * The only field that we actually care about is the pr_fname -- and we + * insist that only pr_fname (and exactly pr_fname) is being written. + */ + if (uiop->uio_offset != offset || uiop->uio_resid != PRFNSZ) + return (0); + + if ((error = uiomove(fname, PRFNSZ, UIO_WRITE, uiop)) != 0) + return (error); + + fname[PRFNSZ - 1] = '\0'; + + if ((error = prlock(pnp, ZNO)) != 0) + return (error); + + bcopy(fname, pnp->pr_common->prc_proc->p_user.u_comm, PRFNSZ); + + prunlock(pnp); + + return (0); +} + /* ARGSUSED */ static int prwrite(vnode_t *vp, uio_t *uiop, int ioflag, cred_t *cr, caller_context_t *ct) @@ -2764,6 +2807,9 @@ prwrite(vnode_t *vp, uio_t *uiop, int ioflag, cred_t *cr, caller_context_t *ct) uiop->uio_resid = resid; return (error); + case PR_PSINFO: + return (pr_write_psinfo(pnp, uiop)); + default: return ((vp->v_type == VDIR)? EISDIR : EBADF); } @@ -4546,6 +4592,9 @@ prgetnode(vnode_t *dp, prnodetype_t type) break; case PR_PSINFO: + pnp->pr_mode = 0644; /* readable by all + owner can write */ + break; + case PR_LPSINFO: case PR_LWPSINFO: case PR_USAGE: |