diff options
author | Angelos D. Keromytis <angelos@cvs.openbsd.org> | 2001-01-23 06:03:00 +0000 |
---|---|---|
committer | Angelos D. Keromytis <angelos@cvs.openbsd.org> | 2001-01-23 06:03:00 +0000 |
commit | d0a5fa42f1b6ebc23d23f9c1ba8eafa468923561 (patch) | |
tree | 263e53231c7486b99b42d7dcf3a7615869a75fb2 /usr.sbin/config | |
parent | 0d359a25c5e8b08e0beec6bc5d040d7bb39b8f3b (diff) |
Allow entries like "foo at bar enable", which override previous
entries like "foo bar bar disable"; useful for kernel config lamers
like myself who don't like to use 'config -e' or 'bsd -c' to manually
enable USB. Tested with uhci/ohci on i386.
Diffstat (limited to 'usr.sbin/config')
-rw-r--r-- | usr.sbin/config/gram.y | 5 | ||||
-rw-r--r-- | usr.sbin/config/scan.l | 3 | ||||
-rw-r--r-- | usr.sbin/config/sem.c | 53 | ||||
-rw-r--r-- | usr.sbin/config/sem.h | 3 |
4 files changed, 59 insertions, 5 deletions
diff --git a/usr.sbin/config/gram.y b/usr.sbin/config/gram.y index adffaaacc53..1012d32d596 100644 --- a/usr.sbin/config/gram.y +++ b/usr.sbin/config/gram.y @@ -1,5 +1,5 @@ %{ -/* $OpenBSD: gram.y,v 1.10 2000/01/04 14:23:43 angelos Exp $ */ +/* $OpenBSD: gram.y,v 1.11 2001/01/23 06:02:58 angelos Exp $ */ /* $NetBSD: gram.y,v 1.14 1997/02/02 21:12:32 thorpej Exp $ */ /* @@ -103,7 +103,7 @@ static void check_maxpart __P((void)); %token AND AT ATTACH BUILD COMPILE_WITH CONFIG DEFINE DEFOPT DEVICE DISABLE %token DUMPS ENDFILE XFILE XOBJECT FLAGS INCLUDE XMACHINE MAJOR MAKEOPTIONS %token MAXUSERS MAXPARTITIONS MINOR ON OPTIONS PSEUDO_DEVICE ROOT SOURCE SWAP -%token WITH NEEDS_COUNT NEEDS_FLAG RMOPTIONS +%token WITH NEEDS_COUNT NEEDS_FLAG RMOPTIONS ENABLE %token <val> NUMBER %token <str> PATHNAME WORD EMPTY @@ -336,6 +336,7 @@ config_spec: MAXUSERS NUMBER { setmaxusers($2); } | CONFIG conf sysparam_list { addconf(&conf); } | PSEUDO_DEVICE WORD npseudo { addpseudo($2, $3); } | + device_instance AT attachment ENABLE { enabledev($1, $3); } | device_instance AT attachment disable locators flags_opt { adddev($1, $3, $5, $6, $4); }; diff --git a/usr.sbin/config/scan.l b/usr.sbin/config/scan.l index e0065b45c01..739e8022cb0 100644 --- a/usr.sbin/config/scan.l +++ b/usr.sbin/config/scan.l @@ -1,5 +1,5 @@ %{ -/* $OpenBSD: scan.l,v 1.13 2000/01/04 14:23:43 angelos Exp $ */ +/* $OpenBSD: scan.l,v 1.14 2001/01/23 06:02:59 angelos Exp $ */ /* $NetBSD: scan.l,v 1.13 1997/02/02 21:12:37 thorpej Exp $ */ /* @@ -93,6 +93,7 @@ define return DEFINE; defopt return DEFOPT; device return DEVICE; disable return DISABLE; +enable return ENABLE; dumps return DUMPS; file return XFILE; flags return FLAGS; diff --git a/usr.sbin/config/sem.c b/usr.sbin/config/sem.c index e4859f78528..dbd2adc4b17 100644 --- a/usr.sbin/config/sem.c +++ b/usr.sbin/config/sem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sem.c,v 1.18 2000/11/15 01:47:14 angelos Exp $ */ +/* $OpenBSD: sem.c,v 1.19 2001/01/23 06:02:59 angelos Exp $ */ /* $NetBSD: sem.c,v 1.10 1996/11/11 23:40:11 gwr Exp $ */ /* @@ -734,6 +734,57 @@ newdevi(name, unit, d) } /* + * Enable an already declared by disabled device. + */ +void +enabledev(name, at) + const char *name, *at; +{ + struct devbase *ib, *ab; + char atbuf[NAMESIZE]; + struct attr *attr; + struct nvlist *nv; + struct devi *i; + const char *cp; + int atunit; + + i = ht_lookup(devitab, name); + if (i == NULL) { + error("invalid device `%s'", name); + return; + } + ib = i->i_base; + + if (split(at, strlen(at), atbuf, sizeof atbuf, &atunit)) { + error("invalid attachment name `%s'", at); + return; + } + cp = intern(atbuf); + ab = ht_lookup(devbasetab, cp); + if (ab == NULL) { + error("invalid attachment device `%s'", cp); + return; + } + for (nv = ab->d_attrs; nv != NULL; nv = nv->nv_next) { + attr = nv->nv_ptr; + if (onlist(attr->a_devs, ib)) + goto foundattachment; + } + error("%s's cannot attach to %s's", ib->d_name, atbuf); + return; + +foundattachment: + while (i && (i->i_atdev != ab)) + i = i->i_alias; + if (i == NULL) { + error("%s at %s not found", name, at); + return; + } + else + i->i_disable = 0; /* Enable */ +} + +/* * Add the named device as attaching to the named attribute (or perhaps * another device instead) plus unit number. */ diff --git a/usr.sbin/config/sem.h b/usr.sbin/config/sem.h index 3dd75d4e745..64949806b40 100644 --- a/usr.sbin/config/sem.h +++ b/usr.sbin/config/sem.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sem.h,v 1.6 1997/01/18 02:24:20 briggs Exp $ */ +/* $OpenBSD: sem.h,v 1.7 2001/01/23 06:02:59 angelos Exp $ */ /* $NetBSD: sem.h,v 1.6 1996/11/11 23:40:10 gwr Exp $ */ /* @@ -61,6 +61,7 @@ void setmajor __P((struct devbase *d, int n)); void addconf __P((struct config *)); void setconf __P((struct nvlist **, const char *, struct nvlist *)); void adddev __P((const char *, const char *, struct nvlist *, int, int)); +void enabledev __P((const char *, const char *)); void addpseudo __P((const char *name, int number)); const char *ref __P((const char *name)); const char *starref __P((const char *name)); |