4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved.
24 */
25
26 /*
27 * modctl system call for loadable module support.
28 */
29
30 #include <sys/param.h>
31 #include <sys/user.h>
32 #include <sys/systm.h>
33 #include <sys/exec.h>
34 #include <sys/file.h>
35 #include <sys/stat.h>
36 #include <sys/conf.h>
37 #include <sys/time.h>
38 #include <sys/reboot.h>
39 #include <sys/fs/ufs_fsdir.h>
40 #include <sys/kmem.h>
41 #include <sys/sysconf.h>
42 #include <sys/cmn_err.h>
43 #include <sys/ddi.h>
3453 }
3454
3455 /*
3456 * DCS: bootstrapping code. If the driver is loaded
3457 * before root mount, it is assumed that the driver
3458 * may be used before mounting root. In order to
3459 * access mappings of global to local minor no.'s
3460 * during installation/open of the driver, we load
3461 * them into memory here while the BOP_interfaces
3462 * are still up.
3463 */
3464 if ((cluster_bootflags & CLUSTER_BOOTED) && !modrootloaded) {
3465 retval = clboot_modload(mp);
3466 }
3467
3468 kmem_free(modinfop, sizeof (struct modinfo));
3469 (void) mod_sysctl(SYS_SET_MVAR, (void *)mp);
3470 retval = install_stubs_by_name(mp, mp->mod_modname);
3471
3472 /*
3473 * Now that the module is loaded, we need to give DTrace
3474 * a chance to notify its providers. This is done via
3475 * the dtrace_modload function pointer.
3476 */
3477 if (strcmp(mp->mod_modname, "dtrace") != 0) {
3478 struct modctl *dmp = mod_hold_by_name("dtrace");
3479
3480 if (dmp != NULL && dtrace_modload != NULL)
3481 (*dtrace_modload)(mp);
3482
3483 mod_release_mod(dmp);
3484 }
3485
3486 } else {
3487 /*
3488 * If load failed then we need to release any requisites
3489 * that we had established.
3490 */
3491 ASSERT(retval);
3492 mod_release_requisites(mp);
|
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright (c) 2017 Joyent, Inc.
25 */
26
27 /*
28 * modctl system call for loadable module support.
29 */
30
31 #include <sys/param.h>
32 #include <sys/user.h>
33 #include <sys/systm.h>
34 #include <sys/exec.h>
35 #include <sys/file.h>
36 #include <sys/stat.h>
37 #include <sys/conf.h>
38 #include <sys/time.h>
39 #include <sys/reboot.h>
40 #include <sys/fs/ufs_fsdir.h>
41 #include <sys/kmem.h>
42 #include <sys/sysconf.h>
43 #include <sys/cmn_err.h>
44 #include <sys/ddi.h>
3454 }
3455
3456 /*
3457 * DCS: bootstrapping code. If the driver is loaded
3458 * before root mount, it is assumed that the driver
3459 * may be used before mounting root. In order to
3460 * access mappings of global to local minor no.'s
3461 * during installation/open of the driver, we load
3462 * them into memory here while the BOP_interfaces
3463 * are still up.
3464 */
3465 if ((cluster_bootflags & CLUSTER_BOOTED) && !modrootloaded) {
3466 retval = clboot_modload(mp);
3467 }
3468
3469 kmem_free(modinfop, sizeof (struct modinfo));
3470 (void) mod_sysctl(SYS_SET_MVAR, (void *)mp);
3471 retval = install_stubs_by_name(mp, mp->mod_modname);
3472
3473 /*
3474 * Perform hotinlines before module is started.
3475 */
3476 do_hotinlines(mp->mod_mp);
3477
3478 /*
3479 * Now that the module is loaded, we need to give DTrace
3480 * a chance to notify its providers. This is done via
3481 * the dtrace_modload function pointer.
3482 */
3483 if (strcmp(mp->mod_modname, "dtrace") != 0) {
3484 struct modctl *dmp = mod_hold_by_name("dtrace");
3485
3486 if (dmp != NULL && dtrace_modload != NULL)
3487 (*dtrace_modload)(mp);
3488
3489 mod_release_mod(dmp);
3490 }
3491
3492 } else {
3493 /*
3494 * If load failed then we need to release any requisites
3495 * that we had established.
3496 */
3497 ASSERT(retval);
3498 mod_release_requisites(mp);
|