Module Name:    src
Committed By:   jnemeth
Date:           Fri Jun  5 11:37:30 UTC 2009

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

Log Message:
Add a new [-d var] option which when combined with -p and -m will allow
you to delete vars from the existing <module>.prop file.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sbin/modload/main.c
cvs rdiff -u -r1.33 -r1.34 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.9 src/sbin/modload/main.c:1.10
--- src/sbin/modload/main.c:1.9	Fri Jun  5 09:31:07 2009
+++ src/sbin/modload/main.c	Fri Jun  5 11:37:30 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.9 2009/06/05 09:31:07 wiz Exp $	*/
+/*	$NetBSD: main.c,v 1.10 2009/06/05 11:37:30 jnemeth Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -28,10 +28,11 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: main.c,v 1.9 2009/06/05 09:31:07 wiz Exp $");
+__RCSID("$NetBSD: main.c,v 1.10 2009/06/05 11:37:30 jnemeth Exp $");
 #endif /* !lint */
 
 #include <sys/module.h>
+#include <sys/queue.h>
 
 #include <assert.h>
 #include <stdbool.h>
@@ -59,26 +60,42 @@
 int
 main(int argc, char **argv)
 {
+	SIMPLEQ_HEAD(del_head, del_item) del_head;
 	modctl_load_t cmdargs;
 	prop_dictionary_t ext_props, props;
-	bool merge_props, output_props;
+	bool del_props, merge_props, output_props;
 	const char *ext_file;
 	char *propsstr;
 	int ch;
 	int flags;
 
+	struct del_item {
+		SIMPLEQ_ENTRY(del_item) del_items;
+		const char *del_key;
+	} *delp;
+
+	SIMPLEQ_INIT(&del_head);
 	ext_file = NULL;
 	ext_props = NULL;
 	props = prop_dictionary_create();
-	merge_props = output_props = false;
+	del_props = merge_props = output_props = false;
 	flags = 0;
 
-	while ((ch = getopt(argc, argv, "b:fi:m:ps:")) != -1) {
+	while ((ch = getopt(argc, argv, "b:d:fi:m:ps:")) != -1) {
 		switch (ch) {
 		case 'b':
 			parse_param(props, optarg, parse_bool_param);
 			break;
 
+		case 'd':
+			del_props = true;
+			delp = malloc(sizeof(struct del_item));
+			if (delp == NULL)
+				errx(EXIT_FAILURE, "Out of memory");
+			delp->del_key = optarg;
+			SIMPLEQ_INSERT_TAIL(&del_head, delp, del_items);
+			break;
+
 		case 'f':
 			flags |= MODCTL_LOAD_FORCE;
 			break;
@@ -124,7 +141,16 @@
 
 			free(propsstr);
 			merge_dicts(ext_props, props);
+
+			if (del_props)
+				SIMPLEQ_FOREACH(delp, &del_head, del_items)
+					prop_dictionary_remove(ext_props,
+					    delp->del_key);
+
 			propsstr = prop_dictionary_externalize(ext_props);
+			if (propsstr == NULL)
+				errx(EXIT_FAILURE, "Failed to process "
+				    "properties");
 		}
 				
 		fputs(propsstr, stdout);
@@ -224,8 +250,8 @@
 	(void)fprintf(stderr,
 	    "Usage: %s [-f] [-b var=boolean] [-i var=integer] "
 	    "[-s var=string] module\n"
-	    "       %s -p [-b var=boolean] [-i var=integer] [-m plist] "
-	    "[-s var=string]\n",
+	    "       %s -p [-b var=boolean] [-d var] [-i var=integer] "
+	    "[-m plist]\n               [-s var=string]\n",
 	    getprogname(), getprogname());
 	exit(EXIT_FAILURE);
 }

Index: src/sbin/modload/modload.8
diff -u src/sbin/modload/modload.8:1.33 src/sbin/modload/modload.8:1.34
--- src/sbin/modload/modload.8:1.33	Fri Jun  5 09:31:07 2009
+++ src/sbin/modload/modload.8	Fri Jun  5 11:37:30 2009
@@ -1,4 +1,4 @@
-.\" $NetBSD: modload.8,v 1.33 2009/06/05 09:31:07 wiz Exp $
+.\" $NetBSD: modload.8,v 1.34 2009/06/05 11:37:30 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 June 3, 2009
+.Dd June 5, 2009
 .Dt MODLOAD 8
 .Os
 .Sh NAME
@@ -48,6 +48,7 @@
 .Nm
 .Fl p
 .Op Fl b Ar var=boolean
+.Op Fl d Ar var
 .Op Fl i Ar var=integer
 .Op Fl m Ar plist
 .Op Fl s Ar var=string
@@ -73,6 +74,14 @@
 .Dv true
 or
 .Dv false .
+.It Fl d Ar var
+When used in conjuction with
+.Fl m ,
+delete
+.Ar var
+from the
+.Ar plist
+specified.
 .It Fl f
 When a module is loaded, the kernel checks if the module is compatible
 with the running kernel and will refuse to load modules that are
@@ -94,6 +103,11 @@
 .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.
+Use
+.Fl m
+and
+.Fl d
+to read and modify an existing property list.
 .It Fl s Ar var=string
 Pass the module a string property with the name
 .Ar var

Reply via email to