Module Name:    src
Committed By:   pgoyette
Date:           Mon Jun 24 13:58:24 UTC 2019

Modified Files:
        src/sys/arch/i386/stand/lib: exec.c libi386.h
        src/sys/lib/libsa: ext2fs.c ffsv1.c ffsv2.c

Log Message:
Now that the ufs module has been split out from ffs and ext2fs, we need
to update the boot-loader to push all modules required to support the
booted filesystem.  We treat the fsmod string as a slash-separated list
of module names (relative to kern.module.path), rather than as a single
module path name.

Note that ffsv1 and ffsv2 are still exempted from the boot-loader's
auto-push, but the list of required filesystems is still noted in the
source.

Also note that arch/sandpoint needs a similar change.  I have not made
this change because I am totally unable to test it.

Tested on my kernel with _no_ built-in file-systems and with the ffs
bootloader settings of fsmod enabled.


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 src/sys/arch/i386/stand/lib/exec.c
cvs rdiff -u -r1.42 -r1.43 src/sys/arch/i386/stand/lib/libi386.h
cvs rdiff -u -r1.27 -r1.28 src/sys/lib/libsa/ext2fs.c
cvs rdiff -u -r1.6 -r1.7 src/sys/lib/libsa/ffsv1.c src/sys/lib/libsa/ffsv2.c

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

Modified files:

Index: src/sys/arch/i386/stand/lib/exec.c
diff -u src/sys/arch/i386/stand/lib/exec.c:1.71 src/sys/arch/i386/stand/lib/exec.c:1.72
--- src/sys/arch/i386/stand/lib/exec.c:1.71	Mon Jun 24 02:48:51 2019
+++ src/sys/arch/i386/stand/lib/exec.c	Mon Jun 24 13:58:24 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: exec.c,v 1.71 2019/06/24 02:48:51 pgoyette Exp $	 */
+/*	$NetBSD: exec.c,v 1.72 2019/06/24 13:58:24 pgoyette Exp $	 */
 
 /*
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -121,6 +121,8 @@
 
 #define MODULE_WARNING_SEC	5
 
+#define MAXMODNAME	32	/* from <sys/module.h> */
+
 extern struct btinfo_console btinfo_console;
 
 boot_module_t *boot_modules;
@@ -190,6 +192,42 @@ fs_add(char *name)
 	return module_add_common(name, BM_TYPE_FS);
 }
 
