xref: /onnv-gate/usr/src/uts/common/dtrace/systrace.c (revision 8803:8c01b39012c9)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
51677Sdp  * Common Development and Distribution License (the "License").
61677Sdp  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*8803SJonathan.Haslam@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate 
270Sstevel@tonic-gate #include <sys/dtrace.h>
280Sstevel@tonic-gate #include <sys/systrace.h>
290Sstevel@tonic-gate #include <sys/stat.h>
300Sstevel@tonic-gate #include <sys/systm.h>
310Sstevel@tonic-gate #include <sys/conf.h>
320Sstevel@tonic-gate #include <sys/ddi.h>
330Sstevel@tonic-gate #include <sys/sunddi.h>
340Sstevel@tonic-gate #include <sys/atomic.h>
350Sstevel@tonic-gate 
360Sstevel@tonic-gate #define	SYSTRACE_ARTIFICIAL_FRAMES	1
370Sstevel@tonic-gate 
380Sstevel@tonic-gate #define	SYSTRACE_SHIFT			16
390Sstevel@tonic-gate #define	SYSTRACE_ISENTRY(x)		((int)(x) >> SYSTRACE_SHIFT)
400Sstevel@tonic-gate #define	SYSTRACE_SYSNUM(x)		((int)(x) & ((1 << SYSTRACE_SHIFT) - 1))
410Sstevel@tonic-gate #define	SYSTRACE_ENTRY(id)		((1 << SYSTRACE_SHIFT) | (id))
420Sstevel@tonic-gate #define	SYSTRACE_RETURN(id)		(id)
430Sstevel@tonic-gate 
440Sstevel@tonic-gate #if ((1 << SYSTRACE_SHIFT) <= NSYSCALL)
450Sstevel@tonic-gate #error 1 << SYSTRACE_SHIFT must exceed number of system calls
460Sstevel@tonic-gate #endif
470Sstevel@tonic-gate 
480Sstevel@tonic-gate static dev_info_t *systrace_devi;
490Sstevel@tonic-gate static dtrace_provider_id_t systrace_id;
500Sstevel@tonic-gate 
510Sstevel@tonic-gate static void
systrace_init(struct sysent * actual,systrace_sysent_t ** interposed)520Sstevel@tonic-gate systrace_init(struct sysent *actual, systrace_sysent_t **interposed)
530Sstevel@tonic-gate {
540Sstevel@tonic-gate 	systrace_sysent_t *sysent = *interposed;
550Sstevel@tonic-gate 	int i;
560Sstevel@tonic-gate 
570Sstevel@tonic-gate 	if (sysent == NULL) {
580Sstevel@tonic-gate 		*interposed = sysent = kmem_zalloc(sizeof (systrace_sysent_t) *
590Sstevel@tonic-gate 		    NSYSCALL, KM_SLEEP);
600Sstevel@tonic-gate 	}
610Sstevel@tonic-gate 
620Sstevel@tonic-gate 	for (i = 0; i < NSYSCALL; i++) {
630Sstevel@tonic-gate 		struct sysent *a = &actual[i];
640Sstevel@tonic-gate 		systrace_sysent_t *s = &sysent[i];
650Sstevel@tonic-gate 
660Sstevel@tonic-gate 		if (LOADABLE_SYSCALL(a) && !LOADED_SYSCALL(a))
670Sstevel@tonic-gate 			continue;
680Sstevel@tonic-gate 
690Sstevel@tonic-gate 		if (a->sy_callc == dtrace_systrace_syscall)
700Sstevel@tonic-gate 			continue;
710Sstevel@tonic-gate 
720Sstevel@tonic-gate #ifdef _SYSCALL32_IMPL
730Sstevel@tonic-gate 		if (a->sy_callc == dtrace_systrace_syscall32)
740Sstevel@tonic-gate 			continue;
750Sstevel@tonic-gate #endif
760Sstevel@tonic-gate 
770Sstevel@tonic-gate 		s->stsy_underlying = a->sy_callc;
780Sstevel@tonic-gate 	}
790Sstevel@tonic-gate }
800Sstevel@tonic-gate 
810Sstevel@tonic-gate /*ARGSUSED*/
820Sstevel@tonic-gate static void
systrace_provide(void * arg,const dtrace_probedesc_t * desc)830Sstevel@tonic-gate systrace_provide(void *arg, const dtrace_probedesc_t *desc)
840Sstevel@tonic-gate {
850Sstevel@tonic-gate 	int i;
860Sstevel@tonic-gate 
870Sstevel@tonic-gate 	if (desc != NULL)
880Sstevel@tonic-gate 		return;
890Sstevel@tonic-gate 
900Sstevel@tonic-gate 	systrace_init(sysent, &systrace_sysent);
910Sstevel@tonic-gate #ifdef _SYSCALL32_IMPL
920Sstevel@tonic-gate 	systrace_init(sysent32, &systrace_sysent32);
930Sstevel@tonic-gate #endif
940Sstevel@tonic-gate 
950Sstevel@tonic-gate 	for (i = 0; i < NSYSCALL; i++) {
960Sstevel@tonic-gate 		if (systrace_sysent[i].stsy_underlying == NULL)
970Sstevel@tonic-gate 			continue;
980Sstevel@tonic-gate 
990Sstevel@tonic-gate 		if (dtrace_probe_lookup(systrace_id, NULL,
1000Sstevel@tonic-gate 		    syscallnames[i], "entry") != 0)
1010Sstevel@tonic-gate 			continue;
1020Sstevel@tonic-gate 
1030Sstevel@tonic-gate 		(void) dtrace_probe_create(systrace_id, NULL, syscallnames[i],
1040Sstevel@tonic-gate 		    "entry", SYSTRACE_ARTIFICIAL_FRAMES,
1050Sstevel@tonic-gate 		    (void *)((uintptr_t)SYSTRACE_ENTRY(i)));
1060Sstevel@tonic-gate 		(void) dtrace_probe_create(systrace_id, NULL, syscallnames[i],
1070Sstevel@tonic-gate 		    "return", SYSTRACE_ARTIFICIAL_FRAMES,
1080Sstevel@tonic-gate 		    (void *)((uintptr_t)SYSTRACE_RETURN(i)));
1090Sstevel@tonic-gate 
1100Sstevel@tonic-gate 		systrace_sysent[i].stsy_entry = DTRACE_IDNONE;
1110Sstevel@tonic-gate 		systrace_sysent[i].stsy_return = DTRACE_IDNONE;
1120Sstevel@tonic-gate #ifdef _SYSCALL32_IMPL
1130Sstevel@tonic-gate 		systrace_sysent32[i].stsy_entry = DTRACE_IDNONE;
1140Sstevel@tonic-gate 		systrace_sysent32[i].stsy_return = DTRACE_IDNONE;
1150Sstevel@tonic-gate #endif
1160Sstevel@tonic-gate 	}
1170Sstevel@tonic-gate }
1180Sstevel@tonic-gate 
1190Sstevel@tonic-gate /*ARGSUSED*/
1200Sstevel@tonic-gate static void
systrace_destroy(void * arg,dtrace_id_t id,void * parg)1210Sstevel@tonic-gate systrace_destroy(void *arg, dtrace_id_t id, void *parg)
1220Sstevel@tonic-gate {
1230Sstevel@tonic-gate 	int sysnum = SYSTRACE_SYSNUM((uintptr_t)parg);
1240Sstevel@tonic-gate 
1250Sstevel@tonic-gate 	/*
1260Sstevel@tonic-gate 	 * There's nothing to do here but assert that we have actually been
1270Sstevel@tonic-gate 	 * disabled.
1280Sstevel@tonic-gate 	 */
1290Sstevel@tonic-gate 	if (SYSTRACE_ISENTRY((uintptr_t)parg)) {
1300Sstevel@tonic-gate 		ASSERT(systrace_sysent[sysnum].stsy_entry == DTRACE_IDNONE);
1310Sstevel@tonic-gate #ifdef _SYSCALL32_IMPL
1320Sstevel@tonic-gate 		ASSERT(systrace_sysent32[sysnum].stsy_entry == DTRACE_IDNONE);
1330Sstevel@tonic-gate #endif
1340Sstevel@tonic-gate 	} else {
1350Sstevel@tonic-gate 		ASSERT(systrace_sysent[sysnum].stsy_return == DTRACE_IDNONE);
1360Sstevel@tonic-gate #ifdef _SYSCALL32_IMPL
1370Sstevel@tonic-gate 		ASSERT(systrace_sysent32[sysnum].stsy_return == DTRACE_IDNONE);
1380Sstevel@tonic-gate #endif
1390Sstevel@tonic-gate 	}
1400Sstevel@tonic-gate }
1410Sstevel@tonic-gate 
1420Sstevel@tonic-gate /*ARGSUSED*/
143*8803SJonathan.Haslam@Sun.COM static int
systrace_enable(void * arg,dtrace_id_t id,void * parg)1440Sstevel@tonic-gate systrace_enable(void *arg, dtrace_id_t id, void *parg)
1450Sstevel@tonic-gate {
1460Sstevel@tonic-gate 	int sysnum = SYSTRACE_SYSNUM((uintptr_t)parg);
1470Sstevel@tonic-gate 	int enabled = (systrace_sysent[sysnum].stsy_entry != DTRACE_IDNONE ||
1480Sstevel@tonic-gate 	    systrace_sysent[sysnum].stsy_return != DTRACE_IDNONE);
1490Sstevel@tonic-gate 
1500Sstevel@tonic-gate 	if (SYSTRACE_ISENTRY((uintptr_t)parg)) {
1510Sstevel@tonic-gate 		systrace_sysent[sysnum].stsy_entry = id;
1520Sstevel@tonic-gate #ifdef _SYSCALL32_IMPL
1530Sstevel@tonic-gate 		systrace_sysent32[sysnum].stsy_entry = id;
1540Sstevel@tonic-gate #endif
1550Sstevel@tonic-gate 	} else {
1560Sstevel@tonic-gate 		systrace_sysent[sysnum].stsy_return = id;
1570Sstevel@tonic-gate #ifdef _SYSCALL32_IMPL
1580Sstevel@tonic-gate 		systrace_sysent32[sysnum].stsy_return = id;
1590Sstevel@tonic-gate #endif
1600Sstevel@tonic-gate 	}
1610Sstevel@tonic-gate 
1620Sstevel@tonic-gate 	if (enabled) {
1630Sstevel@tonic-gate 		ASSERT(sysent[sysnum].sy_callc == dtrace_systrace_syscall);
164*8803SJonathan.Haslam@Sun.COM 		return (0);
1650Sstevel@tonic-gate 	}
1660Sstevel@tonic-gate 
1670Sstevel@tonic-gate 	(void) casptr(&sysent[sysnum].sy_callc,
1680Sstevel@tonic-gate 	    (void *)systrace_sysent[sysnum].stsy_underlying,
1690Sstevel@tonic-gate 	    (void *)dtrace_systrace_syscall);
1700Sstevel@tonic-gate #ifdef _SYSCALL32_IMPL
1710Sstevel@tonic-gate 	(void) casptr(&sysent32[sysnum].sy_callc,
1720Sstevel@tonic-gate 	    (void *)systrace_sysent32[sysnum].stsy_underlying,
1730Sstevel@tonic-gate 	    (void *)dtrace_systrace_syscall32);
1740Sstevel@tonic-gate #endif
175*8803SJonathan.Haslam@Sun.COM 	return (0);
1760Sstevel@tonic-gate }
1770Sstevel@tonic-gate 
1780Sstevel@tonic-gate /*ARGSUSED*/
1790Sstevel@tonic-gate static void
systrace_disable(void * arg,dtrace_id_t id,void * parg)1800Sstevel@tonic-gate systrace_disable(void *arg, dtrace_id_t id, void *parg)
1810Sstevel@tonic-gate {
1820Sstevel@tonic-gate 	int sysnum = SYSTRACE_SYSNUM((uintptr_t)parg);
1830Sstevel@tonic-gate 	int disable = (systrace_sysent[sysnum].stsy_entry == DTRACE_IDNONE ||
1840Sstevel@tonic-gate 	    systrace_sysent[sysnum].stsy_return == DTRACE_IDNONE);
1850Sstevel@tonic-gate 
1860Sstevel@tonic-gate 	if (disable) {
1870Sstevel@tonic-gate 		(void) casptr(&sysent[sysnum].sy_callc,
1880Sstevel@tonic-gate 		    (void *)dtrace_systrace_syscall,
1890Sstevel@tonic-gate 		    (void *)systrace_sysent[sysnum].stsy_underlying);
1900Sstevel@tonic-gate 
1910Sstevel@tonic-gate #ifdef _SYSCALL32_IMPL
1920Sstevel@tonic-gate 		(void) casptr(&sysent32[sysnum].sy_callc,
1930Sstevel@tonic-gate 		    (void *)dtrace_systrace_syscall32,
1940Sstevel@tonic-gate 		    (void *)systrace_sysent32[sysnum].stsy_underlying);
1950Sstevel@tonic-gate #endif
1960Sstevel@tonic-gate 	}
1970Sstevel@tonic-gate 
1980Sstevel@tonic-gate 	if (SYSTRACE_ISENTRY((uintptr_t)parg)) {
1990Sstevel@tonic-gate 		systrace_sysent[sysnum].stsy_entry = DTRACE_IDNONE;
2000Sstevel@tonic-gate #ifdef _SYSCALL32_IMPL
2010Sstevel@tonic-gate 		systrace_sysent32[sysnum].stsy_entry = DTRACE_IDNONE;
2020Sstevel@tonic-gate #endif
2030Sstevel@tonic-gate 	} else {
2040Sstevel@tonic-gate 		systrace_sysent[sysnum].stsy_return = DTRACE_IDNONE;
2050Sstevel@tonic-gate #ifdef _SYSCALL32_IMPL
2060Sstevel@tonic-gate 		systrace_sysent32[sysnum].stsy_return = DTRACE_IDNONE;
2070Sstevel@tonic-gate #endif
2080Sstevel@tonic-gate 	}
2090Sstevel@tonic-gate }
2100Sstevel@tonic-gate 
2110Sstevel@tonic-gate static dtrace_pattr_t systrace_attr = {
2120Sstevel@tonic-gate { DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_COMMON },
2130Sstevel@tonic-gate { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
2140Sstevel@tonic-gate { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_ISA },
2150Sstevel@tonic-gate { DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_COMMON },
2160Sstevel@tonic-gate { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_ISA },
2170Sstevel@tonic-gate };
2180Sstevel@tonic-gate 
2190Sstevel@tonic-gate static dtrace_pops_t systrace_pops = {
2200Sstevel@tonic-gate 	systrace_provide,
2210Sstevel@tonic-gate 	NULL,
2220Sstevel@tonic-gate 	systrace_enable,
2230Sstevel@tonic-gate 	systrace_disable,
2240Sstevel@tonic-gate 	NULL,
2250Sstevel@tonic-gate 	NULL,
2260Sstevel@tonic-gate 	NULL,
2270Sstevel@tonic-gate 	NULL,
2280Sstevel@tonic-gate 	NULL,
2290Sstevel@tonic-gate 	systrace_destroy
2300Sstevel@tonic-gate };
2310Sstevel@tonic-gate 
2320Sstevel@tonic-gate static int
systrace_attach(dev_info_t * devi,ddi_attach_cmd_t cmd)2330Sstevel@tonic-gate systrace_attach(dev_info_t *devi, ddi_attach_cmd_t cmd)
2340Sstevel@tonic-gate {
2350Sstevel@tonic-gate 	switch (cmd) {
2360Sstevel@tonic-gate 	case DDI_ATTACH:
2370Sstevel@tonic-gate 		break;
2380Sstevel@tonic-gate 	case DDI_RESUME:
2390Sstevel@tonic-gate 		return (DDI_SUCCESS);
2400Sstevel@tonic-gate 	default:
2410Sstevel@tonic-gate 		return (DDI_FAILURE);
2420Sstevel@tonic-gate 	}
2430Sstevel@tonic-gate 
2442769Sahl 	systrace_probe = (void (*)())dtrace_probe;
2450Sstevel@tonic-gate 	membar_enter();
2460Sstevel@tonic-gate 
2470Sstevel@tonic-gate 	if (ddi_create_minor_node(devi, "systrace", S_IFCHR, 0,
2480Sstevel@tonic-gate 	    DDI_PSEUDO, NULL) == DDI_FAILURE ||
2491677Sdp 	    dtrace_register("syscall", &systrace_attr, DTRACE_PRIV_USER, NULL,
2500Sstevel@tonic-gate 	    &systrace_pops, NULL, &systrace_id) != 0) {
2510Sstevel@tonic-gate 		systrace_probe = systrace_stub;
2520Sstevel@tonic-gate 		ddi_remove_minor_node(devi, NULL);
2530Sstevel@tonic-gate 		return (DDI_FAILURE);
2540Sstevel@tonic-gate 	}
2550Sstevel@tonic-gate 
2560Sstevel@tonic-gate 	ddi_report_dev(devi);
2570Sstevel@tonic-gate 	systrace_devi = devi;
2580Sstevel@tonic-gate 
2590Sstevel@tonic-gate 	return (DDI_SUCCESS);
2600Sstevel@tonic-gate }
2610Sstevel@tonic-gate 
2620Sstevel@tonic-gate static int
systrace_detach(dev_info_t * devi,ddi_detach_cmd_t cmd)2630Sstevel@tonic-gate systrace_detach(dev_info_t *devi, ddi_detach_cmd_t cmd)
2640Sstevel@tonic-gate {
2650Sstevel@tonic-gate 	switch (cmd) {
2660Sstevel@tonic-gate 	case DDI_DETACH:
2670Sstevel@tonic-gate 		break;
2680Sstevel@tonic-gate 	case DDI_SUSPEND:
2690Sstevel@tonic-gate 		return (DDI_SUCCESS);
2700Sstevel@tonic-gate 	default:
2710Sstevel@tonic-gate 		return (DDI_FAILURE);
2720Sstevel@tonic-gate 	}
2730Sstevel@tonic-gate 
2740Sstevel@tonic-gate 	if (dtrace_unregister(systrace_id) != 0)
2750Sstevel@tonic-gate 		return (DDI_FAILURE);
2760Sstevel@tonic-gate 
2770Sstevel@tonic-gate 	ddi_remove_minor_node(devi, NULL);
2780Sstevel@tonic-gate 	systrace_probe = systrace_stub;
2790Sstevel@tonic-gate 	return (DDI_SUCCESS);
2800Sstevel@tonic-gate }
2810Sstevel@tonic-gate 
2820Sstevel@tonic-gate /*ARGSUSED*/
2830Sstevel@tonic-gate static int
systrace_info(dev_info_t * dip,ddi_info_cmd_t infocmd,void * arg,void ** result)2840Sstevel@tonic-gate systrace_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result)
2850Sstevel@tonic-gate {
2860Sstevel@tonic-gate 	int error;
2870Sstevel@tonic-gate 
2880Sstevel@tonic-gate 	switch (infocmd) {
2890Sstevel@tonic-gate 	case DDI_INFO_DEVT2DEVINFO:
2900Sstevel@tonic-gate 		*result = (void *)systrace_devi;
2910Sstevel@tonic-gate 		error = DDI_SUCCESS;
2920Sstevel@tonic-gate 		break;
2930Sstevel@tonic-gate 	case DDI_INFO_DEVT2INSTANCE:
2940Sstevel@tonic-gate 		*result = (void *)0;
2950Sstevel@tonic-gate 		error = DDI_SUCCESS;
2960Sstevel@tonic-gate 		break;
2970Sstevel@tonic-gate 	default:
2980Sstevel@tonic-gate 		error = DDI_FAILURE;
2990Sstevel@tonic-gate 	}
3000Sstevel@tonic-gate 	return (error);
3010Sstevel@tonic-gate }
3020Sstevel@tonic-gate 
3030Sstevel@tonic-gate /*ARGSUSED*/
3040Sstevel@tonic-gate static int
systrace_open(dev_t * devp,int flag,int otyp,cred_t * cred_p)3050Sstevel@tonic-gate systrace_open(dev_t *devp, int flag, int otyp, cred_t *cred_p)
3060Sstevel@tonic-gate {
3070Sstevel@tonic-gate 	return (0);
3080Sstevel@tonic-gate }
3090Sstevel@tonic-gate 
3100Sstevel@tonic-gate static struct cb_ops systrace_cb_ops = {
3110Sstevel@tonic-gate 	systrace_open,		/* open */
3120Sstevel@tonic-gate 	nodev,			/* close */
3130Sstevel@tonic-gate 	nulldev,		/* strategy */
3140Sstevel@tonic-gate 	nulldev,		/* print */
3150Sstevel@tonic-gate 	nodev,			/* dump */
3160Sstevel@tonic-gate 	nodev,			/* read */
3170Sstevel@tonic-gate 	nodev,			/* write */
3180Sstevel@tonic-gate 	nodev,			/* ioctl */
3190Sstevel@tonic-gate 	nodev,			/* devmap */
3200Sstevel@tonic-gate 	nodev,			/* mmap */
3210Sstevel@tonic-gate 	nodev,			/* segmap */
3220Sstevel@tonic-gate 	nochpoll,		/* poll */
3230Sstevel@tonic-gate 	ddi_prop_op,		/* cb_prop_op */
3240Sstevel@tonic-gate 	0,			/* streamtab  */
3250Sstevel@tonic-gate 	D_NEW | D_MP		/* Driver compatibility flag */
3260Sstevel@tonic-gate };
3270Sstevel@tonic-gate 
3280Sstevel@tonic-gate static struct dev_ops systrace_ops = {
3290Sstevel@tonic-gate 	DEVO_REV,		/* devo_rev, */
3300Sstevel@tonic-gate 	0,			/* refcnt  */
3310Sstevel@tonic-gate 	systrace_info,		/* get_dev_info */
3320Sstevel@tonic-gate 	nulldev,		/* identify */
3330Sstevel@tonic-gate 	nulldev,		/* probe */
3340Sstevel@tonic-gate 	systrace_attach,	/* attach */
3350Sstevel@tonic-gate 	systrace_detach,	/* detach */
3360Sstevel@tonic-gate 	nodev,			/* reset */
3370Sstevel@tonic-gate 	&systrace_cb_ops,	/* driver operations */
3380Sstevel@tonic-gate 	NULL,			/* bus operations */
3397656SSherry.Moore@Sun.COM 	nodev,			/* dev power */
3407656SSherry.Moore@Sun.COM 	ddi_quiesce_not_needed,		/* quiesce */
3410Sstevel@tonic-gate };
3420Sstevel@tonic-gate 
3430Sstevel@tonic-gate /*
3440Sstevel@tonic-gate  * Module linkage information for the kernel.
3450Sstevel@tonic-gate  */
3460Sstevel@tonic-gate static struct modldrv modldrv = {
3470Sstevel@tonic-gate 	&mod_driverops,		/* module type (this is a pseudo driver) */
3480Sstevel@tonic-gate 	"System Call Tracing",	/* name of module */
3490Sstevel@tonic-gate 	&systrace_ops,		/* driver ops */
3500Sstevel@tonic-gate };
3510Sstevel@tonic-gate 
3520Sstevel@tonic-gate static struct modlinkage modlinkage = {
3530Sstevel@tonic-gate 	MODREV_1,
3540Sstevel@tonic-gate 	(void *)&modldrv,
3550Sstevel@tonic-gate 	NULL
3560Sstevel@tonic-gate };
3570Sstevel@tonic-gate 
3580Sstevel@tonic-gate int
_init(void)3590Sstevel@tonic-gate _init(void)
3600Sstevel@tonic-gate {
3610Sstevel@tonic-gate 	return (mod_install(&modlinkage));
3620Sstevel@tonic-gate }
3630Sstevel@tonic-gate 
3640Sstevel@tonic-gate int
_info(struct modinfo * modinfop)3650Sstevel@tonic-gate _info(struct modinfo *modinfop)
3660Sstevel@tonic-gate {
3670Sstevel@tonic-gate 	return (mod_info(&modlinkage, modinfop));
3680Sstevel@tonic-gate }
3690Sstevel@tonic-gate 
3700Sstevel@tonic-gate int
_fini(void)3710Sstevel@tonic-gate _fini(void)
3720Sstevel@tonic-gate {
3730Sstevel@tonic-gate 	return (mod_remove(&modlinkage));
3740Sstevel@tonic-gate }
375