FreeBSD/sys/kern/kern_proc.c
/*
 * This sysctl allows a process to set and retrieve binary osreldate of
 * another process.
 */
This sysctl allows a process to set and retrieve binary osreldate of
another process.
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);
}
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 ) ; }
This sysctl allows a process to set and retrieve binary osreldate of
 another process.
This sysctl allows a process to set and retrieve binary osreldate of another process .