xref: /onnv-gate/usr/src/cmd/devfsadm/i386/xen_link.c (revision 6670:1961a43f2335)
15084Sjohnlev /*
25084Sjohnlev  * CDDL HEADER START
35084Sjohnlev  *
45084Sjohnlev  * The contents of this file are subject to the terms of the
55084Sjohnlev  * Common Development and Distribution License (the "License").
65084Sjohnlev  * You may not use this file except in compliance with the License.
75084Sjohnlev  *
85084Sjohnlev  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
95084Sjohnlev  * or http://www.opensolaris.org/os/licensing.
105084Sjohnlev  * See the License for the specific language governing permissions
115084Sjohnlev  * and limitations under the License.
125084Sjohnlev  *
135084Sjohnlev  * When distributing Covered Code, include this CDDL HEADER in each
145084Sjohnlev  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
155084Sjohnlev  * If applicable, add the following below this CDDL HEADER, with the
165084Sjohnlev  * fields enclosed by brackets "[]" replaced with your own identifying
175084Sjohnlev  * information: Portions Copyright [yyyy] [name of copyright owner]
185084Sjohnlev  *
195084Sjohnlev  * CDDL HEADER END
205084Sjohnlev  */
215084Sjohnlev /*
22*6670Stariq  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
235084Sjohnlev  * Use is subject to license terms.
245084Sjohnlev  */
255084Sjohnlev 
265084Sjohnlev #pragma ident	"%Z%%M%	%I%	%E% SMI"
275084Sjohnlev 
285084Sjohnlev #include <regex.h>
295084Sjohnlev #include <devfsadm.h>
305084Sjohnlev #include <stdio.h>
315084Sjohnlev #include <strings.h>
325084Sjohnlev #include <stdlib.h>
335084Sjohnlev #include <limits.h>
345084Sjohnlev #include <sys/privcmd_impl.h>
355084Sjohnlev #include <sys/domcaps_impl.h>
365084Sjohnlev #include <sys/balloon.h>
375084Sjohnlev 
385084Sjohnlev /*
395084Sjohnlev  * Handle miscellaneous children of xendev
405084Sjohnlev  */
415084Sjohnlev static int devxen(di_minor_t, di_node_t);
42*6670Stariq static int xdt(di_minor_t minor, di_node_t node);
435084Sjohnlev 
445084Sjohnlev static devfsadm_create_t xen_cbt[] = {
455084Sjohnlev 	{ "xendev", DDI_PSEUDO, "xenbus",
465084Sjohnlev 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, devxen,
475084Sjohnlev 	},
485084Sjohnlev 	{ "xendev", DDI_PSEUDO, PRIVCMD_DRIVER_NAME,
495084Sjohnlev 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, devxen,
505084Sjohnlev 	},
515084Sjohnlev 	{ "xendev", DDI_PSEUDO, "evtchn",
525084Sjohnlev 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, devxen,
535084Sjohnlev 	},
545084Sjohnlev 	{ "xendev", DDI_PSEUDO, DOMCAPS_DRIVER_NAME,
555084Sjohnlev 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, devxen,
565084Sjohnlev 	},
575084Sjohnlev 	{ "xendev", DDI_PSEUDO, BALLOON_DRIVER_NAME,
585084Sjohnlev 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, devxen,
595084Sjohnlev 	},
60*6670Stariq 	{ "pseudo", DDI_PSEUDO, "xdt",
61*6670Stariq 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, xdt
62*6670Stariq 	},
635084Sjohnlev };
645084Sjohnlev 
655084Sjohnlev DEVFSADM_CREATE_INIT_V0(xen_cbt);
665084Sjohnlev 
675084Sjohnlev static devfsadm_remove_t xen_remove_cbt[] = {
685084Sjohnlev 	{ "xendev", "^" "xen/xenbus" "$", RM_ALWAYS | RM_PRE | RM_HOT,
695084Sjohnlev 	    ILEVEL_0, devfsadm_rm_all
705084Sjohnlev 	},
715084Sjohnlev 	{ "xendev", "^" PRIVCMD_PATHNAME "$", RM_ALWAYS | RM_PRE | RM_HOT,
725084Sjohnlev 	    ILEVEL_0, devfsadm_rm_all
735084Sjohnlev 	},
745084Sjohnlev 	{ "xendev", "^" "xen/evtchn" "$", RM_ALWAYS | RM_PRE | RM_HOT,
755084Sjohnlev 	    ILEVEL_0, devfsadm_rm_all
765084Sjohnlev 	},
775084Sjohnlev 	{ "xendev", "^" DOMCAPS_PATHNAME "$", RM_ALWAYS | RM_PRE | RM_HOT,
785084Sjohnlev 	    ILEVEL_0, devfsadm_rm_all
795084Sjohnlev 	},
805084Sjohnlev 	{ "xendev", "^" BALLOON_PATHNAME "$", RM_ALWAYS | RM_PRE | RM_HOT,
815084Sjohnlev 	    ILEVEL_0, devfsadm_rm_all
825084Sjohnlev 	},
835084Sjohnlev };
845084Sjohnlev 
855084Sjohnlev DEVFSADM_REMOVE_INIT_V0(xen_remove_cbt);
865084Sjohnlev 
875084Sjohnlev /*
885084Sjohnlev  * /dev/xen/<foo>	->	/devices/xendev/<whatever>:<foo>
895084Sjohnlev  */
905084Sjohnlev static int
devxen(di_minor_t minor,di_node_t node)915084Sjohnlev devxen(di_minor_t minor, di_node_t node)
925084Sjohnlev {
935084Sjohnlev 	char buf[256];
945084Sjohnlev 
955084Sjohnlev 	(void) snprintf(buf, sizeof (buf), "xen/%s", di_minor_name(minor));
965084Sjohnlev 	(void) devfsadm_mklink(buf, node, minor, 0);
975084Sjohnlev 
985084Sjohnlev 	return (DEVFSADM_CONTINUE);
995084Sjohnlev }
100*6670Stariq 
101*6670Stariq static int
xdt(di_minor_t minor,di_node_t node)102*6670Stariq xdt(di_minor_t minor, di_node_t node)
103*6670Stariq {
104*6670Stariq 	char *mname = di_minor_name(minor);
105*6670Stariq 	char path[MAXPATHLEN];
106*6670Stariq 
107*6670Stariq 	(void) snprintf(path, sizeof (path), "dtrace/provider/%s", mname);
108*6670Stariq 	(void) devfsadm_mklink(path, node, minor, 0);
109*6670Stariq 
110*6670Stariq 	return (DEVFSADM_CONTINUE);
111*6670Stariq }
112