Exemple #1
0
int
procfs_doctl(struct proc *curp, struct lwp *lp, struct pfsnode *pfs,
	     struct uio *uio)
{
	struct proc *p = lp->lwp_proc;
	int xlen;
	int error;
	char msg[PROCFS_CTLLEN+1];
	vfs_namemap_t *nm;

	ASSERT_LWKT_TOKEN_HELD(&p->p_token);
	ASSERT_LWKT_TOKEN_HELD(&proc_token);

	if (uio->uio_rw != UIO_WRITE)
		return (EOPNOTSUPP);

	xlen = PROCFS_CTLLEN;
	error = vfs_getuserstr(uio, msg, &xlen);
	if (error)
		return (error);

	/*
	 * Map signal names into signal generation
	 * or debug control.  Unknown commands and/or signals
	 * return EOPNOTSUPP.
	 *
	 * Sending a signal while the process is being debugged
	 * also has the side effect of letting the target continue
	 * to run.  There is no way to single-step a signal delivery.
	 */
	error = EOPNOTSUPP;

	nm = vfs_findname(ctlnames, msg, xlen);
	if (nm) {
		error = procfs_control(curp, lp, nm->nm_val);
	} else {
		nm = vfs_findname(signames, msg, xlen);
		if (nm) {
			if (TRACE_WAIT_P(curp, p)) {
				p->p_xstat = nm->nm_val;
#ifdef FIX_SSTEP
				FIX_SSTEP(lp);
#endif
				/*
				 * Make the process runnable but do not
				 * break its tsleep.
				 */
				proc_unstop(p);
			} else {
				ksignal(p, nm->nm_val);
			}
			error = 0;
		}
	}

	return (error);
}
Exemple #2
0
int
procfs_donote(struct proc *curp, struct lwp *lp, struct pfsnode *pfs,
	      struct uio *uio)
{
	int xlen;
	int error;
	char note[PROCFS_NOTELEN+1];

	if (uio->uio_rw != UIO_WRITE)
		return (EINVAL);

	xlen = PROCFS_NOTELEN;
	error = vfs_getuserstr(uio, note, &xlen);
	if (error)
		return (error);

	/* send to process's notify function */
	return (EOPNOTSUPP);
}