Module Name:    src
Committed By:   jnemeth
Date:           Tue May 19 22:09:59 UTC 2009

Modified Files:
        src/sbin/modload: main.c modload.8

Log Message:
Add -p option which outputs a property list suitable for loading with a
module.  This is in preparation for having the kernel load an optional
<module>.prop alongside a module, which is useful for passing options
to autoloaded modules and modules loaded at boot time.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sbin/modload/main.c
cvs rdiff -u -r1.28 -r1.29 src/sbin/modload/modload.8

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

Modified files:

Index: src/sbin/modload/main.c
diff -u src/sbin/modload/main.c:1.4 src/sbin/modload/main.c:1.5
--- src/sbin/modload/main.c:1.4	Wed Nov 12 12:35:53 2008
+++ src/sbin/modload/main.c	Tue May 19 22:09:59 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.4 2008/11/12 12:35:53 ad Exp $	*/
+/*	$NetBSD: main.c,v 1.5 2009/05/19 22:09:59 jnemeth Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: main.c,v 1.4 2008/11/12 12:35:53 ad Exp $");
+__RCSID("$NetBSD: main.c,v 1.5 2009/05/19 22:09:59 jnemeth Exp $");
 #endif /* !lint */
 
 #include <sys/module.h>
@@ -60,6 +60,7 @@
 {
 	modctl_load_t cmdargs;
 	prop_dictionary_t props;
+	bool output_props = false;
 	char *propsstr;
 	int ch;
 	int flags;
@@ -67,7 +68,7 @@
 	flags = 0;
 	props = prop_dictionary_create();
 
-	while ((ch = getopt(argc, argv, "b:fi:s:")) != -1) {
+	while ((ch = getopt(argc, argv, "b:fi:ps:")) != -1) {
 		switch (ch) {
 		case 'b':
 			parse_param(props, optarg, parse_bool_param);
@@ -81,6 +82,10 @@
 			parse_param(props, optarg, parse_int_param);
 			break;
 
+		case 'p':
+			output_props = true;
+			break;
+
 		case 's':
 			parse_param(props, optarg, parse_string_param);
 			break;
@@ -93,20 +98,24 @@
 
 	argc -= optind;
 	argv += optind;
-	if (argc != 1)
-		usage();
 
 	propsstr = prop_dictionary_externalize(props);
 	if (propsstr == NULL)
 		errx(EXIT_FAILURE, "Failed to process properties");
 
-	cmdargs.ml_filename = argv[0];
-	cmdargs.ml_flags = flags;
-	cmdargs.ml_props = propsstr;
-	cmdargs.ml_propslen = strlen(propsstr);
+	if (output_props)
+		puts(propsstr);
+	else {
+		if (argc != 1)
+			usage();
+		cmdargs.ml_filename = argv[0];
+		cmdargs.ml_flags = flags;
+		cmdargs.ml_props = propsstr;
+		cmdargs.ml_propslen = strlen(propsstr);
 
-	if (modctl(MODCTL_LOAD, &cmdargs)) {
-		err(EXIT_FAILURE, NULL);
+		if (modctl(MODCTL_LOAD, &cmdargs)) {
+			err(EXIT_FAILURE, NULL);
+		}
 	}
 
 	free(propsstr);
@@ -192,7 +201,7 @@
 	(void)fprintf(stderr,
 	    "Usage: %s [-b var=boolean] [-f] [-i var=integer] "
 	    "[-s var=string]\n"
-	    "       <module_name>\n",
+	    "       {-p|<module_name>}\n",
 	    getprogname());
 	exit(EXIT_FAILURE);
 }

Index: src/sbin/modload/modload.8
diff -u src/sbin/modload/modload.8:1.28 src/sbin/modload/modload.8:1.29
--- src/sbin/modload/modload.8:1.28	Mon Nov 17 02:32:09 2008
+++ src/sbin/modload/modload.8	Tue May 19 22:09:59 2009
@@ -1,4 +1,4 @@
-.\" $NetBSD: modload.8,v 1.28 2008/11/17 02:32:09 uwe Exp $
+.\" $NetBSD: modload.8,v 1.29 2009/05/19 22:09:59 jnemeth 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 November 12, 2008
+.Dd May 19, 2009
 .Dt MODLOAD 8
 .Os
 .Sh NAME
@@ -43,6 +43,7 @@
 .Op Fl b Ar name=val
 .Op Fl f
 .Op Fl i Ar name=val
+.Op Fl p
 .Op Fl s Ar name=val
 .Ar module
 .Sh DESCRIPTION
@@ -80,6 +81,9 @@
 .Em Note :
 an incompatible module can cause system instability, including data
 loss or corruption.
+.It Fl p
+Output a property list suitable for loading along with a module.
+When using this option, you do not need to specify a module.
 .It Fl s
 Pass the module a string property with the name
 .Ar name

Reply via email to