From owner-freebsd-bugs@FreeBSD.ORG Mon Feb 23 14:20:05 2009 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9AC071065678 for ; Mon, 23 Feb 2009 14:20:05 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 756C98FC0C for ; Mon, 23 Feb 2009 14:20:05 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id n1NEK5gL007506 for ; Mon, 23 Feb 2009 14:20:05 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id n1NEK5jL007505; Mon, 23 Feb 2009 14:20:05 GMT (envelope-from gnats) Resent-Date: Mon, 23 Feb 2009 14:20:05 GMT Resent-Message-Id: <200902231420.n1NEK5jL007505@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Kuan-Chung Chiu Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3AC0F1065674 for ; Mon, 23 Feb 2009 14:16:59 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 285C68FC0C for ; Mon, 23 Feb 2009 14:16:59 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n1NEGwog056050 for ; Mon, 23 Feb 2009 14:16:58 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id n1NEGwDD056049; Mon, 23 Feb 2009 14:16:58 GMT (envelope-from nobody) Message-Id: <200902231416.n1NEGwDD056049@www.freebsd.org> Date: Mon, 23 Feb 2009 14:16:58 GMT From: Kuan-Chung Chiu To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: conf/132008: [PATCH] to allow using section/nosection in KERNCONF X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Feb 2009 14:20:05 -0000 >Number: 132008 >Category: conf >Synopsis: [PATCH] to allow using section/nosection in KERNCONF >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Mon Feb 23 14:20:05 UTC 2009 >Closed-Date: >Last-Modified: >Originator: Kuan-Chung Chiu >Release: 8.0-CURRENT >Organization: N/A >Environment: FreeBSD Zeta.twbbs.org 8.0-CURRENT FreeBSD 8.0-CURRENT #10: Fri Feb 20 20:42:28 CST 2009 root@Zeta.twbbs.org:/usr/obj/usr/src/sys/ZETA i386 >Description: With this patch we can use section/nosection on KERNCONF to manipulate whole section instead of using many nooption/nodevice. Modify GENERIC as follow: # Debugging for use in -current #DEBUG .. # USB core support section USB2 .. # FireWire support section FireWire .. And the customized kernconf: include GENERIC ident ZETA nosection DEBUG nosection USB2 nosection FireWire this way we can customize KERNCONF more clean and easy. >How-To-Repeat: >Fix: Patch attached with submission follows: diff -ruN config.orig/config.h config/config.h --- config.orig/config.h 2008-11-23 05:12:47.000000000 +0800 +++ config/config.h 2009-02-21 02:09:00.000000000 +0800 @@ -81,6 +81,7 @@ struct device { int d_done; /* processed */ char *d_name; /* name of device (e.g. rk11) */ + char *section; #define UNKNOWN -2 /* -2 means not set yet */ STAILQ_ENTRY(device) d_next; /* Next one in list */ }; @@ -106,6 +107,7 @@ */ struct cputype { char *cpu_name; + char *section; SLIST_ENTRY(cputype) cpu_next; }; @@ -119,6 +121,7 @@ struct opt { char *op_name; char *op_value; + char *section; int op_ownfile; /* true = own file, false = makefile */ SLIST_ENTRY(opt) op_next; SLIST_ENTRY(opt) op_append; diff -ruN config.orig/config.y config/config.y --- config.orig/config.y 2008-11-23 05:12:47.000000000 +0800 +++ config/config.y 2009-02-21 02:09:00.000000000 +0800 @@ -22,6 +22,8 @@ %token NOOPTION %token MAKEOPTIONS %token NOMAKEOPTION +%token SECTION +%token NOSECTION %token SEMICOLON %token INCLUDE %token FILES @@ -29,6 +31,7 @@ %token ID %token NUMBER +%type Sec_name %type Save_id %type Opt_value %type Dev @@ -91,6 +94,8 @@ struct files_name_head fntab; char errbuf[80]; int maxusers; +char section_init[]="main"; +char *section=section_init; #define ns(s) strdup(s) int include(const char *, int); @@ -126,6 +131,8 @@ ; Spec: + Section_spec SEMICOLON + | Device_spec SEMICOLON | Config_spec SEMICOLON @@ -147,6 +154,41 @@ error SEMICOLON ; +Section_spec: + SECTION Sec_name { section = $2; } | + NOSECTION Sec_name { + struct cputype *cp, *cp2; + SLIST_FOREACH_SAFE(cp, &cputype, cpu_next, cp2) { + if (eq(cp->section, $2)){ + SLIST_REMOVE(&cputype, cp, cputype, cpu_next); + free(cp); + } + } + struct opt *op, *op2; + SLIST_FOREACH_SAFE(op, &opt, op_next, op2){ + if(eq(op->section, $2)){ + SLIST_REMOVE(&opt, op, opt, op_next); + free(op->op_name); + free(op); + } + } + SLIST_FOREACH_SAFE(op, &mkopt, op_next, op2){ + if(eq(op->section, $2)){ + SLIST_REMOVE(&mkopt, op, opt, op_next); + free(op->op_name); + free(op); + } + } + struct device *dp, *dp2; + STAILQ_FOREACH_SAFE(dp, &dtab, d_next, dp2){ + if (eq(dp->section, $2)){ + STAILQ_REMOVE(&dtab, dp, device, d_next); + free(dp->d_name); + free(dp); + } + } + } + Config_spec: ARCH Save_id { if (machinename != NULL && !eq($2, machinename)) @@ -167,6 +209,7 @@ struct cputype *cp = (struct cputype *)calloc(1, sizeof (struct cputype)); cp->cpu_name = $2; + cp->section=section; SLIST_INSERT_HEAD(&cputype, cp, cpu_next); } | NOCPU Save_id { @@ -249,6 +292,10 @@ ID { $$ = $1; } ; +Sec_name: + ID { $$ = $1; } + ; + Mkopt_list: Mkopt_list COMMA Mkoption | @@ -365,6 +412,7 @@ np = (struct device *) calloc(1, sizeof *np); np->d_name = name; + np->section = section; STAILQ_INSERT_TAIL(&dtab, np, d_next); } @@ -425,6 +473,7 @@ op->op_name = name; op->op_ownfile = 0; op->op_value = value; + op->section = section; if (op2 != NULL) { while (SLIST_NEXT(op2, op_append) != NULL) op2 = SLIST_NEXT(op2, op_append); diff -ruN config.orig/lang.l config/lang.l --- config.orig/lang.l 2008-11-23 05:12:47.000000000 +0800 +++ config/lang.l 2009-02-21 02:09:00.000000000 +0800 @@ -81,6 +81,8 @@ { "options", OPTIONS }, { "nooption", NOOPTION }, { "nooptions", NOOPTION }, + { "section", SECTION }, + { "nosection", NOSECTION }, { "include", INCLUDE }, { "files", FILES }, { 0, 0 }, >Release-Note: >Audit-Trail: >Unformatted: