Module Name:    src
Committed By:   pgoyette
Date:           Fri Sep  7 23:32:30 UTC 2018

Modified Files:
        src/doc [pgoyette-compat]: COMPAT-branch-notes
        src/sbin/modstat [pgoyette-compat]: main.c modstat.8
        src/share/man/man9 [pgoyette-compat]: module.9
        src/sys/compat/common [pgoyette-compat]: compat_mod.c compat_sysv_mod.c
            kern_mod_80.c
        src/sys/compat/netbsd32 [pgoyette-compat]: netbsd32_module.c
        src/sys/kern [pgoyette-compat]: kern_module.c sys_module.c
        src/sys/sys [pgoyette-compat]: module.h

Log Message:
At the request of reviewers, remove the module alias functionality.

We will rely only on module names and duplicate-symbol detection to
detect module conflicts.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.22 -r1.1.2.23 src/doc/COMPAT-branch-notes
cvs rdiff -u -r1.24.12.2 -r1.24.12.3 src/sbin/modstat/main.c
cvs rdiff -u -r1.22.12.2 -r1.22.12.3 src/sbin/modstat/modstat.8
cvs rdiff -u -r1.42.2.7 -r1.42.2.8 src/share/man/man9/module.9
cvs rdiff -u -r1.24.14.36 -r1.24.14.37 src/sys/compat/common/compat_mod.c
cvs rdiff -u -r1.4.10.3 -r1.4.10.4 src/sys/compat/common/compat_sysv_mod.c
cvs rdiff -u -r1.1.2.3 -r1.1.2.4 src/sys/compat/common/kern_mod_80.c
cvs rdiff -u -r1.6.2.2 -r1.6.2.3 src/sys/compat/netbsd32/netbsd32_module.c
cvs rdiff -u -r1.130.2.21 -r1.130.2.22 src/sys/kern/kern_module.c
cvs rdiff -u -r1.23.2.8 -r1.23.2.9 src/sys/kern/sys_module.c
cvs rdiff -u -r1.41.14.10 -r1.41.14.11 src/sys/sys/module.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/doc/COMPAT-branch-notes
diff -u src/doc/COMPAT-branch-notes:1.1.2.22 src/doc/COMPAT-branch-notes:1.1.2.23
--- src/doc/COMPAT-branch-notes:1.1.2.22	Thu Sep  6 08:22:10 2018
+++ src/doc/COMPAT-branch-notes	Fri Sep  7 23:32:29 2018
@@ -1,16 +1,17 @@
-/* $NetBSD: COMPAT-branch-notes,v 1.1.2.22 2018/09/06 08:22:10 pgoyette Exp $ */
+/* $NetBSD: COMPAT-branch-notes,v 1.1.2.23 2018/09/07 23:32:29 pgoyette Exp $ */
 
 DONE
 ----
-1.  Removed linking of the kernel compat object library into all kernels;
-    using the .o library caused some build breakage, and resulted in the
-    bulk of the compat code being included in every kernel, but without
-    any module linkage.  In turn, this caused failure when loading some
-    modules due to symbols already being defined in the kernel.
-
-2.  Reverted some intentional breakage for loading the sysv_ipc module;
-    the breakage was introduced as the fix for the above-mentioned build
-    breakage.  
+1.  Returned the build to use a .a compat library rather than a .o
+    library.  The original method used was .a but that was changed
+    (fairly recently) as a work-around to address some support
+    routines that were not being included when needed.  These support
+    modules are now included in their own module, and the work-around
+    is therefore no longer needed.
+
+2.  Reverted some intentional auto-load breakage for loading the sysv_ipc
+    module; the breakage was introduced as the fix for the above-mentioned
+    build breakage.  
 
 3.  Split the sysv_ipc compat routines into their own compat_sysv module.
 
@@ -19,34 +20,27 @@ DONE
 5.  Extracted some net/if.c compat routines into the compat module, and
     replaced the originals with indirect (vectored) function calls.
 
-6.  Implemented a mechanism for modules to include "aliases", allowing
-    a single module file to declare multiple names.  For example, a
-    single "compat" module could declare compat_80, compat_70, etc, and
-    other modules could depend on specific compat levels rather than on
-    the entirety of compat.
-
-7.  Reconfirmed existing compat-module dependencies, and update the
+6.  Reconfirmed existing compat-module dependencies, and update the
     defopt/defflag lines in the config files* as needed, to insure that
     built-in dependencies get resolved.
 
-8.  Fixed limits on the number of module depedencies and maximum
+7.  Fixed limits on the number of module depedencies and maximum
     recursion level have been removed.  Previous code for reporting
     module status to userland has been versioned and moved to the
     compat_80 module.
 
