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 #include <sys/ddi.h>
28c5c4113dSnw141292 #include <sys/sunddi.h>
29c5c4113dSnw141292 #include <sys/modctl.h>
30c5c4113dSnw141292 #ifdef DEBUG
31c5c4113dSnw141292 #include <sys/cmn_err.h>
32c5c4113dSnw141292 #endif /* DEBUG */
33c5c4113dSnw141292 #include <sys/kidmap.h>
34c5c4113dSnw141292 #include "kidmap_priv.h"
35c5c4113dSnw141292
36c5c4113dSnw141292
37c5c4113dSnw141292
38c5c4113dSnw141292
39c5c4113dSnw141292 extern struct mod_ops mod_miscops;
40c5c4113dSnw141292
41c5c4113dSnw141292 static struct modlmisc misc =
42c5c4113dSnw141292 {
43c5c4113dSnw141292 &mod_miscops,
44c5c4113dSnw141292 "ID Mapping kernel module"
45c5c4113dSnw141292 };
46c5c4113dSnw141292
47c5c4113dSnw141292 static struct modlinkage linkage =
48c5c4113dSnw141292 {
49c5c4113dSnw141292 MODREV_1,
50c5c4113dSnw141292 (void *) &misc,
51c5c4113dSnw141292 NULL
52c5c4113dSnw141292 };
53c5c4113dSnw141292
54c5c4113dSnw141292
55c5c4113dSnw141292 int
_init()56c5c4113dSnw141292 _init()
57c5c4113dSnw141292 {
58c5c4113dSnw141292 int i;
59c5c4113dSnw141292
60c5c4113dSnw141292 if ((i = mod_install(&linkage)) != 0) {
61c5c4113dSnw141292 #ifdef DEBUG
62c5c4113dSnw141292 cmn_err(CE_WARN, "idmap: Failed to load kernel module");
63c5c4113dSnw141292 #endif /* DEBUG */
64c5c4113dSnw141292 return (i);
65c5c4113dSnw141292 }
66c5c4113dSnw141292
67c5c4113dSnw141292 if (kidmap_start() != 0) {
68c5c4113dSnw141292 #ifdef DEBUG
69c5c4113dSnw141292 cmn_err(CE_WARN, "idmap: Failed to start");
70c5c4113dSnw141292 #endif /* DEBUG */
71c5c4113dSnw141292 return (i);
72c5c4113dSnw141292 }
73c5c4113dSnw141292
74c5c4113dSnw141292 return (i);
75c5c4113dSnw141292 }
76c5c4113dSnw141292
77c5c4113dSnw141292 int
_info(struct modinfo * modinfop)78c5c4113dSnw141292 _info(struct modinfo *modinfop)
79c5c4113dSnw141292 {
80c5c4113dSnw141292 return (mod_info(&linkage, modinfop));
81c5c4113dSnw141292 }
82c5c4113dSnw141292
83c5c4113dSnw141292 int
_fini()84c5c4113dSnw141292 _fini()
85c5c4113dSnw141292 {
86c5c4113dSnw141292 int i;
87c5c4113dSnw141292
88c5c4113dSnw141292 if ((i = kidmap_stop()) != 0) {
89c5c4113dSnw141292 return (i);
90c5c4113dSnw141292 }
91c5c4113dSnw141292
92c5c4113dSnw141292 if ((i = mod_remove(&linkage)) != 0) {
93c5c4113dSnw141292 #ifdef DEBUG
94c5c4113dSnw141292 cmn_err(CE_WARN, "idmap: Failed to remove kernel module");
95c5c4113dSnw141292 #endif /* DEBUG */
96c5c4113dSnw141292 return (i);
97c5c4113dSnw141292 }
98c5c4113dSnw141292
99c5c4113dSnw141292 return (0);
100c5c4113dSnw141292 }
101