summaryrefslogtreecommitdiff
path: root/usr.sbin/config
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2001-12-05 10:11:24 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2001-12-05 10:11:24 +0000
commitb7540bedf1d5e2e1ee1480acc776e01f66979f0f (patch)
treee9a75b6605e8224a846e7d17749c9018608af60e /usr.sbin/config
parentd909564c7bbe37a759e85c032005836550fe28bc (diff)
more free KNF from maja, though this was hard to do
Diffstat (limited to 'usr.sbin/config')
-rw-r--r--usr.sbin/config/cmd.c41
-rw-r--r--usr.sbin/config/config.h8
-rw-r--r--usr.sbin/config/exec.c6
-rw-r--r--usr.sbin/config/exec_aout.c22
-rw-r--r--usr.sbin/config/exec_ecoff.c26
-rw-r--r--usr.sbin/config/exec_elf.c27
-rw-r--r--usr.sbin/config/files.c20
-rw-r--r--usr.sbin/config/main.c4
-rw-r--r--usr.sbin/config/mkmakefile.c6
-rw-r--r--usr.sbin/config/sem.c4
-rw-r--r--usr.sbin/config/ukc.c87
-rw-r--r--usr.sbin/config/ukc.h4
-rw-r--r--usr.sbin/config/ukcutil.c406
13 files changed, 320 insertions, 341 deletions
diff --git a/usr.sbin/config/cmd.c b/usr.sbin/config/cmd.c
index 029ecc90332..915eea8f64e 100644
--- a/usr.sbin/config/cmd.c
+++ b/usr.sbin/config/cmd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd.c,v 1.5 2001/02/04 20:42:12 maja Exp $ */
+/* $OpenBSD: cmd.c,v 1.6 2001/12/05 10:11:23 deraadt 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.5 2001/02/04 20:42:12 maja Exp $";
+static char rcsid[] = "$OpenBSD: cmd.c,v 1.6 2001/12/05 10:11:23 deraadt Exp $";
#endif
#include <sys/types.h>
@@ -85,8 +85,8 @@ int
Xadd(cmd)
cmd_t *cmd;
{
- int a;
short unit, state;
+ int a;
if (strlen(cmd->args) == 0)
printf("Dev expected\n");
@@ -113,7 +113,6 @@ Xbase(cmd)
}
} else
printf("Unknown argument\n");
-
return (CMD_CONT);
}
@@ -121,8 +120,8 @@ int
Xchange(cmd)
cmd_t *cmd;
{
- int a;
short unit, state;
+ int a;
if (strlen(cmd->args) == 0)
printf("DevNo or Dev expected\n");
@@ -132,7 +131,6 @@ Xchange(cmd)
common_dev(cmd->args, a, unit, state, UC_CHANGE);
else
printf("Unknown argument\n");
-
return (CMD_CONT);
}
@@ -140,8 +138,8 @@ int
Xdisable(cmd)
cmd_t *cmd;
{
- int a;
short unit, state;
+ int a;
if (strlen(cmd->args) == 0)
printf("Attr, DevNo or Dev expected\n");
@@ -153,7 +151,6 @@ Xdisable(cmd)
common_dev(cmd->args, a, unit, state, UC_DISABLE);
else
printf("Unknown argument\n");
-
return (CMD_CONT);
}
@@ -161,8 +158,8 @@ int
Xenable(cmd)
cmd_t *cmd;
{
- int a;
short unit, state;
+ int a;
if (strlen(cmd->args) == 0)
printf("Attr, DevNo or Dev expected\n");
@@ -174,7 +171,6 @@ Xenable(cmd)
common_dev(cmd->args, a, unit, state, UC_ENABLE);
else
printf("Unknown argument\n");
-
return (CMD_CONT);
}
@@ -182,8 +178,8 @@ int
Xfind(cmd)
cmd_t *cmd;
{
- int a;
short unit, state;
+ int a;
if (strlen(cmd->args) == 0)
printf("DevNo or Dev expected\n");
@@ -193,7 +189,6 @@ Xfind(cmd)
common_dev(cmd->args, a, unit, state, UC_FIND);
else
printf("Unknown argument\n");
-
return (CMD_CONT);
}
@@ -216,30 +211,27 @@ int
Xlist(cmd)
cmd_t *cmd;
{
- int i = 0;
struct cfdata *cd;
+ int i = 0;
cnt = 0;
-
cd = get_cfdata(0);
- while(cd->cf_attach != 0) {
+ while (cd->cf_attach != 0) {
if (more())
break;
- pdev(i++);
+ pdev(i++);
cd++;
}
if (nopdev == 0) {
- while(i <= (totdev+maxpseudo)) {
+ while (i <= (totdev+maxpseudo)) {
if (more())
break;
pdev(i++);
}
}
-
cnt = -1;
-
return (CMD_CONT);
}
@@ -251,7 +243,6 @@ Xshow(cmd)
show();
else
show_attr(&cmd->args[0]);
-
return (CMD_CONT);
}
@@ -280,27 +271,25 @@ Xtimezone(cmd)
char *c;
ukc_mod_kernel = 1;
-
tz = (struct timezone *)adjust((caddr_t)(nl[TZ_TZ].n_value));
if (strlen(cmd->args) == 0) {
- printf("timezone = %d, dst = %d\n",
+ printf("timezone = %d, dst = %d\n",
tz->tz_minuteswest, tz->tz_dsttime);
} else {
if (number(cmd->args, &num) == 0) {
tz->tz_minuteswest = num;
- c = cmd->args;
+ c = cmd->args;
while ((*c != '\0') && !isspace(*c))
c++;
while ((*c != '\0') && isspace(*c))
c++;
if (strlen(c) != 0 && number(c, &num) == 0)
tz->tz_dsttime = num;
- printf("timezone = %d, dst = %d\n",
+ printf("timezone = %d, dst = %d\n",
tz->tz_minuteswest, tz->tz_dsttime);
- } else
+ } else
printf("Unknown argument\n");
}
-
return (CMD_CONT);
}
diff --git a/usr.sbin/config/config.h b/usr.sbin/config/config.h
index 45ef2683104..426b15447f6 100644
--- a/usr.sbin/config/config.h
+++ b/usr.sbin/config/config.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: config.h,v 1.14 2000/01/04 14:23:43 angelos Exp $ */
+/* $OpenBSD: config.h,v 1.15 2001/12/05 10:11:23 deraadt Exp $ */
/* $NetBSD: config.h,v 1.30 1997/02/02 21:12:30 thorpej Exp $ */
/*
@@ -59,7 +59,7 @@
#if defined(__STDC__) || defined(__cplusplus)
#define __P(protos) protos /* full-blown ANSI C */
#else /* ...STDC */
-#define __P(protos) () /* traditional C preprocessor */
+#define __P(protos) () /* traditional C preprocessor */
#endif /* ...STDC */
#endif /* ...BSD */
@@ -222,11 +222,11 @@ struct devi {
* Files. Each file is either standard (always included) or optional,
* depending on whether it has names on which to *be* optional. The
* options field (fi_optx) is actually an expression tree, with nodes
- * for OR, AND, and NOT, as well as atoms (words) representing some
+ * for OR, AND, and NOT, as well as atoms (words) representing some
* particular option. The node type is stored in the nv_int field.
* Subexpressions appear in the `next' field; for the binary operators
* AND and OR, the left subexpression is first stored in the nv_ptr field.
- *
+ *
* For any file marked as needs-count or needs-flag, fixfiles() will
* build fi_optf, a `flat list' of the options with nv_int fields that
* contain counts or `need' flags; this is used in mkheaders().
diff --git a/usr.sbin/config/exec.c b/usr.sbin/config/exec.c
index cebe4df885c..ece46bc69ab 100644
--- a/usr.sbin/config/exec.c
+++ b/usr.sbin/config/exec.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: exec.c,v 1.1 1999/10/04 20:00:51 deraadt Exp $ */
+/* $OpenBSD: exec.c,v 1.2 2001/12/05 10:11:23 deraadt Exp $ */
/*
* Copyright (c) 1999 Mats O Jansson. All rights reserved.
@@ -34,7 +34,7 @@
#include <stdio.h>
#ifndef LINT
-static char rcsid[] = "$OpenBSD: exec.c,v 1.1 1999/10/04 20:00:51 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: exec.c,v 1.2 2001/12/05 10:11:23 deraadt Exp $";
#endif
#ifdef AOUT_SUPPORT
@@ -67,7 +67,7 @@ caddr_t elf_readjust __P((caddr_t));
int current_exec = -1;
-caddr_t
+caddr_t
adjust(x)
caddr_t x;
{
diff --git a/usr.sbin/config/exec_aout.c b/usr.sbin/config/exec_aout.c
index 1e5c4c2f85d..c481b455aaf 100644
--- a/usr.sbin/config/exec_aout.c
+++ b/usr.sbin/config/exec_aout.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: exec_aout.c,v 1.2 2000/09/30 16:06:34 aaron Exp $ */
+/* $OpenBSD: exec_aout.c,v 1.3 2001/12/05 10:11:23 deraadt Exp $ */
/*
* Copyright (c) 1999 Mats O Jansson. All rights reserved.
@@ -30,7 +30,7 @@
*/
#ifndef LINT
-static char rcsid[] = "$OpenBSD: exec_aout.c,v 1.2 2000/09/30 16:06:34 aaron Exp $";
+static char rcsid[] = "$OpenBSD: exec_aout.c,v 1.3 2001/12/05 10:11:23 deraadt Exp $";
#endif
#include <err.h>
@@ -45,11 +45,11 @@ static char rcsid[] = "$OpenBSD: exec_aout.c,v 1.2 2000/09/30 16:06:34 aaron Exp
#include "ukc.h"
-caddr_t aout_p,aout_r;
+caddr_t aout_p, aout_r;
int aout_psz = 0, aout_rsz = 0;
struct exec aout_ex;
-caddr_t
+caddr_t
aout_adjust(x)
caddr_t x;
{
@@ -95,23 +95,23 @@ aout_loadkernel(file)
char *file;
{
int fd;
- off_t cur,end;
+ off_t cur, end;
if ((fd = open(file, O_RDONLY | O_EXLOCK, 0)) < 0)
err(1, "%s", file);
-
+
if (read(fd, (char *)&aout_ex, sizeof(aout_ex)) != sizeof(aout_ex))
errx(1, "can't read a.out header");
-
+
if (N_BADMAG(aout_ex))
errx(1, "bad a.out magic\n");
-
+
(void)lseek(fd, (off_t)0, SEEK_SET);
aout_psz = (int)(aout_ex.a_text+aout_ex.a_data);
-
+
aout_p = malloc(aout_psz);
-
+
if (read(fd, aout_p, aout_psz) != aout_psz)
errx(1, "can't read a.out text and data");
@@ -125,7 +125,7 @@ aout_loadkernel(file)
if (read(fd, aout_r, aout_rsz) != aout_rsz)
errx(1, "can't read rest of file %s", file);
-
+
close(fd);
}
diff --git a/usr.sbin/config/exec_ecoff.c b/usr.sbin/config/exec_ecoff.c
index ec5e76cb487..6bffbbe691e 100644
--- a/usr.sbin/config/exec_ecoff.c
+++ b/usr.sbin/config/exec_ecoff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: exec_ecoff.c,v 1.4 2000/10/29 00:30:33 aaron Exp $ */
+/* $OpenBSD: exec_ecoff.c,v 1.5 2001/12/05 10:11:23 deraadt Exp $ */
/*
* Copyright (c) 1999 Mats O Jansson. All rights reserved.
@@ -30,7 +30,7 @@
*/
#ifndef LINT
-static char rcsid[] = "$OpenBSD: exec_ecoff.c,v 1.4 2000/10/29 00:30:33 aaron Exp $";
+static char rcsid[] = "$OpenBSD: exec_ecoff.c,v 1.5 2001/12/05 10:11:23 deraadt Exp $";
#endif
#include <err.h>
@@ -46,11 +46,11 @@ static char rcsid[] = "$OpenBSD: exec_ecoff.c,v 1.4 2000/10/29 00:30:33 aaron Ex
#include "ukc.h"
-caddr_t ecoff_p,ecoff_r,ecoff_b;
+caddr_t ecoff_p, ecoff_r, ecoff_b;
int ecoff_psz = 0, ecoff_rsz = 0, ecoff_bsz = 0;
struct ecoff_exechdr ecoff_ex;
-caddr_t
+caddr_t
ecoff_adjust(x)
caddr_t x;
{
@@ -76,11 +76,11 @@ int
ecoff_check(file)
char *file;
{
- int fd,ret = 1;
+ int fd, ret = 1;
if ((fd = open(file, O_RDONLY | O_EXLOCK, 0)) < 0)
return (0);
-
+
if (read(fd,(char *)&ecoff_ex, sizeof(ecoff_ex)) != sizeof(ecoff_ex))
ret = 0;
@@ -98,25 +98,25 @@ ecoff_loadkernel(file)
char *file;
{
int fd;
- off_t beg,cur,end;
+ off_t beg, cur, end;
if ((fd = open(file, O_RDONLY | O_EXLOCK, 0)) < 0)
err(1, "%s", file);
-
+
if (read(fd, (char *)&ecoff_ex, sizeof(ecoff_ex)) != sizeof(ecoff_ex))
errx(1, "can't read ecoff header");
-
+
if (ECOFF_BADMAG(&ecoff_ex))
errx(1, "bad ecoff magic\n");
-
+
ecoff_psz = ecoff_ex.a.tsize + ecoff_ex.a.dsize;
beg = lseek(fd, ECOFF_TXTOFF(&ecoff_ex), SEEK_SET);
-
+
ecoff_bsz = (int)beg;
ecoff_b = malloc(ecoff_bsz);
ecoff_p = malloc(ecoff_psz);
-
+
if (read(fd, ecoff_p, ecoff_psz) != ecoff_psz)
errx(1, "can't read ecoff text and data");
@@ -133,7 +133,7 @@ ecoff_loadkernel(file)
if (read(fd, ecoff_r, ecoff_rsz) != ecoff_rsz)
errx(1, "can't read rest of file %s", file);
-
+
close(fd);
}
diff --git a/usr.sbin/config/exec_elf.c b/usr.sbin/config/exec_elf.c
index b28409ff5d5..ce00480c342 100644
--- a/usr.sbin/config/exec_elf.c
+++ b/usr.sbin/config/exec_elf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: exec_elf.c,v 1.3 2001/01/25 05:42:12 art Exp $ */
+/* $OpenBSD: exec_elf.c,v 1.4 2001/12/05 10:11:23 deraadt Exp $ */
/*
* Copyright (c) 1999 Mats O Jansson. All rights reserved.
@@ -30,7 +30,7 @@
*/
#ifndef LINT
-static char rcsid[] = "$OpenBSD: exec_elf.c,v 1.3 2001/01/25 05:42:12 art Exp $";
+static char rcsid[] = "$OpenBSD: exec_elf.c,v 1.4 2001/12/05 10:11:23 deraadt Exp $";
#endif
#include <err.h>
@@ -46,7 +46,7 @@ static char rcsid[] = "$OpenBSD: exec_elf.c,v 1.3 2001/01/25 05:42:12 art Exp $"
#include "ukc.h"
-caddr_t ptr,rest,pre;
+caddr_t ptr, rest, pre;
Elf_Ehdr elf_ex;
Elf_Phdr *elf_phdr;
Elf_Shdr *elf_shdr;
@@ -54,14 +54,14 @@ char *elf_total;
char *elf_shstrtab;
off_t elf_size;
-caddr_t
+caddr_t
elf_adjust(x)
caddr_t x;
{
int i;
Elf_Shdr *s;
unsigned long y = 0;
-
+
s = elf_shdr;
for (i = 0; i < elf_ex.e_shnum; i++) {
@@ -70,8 +70,7 @@ elf_adjust(x)
if (((unsigned long)x >= s[i].sh_addr) &&
((unsigned long)x < (s[i].sh_addr+s[i].sh_size))) {
y = (unsigned long)&elf_total[(unsigned long)x -
- s[i].sh_addr +
- s[i].sh_offset];
+ s[i].sh_addr + s[i].sh_offset];
break;
}
}
@@ -104,11 +103,11 @@ int
elf_check(file)
char *file;
{
- int fd,ret = 1;
+ int fd, ret = 1;
if ((fd = open(file, O_RDONLY | O_EXLOCK, 0)) < 0)
return (0);
-
+
if (read(fd, (char *)&elf_ex, sizeof(elf_ex)) != sizeof(elf_ex))
ret = 0;
@@ -131,13 +130,13 @@ elf_loadkernel(file)
if ((fd = open(file, O_RDONLY | O_EXLOCK, 0)) < 0)
err(1, "%s", file);
-
+
if (read(fd, (char *)&elf_ex, sizeof(elf_ex)) != sizeof(elf_ex))
errx(1, "can't read elf header");
-
+
if (!IS_ELF(elf_ex))
errx(1, "bad elf magic\n");
-
+
elf_size = lseek(fd, 0L, SEEK_END);
(void)lseek(fd, 0L, SEEK_SET);
elf_total = malloc(elf_size);
@@ -150,9 +149,9 @@ elf_loadkernel(file)
p = elf_phdr;
s = elf_shdr;
-
+
elf_shstrtab = &elf_total[elf_shdr[elf_ex.e_shstrndx].sh_offset];
-
+
close(fd);
}
diff --git a/usr.sbin/config/files.c b/usr.sbin/config/files.c
index 5295d2859a8..84eeadcec53 100644
--- a/usr.sbin/config/files.c
+++ b/usr.sbin/config/files.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: files.c,v 1.7 1997/11/13 08:21:53 deraadt Exp $ */
+/* $OpenBSD: files.c,v 1.8 2001/12/05 10:11:23 deraadt Exp $ */
/* $NetBSD: files.c,v 1.6 1996/03/17 13:18:17 cgd Exp $ */
/*
@@ -177,7 +177,7 @@ addobject(path, optx, flags)
error("duplicate file %s", path);
xerror(oi->oi_srcfile, oi->oi_srcline,
"here is the original definition");
- }
+ }
oi->oi_next = NULL;
oi->oi_srcfile = yyfile;
oi->oi_srcline = currentline();
@@ -187,7 +187,7 @@ addobject(path, optx, flags)
oi->oi_optf = NULL;
*nextobject = oi;
nextobject = &oi->oi_next;
-}
+}
/*
* We have finished reading some "files" file, either ../../conf/files
@@ -290,16 +290,16 @@ fixfiles()
return (err);
}
-/*
+/*
* We have finished reading everything. Tack the objects down: calculate
* selection.
- */
-int
+ */
+int
fixobjects()
-{
+{
struct objects *oi;
struct nvlist *flathead, **flatp;
- int err, sel;
+ int err, sel;
err = 0;
for (oi = allobjects; oi != NULL; oi = oi->oi_next) {
@@ -316,10 +316,10 @@ fixobjects()
continue;
}
- oi->oi_flags |= OI_SEL;
+ oi->oi_flags |= OI_SEL;
}
return (err);
-}
+}
/*
* Called when evaluating a needs-count expression. Make sure the
diff --git a/usr.sbin/config/main.c b/usr.sbin/config/main.c
index bdbd6a75975..f0359cb0d2f 100644
--- a/usr.sbin/config/main.c
+++ b/usr.sbin/config/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.20 2000/01/04 14:23:43 angelos Exp $ */
+/* $OpenBSD: main.c,v 1.21 2001/12/05 10:11:23 deraadt Exp $ */
/* $NetBSD: main.c,v 1.22 1997/02/02 21:12:33 thorpej Exp $ */
/*
@@ -694,7 +694,7 @@ optcmp(sp1, sp2)
r = strcmp(sp1->name, sp2->name);
if (r == 0) {
if (!sp1->val && !sp2->val)
- r = 0;
+ r = 0;
else if (sp1->val && !sp2->val)
r = -1;
else if (sp2->val && !sp1->val)
diff --git a/usr.sbin/config/mkmakefile.c b/usr.sbin/config/mkmakefile.c
index a470bf0fe54..962ea278548 100644
--- a/usr.sbin/config/mkmakefile.c
+++ b/usr.sbin/config/mkmakefile.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mkmakefile.c,v 1.8 2001/01/05 02:55:24 angelos Exp $ */
+/* $OpenBSD: mkmakefile.c,v 1.9 2001/12/05 10:11:23 deraadt Exp $ */
/* $NetBSD: mkmakefile.c,v 1.34 1997/02/02 21:12:36 thorpej Exp $ */
/*
@@ -58,8 +58,8 @@
* Make the Makefile.
*/
-static const char *srcpath __P((struct files *));
-
+static const char *srcpath __P((struct files *));
+
static int emitdefs __P((FILE *));
static int emitfiles __P((FILE *, int));
diff --git a/usr.sbin/config/sem.c b/usr.sbin/config/sem.c
index 9a3e112fd53..8e23e9b0d58 100644
--- a/usr.sbin/config/sem.c
+++ b/usr.sbin/config/sem.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sem.c,v 1.21 2001/01/24 20:13:00 art Exp $ */
+/* $OpenBSD: sem.c,v 1.22 2001/12/05 10:11:23 deraadt Exp $ */
/* $NetBSD: sem.c,v 1.10 1996/11/11 23:40:11 gwr Exp $ */
/*
@@ -846,7 +846,7 @@ adddev(name, at, loclist, flags, disable)
*
* (1) If we're attached to an attribute, then we don't need
* look at the parent base device to see what attributes
- * it has, and make sure that we can attach to them.
+ * it has, and make sure that we can attach to them.
*
* (2) If we're attached to a real device (i.e. named in
* the config file), we want to remember that so that
diff --git a/usr.sbin/config/ukc.c b/usr.sbin/config/ukc.c
index a8b52805d48..8e70d42fe5e 100644
--- a/usr.sbin/config/ukc.c
+++ b/usr.sbin/config/ukc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ukc.c,v 1.5 2001/02/04 20:42:12 maja Exp $ */
+/* $OpenBSD: ukc.c,v 1.6 2001/12/05 10:11:23 deraadt 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.5 2001/02/04 20:42:12 maja Exp $";
+static char rcsid[] = "$OpenBSD: ukc.c,v 1.6 2001/12/05 10:11:23 deraadt Exp $";
#endif
#include <sys/types.h>
@@ -69,95 +69,91 @@ ukc(file, outfile, uflag, force)
char errbuf[_POSIX2_LINE_MAX];
int histlen = 0, ok = 1;
char history[1024], kversion[1024];
-
+
if (file == NULL) {
fprintf(stderr, "%s: no file specified\n", __progname);
usage();
}
loadkernel(file);
-
+
ret = nlist(file, nl);
-
+
if (uflag) {
-
if ((kd = kvm_openfiles(NULL,NULL,NULL,O_RDONLY, errbuf)) == 0)
errx(1, "kvm_openfiles: %s", errbuf);
-
+
if ((ret = kvm_nlist(kd, knl)) == -1)
errx(1, "kvm_nlist: %s", kvm_geterr(kd));
-
+
i = 0;
while (i < NLENTRIES) {
- if ((nl[i].n_type != knl[i].n_type) ||
- (nl[i].n_desc != knl[i].n_desc) ||
- (nl[i].n_value != knl[i].n_value))
+ if (nl[i].n_type != knl[i].n_type ||
+ nl[i].n_desc != knl[i].n_desc ||
+ nl[i].n_value != knl[i].n_value)
ok = 0;
i++;
}
- if ((knl[I_HISTLEN].n_type != 0) && ok) {
+ if (knl[I_HISTLEN].n_type != 0 && ok) {
if (kvm_read(kd, knl[I_HISTLEN].n_value, &histlen,
- sizeof(histlen)) != sizeof(histlen))
+ sizeof(histlen)) != sizeof(histlen))
warnx("cannot read %s: %s",
- knl[I_HISTLEN].n_name,
- kvm_geterr(kd));
+ knl[I_HISTLEN].n_name,
+ kvm_geterr(kd));
}
- if ((knl[CA_HISTORY].n_type != 0) && ok) {
+ if (knl[CA_HISTORY].n_type != 0 && ok) {
if (kvm_read(kd, knl[CA_HISTORY].n_value, history,
- sizeof(history)) != sizeof(history))
+ sizeof(history)) != sizeof(history))
warnx("cannot read %s: %s",
- knl[CA_HISTORY].n_name,
- kvm_geterr(kd));
+ knl[CA_HISTORY].n_name,
+ kvm_geterr(kd));
}
- if ((knl[P_VERSION].n_type != 0) && ok) {
+ if (knl[P_VERSION].n_type != 0 && ok) {
if (kvm_read(kd, knl[P_VERSION].n_value, kversion,
- sizeof(kversion)) != sizeof(kversion))
+ sizeof(kversion)) != sizeof(kversion))
warnx("cannot read %s: %s",
- knl[P_VERSION].n_name,
- kvm_geterr(kd));
+ knl[P_VERSION].n_name,
+ kvm_geterr(kd));
}
- }
+ }
printf("%s", adjust((caddr_t)nl[P_VERSION].n_value));
if (force == 0 && outfile == NULL)
printf("warning: no output file specified\n");
- if ((nl[IA_EXTRALOC].n_type == 0) ||
- (nl[I_NEXTRALOC].n_type == 0) ||
- (nl[I_UEXTRALOC].n_type == 0) ||
- (nl[I_HISTLEN].n_type == 0) ||
- (nl[CA_HISTORY].n_type == 0)) {
+ if (nl[IA_EXTRALOC].n_type == 0 || nl[I_NEXTRALOC].n_type == 0 ||
+ nl[I_UEXTRALOC].n_type == 0 || nl[I_HISTLEN].n_type == 0 ||
+ nl[CA_HISTORY].n_type == 0) {
printf("\
WARNING this kernel doesn't contain all information needed!\n\
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)) {
+
+ 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),
- kversion) != 0)
+ kversion) != 0)
ok = 1;
}
if (!ok) {
printf("WARNING kernel mismatch. -u ignored.\n");
printf("WARNING the running kernel version:\n");
- printf("%s",kversion);
- } else {
- process_history(histlen,history);
- }
+ printf("%s", kversion);
+ } else
+ process_history(histlen, history);
}
if (config()) {
@@ -175,14 +171,13 @@ WARNING this kernel doesn't support pseudo devices.\n");
savekernel(outfile);
}
}
-
return(0);
}
void
init()
{
- int i = 0,fd;
+ int i = 0, fd;
struct cfdata *cd;
short *ln;
int *p;
@@ -191,8 +186,7 @@ init()
#endif
cd = get_cfdata(0); /* get first item */
-
- while(cd->cf_attach != 0) {
+ while (cd->cf_attach != 0) {
maxdev = i;
totdev = i;
@@ -206,7 +200,7 @@ init()
cd++;
}
- while(cd->cf_attach == 0) {
+ while (cd->cf_attach == 0) {
totdev = i;
i++;
cd++;
@@ -223,9 +217,8 @@ init()
fd = 2;
#ifdef NOTDEF
- if (ioctl(fd, TIOCGWINSZ, &w) == 0) {
- printf("row %d col %d\n",w.ws_row,w.ws_col);
- }
+ if (ioctl(fd, TIOCGWINSZ, &w) == 0)
+ printf("row %d col %d\n", w.ws_row, w.ws_col);
if ((s = getenv("LINES")) != NULL)
sc_height = atoi(s);
diff --git a/usr.sbin/config/ukc.h b/usr.sbin/config/ukc.h
index 407fa939e16..7745e9fe742 100644
--- a/usr.sbin/config/ukc.h
+++ b/usr.sbin/config/ukc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ukc.h,v 1.5 2001/08/12 12:03:03 heko Exp $ */
+/* $OpenBSD: ukc.h,v 1.6 2001/12/05 10:11:23 deraadt Exp $ */
/*
* Copyright (c) 1999-2001 Mats O Jansson. All rights reserved.
@@ -121,7 +121,7 @@ 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));
+char *get_pdevnames __P((int));
struct pdevinit *get_pdevinit __P((int));
int more __P(());
diff --git a/usr.sbin/config/ukcutil.c b/usr.sbin/config/ukcutil.c
index 4b62684f664..7a596d92c36 100644
--- a/usr.sbin/config/ukcutil.c
+++ b/usr.sbin/config/ukcutil.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ukcutil.c,v 1.6 2001/02/04 20:42:12 maja Exp $ */
+/* $OpenBSD: ukcutil.c,v 1.7 2001/12/05 10:11:23 deraadt 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.6 2001/02/04 20:42:12 maja Exp $";
+static char rcsid[] = "$OpenBSD: ukcutil.c,v 1.7 2001/12/05 10:11:23 deraadt Exp $";
#endif
#include <sys/types.h>
@@ -54,7 +54,7 @@ get_cfdata(idx)
int idx;
{
return((struct cfdata *)(adjust((caddr_t)nl[P_CFDATA].n_value) +
- idx*sizeof(struct cfdata)));
+ idx*sizeof(struct cfdata)));
}
short *
@@ -62,7 +62,7 @@ get_locnamp(idx)
int idx;
{
return((short *)(adjust((caddr_t)nl[S_LOCNAMP].n_value) +
- idx*sizeof(short)));
+ idx*sizeof(short)));
}
caddr_t *
@@ -70,7 +70,7 @@ get_locnames(idx)
int idx;
{
return((caddr_t *)(adjust((caddr_t)nl[P_LOCNAMES].n_value) +
- idx*sizeof(caddr_t)));
+ idx*sizeof(caddr_t)));
}
int *
@@ -78,18 +78,18 @@ get_extraloc(idx)
int idx;
{
return((int *)(adjust((caddr_t)nl[IA_EXTRALOC].n_value) +
- idx*sizeof(int)));
+ idx*sizeof(int)));
}
-caddr_t *
+char *
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);
+ idx*sizeof(caddr_t));
+ return(char *)adjust((caddr_t)*p);
}
@@ -98,7 +98,7 @@ get_pdevinit(idx)
int idx;
{
return((struct pdevinit *)(adjust((caddr_t)nl[S_PDEVINIT].n_value) +
- idx*sizeof(struct pdevinit)));
+ idx*sizeof(struct pdevinit)));
}
int
@@ -118,7 +118,6 @@ more()
}
cnt++;
}
-
return (quit);
}
@@ -127,20 +126,21 @@ pnum(val)
int val;
{
if (val > -2 && val < 16) {
- printf("%d",val);
- } else {
- switch (base) {
- case 8:
- printf("0%o",val);
- break;
- case 10:
- printf("%d",val);
- break;
- case 16:
- default:
- printf("0x%x",val);
- break;
- }
+ printf("%d", val);
+ return;
+ }
+
+ switch (base) {
+ case 8:
+ printf("0%o", val);
+ break;
+ case 10:
+ printf("%d", val);
+ break;
+ case 16:
+ default:
+ printf("0x%x", val);
+ break;
}
}
@@ -156,9 +156,8 @@ pdevnam(devno)
cdrv = (struct cfdriver *)adjust((caddr_t)cd->cf_driver);
#if defined(OLDSCSIBUS)
- if (strlen(adjust((caddr_t)cdrv->cd_name)) == 0) {
+ if (strlen(adjust((caddr_t)cdrv->cd_name)) == 0)
printf("oldscsibus");
- }
#endif
printf("%s", adjust((caddr_t)cdrv->cd_name));
@@ -185,22 +184,22 @@ pdev(devno)
short devno;
{
struct cfdata *cd;
- short *s,*ln;
+ short *s, *ln;
int *i;
caddr_t *p;
char c;
struct pdevinit *pi;
- if (nopdev == 0) {
- if ((devno > maxdev) && (devno <= totdev)) {
+ 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);
+ 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;
}
}
@@ -360,13 +359,10 @@ attr(cmd, val)
p++;
i++;
}
-
- if (attr == -1) {
+ if (attr == -1)
return (-1);
- }
*val = attr;
-
return(0);
}
@@ -379,8 +375,7 @@ modify(item, val)
int a;
ukc_mod_kernel = 1;
-
- while(1) {
+ while (1) {
printf("%s [", item);
pnum(*val);
printf("] ? ");
@@ -397,9 +392,8 @@ modify(item, val)
printf("Unknown argument\n");
} else
printf("Too many arguments\n");
- } else {
+ } else
break;
- }
}
}
@@ -407,20 +401,15 @@ void
change(devno)
int devno;
{
- struct cfdata *cd,*c;
+ struct cfdata *cd, *c;
caddr_t *p;
struct pdevinit *pi;
- int i,share = 0,*j,*k,*l;
- short *ln,*lk;
+ int i, share = 0, *j = NULL, *k = NULL, *l;
+ short *ln, *lk;
ukc_mod_kernel = 1;
-
- j = k = NULL;
-
if (devno <= maxdev) {
-
pdev(devno);
-
if (ask_yn("change")) {
cd = get_cfdata(devno);
@@ -430,7 +419,6 @@ change(devno)
* locator table. if one does, we may need to
* replace the locators with a new copy.
*/
-
c = get_cfdata(0);
for (i = 0; c->cf_driver; i++) {
if (i != devno && c->cf_loc == cd->cf_loc)
@@ -440,20 +428,21 @@ change(devno)
ln = get_locnamp(cd->cf_locnames);
l = (int *)adjust((caddr_t)cd->cf_loc);
-
+
if (share) {
if (oldkernel) {
printf("Can't do that on this kernel\n");
return;
}
- lk = ln;
+ lk = ln;
i = 0;
while (*lk != -1) {
- lk++; i++;
+ lk++;
+ i++;
}
lk = ln;
-
+
j = (int *)adjust((caddr_t)nl[I_NEXTRALOC].n_value);
k = (int *)adjust((caddr_t)nl[I_UEXTRALOC].n_value);
if ((i + *k) > *j) {
@@ -462,22 +451,21 @@ change(devno)
}
j = l = get_extraloc(*k);
-
bcopy(adjust((caddr_t)cd->cf_loc),
- l, sizeof(int) * i);
+ l, sizeof(int) * i);
}
while (*ln != -1) {
p = get_locnames(*ln);
- modify((char *)adjust(*p),l);
+ modify((char *)adjust(*p), l);
ln++;
l++;
}
modify("flags", &cd->cf_flags);
if (share) {
- if (bcmp(adjust((caddr_t)cd->cf_loc),
- j, sizeof(int) * i)) {
+ if (bcmp(adjust((caddr_t)cd->cf_loc), j,
+ sizeof(int) * i)) {
cd->cf_loc = (int *)readjust((caddr_t)j);
*k = *k + i;
}
@@ -492,20 +480,18 @@ change(devno)
}
if (nopdev == 0) {
- if ((devno > maxdev) && (devno <= totdev)) {
+ if (devno > maxdev && devno <= totdev) {
printf("%3d can't change free slot\n", devno);
return;
}
- if ((devno > totdev) && (devno <= (totdev+maxpseudo))) {
-
+
+ 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));
+ printf("%3d %s changed\n", devno,
+ get_pdevnames(devno - totdev - 1));
pdev(devno);
}
return;
@@ -516,24 +502,21 @@ change(devno)
}
void
-change_history(devno,str)
+change_history(devno, str)
int devno;
char *str;
{
- struct cfdata *cd,*c;
- caddr_t *p;
+ int i, share = 0, *j = NULL, *k = NULL, *l;
+ struct cfdata *cd, *c;
struct pdevinit *pi;
- int i,share = 0,*j,*k,*l;
- short *ln,*lk;
+ short *ln, *lk;
+ caddr_t *p;
ukc_mod_kernel = 1;
- j = k = NULL;
-
- if (devno <= maxdev) {
+ if (devno <= maxdev) {
pdev(devno);
-
cd = get_cfdata(devno);
/*
@@ -541,7 +524,6 @@ change_history(devno,str)
* locator table. if one does, we may need to
* replace the locators with a new copy.
*/
-
c = get_cfdata(0);
for (i = 0; c->cf_driver; i++) {
if (i != devno && c->cf_loc == cd->cf_loc)
@@ -551,20 +533,21 @@ change_history(devno,str)
ln = get_locnamp(cd->cf_locnames);
l = (int *)adjust((caddr_t)cd->cf_loc);
-
+
if (share) {
if (oldkernel) {
printf("Can't do that on this kernel\n");
return;
}
- lk = ln;
+ lk = ln;
i = 0;
while (*lk != -1) {
- lk++; i++;
+ lk++;
+ i++;
}
lk = ln;
-
+
j = (int *)adjust((caddr_t)nl[I_NEXTRALOC].n_value);
k = (int *)adjust((caddr_t)nl[I_UEXTRALOC].n_value);
if ((i + *k) > *j) {
@@ -573,31 +556,36 @@ change_history(devno,str)
}
j = l = get_extraloc(*k);
-
bcopy(adjust((caddr_t)cd->cf_loc),
- l, sizeof(int) * i);
+ l, sizeof(int) * i);
}
while (*ln != -1) {
p = get_locnames(*ln);
*l = atoi(str);
- if (*str == '-') str++;
- while ((*str >= '0') && (*str <= '9')) str++;
- if (*str == ' ') str++;
+ if (*str == '-')
+ str++;
+ while (*str >= '0' && *str <= '9')
+ str++;
+ if (*str == ' ')
+ str++;
ln++;
l++;
}
if (*str) {
cd->cf_flags = atoi(str);
- if (*str == '-') str++;
- while ((*str >= '0') && (*str <= '9')) str++;
- if (*str == ' ') str++;
+ if (*str == '-')
+ str++;
+ while (*str >= '0' && *str <= '9')
+ str++;
+ if (*str == ' ')
+ str++;
}
if (share) {
if (bcmp(adjust((caddr_t)cd->cf_loc),
- j, sizeof(int) * i)) {
+ j, sizeof(int) * i)) {
cd->cf_loc = (int *)readjust((caddr_t)j);
*k = *k + i;
}
@@ -607,36 +595,36 @@ change_history(devno,str)
pdevnam(devno);
printf(" changed\n");
pdev(devno);
-
return;
}
if (nopdev == 0) {
- if ((devno > maxdev) && (devno <= totdev)) {
+ if (devno > maxdev && devno <= totdev) {
printf("%3d can't change free slot\n", devno);
return;
}
- if ((devno > totdev) && (devno <= (totdev+maxpseudo))) {
-
+ 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++;
+ if (*str == '-')
+ str++;
+ while (*str >= '0' && *str <= '9')
+ str++;
+ if (*str == ' ')
+ str++;
}
- printf("%3d %s changed\n", devno, get_pdevnames(devno-totdev-1));
+ printf("%3d %s changed\n", devno,
+ get_pdevnames(devno - totdev - 1));
pdev(devno);
-
return;
}
}
- printf("Unknown devno (max is %d)\n", totdev+maxpseudo);
+ printf("Unknown devno (max is %d)\n", totdev + maxpseudo);
}
void
@@ -649,7 +637,7 @@ disable(devno)
ukc_mod_kernel = 1;
if (devno <= maxdev) {
-
+
cd = get_cfdata(devno);
switch (cd->cf_fstate) {
@@ -678,13 +666,13 @@ disable(devno)
}
if (nopdev == 0) {
- if ((devno > maxdev) && (devno <= totdev)) {
+ 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));
+ if (devno > totdev && devno <= totdev + maxpseudo) {
+ printf("%3d %s can't disable pseudo device\n", devno,
+ get_pdevnames(devno - totdev - 1));
return;
}
}
@@ -699,11 +687,10 @@ enable(devno)
{
struct cfdata *cd;
int done = 0;
-
+
ukc_mod_kernel = 1;
if (devno <= maxdev) {
-
cd = get_cfdata(devno);
switch (cd->cf_fstate) {
@@ -727,18 +714,18 @@ enable(devno)
if (done)
printf(" already");
printf(" enabled\n");
-
+
return;
}
if (nopdev == 0) {
- if ((devno > maxdev) && (devno <= totdev)) {
+ 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));
+ if (devno > totdev && devno <= totdev + maxpseudo) {
+ printf("%3d %s can't enable pseudo device\n", devno,
+ get_pdevnames(devno - totdev - 1));
return;
}
}
@@ -783,14 +770,14 @@ common_attr_val(attr, val, routine)
cd = get_cfdata(0);
- while(cd->cf_attach != 0) {
+ while (cd->cf_attach != 0) {
l = (int *)adjust((caddr_t)cd->cf_loc);
ln = get_locnamp(cd->cf_locnames);
- while(*ln != -1) {
+ while (*ln != -1) {
if (*ln == attr) {
if (val == NULL) {
quit = more();
- pdev(i);
+ pdev(i);
} else {
if (*val == *l) {
quit = more();
@@ -848,9 +835,8 @@ show_attr(cmd)
while (i <= maxlocnames) {
if (strlen((char *)adjust(*p)) == l) {
- if (strncasecmp(cmd, adjust(*p), l) == 0) {
+ if (strncasecmp(cmd, adjust(*p), l) == 0)
attr = i;
- }
}
p++;
i++;
@@ -895,7 +881,7 @@ common_dev(dev, len, unit, state, routine)
cd = get_cfdata(0);
- while(cd->cf_attach != 0) {
+ while (cd->cf_attach != 0) {
cdrv = (struct cfdriver *)adjust((caddr_t)cd->cf_driver);
if (strlen((char *)adjust(cdrv->cd_name)) == len) {
@@ -905,16 +891,15 @@ common_dev(dev, len, unit, state, routine)
* If state == FSTATE_STAR, look for "dev*"
* If state == FSTATE_NOTFOUND, look for "dev0"
*/
- if (strncasecmp(dev,(char *)adjust(cdrv->cd_name),
- len) == 0 &&
+ if (!strncasecmp(dev,(char *)adjust(cdrv->cd_name), len) &&
(state == FSTATE_FOUND ||
- (state == FSTATE_STAR &&
- (cd->cf_fstate == FSTATE_STAR ||
- cd->cf_fstate == FSTATE_DSTAR)) ||
- (state == FSTATE_NOTFOUND &&
- cd->cf_unit == unit &&
- (cd->cf_fstate == FSTATE_NOTFOUND ||
- cd->cf_fstate == FSTATE_DNOTFOUND)))) {
+ (state == FSTATE_STAR &&
+ (cd->cf_fstate == FSTATE_STAR ||
+ cd->cf_fstate == FSTATE_DSTAR)) ||
+ (state == FSTATE_NOTFOUND &&
+ cd->cf_unit == unit &&
+ (cd->cf_fstate == FSTATE_NOTFOUND ||
+ cd->cf_fstate == FSTATE_DNOTFOUND)))) {
if (more())
break;
switch (routine) {
@@ -943,9 +928,9 @@ common_dev(dev, len, unit, state, routine)
if (nopdev == 0) {
for (i = 0; i < maxpseudo; i++) {
- if ((strncasecmp(dev,(char *)get_pdevnames(i),
- len) == 0) && (state == FSTATE_FOUND)) {
- switch(routine) {
+ if (!strncasecmp(dev, (char *)get_pdevnames(i), len) &&
+ state == FSTATE_FOUND) {
+ switch (routine) {
case UC_CHANGE:
change(totdev+1+i);
break;
@@ -959,7 +944,8 @@ common_dev(dev, len, unit, state, routine)
pdev(totdev+1+i);
break;
default:
- printf("Unknown pseudo routine /%c/\n",routine);
+ printf("Unknown pseudo routine /%c/\n",
+ routine);
break;
}
}
@@ -1019,10 +1005,10 @@ add_read(prompt, field, dev, len, val)
struct cfdata *cd;
struct cfdriver *cdrv;
- while(!ok) {
+ while (!ok) {
printf("%s ? ", prompt);
fflush(stdout);
-
+
ask_cmd(&cmd);
if (strlen(cmd.cmd) != 0) {
@@ -1068,7 +1054,7 @@ add(dev, len, unit, state)
{
int i = 0, found = 0, *p;
short *pv;
- struct cfdata new,*cd,*cdp;
+ struct cfdata new, *cd, *cdp;
struct cfdriver *cdrv;
int val, max_unit;
@@ -1088,7 +1074,7 @@ add(dev, len, unit, state)
cd = get_cfdata(0);
- while(cd->cf_attach != 0) {
+ while (cd->cf_attach != 0) {
cdrv = (struct cfdriver *)adjust((caddr_t)cd->cf_driver);
if (strlen((char *)adjust(cdrv->cd_name)) == len &&
@@ -1103,7 +1089,7 @@ add(dev, len, unit, state)
}
add_read("Clone Device (DevNo, 'q' or '?')", 'a', dev, len, &val);
-
+
if (val != -1) {
cd = get_cfdata(val);
new = *cd;
@@ -1114,7 +1100,7 @@ add(dev, len, unit, state)
}
if (val != -1) {
-
+
/* Insert the new record */
cdp = cd = get_cfdata(maxdev+1);
cdp--;
@@ -1128,7 +1114,7 @@ add(dev, len, unit, state)
p = (int *)adjust((caddr_t)nl[I_PV_SIZE].n_value);
pv = (short *)adjust((caddr_t)nl[SA_PV].n_value);
for (i = 0; i < *p; i++) {
- if ((*pv != 1) && (*pv >= val))
+ if (*pv != 1 && *pv >= val)
*pv = *pv + 1;
pv++;
}
@@ -1137,11 +1123,11 @@ add(dev, len, unit, state)
p = (int *)adjust((caddr_t)nl[I_CFROOTS_SIZE].n_value);
pv = (short *)adjust((caddr_t)nl[SA_CFROOTS].n_value);
for (i = 0; i < *p; i++) {
- if ((*pv != 1) && (*pv >= val))
+ if (*pv != 1 && *pv >= val)
*pv = *pv + 1;
pv++;
}
-
+
maxdev++;
max_unit = -1;
@@ -1150,13 +1136,13 @@ add(dev, len, unit, state)
cd = get_cfdata(0);
- while(cd->cf_attach != 0) {
+ while (cd->cf_attach != 0) {
cdrv = (struct cfdriver *)
adjust((caddr_t)cd->cf_driver);
if (strlen((char *)adjust(cdrv->cd_name)) == len &&
strncasecmp(dev, (char *)adjust(cdrv->cd_name),
- len) == 0) {
+ len) == 0) {
switch (cd->cf_fstate) {
case FSTATE_NOTFOUND:
case FSTATE_DNOTFOUND:
@@ -1170,20 +1156,16 @@ add(dev, len, unit, state)
cd++;
}
-
/* For all * entries set unit number to max+1 */
-
max_unit++;
-
cd = get_cfdata(0);
-
- while(cd->cf_attach != 0) {
+ while (cd->cf_attach != 0) {
cdrv = (struct cfdriver *)
- adjust((caddr_t)cd->cf_driver);
+ adjust((caddr_t)cd->cf_driver);
if (strlen((char *)adjust(cdrv->cd_name)) == len &&
strncasecmp(dev, (char *)adjust(cdrv->cd_name),
- len) == 0) {
+ len) == 0) {
switch (cd->cf_fstate) {
case FSTATE_STAR:
case FSTATE_DSTAR:
@@ -1210,7 +1192,7 @@ add_history(devno, unit, state, newno)
{
int i = 0, *p;
short *pv;
- struct cfdata new,*cd,*cdp;
+ struct cfdata new, *cd, *cdp;
struct cfdriver *cdrv;
int val, max_unit;
int len;
@@ -1219,12 +1201,11 @@ add_history(devno, unit, state, newno)
ukc_mod_kernel = 1;
bzero(&new, sizeof(struct cfdata));
-
cd = get_cfdata(devno);
new = *cd;
new.cf_unit = unit;
new.cf_fstate = state;
-
+
val = newno;
cdrv = (struct cfdriver *) adjust((caddr_t)cd->cf_driver);
@@ -1234,17 +1215,16 @@ add_history(devno, unit, state, newno)
/* Insert the new record */
cdp = cd = get_cfdata(maxdev+1);
cdp--;
- for (i = maxdev; val <= i; i--) {
+ for (i = maxdev; val <= i; i--)
*cd-- = *cdp--;
- }
cd = get_cfdata(val);
*cd = new;
-
+
/* Fix indexs in pv */
p = (int *)adjust((caddr_t)nl[I_PV_SIZE].n_value);
pv = (short *)adjust((caddr_t)nl[SA_PV].n_value);
for (i = 0; i < *p; i++) {
- if ((*pv != 1) && (*pv >= val))
+ if (*pv != 1 && *pv >= val)
*pv = *pv + 1;
pv++;
}
@@ -1253,26 +1233,23 @@ add_history(devno, unit, state, newno)
p = (int *)adjust((caddr_t)nl[I_CFROOTS_SIZE].n_value);
pv = (short *)adjust((caddr_t)nl[SA_CFROOTS].n_value);
for (i = 0; i < *p; i++) {
- if ((*pv != 1) && (*pv >= val))
+ if (*pv != 1 && *pv >= val)
*pv = *pv + 1;
pv++;
}
-
+
maxdev++;
-
max_unit = -1;
/* Find max unit number of the device type */
-
cd = get_cfdata(0);
-
- while(cd->cf_attach != 0) {
+ while (cd->cf_attach != 0) {
cdrv = (struct cfdriver *)
- adjust((caddr_t)cd->cf_driver);
+ adjust((caddr_t)cd->cf_driver);
if (strlen((char *)adjust(cdrv->cd_name)) == len &&
strncasecmp(dev, (char *)adjust(cdrv->cd_name),
- len) == 0) {
+ len) == 0) {
switch (cd->cf_fstate) {
case FSTATE_NOTFOUND:
case FSTATE_DNOTFOUND:
@@ -1286,20 +1263,16 @@ add_history(devno, unit, state, newno)
cd++;
}
-
/* For all * entries set unit number to max+1 */
-
max_unit++;
-
cd = get_cfdata(0);
-
- while(cd->cf_attach != 0) {
+ while (cd->cf_attach != 0) {
cdrv = (struct cfdriver *)
- adjust((caddr_t)cd->cf_driver);
+ adjust((caddr_t)cd->cf_driver);
if (strlen((char *)adjust(cdrv->cd_name)) == len &&
strncasecmp(dev, (char *)adjust(cdrv->cd_name),
- len) == 0) {
+ len) == 0) {
switch (cd->cf_fstate) {
case FSTATE_STAR:
case FSTATE_DSTAR:
@@ -1312,12 +1285,10 @@ add_history(devno, unit, state, newno)
cd++;
}
-
printf("%3d ", newno);
pdevnam(newno);
printf(" added\n");
pdev(val);
-
}
int
@@ -1341,7 +1312,8 @@ again:
if (cmd.cmd[0] == '\0')
goto again;
for (i = 0; cmd_table[i].cmd != NULL; i++)
- if (strstr(cmd_table[i].cmd, cmd.cmd)==cmd_table[i].cmd)
+ if (strstr(cmd_table[i].cmd, cmd.cmd) ==
+ cmd_table[i].cmd)
break;
/* Quick hack to put in '?' == 'help' */
@@ -1369,13 +1341,13 @@ again:
}
void
-process_history(len,buf)
+process_history(len, buf)
int len;
char *buf;
{
char *c;
- int devno,newno;
- short unit,state;
+ int devno, newno;
+ short unit, state;
struct timezone *tz;
if (len == 0) {
@@ -1384,66 +1356,92 @@ process_history(len,buf)
}
printf("Processing history...\n");
-
+
buf[len] = 0;
c = buf;
-
+
while (*c != NULL) {
switch (*c) {
case 'a':
- c++; c++;
+ c++;
+ c++;
devno = atoi(c);
- while ((*c >= '0') && (*c <= '9')) c++; c++;
+ while (*c >= '0' && *c <= '9')
+ c++;
+ c++;
unit = atoi(c);
if (*c == '-') c++;
- while ((*c >= '0') && (*c <= '9')) c++; c++;
+ while (*c >= '0' && *c <= '9')
+ c++;
+ c++;
state = atoi(c);
- if (*c == '-') c++;
- while ((*c >= '0') && (*c <= '9')) c++; c++;
+ if (*c == '-')
+ c++;
+ while (*c >= '0' && *c <= '9')
+ c++;
+ c++;
newno = atoi(c);
- while ((*c >= '0') && (*c <= '9')) c++;
- add_history(devno,unit,state,newno);
- while (*c != '\n') c++; c++;
+ while (*c >= '0' && *c <= '9')
+ c++;
+ add_history(devno, unit, state, newno);
+ while (*c != '\n')
+ c++;
+ c++;
break;
case 'c':
- c++; c++;
+ c++;
+ c++;
devno = atoi(c);
- while ((*c >= '0') && (*c <= '9')) c++;
- if (*c == ' ') c++;
- if (*c != '\n') {
- change_history(devno,c);
- }
- while (*c != '\n') c++; c++;
+ while (*c >= '0' && *c <= '9')
+ c++;
+ if (*c == ' ')
+ c++;
+ if (*c != '\n')
+ change_history(devno, c);
+ while (*c != '\n')
+ c++;
+ c++;
break;
case 'd':
c++;
devno = atoi(c);
disable(devno);
- while (*c != '\n') c++; c++;
+ while (*c != '\n')
+ c++;
+ c++;
break;
case 'e':
c++;
devno = atoi(c);
enable(devno);
- while (*c != '\n') c++; c++;
+ while (*c != '\n')
+ c++;
+ c++;
break;
case 't':
- c++; c++;
+ c++;
+ c++;
tz = (struct timezone *)adjust((caddr_t)nl[TZ_TZ].
n_value);
tz->tz_minuteswest = atoi(c);
- while (*c != ' ') c++; c++;
+ while (*c != ' ')
+ c++;
+ c++;
tz->tz_dsttime = atoi(c);
- while (*c != '\n') c++; c++;
+ while (*c != '\n')
+ c++;
+ c++;
ukc_mod_kernel = 1;
break;
case 'q':
- while (*c != NULL) c++;
+ while (*c != NULL)
+ c++;
break;
default:
- printf("unknown command %c\n",*c);
- while ((*c != NULL) && (*c != '\n')) c++;
+ printf("unknown command %c\n", *c);
+ while (*c != NULL && *c != '\n')
+ c++;
break;
}
}