summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authortrociny <trociny@FreeBSD.org>2012-03-23 20:05:41 +0000
committertrociny <trociny@FreeBSD.org>2012-03-23 20:05:41 +0000
commit0079b1f6c583d2499d00205f60934561dfe9989b (patch)
treece9746294c6dffa417aef7231862c776904b95bc /sys/kern
parentf150c5bbfc1a83c3f8e6c17cea1fa16375bccc3b (diff)
downloadFreeBSD-src-0079b1f6c583d2499d00205f60934561dfe9989b.zip
FreeBSD-src-0079b1f6c583d2499d00205f60934561dfe9989b.tar.gz
Add a sysctl to set and retrieve binary osreldate of another process.
Suggested by: kib Reviewed by: kib MFC after: 2 weeks
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_proc.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c
index b922cd2..e6c4c72 100644
--- a/sys/kern/kern_proc.c
+++ b/sys/kern/kern_proc.c
@@ -2499,6 +2499,52 @@ sysctl_kern_proc_umask(SYSCTL_HANDLER_ARGS)
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_PS_STRINGS, ps_strings, CTLFLAG_RD |
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");
OpenPOWER on IntegriCloud