summaryrefslogtreecommitdiff
path: root/usr.sbin/config/sem.c
diff options
context:
space:
mode:
authorAngelos D. Keromytis <angelos@cvs.openbsd.org>2001-01-23 06:03:00 +0000
committerAngelos D. Keromytis <angelos@cvs.openbsd.org>2001-01-23 06:03:00 +0000
commitd0a5fa42f1b6ebc23d23f9c1ba8eafa468923561 (patch)
tree263e53231c7486b99b42d7dcf3a7615869a75fb2 /usr.sbin/config/sem.c
parent0d359a25c5e8b08e0beec6bc5d040d7bb39b8f3b (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/sem.c')
-rw-r--r--usr.sbin/config/sem.c53
1 files changed, 52 insertions, 1 deletions
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.
*/