xref: /onnv-gate/usr/src/cmd/devfsadm/zfs_link.c (revision 10588:dc03f981ea18)
1789Sahrens /*
2789Sahrens  * CDDL HEADER START
3789Sahrens  *
4789Sahrens  * The contents of this file are subject to the terms of the
5*10588SEric.Taylor@Sun.COM  * Common Development and Distribution License (the "License").
6*10588SEric.Taylor@Sun.COM  * You may not use this file except in compliance with the License.
7789Sahrens  *
8789Sahrens  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9789Sahrens  * or http://www.opensolaris.org/os/licensing.
10789Sahrens  * See the License for the specific language governing permissions
11789Sahrens  * and limitations under the License.
12789Sahrens  *
13789Sahrens  * When distributing Covered Code, include this CDDL HEADER in each
14789Sahrens  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15789Sahrens  * If applicable, add the following below this CDDL HEADER, with the
16789Sahrens  * fields enclosed by brackets "[]" replaced with your own identifying
17789Sahrens  * information: Portions Copyright [yyyy] [name of copyright owner]
18789Sahrens  *
19789Sahrens  * CDDL HEADER END
20789Sahrens  */
21789Sahrens /*
22*10588SEric.Taylor@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23789Sahrens  * Use is subject to license terms.
24789Sahrens  */
25789Sahrens 
26789Sahrens #include <regex.h>
27789Sahrens #include <devfsadm.h>
28789Sahrens #include <stdio.h>
29789Sahrens #include <strings.h>
30789Sahrens #include <stdlib.h>
31789Sahrens #include <limits.h>
32789Sahrens #include <sys/mkdev.h>
33789Sahrens #include <sys/fs/zfs.h>
34789Sahrens 
35*10588SEric.Taylor@Sun.COM /* zfs name info */
36789Sahrens 
37789Sahrens static int zfs(di_minor_t minor, di_node_t node);
38789Sahrens 
39789Sahrens /*
40789Sahrens  * devfs create callback register
41789Sahrens  */
42789Sahrens static devfsadm_create_t zfs_create_cbt[] = {
43789Sahrens 	{ "pseudo", "ddi_pseudo", ZFS_DRIVER,
44789Sahrens 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, zfs,
45789Sahrens 	},
46789Sahrens };
47789Sahrens DEVFSADM_CREATE_INIT_V0(zfs_create_cbt);
48789Sahrens 
49789Sahrens /*
50*10588SEric.Taylor@Sun.COM  * The zfs control node looks like this:
51789Sahrens  *	/dev/zfs -> /devices/pseudo/zfs@0:zfs
52789Sahrens  */
53789Sahrens static int
zfs(di_minor_t minor,di_node_t node)54789Sahrens zfs(di_minor_t minor, di_node_t node)
55789Sahrens {
56789Sahrens 	char mn[MAXNAMELEN + 1];
57789Sahrens 
58789Sahrens 	(void) strcpy(mn, di_minor_name(minor));
59789Sahrens 
60789Sahrens 	if (strcmp(mn, ZFS_DRIVER) == 0) {
61789Sahrens 		(void) devfsadm_mklink(ZFS_DRIVER, node, minor, 0);
62789Sahrens 	}
63789Sahrens 	return (DEVFSADM_CONTINUE);
64789Sahrens }
65