-9.  The old monolithic compat module has been broken into multiple
+8.  The old monolithic compat module has been broken into multiple
     modules, one for each old NetBSD version.  The monolithic module
-    is still available, and uses the alias mechanism to "advertise"
-    that the component modules are available.
+    is still available.
 
     Similarly, the compat_sysv module has also been split into several
-    version-specific modules.  (A mini-monolithic compat_sysv module
-    is still provided.)
+    version-specific modules, and the mini-monolithic compat_sysv module
+    is still provided.
 
-10. syscalls.master has been updated to autoload the version-specific
+9.  syscalls.master has been updated to autoload the version-specific
     compat modules rather than the monolithic modules.
 
-11. Separated COMPAT_BSDPTY stuff, allowing the COMPAT_60 module to be
+10. Separated COMPAT_BSDPTY stuff, allowing the COMPAT_60 module to be
     built regardless.
 
 

Index: src/sbin/modstat/main.c
diff -u src/sbin/modstat/main.c:1.24.12.2 src/sbin/modstat/main.c:1.24.12.3
--- src/sbin/modstat/main.c:1.24.12.2	Tue Apr  3 08:29:44 2018
+++ src/sbin/modstat/main.c	Fri Sep  7 23:32:30 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.24.12.2 2018/04/03 08:29:44 pgoyette Exp $	*/
+/*	$NetBSD: main.c,v 1.24.12.3 2018/09/07 23:32:30 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: main.c,v 1.24.12.2 2018/04/03 08:29:44 pgoyette Exp $");
+__RCSID("$NetBSD: main.c,v 1.24.12.3 2018/09/07 23:32:30 pgoyette Exp $");
 #endif /* !lint */
 
 #include <sys/module.h>
