From owner-svn-src-all@FreeBSD.ORG Fri Apr 6 16:28:43 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E6246106566C; Fri, 6 Apr 2012 16:28:43 +0000 (UTC) (envelope-from trociny@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B69B68FC12; Fri, 6 Apr 2012 16:28:43 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q36GShWW016965; Fri, 6 Apr 2012 16:28:43 GMT (envelope-from trociny@svn.freebsd.org) Received: (from trociny@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q36GShUo016962; Fri, 6 Apr 2012 16:28:43 GMT (envelope-from trociny@svn.freebsd.org) Message-Id: <201204061628.q36GShUo016962@svn.freebsd.org> From: Mikolaj Golub Date: Fri, 6 Apr 2012 16:28:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r233950 - in stable/9/sys: kern sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2012 16:28:44 -0000 Author: trociny Date: Fri Apr 6 16:28:43 2012 New Revision: 233950 URL: http://svn.freebsd.org/changeset/base/233950 Log: MFC r233389: Add a sysctl to set and retrieve binary osreldate of another process. Suggested by: kib Reviewed by: kib Modified: stable/9/sys/kern/kern_proc.c stable/9/sys/sys/sysctl.h Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/kern/kern_proc.c ============================================================================== --- stable/9/sys/kern/kern_proc.c Fri Apr 6 16:03:38 2012 (r233949) +++ stable/9/sys/kern/kern_proc.c Fri Apr 6 16:28:43 2012 (r233950) @@ -2499,6 +2499,52 @@ sysctl_kern_proc_umask(SYSCTL_HANDLER_AR return (error); } +/* + * This sysctl allows a process to set and retrieve binary osreldate of + * another process. + */ +static int +sysctl_kern_proc_osrel(SYSCTL_HANDLER_ARGS) +{ + int *name = (int *)arg1; + u_int namelen = arg2; + struct proc *p; + int flags, error, osrel; + + if (namelen != 1) + return (EINVAL); + + if (req->newptr != NULL && req->newlen != sizeof(osrel)) + return (EINVAL); + + flags = PGET_HOLD | PGET_NOTWEXIT; + if (req->newptr != NULL) + flags |= PGET_CANDEBUG; + else + flags |= PGET_CANSEE; + error = pget((pid_t)name[0], flags, &p); + if (error != 0) + return (error); + + error = SYSCTL_OUT(req, &p->p_osrel, sizeof(p->p_osrel)); + if (error != 0) + goto errout; + + if (req->newptr != NULL) { + error = SYSCTL_IN(req, &osrel, sizeof(osrel)); + if (error != 0) + goto errout; + if (osrel < 0) { + error = EINVAL; + goto errout; + } + p->p_osrel = osrel; + } +errout: + PRELE(p); + return (error); +} + SYSCTL_NODE(_kern, KERN_PROC, proc, CTLFLAG_RD, 0, "Process table"); SYSCTL_PROC(_kern_proc, KERN_PROC_ALL, all, CTLFLAG_RD|CTLTYPE_STRUCT| @@ -2603,3 +2649,7 @@ static SYSCTL_NODE(_kern_proc, KERN_PROC static SYSCTL_NODE(_kern_proc, KERN_PROC_UMASK, umask, CTLFLAG_RD | CTLFLAG_MPSAFE, sysctl_kern_proc_umask, "Process umask"); + +static SYSCTL_NODE(_kern_proc, KERN_PROC_OSREL, osrel, CTLFLAG_RW | + CTLFLAG_ANYBODY | CTLFLAG_MPSAFE, sysctl_kern_proc_osrel, + "Process binary osreldate"); Modified: stable/9/sys/sys/sysctl.h ============================================================================== --- stable/9/sys/sys/sysctl.h Fri Apr 6 16:03:38 2012 (r233949) +++ stable/9/sys/sys/sysctl.h Fri Apr 6 16:28:43 2012 (r233950) @@ -564,6 +564,7 @@ SYSCTL_ALLOWED_TYPES(UINT64, uint64_t *a #define KERN_PROC_RLIMIT 37 /* process resource limits */ #define KERN_PROC_PS_STRINGS 38 /* get ps_strings location */ #define KERN_PROC_UMASK 39 /* process umask */ +#define KERN_PROC_OSREL 40 /* osreldate for process binary */ /* * KERN_IPC identifiers