Date: Fri, 6 Apr 2012 16:30:17 +0000 (UTC) From: Mikolaj Golub <trociny@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r233951 - in stable/8/sys: kern sys Message-ID: <201204061630.q36GUHc8017062@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: trociny Date: Fri Apr 6 16:30:17 2012 New Revision: 233951 URL: http://svn.freebsd.org/changeset/base/233951 Log: MFC r233389: Add a sysctl to set and retrieve binary osreldate of another process. Suggested by: kib Reviewed by: kib Modified: stable/8/sys/kern/kern_proc.c stable/8/sys/sys/sysctl.h Directory Properties: stable/8/sys/ (props changed) Modified: stable/8/sys/kern/kern_proc.c ============================================================================== --- stable/8/sys/kern/kern_proc.c Fri Apr 6 16:28:43 2012 (r233950) +++ stable/8/sys/kern/kern_proc.c Fri Apr 6 16:30:17 2012 (r233951) @@ -1976,6 +1976,52 @@ sysctl_kern_proc_groups(SYSCTL_HANDLER_A 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| @@ -2063,3 +2109,7 @@ static SYSCTL_NODE(_kern_proc, KERN_PROC static SYSCTL_NODE(_kern_proc, KERN_PROC_GROUPS, groups, CTLFLAG_RD | CTLFLAG_MPSAFE, sysctl_kern_proc_groups, "Process groups"); + +static SYSCTL_NODE(_kern_proc, KERN_PROC_OSREL, osrel, CTLFLAG_RW | + CTLFLAG_ANYBODY | CTLFLAG_MPSAFE, sysctl_kern_proc_osrel, + "Process binary osreldate"); Modified: stable/8/sys/sys/sysctl.h ============================================================================== --- stable/8/sys/sys/sysctl.h Fri Apr 6 16:28:43 2012 (r233950) +++ stable/8/sys/sys/sysctl.h Fri Apr 6 16:30:17 2012 (r233951) @@ -493,6 +493,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_e #define KERN_PROC_VMMAP 32 /* VM map entries for process */ #define KERN_PROC_FILEDESC 33 /* File descriptors for process */ #define KERN_PROC_GROUPS 34 /* process groups */ +#define KERN_PROC_OSREL 40 /* osreldate for process binary */ /* * KERN_IPC identifiers
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201204061630.q36GUHc8017062>