xref: /titanic_50/usr/src/cmd/devfsadm/i386/xen_link.c (revision c7158ae983f5a04c4a998f468ecefba6d23ba721)
1843e1988Sjohnlev /*
2843e1988Sjohnlev  * CDDL HEADER START
3843e1988Sjohnlev  *
4843e1988Sjohnlev  * The contents of this file are subject to the terms of the
5843e1988Sjohnlev  * Common Development and Distribution License (the "License").
6843e1988Sjohnlev  * You may not use this file except in compliance with the License.
7843e1988Sjohnlev  *
8843e1988Sjohnlev  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9843e1988Sjohnlev  * or http://www.opensolaris.org/os/licensing.
10843e1988Sjohnlev  * See the License for the specific language governing permissions
11843e1988Sjohnlev  * and limitations under the License.
12843e1988Sjohnlev  *
13843e1988Sjohnlev  * When distributing Covered Code, include this CDDL HEADER in each
14843e1988Sjohnlev  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15843e1988Sjohnlev  * If applicable, add the following below this CDDL HEADER, with the
16843e1988Sjohnlev  * fields enclosed by brackets "[]" replaced with your own identifying
17843e1988Sjohnlev  * information: Portions Copyright [yyyy] [name of copyright owner]
18843e1988Sjohnlev  *
19843e1988Sjohnlev  * CDDL HEADER END
20843e1988Sjohnlev  */
21843e1988Sjohnlev /*
22*c7158ae9Stariq  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23843e1988Sjohnlev  * Use is subject to license terms.
24843e1988Sjohnlev  */
25843e1988Sjohnlev 
26843e1988Sjohnlev #pragma ident	"%Z%%M%	%I%	%E% SMI"
27843e1988Sjohnlev 
28843e1988Sjohnlev #include <regex.h>
29843e1988Sjohnlev #include <devfsadm.h>
30843e1988Sjohnlev #include <stdio.h>
31843e1988Sjohnlev #include <strings.h>
32843e1988Sjohnlev #include <stdlib.h>
33843e1988Sjohnlev #include <limits.h>
34843e1988Sjohnlev #include <sys/privcmd_impl.h>
35843e1988Sjohnlev #include <sys/domcaps_impl.h>
36843e1988Sjohnlev #include <sys/balloon.h>
37843e1988Sjohnlev 
38843e1988Sjohnlev /*
39843e1988Sjohnlev  * Handle miscellaneous children of xendev
40843e1988Sjohnlev  */
41843e1988Sjohnlev static int devxen(di_minor_t, di_node_t);
42*c7158ae9Stariq static int xdt(di_minor_t minor, di_node_t node);
43843e1988Sjohnlev 
44843e1988Sjohnlev static devfsadm_create_t xen_cbt[] = {
45843e1988Sjohnlev 	{ "xendev", DDI_PSEUDO, "xenbus",
46843e1988Sjohnlev 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, devxen,
47843e1988Sjohnlev 	},
48843e1988Sjohnlev 	{ "xendev", DDI_PSEUDO, PRIVCMD_DRIVER_NAME,
49843e1988Sjohnlev 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, devxen,
50843e1988Sjohnlev 	},
51843e1988Sjohnlev 	{ "xendev", DDI_PSEUDO, "evtchn",
52843e1988Sjohnlev 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, devxen,
53843e1988Sjohnlev 	},
54843e1988Sjohnlev 	{ "xendev", DDI_PSEUDO, DOMCAPS_DRIVER_NAME,
55843e1988Sjohnlev 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, devxen,
56843e1988Sjohnlev 	},
57843e1988Sjohnlev 	{ "xendev", DDI_PSEUDO, BALLOON_DRIVER_NAME,
58843e1988Sjohnlev 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, devxen,
59843e1988Sjohnlev 	},
60*c7158ae9Stariq 	{ "pseudo", DDI_PSEUDO, "xdt",
61*c7158ae9Stariq 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, xdt
62*c7158ae9Stariq 	},
63843e1988Sjohnlev };
64843e1988Sjohnlev 
65843e1988Sjohnlev DEVFSADM_CREATE_INIT_V0(xen_cbt);
66843e1988Sjohnlev 
67843e1988Sjohnlev static devfsadm_remove_t xen_remove_cbt[] = {
68843e1988Sjohnlev 	{ "xendev", "^" "xen/xenbus" "$", RM_ALWAYS | RM_PRE | RM_HOT,
69843e1988Sjohnlev 	    ILEVEL_0, devfsadm_rm_all
70843e1988Sjohnlev 	},
71843e1988Sjohnlev 	{ "xendev", "^" PRIVCMD_PATHNAME "$", RM_ALWAYS | RM_PRE | RM_HOT,
72843e1988Sjohnlev 	    ILEVEL_0, devfsadm_rm_all
73843e1988Sjohnlev 	},
74843e1988Sjohnlev 	{ "xendev", "^" "xen/evtchn" "$", RM_ALWAYS | RM_PRE | RM_HOT,
75843e1988Sjohnlev 	    ILEVEL_0, devfsadm_rm_all
76843e1988Sjohnlev 	},
77843e1988Sjohnlev 	{ "xendev", "^" DOMCAPS_PATHNAME "$", RM_ALWAYS | RM_PRE | RM_HOT,
78843e1988Sjohnlev 	    ILEVEL_0, devfsadm_rm_all
79843e1988Sjohnlev 	},
80843e1988Sjohnlev 	{ "xendev", "^" BALLOON_PATHNAME "$", RM_ALWAYS | RM_PRE | RM_HOT,
81843e1988Sjohnlev 	    ILEVEL_0, devfsadm_rm_all
82843e1988Sjohnlev 	},
83843e1988Sjohnlev };
84843e1988Sjohnlev 
85843e1988Sjohnlev DEVFSADM_REMOVE_INIT_V0(xen_remove_cbt);
86843e1988Sjohnlev 
87843e1988Sjohnlev /*
88843e1988Sjohnlev  * /dev/xen/<foo>	->	/devices/xendev/<whatever>:<foo>
89843e1988Sjohnlev  */
90843e1988Sjohnlev static int
devxen(di_minor_t minor,di_node_t node)91843e1988Sjohnlev devxen(di_minor_t minor, di_node_t node)
92843e1988Sjohnlev {
93843e1988Sjohnlev 	char buf[256];
94843e1988Sjohnlev 
95843e1988Sjohnlev 	(void) snprintf(buf, sizeof (buf), "xen/%s", di_minor_name(minor));
96843e1988Sjohnlev 	(void) devfsadm_mklink(buf, node, minor, 0);
97843e1988Sjohnlev 
98843e1988Sjohnlev 	return (DEVFSADM_CONTINUE);
99843e1988Sjohnlev }
100*c7158ae9Stariq 
101*c7158ae9Stariq static int
xdt(di_minor_t minor,di_node_t node)102*c7158ae9Stariq xdt(di_minor_t minor, di_node_t node)
103*c7158ae9Stariq {
104*c7158ae9Stariq 	char *mname = di_minor_name(minor);
105*c7158ae9Stariq 	char path[MAXPATHLEN];
106*c7158ae9Stariq 
107*c7158ae9Stariq 	(void) snprintf(path, sizeof (path), "dtrace/provider/%s", mname);
108*c7158ae9Stariq 	(void) devfsadm_mklink(path, node, minor, 0);
109*c7158ae9Stariq 
110*c7158ae9Stariq 	return (DEVFSADM_CONTINUE);
111*c7158ae9Stariq }
112