summaryrefslogtreecommitdiffstats
path: root/usr.sbin/config
diff options
context:
space:
mode:
authorru <ru@FreeBSD.org>2003-02-15 02:39:13 +0000
committerru <ru@FreeBSD.org>2003-02-15 02:39:13 +0000
commit146e03f2e3c59496cae094cdd714aa8dfe9297c3 (patch)
tree1eb36702a724ee0a51ac4400051207c8ce5896ed /usr.sbin/config
parentb9cd8d8951aa733eb624c5f9a4218393f0403a72 (diff)
downloadFreeBSD-src-146e03f2e3c59496cae094cdd714aa8dfe9297c3.zip
FreeBSD-src-146e03f2e3c59496cae094cdd714aa8dfe9297c3.tar.gz
Implemented a simple "nodevice" config(8) command that cancels
the effect of the "device" command, and use it to generate the OLDCARD from GENERIC. Suggested by: bde
Diffstat (limited to 'usr.sbin/config')
-rw-r--r--usr.sbin/config/config.y47
-rw-r--r--usr.sbin/config/lang.l3
2 files changed, 49 insertions, 1 deletions
diff --git a/usr.sbin/config/config.y b/usr.sbin/config/config.y
index c30171f..aa8a40a 100644
--- a/usr.sbin/config/config.y
+++ b/usr.sbin/config/config.y
@@ -14,6 +14,7 @@
%token HINTS
%token IDENT
%token MAXUSERS
+%token NODEVICE
%token PROFILE
%token OPTIONS
%token MAKEOPTIONS
@@ -242,6 +243,12 @@ Device_spec:
if ($3 == 0)
errx(1, "%s:%d: devices with zero units are not "
"likely to be correct", yyfile, yyline);
+ } |
+ NODEVICE Dev
+ = {
+ rmopt(&opt, devopt($2));
+ /* and the device part */
+ rmdev($2);
} ;
%%
@@ -268,6 +275,27 @@ newdev(char *name, int count)
STAILQ_INSERT_TAIL(&dtab, np, d_next);
}
+/*
+ * remove a device from the list of devices
+ */
+static void
+rmdev(char *name)
+{
+ struct device *dp, *rmdp;
+
+ STAILQ_FOREACH(dp, &dtab, d_next) {
+ if (eq(dp->d_name, name)) {
+ rmdp = dp;
+ dp = STAILQ_NEXT(dp, d_next);
+ STAILQ_REMOVE(&dtab, rmdp, device, d_next);
+ free(rmdp->d_name);
+ free(rmdp);
+ if (dp == NULL)
+ break;
+ }
+ }
+}
+
static void
newopt(struct opt_head *list, char *name, char *value)
{
@@ -280,3 +308,22 @@ newopt(struct opt_head *list, char *name, char *value)
op->op_value = value;
SLIST_INSERT_HEAD(list, op, op_next);
}
+
+static void
+rmopt(struct opt_head *list, char *name)
+{
+ struct opt *op, *rmop;
+
+ SLIST_FOREACH(op, list, op_next) {
+ if (eq(op->op_name, name)) {
+ rmop = op;
+ op = SLIST_NEXT(op, op_next);
+ SLIST_REMOVE(list, rmop, opt, op_next);
+ free(rmop->op_name);
+ free(rmop->op_value);
+ free(rmop);
+ if (op == NULL)
+ break;
+ }
+ }
+}
diff --git a/usr.sbin/config/lang.l b/usr.sbin/config/lang.l
index bef36f1..6884bd1 100644
--- a/usr.sbin/config/lang.l
+++ b/usr.sbin/config/lang.l
@@ -73,6 +73,7 @@ struct kt {
{ "machine", ARCH }, /* MACHINE is defined in /sys/param.h */
{ "makeoptions", MAKEOPTIONS },
{ "maxusers", MAXUSERS },
+ { "nodevice", NODEVICE },
{ "profile", PROFILE },
{ "option", OPTIONS },
{ "options", OPTIONS },
@@ -109,7 +110,7 @@ ID [A-Za-z_][-A-Za-z_0-9]*
if ((i = kw_lookup(yytext)) == -1)
REJECT;
- if (i == DEVICE)
+ if (i == DEVICE || i == NODEVICE)
BEGIN NONUM;
return i;
}
OpenPOWER on IntegriCloud