Date: Mon, 24 Apr 2006 02:33:57 GMT From: John Birrell <jb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 95980 for review Message-ID: <200604240233.k3O2Xu8g066653@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200604240233.k3O2Xu8g066653>