1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 /* 28 * MAC Services Module 29 */ 30 31 #include <sys/types.h> 32 #include <sys/conf.h> 33 #include <sys/stat.h> 34 #include <sys/stream.h> 35 #include <sys/modctl.h> 36 #include <sys/atomic.h> 37 38 #include <sys/mac.h> 39 #include <sys/mac_impl.h> 40 41 static struct modlmisc i_mac_modlmisc = { 42 &mod_miscops, 43 MAC_INFO 44 }; 45 46 static struct modlinkage i_mac_modlinkage = { 47 MODREV_1, 48 &i_mac_modlmisc, 49 NULL 50 }; 51 52 /* 53 * Module initialization functions. 54 */ 55 56 static void 57 i_mac_mod_init(void) 58 { 59 mac_init(); 60 } 61 62 static int 63 i_mac_mod_fini(void) 64 { 65 int err; 66 67 if ((err = mac_fini()) != 0) 68 return (err); 69 70 return (0); 71 } 72 73 /* 74 * modlinkage functions. 75 */ 76 77 int 78 _init(void) 79 { 80 int err; 81 82 i_mac_mod_init(); 83 84 if ((err = mod_install(&i_mac_modlinkage)) != 0) { 85 (void) i_mac_mod_fini(); 86 return (err); 87 } 88 89 #ifdef DEBUG 90 cmn_err(CE_NOTE, "!%s loaded", MAC_INFO); 91 #endif /* DEBUG */ 92 93 return (0); 94 } 95 96 int 97 _fini(void) 98 { 99 int err; 100 101 if ((err = i_mac_mod_fini()) != 0) 102 return (err); 103 104 if ((err = mod_remove(&i_mac_modlinkage)) != 0) 105 return (err); 106 107 #ifdef DEBUG 108 cmn_err(CE_NOTE, "!%s unloaded", MAC_INFO); 109 #endif /* DEBUG */ 110 111 return (0); 112 } 113 114 int 115 _info(struct modinfo *modinfop) 116 { 117 return (mod_info(&i_mac_modlinkage, modinfop)); 118 } 119