From owner-svn-src-all@FreeBSD.ORG Sun May 2 06:18:58 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 194B3106566B; Sun, 2 May 2010 06:18:58 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [69.147.83.44]) by mx1.freebsd.org (Postfix) with ESMTP id E39A88FC0C; Sun, 2 May 2010 06:18:57 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o426Ivb9068713; Sun, 2 May 2010 06:18:57 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o426Ivm7068711; Sun, 2 May 2010 06:18:57 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <201005020618.o426Ivm7068711@svn.freebsd.org> From: Warner Losh Date: Sun, 2 May 2010 06:18:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r207493 - stable/8/usr.sbin/config X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 May 2010 06:18:58 -0000 Author: imp Date: Sun May 2 06:18:57 2010 New Revision: 207493 URL: http://svn.freebsd.org/changeset/base/207493 Log: MFC r207265: Require the option that's mapped be listed in the options file. This will allow people with old config options to either have it just work (if config is new enough), or get a version error (if their config is about 7.0 or newer) rather than getting a cryptic error about duplicated options in the options file, or getting an error about an unknown option, at which point they'd update their config file only to learn they need a new config, only to learn they didn't really need to update their config file... All this because our version checking was in the wrong place for the past decade... # hopefully this is the last change, and we'll be able to config with an # 8.0 GENERIC file on stable/8 after I merge this change and add the # compat options. Modified: stable/8/usr.sbin/config/mkoptions.c Directory Properties: stable/8/usr.sbin/config/ (props changed) Modified: stable/8/usr.sbin/config/mkoptions.c ============================================================================== --- stable/8/usr.sbin/config/mkoptions.c Sun May 2 06:18:08 2010 (r207492) +++ stable/8/usr.sbin/config/mkoptions.c Sun May 2 06:18:57 2010 (r207493) @@ -292,32 +292,49 @@ tooption(char *name) static void -insert_option(char *this, char *val, int flags) +check_duplicate(const char *fname, const char *this) { struct opt_list *po; + SLIST_FOREACH(po, &otab, o_next) { + if (eq(po->o_name, this)) { + printf("%s: Duplicate option %s.\n", + fname, this); + exit(1); + } + } +} + +static void +insert_option(const char *fname, char *this, char *val) +{ + struct opt_list *po; + + check_duplicate(fname, this); po = (struct opt_list *) calloc(1, sizeof *po); if (po == NULL) err(EXIT_FAILURE, "calloc"); po->o_name = this; po->o_file = val; - po->o_flags = flags; + po->o_flags = 0; SLIST_INSERT_HEAD(&otab, po, o_next); } - static void -check_duplicate(const char *fname, const char *this) +update_option(const char *this, char *val, int flags) { struct opt_list *po; SLIST_FOREACH(po, &otab, o_next) { if (eq(po->o_name, this)) { - printf("%s: Duplicate option %s.\n", - fname, this); - exit(1); + free(po->o_file); + po->o_file = val; + po->o_flags = flags; + return; } } + printf("Compat option %s not listed in options file.\n", this); + exit(1); } static int @@ -355,8 +372,10 @@ read_option_file(const char *fname, int free(s); } val = ns(val); - check_duplicate(fname, this); - insert_option(this, val, flags); + if (flags == 0) + insert_option(fname, this, val); + else + update_option(this, val, flags); } (void)fclose(fp); return (1);