diff options
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/config/cmd.c | 12 | ||||
-rw-r--r-- | usr.sbin/config/mkioconf.c | 15 | ||||
-rw-r--r-- | usr.sbin/config/ukc.c | 22 | ||||
-rw-r--r-- | usr.sbin/config/ukc.h | 30 | ||||
-rw-r--r-- | usr.sbin/config/ukcutil.c | 163 |
5 files changed, 216 insertions, 26 deletions
diff --git a/usr.sbin/config/cmd.c b/usr.sbin/config/cmd.c index cba1816ee1a..029ecc90332 100644 --- a/usr.sbin/config/cmd.c +++ b/usr.sbin/config/cmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd.c,v 1.4 2001/01/31 22:41:32 maja Exp $ */ +/* $OpenBSD: cmd.c,v 1.5 2001/02/04 20:42:12 maja Exp $ */ /* * Copyright (c) 1999-2001 Mats O Jansson. All rights reserved. @@ -30,7 +30,7 @@ */ #ifndef LINT -static char rcsid[] = "$OpenBSD: cmd.c,v 1.4 2001/01/31 22:41:32 maja Exp $"; +static char rcsid[] = "$OpenBSD: cmd.c,v 1.5 2001/02/04 20:42:12 maja Exp $"; #endif #include <sys/types.h> @@ -230,6 +230,14 @@ Xlist(cmd) cd++; } + if (nopdev == 0) { + while(i <= (totdev+maxpseudo)) { + if (more()) + break; + pdev(i++); + } + } + cnt = -1; return (CMD_CONT); diff --git a/usr.sbin/config/mkioconf.c b/usr.sbin/config/mkioconf.c index 980a7ae3f3e..1547bfc2370 100644 --- a/usr.sbin/config/mkioconf.c +++ b/usr.sbin/config/mkioconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mkioconf.c,v 1.15 1999/10/02 07:38:20 deraadt Exp $ */ +/* $OpenBSD: mkioconf.c,v 1.16 2001/02/04 20:42:12 maja Exp $ */ /* $NetBSD: mkioconf.c,v 1.41 1996/11/11 14:18:49 mycroft Exp $ */ /* @@ -464,6 +464,7 @@ emitpseudo(fp) { register struct devi *i; register struct devbase *d; + int cnt = 0; if (fputs("\n/* pseudo-devices */\n", fp) < 0) return (1); @@ -471,6 +472,18 @@ emitpseudo(fp) if (fprintf(fp, "extern void %sattach __P((int));\n", i->i_base->d_name) < 0) return (1); + if (fputs("\nchar *pdevnames[] = {\n", fp) < 0) + return (1); + for (i = allpseudo; i != NULL; i = i->i_next) { + d = i->i_base; + if (fprintf(fp, "\t\"%s\",\n", d->d_name) < 0) + return (1); + cnt++; + } + if (fputs("};\n", fp) < 0) + return (1); + if (fprintf(fp, "\nint pdevnames_size = %d;\n", cnt) < 0) + return (1); if (fputs("\nstruct pdevinit pdevinit[] = {\n", fp) < 0) return (1); for (i = allpseudo; i != NULL; i = i->i_next) { diff --git a/usr.sbin/config/ukc.c b/usr.sbin/config/ukc.c index 2a455d3d7f2..a8b52805d48 100644 --- a/usr.sbin/config/ukc.c +++ b/usr.sbin/config/ukc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ukc.c,v 1.4 2001/01/31 22:41:32 maja Exp $ */ +/* $OpenBSD: ukc.c,v 1.5 2001/02/04 20:42:12 maja Exp $ */ /* * Copyright (c) 1999-2001 Mats O Jansson. All rights reserved. @@ -30,7 +30,7 @@ */ #ifndef LINT -static char rcsid[] = "$OpenBSD: ukc.c,v 1.4 2001/01/31 22:41:32 maja Exp $"; +static char rcsid[] = "$OpenBSD: ukc.c,v 1.5 2001/02/04 20:42:12 maja Exp $"; #endif #include <sys/types.h> @@ -124,8 +124,6 @@ ukc(file, outfile, uflag, force) if (force == 0 && outfile == NULL) printf("warning: no output file specified\n"); - init(); - if ((nl[IA_EXTRALOC].n_type == 0) || (nl[I_NEXTRALOC].n_type == 0) || (nl[I_UEXTRALOC].n_type == 0) || @@ -137,6 +135,16 @@ WARNING the commands add and change might not work.\n"); oldkernel = 1; } + if ((nl[P_PDEVNAMES].n_type == 0) || + (nl[I_PDEVSIZE].n_type == 0) || + (nl[S_PDEVINIT].n_type == 0)) { + printf("\ +WARNING this kernel doesn't support pseudo devices.\n"); + nopdev = 1; + } + + init(); + if (uflag) { if (ok) { if (strcmp(adjust((caddr_t)nl[P_VERSION].n_value), @@ -177,6 +185,7 @@ init() int i = 0,fd; struct cfdata *cd; short *ln; + int *p; #ifdef NOTDEF struct winsize w; #endif @@ -205,6 +214,11 @@ init() totdev = totdev - 1; + if (nopdev == 0) { + p = (int *)adjust((caddr_t)nl[I_PDEVSIZE].n_value); + maxpseudo = *p; + } + if ((fd = open("/dev/tty", O_RDWR)) < 0) fd = 2; diff --git a/usr.sbin/config/ukc.h b/usr.sbin/config/ukc.h index 0188a2d26f5..a11280e1836 100644 --- a/usr.sbin/config/ukc.h +++ b/usr.sbin/config/ukc.h @@ -1,7 +1,7 @@ -/* $OpenBSD: ukc.h,v 1.3 2001/01/24 20:12:27 art Exp $ */ +/* $OpenBSD: ukc.h,v 1.4 2001/02/04 20:42:12 maja Exp $ */ /* - * Copyright (c) 1999 Mats O Jansson. All rights reserved. + * Copyright (c) 1999-2001 Mats O Jansson. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -47,7 +47,10 @@ #define I_HISTLEN 12 #define CA_HISTORY 13 #define TZ_TZ 14 -#define NLENTRIES 15 +#define P_PDEVNAMES 15 +#define I_PDEVSIZE 16 +#define S_PDEVINIT 17 +#define NLENTRIES 18 #ifdef UKC_MAIN struct nlist nl[] = { @@ -66,6 +69,9 @@ struct nlist nl[] = { { "_userconf_histlen" }, { "_userconf_history" }, { "_tz" }, + { "_pdevnames" }, + { "_pdevnames_size" }, + { "_pdevinit" }, { NULL }, }; struct nlist knl[] = { @@ -84,30 +90,39 @@ struct nlist knl[] = { { "_userconf_histlen" }, { "_userconf_history" }, { "_tz" }, + { "_pdevnames" }, + { "_pdevnames_size" }, + { "_pdevinit" }, { NULL }, }; int maxdev = 0; int totdev = 0; +int maxpseudo = 0; int maxlocnames = 0; int base = 16; int cnt = -1; int lines = 18; int oldkernel = 0; +int nopdev = 0; #else extern struct nlist nl[]; extern int maxdev; extern int totdev; +extern int maxpseudo; extern int maxlocnames; extern int base; extern int cnt; extern int lines; extern int oldkernel; +extern int nopdev; #endif -struct cfdata *get_cfdata __P((int)); -short *get_locnamp __P((int)); -caddr_t *get_locnames __P((int)); -int *get_extraloc __P((int)); +struct cfdata *get_cfdata __P((int)); +short *get_locnamp __P((int)); +caddr_t *get_locnames __P((int)); +int *get_extraloc __P((int)); +caddr_t *get_pdevnames __P((int)); +struct pdevinit *get_pdevinit __P((int)); int more __P(()); void pnum __P((int)); @@ -139,3 +154,4 @@ void process_history __P((int, char *)); #endif _UTIL_H + diff --git a/usr.sbin/config/ukcutil.c b/usr.sbin/config/ukcutil.c index c7c52ab4052..4b62684f664 100644 --- a/usr.sbin/config/ukcutil.c +++ b/usr.sbin/config/ukcutil.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ukcutil.c,v 1.5 2001/01/31 22:41:32 maja Exp $ */ +/* $OpenBSD: ukcutil.c,v 1.6 2001/02/04 20:42:12 maja Exp $ */ /* * Copyright (c) 1999-2001 Mats O Jansson. All rights reserved. @@ -30,7 +30,7 @@ */ #ifndef LINT -static char rcsid[] = "$OpenBSD: ukcutil.c,v 1.5 2001/01/31 22:41:32 maja Exp $"; +static char rcsid[] = "$OpenBSD: ukcutil.c,v 1.6 2001/02/04 20:42:12 maja Exp $"; #endif #include <sys/types.h> @@ -81,6 +81,26 @@ get_extraloc(idx) idx*sizeof(int))); } +caddr_t * +get_pdevnames(idx) + int idx; +{ + caddr_t *p; + + p = (caddr_t *)adjust((caddr_t)nl[P_PDEVNAMES].n_value + + idx*sizeof(caddr_t)); + return(caddr_t *)adjust((caddr_t)*p); + +} + +struct pdevinit * +get_pdevinit(idx) + int idx; +{ + return((struct pdevinit *)(adjust((caddr_t)nl[S_PDEVINIT].n_value) + + idx*sizeof(struct pdevinit))); +} + int more() { @@ -169,8 +189,23 @@ pdev(devno) int *i; caddr_t *p; char c; + struct pdevinit *pi; + + if (nopdev == 0) { + if ((devno > maxdev) && (devno <= totdev)) { + printf("%3d free slot (for add)\n", devno); + return; + } + if ((devno > totdev) && (devno <= (totdev+maxpseudo))) { + pi = get_pdevinit(devno-totdev-1); + printf("%3d %s count %d (pseudo device)\n", devno, + get_pdevnames(devno-totdev-1), + pi->pdev_count); + return; + } + } - if (devno > maxdev) { + if (devno > maxdev) { printf("Unknown devno (max is %d)\n", maxdev); return; } @@ -374,6 +409,7 @@ change(devno) { struct cfdata *cd,*c; caddr_t *p; + struct pdevinit *pi; int i,share = 0,*j,*k,*l; short *ln,*lk; @@ -452,9 +488,31 @@ change(devno) printf(" changed\n"); pdev(devno); } - } else { - printf("Unknown devno (max is %d)\n", maxdev); + return; + } + + if (nopdev == 0) { + if ((devno > maxdev) && (devno <= totdev)) { + printf("%3d can't change free slot\n", devno); + return; + } + if ((devno > totdev) && (devno <= (totdev+maxpseudo))) { + + pdev(devno); + + if (ask_yn("change")) { + + pi = get_pdevinit(devno-totdev-1); + + modify("count", &pi->pdev_count); + printf("%3d %s changed\n", devno, get_pdevnames(devno-totdev-1)); + pdev(devno); + } + return; + } } + + printf("Unknown devno (max is %d)\n", totdev+maxpseudo); } void @@ -464,6 +522,7 @@ change_history(devno,str) { struct cfdata *cd,*c; caddr_t *p; + struct pdevinit *pi; int i,share = 0,*j,*k,*l; short *ln,*lk; @@ -549,9 +608,35 @@ change_history(devno,str) printf(" changed\n"); pdev(devno); - } else { - printf("Unknown devno (max is %d)\n", maxdev); + return; + } + + if (nopdev == 0) { + if ((devno > maxdev) && (devno <= totdev)) { + printf("%3d can't change free slot\n", devno); + return; + } + if ((devno > totdev) && (devno <= (totdev+maxpseudo))) { + + pdev(devno); + + pi = get_pdevinit(devno-totdev-1); + + if (*str) { + pi->pdev_count = atoi(str); + if (*str == '-') str++; + while ((*str >= '0') && (*str <= '9')) str++; + if (*str == ' ') str++; + } + + printf("%3d %s changed\n", devno, get_pdevnames(devno-totdev-1)); + pdev(devno); + + return; + } } + + printf("Unknown devno (max is %d)\n", totdev+maxpseudo); } void @@ -588,9 +673,24 @@ disable(devno) if (done) printf(" already"); printf(" disabled\n"); - } else { - printf("Unknown devno (max is %d)\n", maxdev); + + return; } + + if (nopdev == 0) { + if ((devno > maxdev) && (devno <= totdev)) { + printf("%3d can't disable free slot\n", devno); + return; + } + if ((devno > totdev) && (devno <= (totdev+maxpseudo))) { + printf("%3d %s can't disable pseudo device\n", devno, + get_pdevnames(devno-totdev-1)); + return; + } + } + + printf("Unknown devno (max is %d)\n", totdev+maxpseudo); + } void @@ -627,9 +727,23 @@ enable(devno) if (done) printf(" already"); printf(" enabled\n"); - } else { - printf("Unknown devno (max is %d)\n", maxdev); + + return; } + + if (nopdev == 0) { + if ((devno > maxdev) && (devno <= totdev)) { + printf("%3d can't enable free slot\n", devno); + return; + } + if ((devno > totdev) && (devno <= (totdev+maxpseudo))) { + printf("%3d %s can't enable pseudo device\n", devno, + get_pdevnames(devno-totdev-1)); + return; + } + } + + printf("Unknown devno (max is %d)\n", totdev+maxpseudo); } void @@ -827,6 +941,31 @@ common_dev(dev, len, unit, state, routine) cd++; } + if (nopdev == 0) { + for (i = 0; i < maxpseudo; i++) { + if ((strncasecmp(dev,(char *)get_pdevnames(i), + len) == 0) && (state == FSTATE_FOUND)) { + switch(routine) { + case UC_CHANGE: + change(totdev+1+i); + break; + case UC_ENABLE: + enable(totdev+1+i); + break; + case UC_DISABLE: + disable(totdev+1+i); + break; + case UC_FIND: + pdev(totdev+1+i); + break; + default: + printf("Unknown pseudo routine /%c/\n",routine); + break; + } + } + } + } + switch (routine) { case UC_CHANGE: break; @@ -943,7 +1082,7 @@ add(dev, len, unit, state) } if (state == FSTATE_FOUND) { - printf("Device not complete number or * is missing/n"); + printf("Device not complete number or * is missing\n"); return; } |