From owner-p4-projects@FreeBSD.ORG Mon Apr 24 02:33:58 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 3864616A402; Mon, 24 Apr 2006 02:33:58 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D67D916A400 for ; Mon, 24 Apr 2006 02:33:57 +0000 (UTC) (envelope-from jb@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7179C43D55 for ; Mon, 24 Apr 2006 02:33:57 +0000 (GMT) (envelope-from jb@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id k3O2XvwW066691 for ; Mon, 24 Apr 2006 02:33:57 GMT (envelope-from jb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id k3O2Xu8g066653 for perforce@freebsd.org; Mon, 24 Apr 2006 02:33:57 GMT (envelope-from jb@freebsd.org) Date: Mon, 24 Apr 2006 02:33:57 GMT Message-Id: <200604240233.k3O2Xu8g066653@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jb@freebsd.org using -f From: John Birrell To: Perforce Change Reviews Cc: Subject: PERFORCE change 95980 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Apr 2006 02:33:58 -0000 http://perforce.freebsd.org/chv.cgi?CH=95980 Change 95980 by jb@jb_freebsd2 on 2006/04/24 02:33:29 Use a structure for the ENABLE ioctl so that the DOF pointer can be passed in and the number of probes matched returned without having to do some hairy casts. Affected files ... .. //depot/projects/dtrace/src/sys/cddl/dev/dtrace/dtrace_ioctl.c#4 edit .. //depot/projects/dtrace/src/sys/contrib/opensolaris/uts/common/sys/dtrace.h#6 edit Differences ... ==== //depot/projects/dtrace/src/sys/cddl/dev/dtrace/dtrace_ioctl.c#4 (text+ko) ==== @@ -24,10 +24,13 @@ /* ARGSUSED */ static int -dtrace_ioctl(struct cdev *dev __unused, u_long cmd, caddr_t addr __unused, - int flags __unused, struct thread *td __unused) +dtrace_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, + int flags __unused, struct thread *td) { + dtrace_state_t *state = dev->si_drv1; int error = 0; + if (state == NULL) + return (EINVAL); switch (cmd) { case DTRACEIOC_AGGDESC: @@ -44,7 +47,6 @@ break; case DTRACEIOC_CONF: { dtrace_conf_t conf; -printf("DTRACEIOC_CONF:\n"); bzero(&conf, sizeof (conf)); conf.dtc_difversion = DIF_VERSION; conf.dtc_difintregs = DIF_DIR_NREGS; @@ -61,37 +63,31 @@ break; case DTRACEIOC_ENABLE: { dof_hdr_t *dof = NULL; -#ifdef DOODAD dtrace_enabling_t *enab = NULL; dtrace_vstate_t *vstate; -#endif int err = 0; int rval; - void **p = (void **) addr; -printf("DTRACEIOC_ENABLE: p %p *p %p\n",p,*p); + dtrace_enable_io_t *p = (dtrace_enable_io_t *) addr; /* * If a NULL argument has been passed, we take this as our * cue to reevaluate our enablings. */ - if (*p == NULL) { + if (p->dof == NULL) { mutex_enter(&cpu_lock); mutex_enter(&dtrace_lock); -#ifdef DOODAD - err = dtrace_enabling_matchstate(state, *p); -#endif + err = dtrace_enabling_matchstate(state, &p->n_matched); mutex_exit(&dtrace_lock); mutex_exit(&cpu_lock); return (err); } - if ((dof = dtrace_dof_copyin((uintptr_t) *p, &rval)) == NULL) + if ((dof = dtrace_dof_copyin((uintptr_t) p->dof, &rval)) == NULL) return (rval); mutex_enter(&cpu_lock); mutex_enter(&dtrace_lock); -#ifdef DOODAD vstate = &state->dts_vstate; if (state->dts_activity != DTRACE_ACTIVITY_INACTIVE) { @@ -116,12 +112,11 @@ return (rval); } - if ((err = dtrace_enabling_match(enab, *p)) == 0) { + if ((err = dtrace_enabling_match(enab, &p->n_matched)) == 0) { err = dtrace_enabling_retain(enab); } else { dtrace_enabling_destroy(enab); } -#endif mutex_exit(&cpu_lock); mutex_exit(&dtrace_lock); @@ -145,7 +140,6 @@ dtrace_argdesc_t *desc = (dtrace_argdesc_t *) addr; dtrace_probe_t *probe; dtrace_provider_t *prov; -printf("DTRACEIOC_PROBEARG:\n"); if (desc->dtargd_id == DTRACE_IDNONE) return (EINVAL); @@ -205,7 +199,6 @@ uint32_t priv = 0; uid_t uid = 0; zoneid_t zoneid = 0; -printf("%s:\n",(cmd == DTRACEIOC_PROBEMATCH) ? "DTRACEIOC_PROBEMATCH":"DTRACEIOC_PROBES"); p_desc->dtpd_provider[DTRACE_PROVNAMELEN - 1] = '\0'; p_desc->dtpd_mod[DTRACE_MODNAMELEN - 1] = '\0'; @@ -266,7 +259,6 @@ case DTRACEIOC_PROVIDER: { dtrace_providerdesc_t *pvd = (dtrace_providerdesc_t *) addr; dtrace_provider_t *pvp; -printf("DTRACEIOC_PROVIDER:\n"); pvd->dtvd_name[DTRACE_PROVNAMELEN - 1] = '\0'; mutex_enter(&dtrace_provider_lock); ==== //depot/projects/dtrace/src/sys/contrib/opensolaris/uts/common/sys/dtrace.h#6 (text) ==== @@ -1205,7 +1205,12 @@ #define DTRACEIOC_BUFSNAP _IO('x',4) /* snapshot buffer */ #define DTRACEIOC_PROBEMATCH _IOWR('x',5,dtrace_probedesc_t) /* match probes */ -#define DTRACEIOC_ENABLE _IOWR('x',6,void *) /* enable probes */ +typedef struct { + void *dof; /* DOF userland address written to driver. */ + int n_matched; /* # matches returned by driver. */ +} dtrace_enable_io_t; +#define DTRACEIOC_ENABLE _IOWR('x',6,dtrace_enable_io_t) + /* enable probes */ #define DTRACEIOC_AGGSNAP _IO('x',7) /* snapshot agg. */ #define DTRACEIOC_EPROBE _IO('x',8) /* get eprobe desc. */ #define DTRACEIOC_PROBEARG _IOWR('x',9,dtrace_argdesc_t)