| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: kern_module.c,v 1.130.2.2 2018/03/11 07:25:59 pgoyette Exp $ */ | | 1 | /* $NetBSD: kern_module.c,v 1.130.2.3 2018/03/11 08:32:21 pgoyette Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2008 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2008 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software developed for The NetBSD Foundation | | 7 | * This code is derived from software developed for The NetBSD Foundation |
8 | * by Andrew Doran. | | 8 | * by Andrew Doran. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -24,27 +24,27 @@ | | | @@ -24,27 +24,27 @@ |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | * POSSIBILITY OF SUCH DAMAGE. | | 29 | * POSSIBILITY OF SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | /* | | 32 | /* |
33 | * Kernel module support. | | 33 | * Kernel module support. |
34 | */ | | 34 | */ |
35 | | | 35 | |
36 | #include <sys/cdefs.h> | | 36 | #include <sys/cdefs.h> |
37 | __KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.130.2.2 2018/03/11 07:25:59 pgoyette Exp $"); | | 37 | __KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.130.2.3 2018/03/11 08:32:21 pgoyette Exp $"); |
38 | | | 38 | |
39 | #define _MODULE_INTERNAL | | 39 | #define _MODULE_INTERNAL |
40 | | | 40 | |
41 | #ifdef _KERNEL_OPT | | 41 | #ifdef _KERNEL_OPT |
42 | #include "opt_ddb.h" | | 42 | #include "opt_ddb.h" |
43 | #include "opt_modular.h" | | 43 | #include "opt_modular.h" |
44 | #endif | | 44 | #endif |
45 | | | 45 | |
46 | #include <sys/param.h> | | 46 | #include <sys/param.h> |
47 | #include <sys/systm.h> | | 47 | #include <sys/systm.h> |
48 | #include <sys/kernel.h> | | 48 | #include <sys/kernel.h> |
49 | #include <sys/proc.h> | | 49 | #include <sys/proc.h> |
50 | #include <sys/kauth.h> | | 50 | #include <sys/kauth.h> |
| @@ -656,27 +656,27 @@ module_unload(const char *name) | | | @@ -656,27 +656,27 @@ module_unload(const char *name) |
656 | kernconfig_unlock(); | | 656 | kernconfig_unlock(); |
657 | | | 657 | |
658 | return error; | | 658 | return error; |
659 | } | | 659 | } |
660 | | | 660 | |
661 | /* | | 661 | /* |
662 | * module_alias_lookup | | 662 | * module_alias_lookup |
663 | * | | 663 | * |
664 | * locate a name within a module's alias list | | 664 | * locate a name within a module's alias list |
665 | */ | | 665 | */ |
666 | int | | 666 | int |
667 | module_alias_lookup(const char *name, module_t *mod) | | 667 | module_alias_lookup(const char *name, module_t *mod) |
668 | { | | 668 | { |
669 | const char * const aliasp[]; | | 669 | const char * const *aliasp; |
670 | | | 670 | |
671 | aliasp = *mod->mod_info->mi_aliases; | | 671 | aliasp = *mod->mod_info->mi_aliases; |
672 | if (aliasp == NULL) | | 672 | if (aliasp == NULL) |
673 | return 0; | | 673 | return 0; |
674 | while (*aliasp) | | 674 | while (*aliasp) |
675 | if (strcmp(*aliasp++, name) == 0) | | 675 | if (strcmp(*aliasp++, name) == 0) |
676 | return 1; | | 676 | return 1; |
677 | return 0; | | 677 | return 0; |
678 | } | | 678 | } |
679 | | | 679 | |
680 | /* | | 680 | /* |
681 | * module_lookup: | | 681 | * module_lookup: |
682 | * | | 682 | * |
| @@ -774,27 +774,27 @@ module_enqueue(module_t *mod) | | | @@ -774,27 +774,27 @@ module_enqueue(module_t *mod) |
774 | } | | 774 | } |
775 | | | 775 | |
776 | /* | | 776 | /* |
777 | * module_do_builtin: | | 777 | * module_do_builtin: |
778 | * | | 778 | * |
779 | * Initialize a module from the list of modules that are | | 779 | * Initialize a module from the list of modules that are |
780 | * already linked into the kernel. | | 780 | * already linked into the kernel. |
781 | */ | | 781 | */ |
782 | static int | | 782 | static int |
783 | module_do_builtin(const module_t *pmod, const char *name, module_t **modp, | | 783 | module_do_builtin(const module_t *pmod, const char *name, module_t **modp, |
784 | prop_dictionary_t props) | | 784 | prop_dictionary_t props) |
785 | { | | 785 | { |
786 | const char *p, *s; | | 786 | const char *p, *s; |
787 | const char * const aliasp[]; | | 787 | const char * const *aliasp; |
788 | char buf[MAXMODNAME]; | | 788 | char buf[MAXMODNAME]; |
789 | modinfo_t *mi = NULL; | | 789 | modinfo_t *mi = NULL; |
790 | module_t *mod, *mod2, *mod_loaded, *prev_active; | | 790 | module_t *mod, *mod2, *mod_loaded, *prev_active; |
791 | size_t len; | | 791 | size_t len; |
792 | int error; | | 792 | int error; |
793 | | | 793 | |
794 | KASSERT(kernconfig_is_held()); | | 794 | KASSERT(kernconfig_is_held()); |
795 | | | 795 | |
796 | /* | | 796 | /* |
797 | * Search the list to see if we have a module by this name. | | 797 | * Search the list to see if we have a module by this name. |
798 | */ | | 798 | */ |
799 | TAILQ_FOREACH(mod, &module_builtins, mod_chain) { | | 799 | TAILQ_FOREACH(mod, &module_builtins, mod_chain) { |
800 | if (strcmp(mod->mod_info->mi_name, name) == 0) { | | 800 | if (strcmp(mod->mod_info->mi_name, name) == 0) { |
| @@ -900,27 +900,27 @@ module_do_load(const char *name, bool is | | | @@ -900,27 +900,27 @@ module_do_load(const char *name, bool is |
900 | { | | 900 | { |
901 | #define MODULE_MAX_DEPTH 6 | | 901 | #define MODULE_MAX_DEPTH 6 |
902 | | | 902 | |
903 | TAILQ_HEAD(pending_t, module); | | 903 | TAILQ_HEAD(pending_t, module); |
904 | static int depth = 0; | | 904 | static int depth = 0; |
905 | static struct pending_t *pending_lists[MODULE_MAX_DEPTH]; | | 905 | static struct pending_t *pending_lists[MODULE_MAX_DEPTH]; |
906 | struct pending_t *pending; | | 906 | struct pending_t *pending; |
907 | struct pending_t new_pending = TAILQ_HEAD_INITIALIZER(new_pending); | | 907 | struct pending_t new_pending = TAILQ_HEAD_INITIALIZER(new_pending); |
908 | modinfo_t *mi; | | 908 | modinfo_t *mi; |
909 | module_t *mod, *mod2, *prev_active; | | 909 | module_t *mod, *mod2, *prev_active; |
910 | prop_dictionary_t filedict; | | 910 | prop_dictionary_t filedict; |
911 | char buf[MAXMODNAME]; | | 911 | char buf[MAXMODNAME]; |
912 | const char *s, *p; | | 912 | const char *s, *p; |
913 | const char * const aliasp[]; | | 913 | const char * const *aliasp; |
914 | int error; | | 914 | int error; |
915 | size_t len; | | 915 | size_t len; |
916 | | | 916 | |
917 | KASSERT(kernconfig_is_held()); | | 917 | KASSERT(kernconfig_is_held()); |
918 | | | 918 | |
919 | filedict = NULL; | | 919 | filedict = NULL; |
920 | error = 0; | | 920 | error = 0; |
921 | | | 921 | |
922 | /* | | 922 | /* |
923 | * Avoid recursing too far. | | 923 | * Avoid recursing too far. |
924 | */ | | 924 | */ |
925 | if (++depth > MODULE_MAX_DEPTH) { | | 925 | if (++depth > MODULE_MAX_DEPTH) { |
926 | module_error("recursion too deep for `%s' %d > %d", name, | | 926 | module_error("recursion too deep for `%s' %d > %d", name, |