Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 15 Apr 2010 15:10:46 +0000 (UTC)
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r206664 - head/usr.sbin/config
Message-ID:  <201004151510.o3FFAkRP034444@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: imp
Date: Thu Apr 15 15:10:46 2010
New Revision: 206664
URL: http://svn.freebsd.org/changeset/base/206664

Log:
  Allow option aliasing.  Lines of the form:
  
  OLD_OPT = NEW_OPT
  
  in options* files will now map OLD_OPT to NEW_OPT with a friendly
  message.  This is indented for situations where we need to preserve an
  interface in the config file in an upwards compatible fashion on a
  stable branch.
  
  Reviewed by:	nwhitehorn@
  MFC after:	3 days

Modified:
  head/usr.sbin/config/config.h
  head/usr.sbin/config/mkoptions.c

Modified: head/usr.sbin/config/config.h
==============================================================================
--- head/usr.sbin/config/config.h	Thu Apr 15 14:26:52 2010	(r206663)
+++ head/usr.sbin/config/config.h	Thu Apr 15 15:10:46 2010	(r206664)
@@ -129,6 +129,8 @@ SLIST_HEAD(opt_head, opt) opt, mkopt, rm
 struct opt_list {
 	char *o_name;
 	char *o_file;
+	int o_flags;
+#define OL_ALIAS	1
 	SLIST_ENTRY(opt_list) o_next;
 };
 

Modified: head/usr.sbin/config/mkoptions.c
==============================================================================
--- head/usr.sbin/config/mkoptions.c	Thu Apr 15 14:26:52 2010	(r206663)
+++ head/usr.sbin/config/mkoptions.c	Thu Apr 15 15:10:46 2010	(r206664)
@@ -94,6 +94,17 @@ options(void)
 	SLIST_INSERT_HEAD(&opt, op, op_next);
 
 	read_options();
+	SLIST_FOREACH(op, &opt, op_next) {
+		SLIST_FOREACH(ol, &otab, o_next) {
+			if (eq(op->op_name, ol->o_name) &&
+			    (ol->o_flags & OL_ALIAS)) {
+				printf("Mapping option %s to %s.\n",
+				    op->op_name, ol->o_file);
+				op->op_name = ol->o_file;
+				break;
+			}
+		}
+	}
 	SLIST_FOREACH(ol, &otab, o_next)
 		do_option(ol->o_name);
 	SLIST_FOREACH(op, &opt, op_next) {
@@ -124,7 +135,6 @@ do_option(char *name)
 	int tidy;
 
 	file = tooption(name);
-
 	/*
 	 * Check to see if the option was specified..
 	 */
@@ -292,6 +302,7 @@ read_options(void)
 	struct opt_list *po;
 	int first = 1;
 	char genopt[MAXPATHLEN];
+	int flags = 0;
 
 	SLIST_INIT(&otab);
 	(void) snprintf(fname, sizeof(fname), "../../conf/options");
@@ -301,6 +312,7 @@ openit:
 		return;
 	}
 next:
+	flags = 0;
 	wd = get_word(fp);
 	if (wd == (char *)EOF) {
 		(void) fclose(fp);
@@ -332,6 +344,18 @@ next:
 		(void) snprintf(genopt, sizeof(genopt), "opt_%s.h", lower(s));
 		val = genopt;
 		free(s);
+	} else if (eq(val, "=")) {
+		val = get_word(fp);
+		if (val == (char *)EOF) {
+			printf("%s: unexpected end of file\n", fname);
+			exit(1);
+		}
+		if (val == 0) {
+			printf("%s: Expected a right hand side at %s\n", fname,
+			    this);
+			exit(1);
+		}
+		flags |= OL_ALIAS;
 	}
 	val = ns(val);
 
@@ -348,6 +372,7 @@ next:
 		err(EXIT_FAILURE, "calloc");
 	po->o_name = this;
 	po->o_file = val;
+	po->o_flags = flags;
 	SLIST_INSERT_HEAD(&otab, po, o_next);
 
 	goto next;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201004151510.o3FFAkRP034444>