xref: /illumos-gate/usr/src/cmd/devfsadm/vscan_link.c (revision 2a8bcb4e)
1*bfc848c6Sjm /*
2*bfc848c6Sjm  * CDDL HEADER START
3*bfc848c6Sjm  *
4*bfc848c6Sjm  * The contents of this file are subject to the terms of the
5*bfc848c6Sjm  * Common Development and Distribution License (the "License").
6*bfc848c6Sjm  * You may not use this file except in compliance with the License.
7*bfc848c6Sjm  *
8*bfc848c6Sjm  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*bfc848c6Sjm  * or http://www.opensolaris.org/os/licensing.
10*bfc848c6Sjm  * See the License for the specific language governing permissions
11*bfc848c6Sjm  * and limitations under the License.
12*bfc848c6Sjm  *
13*bfc848c6Sjm  * When distributing Covered Code, include this CDDL HEADER in each
14*bfc848c6Sjm  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*bfc848c6Sjm  * If applicable, add the following below this CDDL HEADER, with the
16*bfc848c6Sjm  * fields enclosed by brackets "[]" replaced with your own identifying
17*bfc848c6Sjm  * information: Portions Copyright [yyyy] [name of copyright owner]
18*bfc848c6Sjm  *
19*bfc848c6Sjm  * CDDL HEADER END
20*bfc848c6Sjm  */
21*bfc848c6Sjm /*
22*bfc848c6Sjm  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23*bfc848c6Sjm  * Use is subject to license terms.
24*bfc848c6Sjm  */
25*bfc848c6Sjm 
26*bfc848c6Sjm #include <devfsadm.h>
27*bfc848c6Sjm #include <strings.h>
28*bfc848c6Sjm #include <stdio.h>
29*bfc848c6Sjm #include <sys/vscan.h>
30*bfc848c6Sjm 
31*bfc848c6Sjm static int vscan(di_minor_t minor, di_node_t node);
32*bfc848c6Sjm 
33*bfc848c6Sjm static devfsadm_create_t vscan_create_cbt[] = {
34*bfc848c6Sjm 	{ "pseudo", "ddi_pseudo", "vscan",
35*bfc848c6Sjm 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, vscan },
36*bfc848c6Sjm };
37*bfc848c6Sjm DEVFSADM_CREATE_INIT_V0(vscan_create_cbt);
38*bfc848c6Sjm 
39*bfc848c6Sjm static devfsadm_remove_t vscan_remove_cbt[] = {
40*bfc848c6Sjm 	{ "vscan", "^vscan/vscan[0-9]+$", RM_HOT | RM_POST,
41*bfc848c6Sjm 		ILEVEL_0, devfsadm_rm_all
42*bfc848c6Sjm 	}
43*bfc848c6Sjm };
44*bfc848c6Sjm DEVFSADM_REMOVE_INIT_V0(vscan_remove_cbt);
45*bfc848c6Sjm 
46*bfc848c6Sjm static int
vscan(di_minor_t minor,di_node_t node)47*bfc848c6Sjm vscan(di_minor_t minor, di_node_t node)
48*bfc848c6Sjm {
49*bfc848c6Sjm 	char *mname = di_minor_name(minor);
50*bfc848c6Sjm 	char path[MAXPATHLEN];
51*bfc848c6Sjm 
52*bfc848c6Sjm 	(void) snprintf(path, sizeof (path), "vscan/%s", mname);
53*bfc848c6Sjm 	(void) devfsadm_mklink(path, node, minor, 0);
54*bfc848c6Sjm 
55*bfc848c6Sjm 	return (DEVFSADM_CONTINUE);
56*bfc848c6Sjm }
57