+/*
+ * Add a /-separated list of module names to the boot list
+ */
+void
+module_add_split(const char *name, uint8_t type)
+{
+	char mod_name[MAXMODNAME];
+	int i;
+	const char *mp = name;
+	char *ep;
+
+	while (*mp) {				/* scan list of module names */
+		i = MAXMODNAME;
+		ep = mod_name;
+		while (--i) {			/* scan for end of first name */
+			*ep = *mp;
+			if (*ep == '/')		/* NUL-terminate the name */
+				*ep = '\0';
+
+			if (*ep == 0 ) {	/* add non-empty name */
+				if (ep != mod_name)
+					module_add_common(mod_name, type);
+				break;
+			}
+			ep++; mp++;
+		}
+		if (*ep != 0) {
+			printf("module name too long\n");
+			return;
+		}
+		if  (*mp == '/') {		/* skip separator if more */
+			mp++;
+		}
+	}
+}
+
 static void
 module_add_common(const char *name, uint8_t type)
 {
@@ -305,7 +343,7 @@ common_load_prekern(const char *file, u_
 
 	/* If the root fs type is unusual, load its module. */
 	if (fsmod != NULL)
-		module_add_common(fsmod, BM_TYPE_KMOD);
+		module_add_split(fsmod, BM_TYPE_KMOD);
 
 	bi_prekern.kernpa_start = kernpa_start;
 	bi_prekern.kernpa_end = kernpa_end;
@@ -383,7 +421,7 @@ common_load_kernel(const char *file, u_l
 
 	/* If the root fs type is unusual, load its module. */
 	if (fsmod != NULL)
-		module_add_common(fsmod, BM_TYPE_KMOD);
+		module_add_split(fsmod, BM_TYPE_KMOD);
 
 	/*
 	 * Gather some information for the kernel. Do this after the
@@ -572,7 +610,7 @@ count_netbsd(const char *file, u_long *r
 
 		/* If the root fs type is unusual, load its module. */
 		if (fsmod != NULL)
-			module_add_common(fsmod, BM_TYPE_KMOD);
+			module_add_split(fsmod, BM_TYPE_KMOD);
 
 		for (bm = boot_modules; bm; bm = bm->bm_next) {
 			fd = module_open(bm, 0, kdev, base_path, false);

Index: src/sys/arch/i386/stand/lib/libi386.h
diff -u src/sys/arch/i386/stand/lib/libi386.h:1.42 src/sys/arch/i386/stand/lib/libi386.h:1.43
--- src/sys/arch/i386/stand/lib/libi386.h:1.42	Sun Mar 12 05:33:48 2017
+++ src/sys/arch/i386/stand/lib/libi386.h	Mon Jun 24 13:58:24 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: libi386.h,v 1.42 2017/03/12 05:33:48 nonaka Exp $	*/
+/*	$NetBSD: libi386.h,v 1.43 2019/06/24 13:58:24 pgoyette Exp $	*/
 
 /*
  * Copyright (c) 1996
@@ -145,6 +145,7 @@ void splash_add(char *);
 void rnd_add(char *);
 void fs_add(char *);
 void userconf_add(char *);
+void module_add_split(const char *, uint8_t);
 
 struct btinfo_framebuffer;
 void framebuffer_configure(struct btinfo_framebuffer *);

Index: src/sys/lib/libsa/ext2fs.c
diff -u src/sys/lib/libsa/ext2fs.c:1.27 src/sys/lib/libsa/ext2fs.c:1.28
--- src/sys/lib/libsa/ext2fs.c:1.27	Fri Apr  5 20:09:29 2019
+++ src/sys/lib/libsa/ext2fs.c	Mon Jun 24 13:58:24 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs.c,v 1.27 2019/04/05 20:09:29 christos Exp $	*/
+/*	$NetBSD: ext2fs.c,v 1.28 2019/06/24 13:58:24 pgoyette Exp $	*/
 
 /*
  * Copyright (c) 1997 Manuel Bouyer.
@@ -692,7 +692,7 @@ out:
 	if (rc)
 		ext2fs_close(f);
 	else
-		fsmod = "ext2fs";
+		fsmod = "ufs/ext2fs";
 	return rc;
 }
 

Index: src/sys/lib/libsa/ffsv1.c
diff -u src/sys/lib/libsa/ffsv1.c:1.6 src/sys/lib/libsa/ffsv1.c:1.7
--- src/sys/lib/libsa/ffsv1.c:1.6	Mon May 21 21:34:16 2012
+++ src/sys/lib/libsa/ffsv1.c	Mon Jun 24 13:58:24 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ffsv1.c,v 1.6 2012/05/21 21:34:16 dsl Exp $ */
+/* $NetBSD: ffsv1.c,v 1.7 2019/06/24 13:58:24 pgoyette Exp $ */
 
 #define LIBSA_FFSv1
 
@@ -15,4 +15,8 @@
 #define ufs_dinode	ufs1_dinode
 #define indp_t		int32_t
 
+#if 0
+#define	FSMOD	"wapbl/ufs/ffs"
+#endif
+
 #include "ufs.c"
Index: src/sys/lib/libsa/ffsv2.c
diff -u src/sys/lib/libsa/ffsv2.c:1.6 src/sys/lib/libsa/ffsv2.c:1.7
--- src/sys/lib/libsa/ffsv2.c:1.6	Mon May 21 21:34:16 2012
+++ src/sys/lib/libsa/ffsv2.c	Mon Jun 24 13:58:24 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ffsv2.c,v 1.6 2012/05/21 21:34:16 dsl Exp $ */
+/* $NetBSD: ffsv2.c,v 1.7 2019/06/24 13:58:24 pgoyette Exp $ */
 
 #define LIBSA_FFSv2
 
@@ -15,4 +15,8 @@
 #define ufs_dinode	ufs2_dinode
 #define indp_t		int64_t
 
+#if 0
+#define	FSMOD	"wapbl/ufs/ffs"
+#endif
+
 #include "ufs.c"

Reply via email to