diff options
author | 2008-03-24 21:35:03 +0000 | |
---|---|---|
committer | 2008-03-24 21:35:03 +0000 | |
commit | 1eb41ac0f71ee4d9f571a6eb09c4ff0e05e0f6f2 (patch) | |
tree | 9fcb44d88847592d9a93196a7a9092202803c74e | |
parent | add "sparc64" to .Dt; (diff) | |
download | wireguard-openbsd-1eb41ac0f71ee4d9f571a6eb09c4ff0e05e0f6f2.tar.xz wireguard-openbsd-1eb41ac0f71ee4d9f571a6eb09c4ff0e05e0f6f2.zip |
Make it possible to disable/enable pseudo devices in UKC, config file and
at config -e. -moj ok deraadt@
-rw-r--r-- | sys/kern/subr_userconf.c | 35 | ||||
-rw-r--r-- | usr.sbin/config/gram.y | 4 | ||||
-rw-r--r-- | usr.sbin/config/mkioconf.c | 9 | ||||
-rw-r--r-- | usr.sbin/config/sem.c | 5 | ||||
-rw-r--r-- | usr.sbin/config/sem.h | 4 | ||||
-rw-r--r-- | usr.sbin/config/ukcutil.c | 39 |
6 files changed, 72 insertions, 24 deletions
diff --git a/sys/kern/subr_userconf.c b/sys/kern/subr_userconf.c index f43115f7a60..b60aa9af7c8 100644 --- a/sys/kern/subr_userconf.c +++ b/sys/kern/subr_userconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_userconf.c,v 1.34 2005/12/09 09:09:52 jsg Exp $ */ +/* $OpenBSD: subr_userconf.c,v 1.35 2008/03/24 21:35:03 maja Exp $ */ /* * Copyright (c) 1996-2001 Mats O Jansson <moj@stacken.kth.se> @@ -257,9 +257,12 @@ userconf_pdev(short devno) if (devno > userconf_totdev && devno <= userconf_totdev+pdevnames_size) { - printf("%3d %s count %d (pseudo device)\n", devno, + printf("%3d %s count %d", devno, pdevnames[devno-userconf_totdev-1], - pdevinit[devno-userconf_totdev-1].pdev_count); + abs(pdevinit[devno-userconf_totdev-1].pdev_count)); + if (pdevinit[devno-userconf_totdev-1].pdev_count < 1) + printf(" disable"); + printf(" (pseudo device)\n"); return; } @@ -598,8 +601,17 @@ userconf_disable(int devno) if (devno > userconf_totdev && devno <= userconf_totdev+pdevnames_size) { - printf("%3d %s can't disable pseudo device\n", devno, - pdevnames[devno-userconf_totdev-1]); + printf("%3d %", devno, pdevnames[devno-userconf_totdev-1]); + if (pdevinit[devno-userconf_totdev-1].pdev_count < 1) { + printf(" already "); + } else { + pdevinit[devno-userconf_totdev-1].pdev_count *= -1; + /* XXX add cmd 'd' <devno> eoc */ + userconf_hist_cmd('d'); + userconf_hist_int(devno); + userconf_hist_eoc(); + } + printf(" disabled\n"); return; } @@ -649,8 +661,17 @@ userconf_enable(int devno) if (devno > userconf_totdev && devno <= userconf_totdev+pdevnames_size) { - printf("%3d %s can't enable pseudo device\n", devno, - pdevnames[devno-userconf_totdev-1]); + printf("%3d %", devno, pdevnames[devno-userconf_totdev-1]); + if (pdevinit[devno-userconf_totdev-1].pdev_count > 0) { + printf(" already"); + } else { + pdevinit[devno-userconf_totdev-1].pdev_count *= -1; + /* XXX add cmd 'e' <devno> eoc */ + userconf_hist_cmd('e'); + userconf_hist_int(devno); + userconf_hist_eoc(); + } + printf(" enabled\n"); return; } 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; } } |