@@ -67,7 +67,7 @@ static const char *sources[] = {
 const unsigned int source_max = __arraycount(sources);
 
 static const char *modflags[] = {
-	"-", "f", "a", "af", "A", "Af", "Aa", "Aaf"
+	"-", "f", "a", "af"
 };
 
 int

Index: src/sbin/modstat/modstat.8
diff -u src/sbin/modstat/modstat.8:1.22.12.2 src/sbin/modstat/modstat.8:1.22.12.3
--- src/sbin/modstat/modstat.8:1.22.12.2	Thu Mar 15 10:03:04 2018
+++ src/sbin/modstat/modstat.8	Fri Sep  7 23:32:30 2018
@@ -1,4 +1,4 @@
-.\" $NetBSD: modstat.8,v 1.22.12.2 2018/03/15 10:03:04 pgoyette Exp $
+.\" $NetBSD: modstat.8,v 1.22.12.3 2018/09/07 23:32:30 pgoyette Exp $
 .\"
 .\" Copyright (c) 1993 Christopher G. Demetriou
 .\" All rights reserved.
@@ -32,7 +32,7 @@
 .\"
 .\" <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
 .\"
-.Dd September 12, 2016
+.Dd September 8, 2018
 .Dt MODSTAT 8
 .Os
 .Sh NAME
@@ -40,8 +40,8 @@
 .Nd display status of loaded kernel modules
 .Sh SYNOPSIS
 .Nm
-.Op Fl Aaen
-.Op Ar name
+.Op Fl Aaek
+.Op Fl n Ar name | name
 .Sh DESCRIPTION
 The
 .Nm
@@ -102,11 +102,6 @@ Requires the
 flag
 .Fl f
 (force) to be loaded.
-.It Dv A
-The named module is an alias for another module.
-The REQUIRES column contains the
-.Dq real
-module name.
 .El
 .It Li REFS
 Number of references held on the module.

Index: src/share/man/man9/module.9
diff -u src/share/man/man9/module.9:1.42.2.7 src/share/man/man9/module.9:1.42.2.8
--- src/share/man/man9/module.9:1.42.2.7	Mon Jun 25 07:25:37 2018
+++ src/share/man/man9/module.9	Fri Sep  7 23:32:30 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: module.9,v 1.42.2.7 2018/06/25 07:25:37 pgoyette Exp $
+.\"	$NetBSD: module.9,v 1.42.2.8 2018/09/07 23:32:30 pgoyette Exp $
 .\"
 .\" Copyright (c) 2010 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd June 19, 2018
+.Dd September 8, 2018
 .Dt MODULE 9
 .Os
 .Sh NAME
@@ -52,7 +52,6 @@
 .Sh SYNOPSIS
 .In sys/module.h
 .Fn MODULE "class" "name" "required"
-.Fn MODULE_WITH_ALIASES "class" "name" "required" "aliases"
 .Ft int
 .Fn module_load "const char *name" "int flags" "prop_dictionary_t props" \
 "modclass_t class"
@@ -125,12 +124,9 @@ The module subsystem is protected by the
 .Sh FUNCTIONS
 .Bl -tag -width abcd
 .It Fn MODULE "class" "name" "required"
-.It Fn MODULE_WITH_ALIASES "class" "name" "required" "aliases"
 The
 .Fn MODULE
-and
-.Fn MODULE_WITH_ALIASES
-macros create and initialize a
+macro creates and initialize a
 .Vt modinfo_t
 structure.
 The
@@ -173,30 +169,7 @@ When a module is loaded, all of its requ
 initialized before the module itself is loaded.
 Loading of required modules is a recursive operation.
 .Pp
-The
-.Fa aliases
-argument is a pointer to a NULL-terminated constant array of constant
-strings.
-Each string in the array is an alternate name (i.e., an alias) of the
-module.
-Module names and aliases must all be unique; a module cannot be loaded
-if its name or any of its aliases matches the name or an alias of any
-already-loaded module.
-(Module names are displayed by the
-.Xr modstat 8
-utility, with an
-.Dv A
-in the flags column.)
-.Pp
-For example,
-.Bd -literal
-	const char * const my_pets[] = { "dog", "cat", "bird", NULL };
-
-	MODULE_WITH_ALIASES(MODULE_CLASS_MISC, pets, NULL, &my_pets);
-.Ed
-.Pp
-If there are no required modules or aliases, these arguments should be
-specified as
+If there are no required modules, this argument should be specified as
 .Dv NULL .
 .Pp
 In addition to the explicit arguments, the

Index: src/sys/compat/common/compat_mod.c
diff -u src/sys/compat/common/compat_mod.c:1.24.14.36 src/sys/compat/common/compat_mod.c:1.24.14.37
--- src/sys/compat/common/compat_mod.c:1.24.14.36	Mon May 21 04:36:03 2018
+++ src/sys/compat/common/compat_mod.c	Fri Sep  7 23:32:30 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat_mod.c,v 1.24.14.36 2018/05/21 04:36:03 pgoyette Exp $	*/
+/*	$NetBSD: compat_mod.c,v 1.24.14.37 2018/09/07 23:32:30 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: compat_mod.c,v 1.24.14.36 2018/05/21 04:36:03 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_mod.c,v 1.24.14.37 2018/09/07 23:32:30 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -53,13 +53,7 @@ __KERNEL_RCSID(0, "$NetBSD: compat_mod.c
 #include <compat/common/compat_util.h>
 #include <compat/common/compat_mod.h>
 
-static const char * const compat_includes[] = {
-	"compat_80", "compat_70", "compat_60", "compat_50", "compat_40",
-	"compat_30", "compat_20", "compat_16", "compat_14", "compat_13",
-	"compat_12", "compat_10", "compat_09", "compat_43", NULL
-};
-
-MODULE_WITH_ALIASES(MODULE_CLASS_EXEC, compat, NULL, &compat_includes);
+MODULE(MODULE_CLASS_EXEC, compat, NULL);
 
 extern krwlock_t ttcompat_lock;
 

Index: src/sys/compat/common/compat_sysv_mod.c
diff -u src/sys/compat/common/compat_sysv_mod.c:1.4.10.3 src/sys/compat/common/compat_sysv_mod.c:1.4.10.4
--- src/sys/compat/common/compat_sysv_mod.c:1.4.10.3	Tue Sep  4 11:25:53 2018
+++ src/sys/compat/common/compat_sysv_mod.c	Fri Sep  7 23:32:30 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat_sysv_mod.c,v 1.4.10.3 2018/09/04 11:25:53 pgoyette Exp $	*/
+/*	$NetBSD: compat_sysv_mod.c,v 1.4.10.4 2018/09/07 23:32:30 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: compat_sysv_mod.c,v 1.4.10.3 2018/09/04 11:25:53 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_sysv_mod.c,v 1.4.10.4 2018/09/07 23:32:30 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -46,12 +46,7 @@ __KERNEL_RCSID(0, "$NetBSD: compat_sysv_
 
 #include <compat/common/compat_sysv_mod.h>
 
-static const char * const compat_sysv_includes[] = {
-        "compat_sysv_50", "compat_sysv_14", "compat_sysv_10", NULL
-};
-
-MODULE_WITH_ALIASES(MODULE_CLASS_EXEC, compat_sysv, "sysv_ipc",
-    &compat_sysv_includes);
+MODULE(MODULE_CLASS_EXEC, compat_sysv, "sysv_ipc");
 
 /* Build the syscall package based on options specified */
 

Index: src/sys/compat/common/kern_mod_80.c
diff -u src/sys/compat/common/kern_mod_80.c:1.1.2.3 src/sys/compat/common/kern_mod_80.c:1.1.2.4
--- src/sys/compat/common/kern_mod_80.c:1.1.2.3	Thu Sep  6 21:37:43 2018
+++ src/sys/compat/common/kern_mod_80.c	Fri Sep  7 23:32:30 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_mod_80.c,v 1.1.2.3 2018/09/06 21:37:43 pgoyette Exp $	*/
+/*	$NetBSD: kern_mod_80.c,v 1.1.2.4 2018/09/07 23:32:30 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_mod_80.c,v 1.1.2.3 2018/09/06 21:37:43 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_mod_80.c,v 1.1.2.4 2018/09/07 23:32:30 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_modular.h"
@@ -51,18 +51,6 @@ __KERNEL_RCSID(0, "$NetBSD: kern_mod_80.
 
 #include <compat/common/compat_mod.h>
 
-static void
-copy_oalias(omodstat_t *oms, const char * const *aliasp, modinfo_t *mi,
-    module_t *mod)
-{
-
-	strlcpy(oms->oms_name, *aliasp, sizeof(oms->oms_name));
-	strlcpy(oms->oms_required, mi->mi_name, sizeof(oms->oms_required));
-	oms->oms_class = mi->mi_class;
-	oms->oms_source = mod->mod_source;
-	oms->oms_flags = mod->mod_flags | MODFLG_IS_ALIAS;
-}
-
 static int
 compat_80_modstat(int cmd, struct iovec *iov, void *arg)
 {
@@ -76,7 +64,6 @@ compat_80_modstat(int cmd, struct iovec 
 	int error;
 	int omscnt;
 	bool stataddr;
-	const char * const *aliasp;
 	const char *suffix = "...";
 
 	if (cmd != MODCTL_OSTAT)
@@ -97,18 +84,10 @@ compat_80_modstat(int cmd, struct iovec 
 	TAILQ_FOREACH(mod, &module_list, mod_chain) {
 		omscnt++;
 		mi = mod->mod_info;
-		if ((aliasp = *mi->mi_aliases) != NULL) {
-			while (*aliasp++ != NULL)
-				omscnt++;
-		}
 	}
 	TAILQ_FOREACH(mod, &module_builtins, mod_chain) {
 		omscnt++;
 		mi = mod->mod_info;
-		if ((aliasp = *mi->mi_aliases) != NULL) {
-			while (*aliasp++ != NULL)
-				omscnt++;
-		}
 	}
 	omslen = omscnt * sizeof(omodstat_t);
 	omso = kmem_zalloc(omslen, KM_SLEEP);
@@ -136,14 +115,6 @@ compat_80_modstat(int cmd, struct iovec 
 		oms->oms_source = mod->mod_source;
 		oms->oms_flags = mod->mod_flags;
 		oms++;
-		aliasp = *mi->mi_aliases;
-		if (aliasp == NULL)
-			continue;
-		while (*aliasp) {
-			copy_oalias(oms, aliasp, mi, mod);
-			aliasp++;
-			oms++;
-		}
 	}
 	TAILQ_FOREACH(mod, &module_builtins, mod_chain) {
 		mi = mod->mod_info;
@@ -168,14 +139,6 @@ compat_80_modstat(int cmd, struct iovec 
 		KASSERT(mod->mod_source == MODULE_SOURCE_KERNEL);
 		oms->oms_source = mod->mod_source;
 		oms++;
-		aliasp = *mi->mi_aliases;
-		if (aliasp == NULL)
-			continue;
-		while (*aliasp) {
-			copy_oalias(oms, aliasp, mi, mod);
-			aliasp++;
-			oms++;
-		}
 	}
 	kernconfig_unlock();
 	error = copyout(omso, iov->iov_base, uimin(omslen, iov->iov_len));

Index: src/sys/compat/netbsd32/netbsd32_module.c
diff -u src/sys/compat/netbsd32/netbsd32_module.c:1.6.2.2 src/sys/compat/netbsd32/netbsd32_module.c:1.6.2.3
--- src/sys/compat/netbsd32/netbsd32_module.c:1.6.2.2	Thu Sep  6 06:55:46 2018
+++ src/sys/compat/netbsd32/netbsd32_module.c	Fri Sep  7 23:32:30 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_module.c,v 1.6.2.2 2018/09/06 06:55:46 pgoyette Exp $	*/
+/*	$NetBSD: netbsd32_module.c,v 1.6.2.3 2018/09/07 23:32:30 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_module.c,v 1.6.2.2 2018/09/06 06:55:46 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_module.c,v 1.6.2.3 2018/09/07 23:32:30 pgoyette Exp $");
 
 #include <sys/param.h>
 #include <sys/dirent.h>
@@ -43,18 +43,6 @@ __KERNEL_RCSID(0, "$NetBSD: netbsd32_mod
 #include <compat/netbsd32/netbsd32_conv.h>
 
 #ifdef COMPAT_80
-static void
-copy_oalias(omodstat_t *oms, const char * const *aliasp, modinfo_t *mi,
-    module_t *mod)
-{
-
-	strlcpy(oms->oms_name, *aliasp, sizeof(oms->oms_name));
-	strlcpy(oms->oms_required, mi->mi_name, sizeof(oms->oms_required));
-	oms->oms_class = mi->mi_class;
-	oms->oms_source = mod->mod_source;
-	oms->oms_flags = mod->mod_flags | MODFLG_IS_ALIAS;
-}
-
 static int
 modctl32_handle_ostat(int cmd, struct netbsd32_iovec *iov, void *arg)
 {
@@ -68,7 +56,6 @@ modctl32_handle_ostat(int cmd, struct ne
 	int error;
 	int omscnt;
 	bool stataddr;
-	const char * const *aliasp;
 	const char *suffix = "...";
 
 	if (cmd != MODCTL_OSTAT)
@@ -84,18 +71,10 @@ modctl32_handle_ostat(int cmd, struct ne
 	TAILQ_FOREACH(mod, &module_list, mod_chain) {
 		omscnt++;
 		mi = mod->mod_info;
-		if ((aliasp = *mi->mi_aliases) != NULL) {
-			while (*aliasp++ != NULL)
-			omscnt++;
-		}
 	}
 	TAILQ_FOREACH(mod, &module_builtins, mod_chain) {
 		omscnt++;
 		mi = mod->mod_info;
-		if ((aliasp = *mi->mi_aliases) != NULL) {
-			while (*aliasp++ != NULL)
-			omscnt++;
-		}
 	}
 	omslen = omscnt * sizeof(omodstat_t);
 	omso = kmem_zalloc(omslen, KM_SLEEP);
@@ -123,14 +102,6 @@ modctl32_handle_ostat(int cmd, struct ne
 		oms->oms_source = mod->mod_source;
 		oms->oms_flags = mod->mod_flags;
 		oms++;
-		aliasp = *mi->mi_aliases;
-		if (aliasp == NULL)
-			continue;
-		while (*aliasp) {
-			copy_oalias(oms, aliasp, mi, mod);
-			aliasp++;
-			oms++;
-		}
 	}
 	TAILQ_FOREACH(mod, &module_builtins, mod_chain) {
 		mi = mod->mod_info;
@@ -155,14 +126,6 @@ modctl32_handle_ostat(int cmd, struct ne
 		KASSERT(mod->mod_source == MODULE_SOURCE_KERNEL);
 		oms->oms_source = mod->mod_source;
 		oms++;
-		aliasp = *mi->mi_aliases;
-		if (aliasp == NULL)
-			continue;
-		while (*aliasp) {
-			copy_oalias(oms, aliasp, mi, mod);
-			aliasp++;
-			oms++;
-		}
 	}
 	kernconfig_unlock();
 	error = copyout(omso, NETBSD32PTR64(iov->iov_base),
@@ -177,18 +140,6 @@ modctl32_handle_ostat(int cmd, struct ne
 }
 #endif	/* COMPAT_80 */
 
-static void
-copy_alias(modstat_t *ms, const char * const *aliasp, modinfo_t *mi,
-    module_t *mod)
-{
-
-	strlcpy(ms->ms_name, *aliasp, sizeof(ms->ms_name));
-	ms->ms_class = mi->mi_class;
-	ms->ms_source = mod->mod_source;
-	ms->ms_flags = mod->mod_flags | MODFLG_IS_ALIAS;
-	ms->ms_reqoffset = 0;
-}
-
 static int
 modctl32_handle_stat(struct netbsd32_iovec *iov, void *arg)
 {
@@ -209,7 +160,6 @@ modctl32_handle_stat(struct netbsd32_iov
 	int off;
 	int error;
 	bool stataddr;
-	const char * const *aliasp;
 
 	/* If not privileged, don't expose kernel addresses. */
 	error = kauth_authorize_system(kauth_cred_get(), KAUTH_SYSTEM_MODULE,
@@ -227,22 +177,14 @@ modctl32_handle_stat(struct netbsd32_iov
 	TAILQ_FOREACH(mod, &module_list, mod_chain) {
 		ms_cnt++;
 		mi = mod->mod_info;
-		if ((aliasp = *mi->mi_aliases) != NULL) {
-			while (*aliasp++ != NULL)
-				ms_cnt++;
-		}
 		if (mi->mi_required != NULL) {
 			req_cnt++;
 			req_len += strlen(mi->mi_required) + 1;
 		}
 	}
 	TAILQ_FOREACH(mod, &module_builtins, mod_chain) {
-	ms_cnt++;
-	mi = mod->mod_info;
-	if ((aliasp = *mi->mi_aliases) != NULL) {
-		while (*aliasp++ != NULL)
-			ms_cnt++;
-		}
+		ms_cnt++;
+		mi = mod->mod_info;
 		if (mi->mi_required != NULL) {
 			req_cnt++;
 			req_len += strlen(mi->mi_required) + 1;
@@ -263,34 +205,26 @@ modctl32_handle_stat(struct netbsd32_iov
 	 * build-in module lists
 	 */
 	TAILQ_FOREACH(mod, &module_list, mod_chain) {
-	mi = mod->mod_info;
-	strlcpy(ms->ms_name, mi->mi_name, sizeof(ms->ms_name));
-	if (mi->mi_required != NULL) {
-		ms->ms_reqoffset = off;
-		used = strlcpy(req,  mi->mi_required, req_len - off);
-		KASSERTMSG(used < req_len - off, "reqlist grew!");
-		off = used + 1;
-		req += used + 1;
-	} else
-		ms->ms_reqoffset = 0;
-	if (mod->mod_kobj != NULL && stataddr) {
-		kobj_stat(mod->mod_kobj, &addr, &size);
-		ms->ms_addr = addr;
-		ms->ms_size = size;
-	}
-	ms->ms_class = mi->mi_class;
-	ms->ms_refcnt = mod->mod_refcnt;
-	ms->ms_source = mod->mod_source;
-	ms->ms_flags = mod->mod_flags;
-	ms++;
-	aliasp = *mi->mi_aliases;
-	if (aliasp == NULL)
-		continue;
-	while (*aliasp) {
-		copy_alias(ms, aliasp, mi, mod);
-		aliasp++;
-		ms++;
+		mi = mod->mod_info;
+		strlcpy(ms->ms_name, mi->mi_name, sizeof(ms->ms_name));
+		if (mi->mi_required != NULL) {
+			ms->ms_reqoffset = off;
+			used = strlcpy(req,  mi->mi_required, req_len - off);
+			KASSERTMSG(used < req_len - off, "reqlist grew!");
+			off = used + 1;
+			req += used + 1;
+		} else
+			ms->ms_reqoffset = 0;
+		if (mod->mod_kobj != NULL && stataddr) {
+			kobj_stat(mod->mod_kobj, &addr, &size);
+			ms->ms_addr = addr;
+			ms->ms_size = size;
 		}
+		ms->ms_class = mi->mi_class;
+		ms->ms_refcnt = mod->mod_refcnt;
+		ms->ms_source = mod->mod_source;
+		ms->ms_flags = mod->mod_flags;
+		ms++;
 	}
 	TAILQ_FOREACH(mod, &module_builtins, mod_chain) {
 		mi = mod->mod_info;
@@ -313,14 +247,6 @@ modctl32_handle_stat(struct netbsd32_iov
 		KASSERT(mod->mod_source == MODULE_SOURCE_KERNEL);
 		ms->ms_source = mod->mod_source;
 		ms++;
-		aliasp = *mi->mi_aliases;
-		if (aliasp == NULL)
-			continue;
-		while (*aliasp) {
-			copy_alias(ms, aliasp, mi, mod);
-			aliasp++;
-			ms++;
-		}
 	}
 	kernconfig_unlock();
 

Index: src/sys/kern/kern_module.c
diff -u src/sys/kern/kern_module.c:1.130.2.21 src/sys/kern/kern_module.c:1.130.2.22
--- src/sys/kern/kern_module.c:1.130.2.21	Thu Sep  6 06:56:41 2018
+++ src/sys/kern/kern_module.c	Fri Sep  7 23:32:30 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_module.c,v 1.130.2.21 2018/09/06 06:56:41 pgoyette Exp $	*/
+/*	$NetBSD: kern_module.c,v 1.130.2.22 2018/09/07 23:32:30 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.130.2.21 2018/09/06 06:56:41 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.130.2.22 2018/09/07 23:32:30 pgoyette Exp $");
 
 #define _MODULE_INTERNAL
 
@@ -117,7 +117,6 @@ static int	module_fetch_info(module_t *)
 static void	module_thread(void *);
 
 static module_t	*module_lookup(const char *);
-int		module_alias_lookup(const char *, module_t *);
 static void	module_enqueue(module_t *);
 
 static bool	module_merge_dicts(prop_dictionary_t, const prop_dictionary_t);
@@ -730,26 +729,6 @@ module_unload(const char *name)
 }
 
 /*
- * module_alias_lookup
- *
- *	locate a name within a module's alias list
- */
-int
-module_alias_lookup(const char *name, module_t *mod)
-{
-	const char * const *aliasp;
-
-	aliasp = *mod->mod_info->mi_aliases;
-	if (aliasp == NULL)
-		return 0;
-	while (*aliasp) {
-		if (strcmp(*aliasp++, name) == 0)
-			return 1;
-	}
-	return 0;
-}
-
-/*
  * module_lookup:
  *
  *	Look up a module by name.
@@ -764,8 +743,6 @@ module_lookup(const char *name)
 	TAILQ_FOREACH(mod, &module_list, mod_chain) {
 		if (strcmp(mod->mod_info->mi_name, name) == 0)
 			break;
-		if (module_alias_lookup(name, mod))
-			break;
 	}
 
 	return mod;
@@ -867,7 +844,6 @@ module_do_builtin(const module_t *pmod, 
     prop_dictionary_t props)
 {
 	const char *p, *s;
-	const char * const *aliasp;
 	char buf[MAXMODNAME];
 	modinfo_t *mi = NULL;
 	module_t *mod, *mod2, *mod_loaded, *prev_active;
@@ -938,23 +914,6 @@ module_do_builtin(const module_t *pmod, 
 	}
 
 	/*
-	 * Confirm that none of the module's aliases already exist
-	 */
-
-	if ((aliasp = *mod->mod_info->mi_aliases) != NULL) {
-		while (*aliasp) {
-			if ((mod2 = module_lookup(*aliasp++)) != NULL) {
-				if (modp != NULL)
-					*modp = mod2;
-				error = EEXIST;
-				module_error("built-in module %s alias %s "
-				    "already exists in module %s", name,
-				    *--aliasp, mod2->mod_info->mi_name);
-				goto fail;
-			}
-		}
-	}
-	/*
 	 * Try to initialize the module.
 	 */
 	prev_active = module_active;
@@ -1016,7 +975,6 @@ module_do_load(const char *name, bool is
 	prop_dictionary_t filedict;
 	char buf[MAXMODNAME];
 	const char *s, *p;
-	const char * const *aliasp;
 	int error;
 	size_t len;
 
@@ -1264,22 +1222,6 @@ module_do_load(const char *name, bool is
 			goto fail;
 		}
 	}
-	/*
-	 * One last check for duplicate module name/alias
-	 */
-	if ((aliasp = *mod->mod_info->mi_aliases) != NULL) {
-		while (*aliasp != NULL) {
-			if ((mod2 = module_lookup(*aliasp)) != NULL) {
-				module_error("Module `%s' alias `%s' already "
-				    "exists", mod->mod_info->mi_name, *aliasp);
-				error = EEXIST;
-				if (modp != NULL)
-					*modp = mod2;
-				goto fail;
-			}
-			aliasp++;
-		}
-	}
 
 	prev_active = module_active;
 	module_active = mod;

Index: src/sys/kern/sys_module.c
diff -u src/sys/kern/sys_module.c:1.23.2.8 src/sys/kern/sys_module.c:1.23.2.9
--- src/sys/kern/sys_module.c:1.23.2.8	Thu Sep  6 06:56:42 2018
+++ src/sys/kern/sys_module.c	Fri Sep  7 23:32:30 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_module.c,v 1.23.2.8 2018/09/06 06:56:42 pgoyette Exp $	*/
+/*	$NetBSD: sys_module.c,v 1.23.2.9 2018/09/07 23:32:30 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_module.c,v 1.23.2.8 2018/09/06 06:56:42 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_module.c,v 1.23.2.9 2018/09/07 23:32:30 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_modular.h"
@@ -111,19 +111,6 @@ out1:
 	return error;
 }
 
-static void
-copy_alias(modstat_t *ms, const char * const *aliasp, modinfo_t *mi,
-    module_t *mod)
-{
-
-	strlcpy(ms->ms_name, *aliasp, sizeof(ms->ms_name));
-	ms->ms_class = mi->mi_class;
-	ms->ms_source = mod->mod_source;
-	ms->ms_flags = mod->mod_flags;
-	SET(ms->ms_flags, MODFLG_IS_ALIAS);
-	ms->ms_reqoffset = 0;
-}
-
 static int
 handle_modctl_stat(struct iovec *iov, void *arg)
 {
@@ -144,7 +131,6 @@ handle_modctl_stat(struct iovec *iov, vo
 	int off;
 	int error;
 	bool stataddr;
-	const char * const *aliasp;
 
 	/* If not privileged, don't expose kernel addresses. */
 	error = kauth_authorize_process(kauth_cred_get(), KAUTH_PROCESS_CANSEE,
@@ -162,10 +148,6 @@ handle_modctl_stat(struct iovec *iov, vo
 	TAILQ_FOREACH(mod, &module_list, mod_chain) {
 		ms_cnt++;
 		mi = mod->mod_info;
-		if ((aliasp = *mi->mi_aliases) != NULL) {
-			while (*aliasp++ != NULL)
-				ms_cnt++;
-		}
 		if (mi->mi_required != NULL) {
 			req_cnt++;
 			req_len += strlen(mi->mi_required) + 1;
@@ -174,10 +156,6 @@ handle_modctl_stat(struct iovec *iov, vo
 	TAILQ_FOREACH(mod, &module_builtins, mod_chain) {
 		ms_cnt++;
 		mi = mod->mod_info;
-		if ((aliasp = *mi->mi_aliases) != NULL) {
-			while (*aliasp++ != NULL)
-				ms_cnt++;
-		}
 		if (mi->mi_required != NULL) {
 			req_cnt++;
 			req_len += strlen(mi->mi_required) + 1;
@@ -218,14 +196,6 @@ handle_modctl_stat(struct iovec *iov, vo
 		ms->ms_source = mod->mod_source;
 		ms->ms_flags = mod->mod_flags;
 		ms++;
-		aliasp = *mi->mi_aliases;
-		if (aliasp == NULL)
-			continue;
-		while (*aliasp) {
-			copy_alias(ms, aliasp, mi, mod);
-			aliasp++;
-			ms++;
-		}
 	}
 	TAILQ_FOREACH(mod, &module_builtins, mod_chain) {
 		mi = mod->mod_info;
@@ -248,14 +218,6 @@ handle_modctl_stat(struct iovec *iov, vo
 		KASSERT(mod->mod_source == MODULE_SOURCE_KERNEL);
 		ms->ms_source = mod->mod_source;
 		ms++;
-		aliasp = *mi->mi_aliases;
-		if (aliasp == NULL)
-			continue;
-		while (*aliasp) {
-			copy_alias(ms, aliasp, mi, mod);
-			aliasp++;
-			ms++;
-		}
 	}
 	kernconfig_unlock();
 

Index: src/sys/sys/module.h
diff -u src/sys/sys/module.h:1.41.14.10 src/sys/sys/module.h:1.41.14.11
--- src/sys/sys/module.h:1.41.14.10	Mon Jun 25 10:11:21 2018
+++ src/sys/sys/module.h	Fri Sep  7 23:32:30 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: module.h,v 1.41.14.10 2018/06/25 10:11:21 pgoyette Exp $	*/
+/*	$NetBSD: module.h,v 1.41.14.11 2018/09/07 23:32:30 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -79,7 +79,6 @@ typedef struct modinfo {
 	int			(*mi_modcmd)(modcmd_t, void *);
 	const char		*mi_name;
 	const char		*mi_required;
-	const char * const	(*mi_aliases)[];
 } const modinfo_t;
 
 /* Per module information, maintained by kern_module.c */ 
@@ -88,7 +87,6 @@ typedef struct module {
 	int			mod_flags;
 #define MODFLG_MUST_FORCE	0x01
 #define MODFLG_AUTO_LOADED	0x02
-#define	MODFLG_IS_ALIAS		0x04	/* only for export via modstat_t */
 	const modinfo_t		*mod_info;
 	struct kobj		*mod_kobj;
 	TAILQ_ENTRY(module)	mod_chain;
@@ -152,27 +150,17 @@ static void __CONCAT(moddtor_,name)(void
 
 #endif /* RUMP_USE_CTOR */
 
-#define	MODULE_WITH_ALIASES(class, name, required, aliases)	\
+#define	MODULE(class, name, required)				\
 static int __CONCAT(name,_modcmd)(modcmd_t, void *);		\
 static const modinfo_t __CONCAT(name,_modinfo) = {		\
 	.mi_version = __NetBSD_Version__,			\
 	.mi_class = (class),					\
 	.mi_modcmd = __CONCAT(name,_modcmd),			\
 	.mi_name = __STRING(name),				\
-	.mi_aliases = (aliases),				\
 	.mi_required = (required)				\
 }; 								\
 _MODULE_REGISTER(name)
 
-#define	MODULE(class, name, required)				\
-	MODULE_WITH_ALIASES(class, name, required, NULL)
-
-#ifdef PRG
-static mod_alias_list __CONCAT(name,_aliases) = { aliases };	\
-	.mi_aliases = & __CONCAT(name,_aliases),		\
-
-#endif
-
 TAILQ_HEAD(modlist, module);
 
 extern struct vm_map	*module_map;

Reply via email to