xref: /titanic_50/usr/src/uts/common/idmap/idmap_mod.c (revision bda89588bd7667394a834e8a9a34612cce2ae9c3)
1c5c4113dSnw141292 /*
2c5c4113dSnw141292  * CDDL HEADER START
3c5c4113dSnw141292  *
4c5c4113dSnw141292  * The contents of this file are subject to the terms of the
5c5c4113dSnw141292  * Common Development and Distribution License (the "License").
6c5c4113dSnw141292  * You may not use this file except in compliance with the License.
7c5c4113dSnw141292  *
8c5c4113dSnw141292  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9c5c4113dSnw141292  * or http://www.opensolaris.org/os/licensing.
10c5c4113dSnw141292  * See the License for the specific language governing permissions
11c5c4113dSnw141292  * and limitations under the License.
12c5c4113dSnw141292  *
13c5c4113dSnw141292  * When distributing Covered Code, include this CDDL HEADER in each
14c5c4113dSnw141292  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15c5c4113dSnw141292  * If applicable, add the following below this CDDL HEADER, with the
16c5c4113dSnw141292  * fields enclosed by brackets "[]" replaced with your own identifying
17c5c4113dSnw141292  * information: Portions Copyright [yyyy] [name of copyright owner]
18c5c4113dSnw141292  *
19c5c4113dSnw141292  * CDDL HEADER END
20c5c4113dSnw141292  */
21c5c4113dSnw141292 
22c5c4113dSnw141292 /*
23*bda89588Sjp151216  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24c5c4113dSnw141292  * Use is subject to license terms.
25c5c4113dSnw141292  */
26c5c4113dSnw141292 
27c5c4113dSnw141292 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28c5c4113dSnw141292 
29c5c4113dSnw141292 #include <sys/ddi.h>
30c5c4113dSnw141292 #include <sys/sunddi.h>
31c5c4113dSnw141292 #include <sys/modctl.h>
32c5c4113dSnw141292 #ifdef	DEBUG
33c5c4113dSnw141292 #include <sys/cmn_err.h>
34c5c4113dSnw141292 #endif	/* DEBUG */
35c5c4113dSnw141292 #include <sys/kidmap.h>
36c5c4113dSnw141292 #include "kidmap_priv.h"
37c5c4113dSnw141292 
38c5c4113dSnw141292 
39c5c4113dSnw141292 
40c5c4113dSnw141292 
41c5c4113dSnw141292 extern struct mod_ops mod_miscops;
42c5c4113dSnw141292 
43c5c4113dSnw141292 static struct modlmisc misc =
44c5c4113dSnw141292 {
45c5c4113dSnw141292 	&mod_miscops,
46c5c4113dSnw141292 	"ID Mapping kernel module"
47c5c4113dSnw141292 };
48c5c4113dSnw141292 
49c5c4113dSnw141292 static struct modlinkage linkage =
50c5c4113dSnw141292 {
51c5c4113dSnw141292 	MODREV_1,
52c5c4113dSnw141292 	(void *) &misc,
53c5c4113dSnw141292 	NULL
54c5c4113dSnw141292 };
55c5c4113dSnw141292 
56c5c4113dSnw141292 
57c5c4113dSnw141292 int
_init()58c5c4113dSnw141292 _init()
59c5c4113dSnw141292 {
60c5c4113dSnw141292 	int i;
61c5c4113dSnw141292 
62c5c4113dSnw141292 	if ((i =  mod_install(&linkage)) != 0) {
63c5c4113dSnw141292 #ifdef	DEBUG
64c5c4113dSnw141292 		cmn_err(CE_WARN, "idmap: Failed to load kernel module");
65c5c4113dSnw141292 #endif	/* DEBUG */
66c5c4113dSnw141292 		return (i);
67c5c4113dSnw141292 	}
68c5c4113dSnw141292 
69c5c4113dSnw141292 	if (kidmap_start() != 0) {
70c5c4113dSnw141292 #ifdef	DEBUG
71c5c4113dSnw141292 		cmn_err(CE_WARN, "idmap: Failed to start");
72c5c4113dSnw141292 #endif	/* DEBUG */
73c5c4113dSnw141292 		return (i);
74c5c4113dSnw141292 	}
75c5c4113dSnw141292 
76c5c4113dSnw141292 	return (i);
77c5c4113dSnw141292 }
78c5c4113dSnw141292 
79c5c4113dSnw141292 int
_info(struct modinfo * modinfop)80c5c4113dSnw141292 _info(struct modinfo *modinfop)
81c5c4113dSnw141292 {
82c5c4113dSnw141292 	return (mod_info(&linkage, modinfop));
83c5c4113dSnw141292 }
84c5c4113dSnw141292 
85c5c4113dSnw141292 int
_fini()86c5c4113dSnw141292 _fini()
87c5c4113dSnw141292 {
88c5c4113dSnw141292 	int i;
89c5c4113dSnw141292 
90c5c4113dSnw141292 	if ((i = kidmap_stop()) != 0) {
91c5c4113dSnw141292 		return (i);
92c5c4113dSnw141292 	}
93c5c4113dSnw141292 
94c5c4113dSnw141292 	if ((i = mod_remove(&linkage)) != 0) {
95c5c4113dSnw141292 #ifdef	DEBUG
96c5c4113dSnw141292 		cmn_err(CE_WARN, "idmap: Failed to remove kernel module");
97c5c4113dSnw141292 #endif	/* DEBUG */
98c5c4113dSnw141292 		return (i);
99c5c4113dSnw141292 	}
100c5c4113dSnw141292 
101c5c4113dSnw141292 	return (0);
102c5c4113dSnw141292 }
103