summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorMats O Jansson <maja@cvs.openbsd.org>2008-03-24 21:35:04 +0000
committerMats O Jansson <maja@cvs.openbsd.org>2008-03-24 21:35:04 +0000
commitad7fc670c0c5123083d2a7d3cb35f96026e7fdf7 (patch)
treead6463d479a29b8fc76413749bec82159aae625e /usr.sbin
parent7faefa92c49f7130c68e4c5d7f86a2df68e94a75 (diff)
Make it possible to disable/enable pseudo devices in UKC, config file and
at config -e. -moj ok deraadt@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/config/gram.y4
-rw-r--r--usr.sbin/config/mkioconf.c9
-rw-r--r--usr.sbin/config/sem.c5
-rw-r--r--usr.sbin/config/sem.h4
-rw-r--r--usr.sbin/config/ukcutil.c39
5 files changed, 44 insertions, 17 deletions
diff --git a/usr.sbin/config/gram.y b/usr.sbin/config/gram.y
index 265fd011b30..0cbd36abcf1 100644
--- a/usr.sbin/config/gram.y
+++ b/usr.sbin/config/gram.y
@@ -1,5 +1,5 @@
%{
-/* $OpenBSD: gram.y,v 1.21 2008/03/22 22:35:15 deraadt Exp $ */
+/* $OpenBSD: gram.y,v 1.22 2008/03/24 21:35:03 maja Exp $ */
/* $NetBSD: gram.y,v 1.14 1997/02/02 21:12:32 thorpej Exp $ */
/*
@@ -346,7 +346,7 @@ config_spec:
MAKEOPTIONS mkopt_list |
MAXUSERS NUMBER { setmaxusers($2); } |
CONFIG conf sysparam_list { addconf(&conf); } |
- PSEUDO_DEVICE WORD npseudo { addpseudo($2, $3); } |
+ PSEUDO_DEVICE WORD npseudo disable { addpseudo($2, $3, $4); } |
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/mkioconf.c b/usr.sbin/config/mkioconf.c
index 374a2115fbc..2534d0826ef 100644
--- a/usr.sbin/config/mkioconf.c
+++ b/usr.sbin/config/mkioconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mkioconf.c,v 1.27 2005/01/02 21:59:33 deraadt Exp $ */
+/* $OpenBSD: mkioconf.c,v 1.28 2008/03/24 21:35:03 maja Exp $ */
/* $NetBSD: mkioconf.c,v 1.41 1996/11/11 14:18:49 mycroft Exp $ */
/*
@@ -449,7 +449,7 @@ emitpseudo(FILE *fp)
{
struct devi *i;
struct devbase *d;
- int cnt = 0;
+ int cnt = 0, umax;
if (fputs("\n/* pseudo-devices */\n", fp) < 0)
return (1);
@@ -473,8 +473,11 @@ emitpseudo(FILE *fp)
return (1);
for (i = allpseudo; i != NULL; i = i->i_next) {
d = i->i_base;
+ umax = d->d_umax;
+ if (i->i_disable)
+ umax*=-1;
if (fprintf(fp, "\t{ %sattach, %d },\n",
- d->d_name, d->d_umax) < 0)
+ d->d_name, umax) < 0)
return (1);
}
return (fputs("\t{ NULL, 0 }\n};\n", fp) < 0);
diff --git a/usr.sbin/config/sem.c b/usr.sbin/config/sem.c
index 3d5e60491c5..a3aff9f4f6a 100644
--- a/usr.sbin/config/sem.c
+++ b/usr.sbin/config/sem.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sem.c,v 1.30 2004/01/04 18:30:05 deraadt Exp $ */
+/* $OpenBSD: sem.c,v 1.31 2008/03/24 21:35:03 maja Exp $ */
/* $NetBSD: sem.c,v 1.10 1996/11/11 23:40:11 gwr Exp $ */
/*
@@ -888,7 +888,7 @@ bad:
}
void
-addpseudo(const char *name, int number)
+addpseudo(const char *name, int number, int disable)
{
struct devbase *d;
struct devi *i;
@@ -910,6 +910,7 @@ addpseudo(const char *name, int number)
i = newdevi(name, number - 1, d); /* foo 16 => "foo0..foo15" */
if (ht_insert(devitab, name, i))
panic("addpseudo(%s)", name);
+ i->i_disable = disable;
selectbase(d, NULL);
*nextpseudo = i;
nextpseudo = &i->i_next;
diff --git a/usr.sbin/config/sem.h b/usr.sbin/config/sem.h
index dbf27e91618..4fbfcd6793a 100644
--- a/usr.sbin/config/sem.h
+++ b/usr.sbin/config/sem.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sem.h,v 1.12 2003/06/28 04:55:07 deraadt Exp $ */
+/* $OpenBSD: sem.h,v 1.13 2008/03/24 21:35:03 maja Exp $ */
/* $NetBSD: sem.h,v 1.6 1996/11/11 23:40:10 gwr Exp $ */
/*
@@ -57,7 +57,7 @@ void addconf(struct config *);
void setconf(struct nvlist **, const char *, struct nvlist *);
void adddev(const char *, const char *, struct nvlist *, int, int);
void enabledev(const char *, const char *);
-void addpseudo(const char *name, int number);
+void addpseudo(const char *name, int number, int disable);
const char *ref(const char *name);
const char *starref(const char *name);
const char *wildref(const char *name);
diff --git a/usr.sbin/config/ukcutil.c b/usr.sbin/config/ukcutil.c
index ce38166c26a..c800a7eeb09 100644
--- a/usr.sbin/config/ukcutil.c
+++ b/usr.sbin/config/ukcutil.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ukcutil.c,v 1.16 2008/03/23 15:00:29 maja Exp $ */
+/* $OpenBSD: ukcutil.c,v 1.17 2008/03/24 21:35:03 maja Exp $ */
/*
* Copyright (c) 1999-2001 Mats O Jansson. All rights reserved.
@@ -25,7 +25,7 @@
*/
#ifndef LINT
-static char rcsid[] = "$OpenBSD: ukcutil.c,v 1.16 2008/03/23 15:00:29 maja Exp $";
+static char rcsid[] = "$OpenBSD: ukcutil.c,v 1.17 2008/03/24 21:35:03 maja Exp $";
#endif
#include <sys/types.h>
@@ -183,9 +183,12 @@ pdev(short devno)
}
if (devno > totdev && devno <= totdev + maxpseudo) {
pi = get_pdevinit(devno - totdev -1);
- printf("%3d %s count %d (pseudo device)\n", devno,
+ printf("%3d %s count %d", devno,
get_pdevnames(devno - totdev - 1),
- pi->pdev_count);
+ abs(pi->pdev_count));
+ if (pi->pdev_count < 0)
+ printf(" disable");
+ printf(" (pseudo device)\n");
return;
}
}
@@ -602,6 +605,7 @@ void
disable(int devno)
{
struct cfdata *cd;
+ struct pdevinit *pi;
int done = 0;
if (devno <= maxdev) {
@@ -642,8 +646,17 @@ disable(int devno)
return;
}
if (devno > totdev && devno <= totdev + maxpseudo) {
- printf("%3d %s can't disable pseudo device\n", devno,
- get_pdevnames(devno - totdev - 1));
+ pi = get_pdevinit(devno-totdev-1);
+
+ printf("%3d %s", devno,
+ get_pdevnames(devno - totdev - 1));
+ if (pi->pdev_count < 1) {
+ printf(" already");
+ } else {
+ ukc_mod_kernel = 1;
+ pi->pdev_count*=-1;
+ }
+ printf(" disabled\n");
return;
}
}
@@ -656,6 +669,7 @@ void
enable(int devno)
{
struct cfdata *cd;
+ struct pdevinit *pi;
int done = 0;
if (devno <= maxdev) {
@@ -695,8 +709,17 @@ enable(int devno)
return;
}
if (devno > totdev && devno <= totdev + maxpseudo) {
- printf("%3d %s can't enable pseudo device\n", devno,
- get_pdevnames(devno - totdev - 1));
+ pi = get_pdevinit(devno-totdev-1);
+
+ printf("%3d %s", devno,
+ get_pdevnames(devno - totdev - 1));
+ if (pi->pdev_count > 0) {
+ printf(" already");
+ } else {
+ ukc_mod_kernel = 1;
+ pi->pdev_count*=-1;
+ }
+ printf(" enabled\n");
return;
}
}