diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2002-03-23 13:30:25 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2002-03-23 13:30:25 +0000 |
commit | 6f28e589c4cd1bc8d86baf0ad9ac00c75e0e2489 (patch) | |
tree | 2dd3e3a453b121b2e09f56e366604ef488bb3aec /usr.sbin/config | |
parent | d5dbb93c5f932440dcab912174cdcaace0478710 (diff) |
small cleanups:
ansi prototypes,
help formating,
common code to handle integer parameters.
Let SystemV shm parameters be settable.
Diffstat (limited to 'usr.sbin/config')
-rw-r--r-- | usr.sbin/config/cmd.c | 165 | ||||
-rw-r--r-- | usr.sbin/config/cmd.h | 4 | ||||
-rw-r--r-- | usr.sbin/config/config.8 | 8 | ||||
-rw-r--r-- | usr.sbin/config/ukc.c | 28 | ||||
-rw-r--r-- | usr.sbin/config/ukc.h | 12 | ||||
-rw-r--r-- | usr.sbin/config/ukcutil.c | 6 |
6 files changed, 102 insertions, 121 deletions
diff --git a/usr.sbin/config/cmd.c b/usr.sbin/config/cmd.c index 17f989fbcff..6e86ae0687d 100644 --- a/usr.sbin/config/cmd.c +++ b/usr.sbin/config/cmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd.c,v 1.7 2002/02/17 23:01:19 maja Exp $ */ +/* $OpenBSD: cmd.c,v 1.8 2002/03/23 13:30:24 espie 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.7 2002/02/17 23:01:19 maja Exp $"; +static char rcsid[] = "$OpenBSD: cmd.c,v 1.8 2002/03/23 13:30:24 espie Exp $"; #endif #include <sys/types.h> @@ -48,45 +48,46 @@ static char rcsid[] = "$OpenBSD: cmd.c,v 1.7 2002/02/17 23:01:19 maja Exp $"; #include "exec.h" extern int ukc_mod_kernel; +static void int_variable_adjust(const cmd_t *, int, const char *); /* Our command table */ cmd_table_t cmd_table[] = { - {"help", Xhelp, "\t\t", "Command help list"}, - {"add", Xadd, "dev\t\t", "Add a device"}, - {"base", Xbase, "8|10|16\t\t", "Base on large numbers"}, - {"change", Xchange, "devno|dev\t", "Change device"}, + {"help", Xhelp, "", "Command help list"}, + {"add", Xadd, "dev", "Add a device"}, + {"base", Xbase, "8|10|16", "Base on large numbers"}, + {"change", Xchange, "devno|dev", "Change device"}, {"disable",Xdisable, "attr val|devno|dev", "Disable device"}, {"enable", Xenable, "attr val|devno|dev", "Enable device"}, - {"find", Xfind, "devno|dev\t", "Find device"}, - {"list", Xlist, "\t\t", "List configuration"}, - {"lines", Xlines, "count\t\t", "# of lines per page"}, - {"show", Xshow, "[attr [val]]\t", "Show attribute"}, - {"exit", Xexit, "\t\t", "Exit, without saving changes"}, - {"quit", Xquit, "\t\t", "Quit, saving current changes"}, - {"timezone", Xtimezone, "[mins [dst]]\t", "Show/change timezone"}, - {"nmbclust", Xnmbclusters, "[number]\t", "Show/change NMBCLUSTERS"}, - {"cachepct", Xbufcachepct, "[number]\t", "Show/change BUFCACHEPERCENT"}, - {"nkmempg", Xnkmempg, "[number]\t", "Show/change NKMEMPAGES"}, + {"find", Xfind, "devno|dev", "Find device"}, + {"list", Xlist, "", "List configuration"}, + {"lines", Xlines, "count", "# of lines per page"}, + {"show", Xshow, "[attr [val]]", "Show attribute"}, + {"exit", Xexit, "", "Exit, without saving changes"}, + {"quit", Xquit, "", "Quit, saving current changes"}, + {"timezone", Xtimezone, "[mins [dst]]", "Show/change timezone"}, + {"nmbclust", Xnmbclusters, "[number]", "Show/change NMBCLUSTERS"}, + {"cachepct", Xbufcachepct, "[number]", "Show/change BUFCACHEPERCENT"}, + {"nkmempg", Xnkmempg, "[number]", "Show/change NKMEMPAGES"}, + {"shmseg", Xshmseg, "[number]", "Show/change SHMSEG"}, + {"shmmaxpgs", Xshmmaxpgs,"[number]", "Show/change SHMMAXPGS"}, {NULL, NULL, NULL, NULL} }; int -Xhelp(cmd) - cmd_t *cmd; +Xhelp(cmd_t *cmd) { cmd_table_t *cmd_table = cmd->table; int i; /* Hmm, print out cmd_table here... */ for (i = 0; cmd_table[i].cmd != NULL; i++) - printf("\t%s\t%s\t%s\n", cmd_table[i].cmd, + printf("\t%-12s%-20s%s\n", cmd_table[i].cmd, cmd_table[i].opt, cmd_table[i].help); return (CMD_CONT); } int -Xadd(cmd) - cmd_t *cmd; +Xadd(cmd_t *cmd) { short unit, state; int a; @@ -101,8 +102,7 @@ Xadd(cmd) } int -Xbase(cmd) - cmd_t *cmd; +Xbase(cmd_t *cmd) { int a; @@ -120,8 +120,7 @@ Xbase(cmd) } int -Xchange(cmd) - cmd_t *cmd; +Xchange(cmd_t *cmd) { short unit, state; int a; @@ -138,8 +137,7 @@ Xchange(cmd) } int -Xdisable(cmd) - cmd_t *cmd; +Xdisable(cmd_t *cmd) { short unit, state; int a; @@ -158,8 +156,7 @@ Xdisable(cmd) } int -Xenable(cmd) - cmd_t *cmd; +Xenable(cmd_t *cmd) { short unit, state; int a; @@ -178,8 +175,7 @@ Xenable(cmd) } int -Xfind(cmd) - cmd_t *cmd; +Xfind(cmd_t *cmd) { short unit, state; int a; @@ -196,8 +192,7 @@ Xfind(cmd) } int -Xlines(cmd) - cmd_t *cmd; +Xlines(cmd_t *cmd) { int a; @@ -211,8 +206,7 @@ Xlines(cmd) } int -Xlist(cmd) - cmd_t *cmd; +Xlist(cmd_t *cmd) { struct cfdata *cd; int i = 0; @@ -239,8 +233,7 @@ Xlist(cmd) } int -Xshow(cmd) - cmd_t *cmd; +Xshow(cmd_t *cmd) { if (strlen(cmd->args) == 0) show(); @@ -250,24 +243,21 @@ Xshow(cmd) } int -Xquit(cmd) - cmd_t *cmd; +Xquit(cmd_t *cmd) { /* Nothing to do here */ return (CMD_SAVE); } int -Xexit(cmd) - cmd_t *cmd; +Xexit(cmd_t *cmd) { /* Nothing to do here */ return (CMD_EXIT); } int -Xtimezone(cmd) - cmd_t *cmd; +Xtimezone(cmd_t *cmd) { struct timezone *tz; int num; @@ -296,86 +286,61 @@ Xtimezone(cmd) } return (CMD_CONT); } -int -Xnmbclusters(cmd) - cmd_t *cmd; + +void +int_variable_adjust(const cmd_t *cmd, int idx, const char *name) { - int *pnmbclusters,num; + int *v, num; - if (nl[I_NMBCLUSTERS].n_type != 0) { + if (nl[idx].n_type != 0) { ukc_mod_kernel = 1; - pnmbclusters = (int *)adjust((caddr_t)(nl[I_NMBCLUSTERS]. - n_value)); + v = (int *)adjust((caddr_t)(nl[idx].n_value)); if (strlen(cmd->args) == 0) { - printf("nmbclusters = %d\n", *pnmbclusters); + printf("%s = %d\n", name, *v); } else { if (number(cmd->args, &num) == 0) { - *pnmbclusters = num; - printf("nmbclusters = %d\n", *pnmbclusters); + *v = num; + printf("%s = %d\n", name, *v); } else printf("Unknown argument\n"); } } else - printf("\ -This kernel does not support modification of NMBCLUSTERS.\n"); + printf("This kernel does not support modification of %s.\n", + name); +} +int +Xnmbclusters(cmd_t *cmd) +{ + int_variable_adjust(cmd, I_NMBCLUSTERS, "nmbclusters"); return (CMD_CONT); } int -Xbufcachepct(cmd) - cmd_t *cmd; +Xbufcachepct(cmd_t *cmd) { - int *pbufcachepct,num; - - if (nl[I_BUFCACHEPCT].n_type != 0) { - ukc_mod_kernel = 1; - - pbufcachepct = (int *)adjust((caddr_t)(nl[I_BUFCACHEPCT]. - n_value)); - - if (strlen(cmd->args) == 0) { - printf("bufcachepercent = %d\n", *pbufcachepct); - } else { - if (number(cmd->args, &num) == 0) { - *pbufcachepct = num; - printf("bufcachepercent = %d\n", *pbufcachepct); - } else - printf("Unknown argument\n"); - } - } else - printf("\ -This kernel does not support modification of BUFCACHEPERCENT.\n"); - + int_variable_adjust(cmd, I_BUFCACHEPCT, "bufcachepercent"); return (CMD_CONT); } int -Xnkmempg(cmd) - cmd_t *cmd; +Xnkmempg(cmd_t *cmd) { - int *pnkmempg,num; - - if (nl[I_NKMEMPG].n_type != 0) { - ukc_mod_kernel = 1; - - pnkmempg = (int *)adjust((caddr_t)(nl[I_NKMEMPG]. - n_value)); - - if (strlen(cmd->args) == 0) { - printf("nkmempages = %d\n", *pnkmempg); - } else { - if (number(cmd->args, &num) == 0) { - *pnkmempg = num; - printf("nkmempages = %d\n", *pnkmempg); - } else - printf("Unknown argument\n"); - } - } else - printf("\ -This kernel does not support modification of NKMEMPAGES.\n"); + int_variable_adjust(cmd, I_NKMEMPG, "nkmempages"); + return (CMD_CONT); +} +int +Xshmseg(cmd_t *cmd) +{ + int_variable_adjust(cmd, I_SHMSEG, "shmseg"); return (CMD_CONT); } + +int +Xshmmaxpgs(cmd_t *cmd) +{ + int_variable_adjust(cmd, I_SHMMAXPGS, "shmmaxpgs"); +} diff --git a/usr.sbin/config/cmd.h b/usr.sbin/config/cmd.h index 556fdac0cac..384314b12ad 100644 --- a/usr.sbin/config/cmd.h +++ b/usr.sbin/config/cmd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd.h,v 1.5 2002/02/17 23:01:19 maja Exp $ */ +/* $OpenBSD: cmd.h,v 1.6 2002/03/23 13:30:24 espie Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -75,6 +75,8 @@ int Xtimezone(cmd_t *); int Xnmbclusters(cmd_t *); int Xbufcachepct(cmd_t *); int Xnkmempg(cmd_t *); +int Xshmseg(cmd_t *); +int Xshmmaxpgs(cmd_t *); #endif /* _CMD_H */ diff --git a/usr.sbin/config/config.8 b/usr.sbin/config/config.8 index f89fdcb227e..dbabc85d037 100644 --- a/usr.sbin/config/config.8 +++ b/usr.sbin/config/config.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: config.8,v 1.27 2002/02/17 23:01:19 maja Exp $ +.\" $OpenBSD: config.8,v 1.28 2002/03/23 13:30:24 espie Exp $ .\" $NetBSD: config.8,v 1.10 1996/08/31 20:58:16 mycroft Exp $ .\" .\" Copyright (c) 1980, 1991, 1993 @@ -357,6 +357,12 @@ Without arguments, displays its current value. .It Ic nkmempg Op Ar number Change the NKMEMPAGES value. Without arguments, displays its current value. +.It Ic shmseg Op Ar number +Change the SHMSEG value. +Without arguments, displays its current value. +.It Ic shmmaxpgs Op Ar number +Change the SHMMAXPGS value. +Without arguments, displays its current value. .El .Sh EXAMPLES (First synopsis) A custom kernel is built in the following way. diff --git a/usr.sbin/config/ukc.c b/usr.sbin/config/ukc.c index fbbef65b7e7..bc2641099ab 100644 --- a/usr.sbin/config/ukc.c +++ b/usr.sbin/config/ukc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ukc.c,v 1.8 2002/02/17 23:01:19 maja Exp $ */ +/* $OpenBSD: ukc.c,v 1.9 2002/03/23 13:30:24 espie 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.8 2002/02/17 23:01:19 maja Exp $"; +static char rcsid[] = "$OpenBSD: ukc.c,v 1.9 2002/03/23 13:30:24 espie Exp $"; #endif #include <sys/types.h> @@ -56,6 +56,14 @@ void usage(void); int ukc_mod_kernel = 0; +static void +check_int(int idx, const char *name) +{ + if (nl[idx].n_type == 0) + printf("WARNING this kernel doesn't support modification " + "of %s.\n", name); +} + int ukc(file, outfile, uflag, force) char *file; @@ -140,17 +148,11 @@ WARNING this kernel doesn't support pseudo devices.\n"); nopdev = 1; } - if (nl[I_NMBCLUSTERS].n_type == 0) - printf("\ -WARNING this kernel doesn't support modification of NMCLUSTERS.\n"); - - if (nl[I_BUFCACHEPCT].n_type == 0) - printf("\ -WARNING this kernel doesn't support modification of BUFCACHEPERCENT.\n"); - - if (nl[I_NKMEMPG].n_type == 0) - printf("\ -WARNING this kernel doesn't support modification of NKMEMPAGES.\n"); + check_int(I_NMBCLUSTERS, "NMCLUSTERS"); + check_int(I_BUFCACHEPCT, "BUFCACHEPERCENT"); + check_int(I_NKMEMPG, "NKMEMPAGES"); + check_int(I_SHMSEG, "SHMSEG"); + check_int(I_SHMMAXPGS, "SHMMAXPGS"); init(); diff --git a/usr.sbin/config/ukc.h b/usr.sbin/config/ukc.h index b8893d2f812..9c106cc636d 100644 --- a/usr.sbin/config/ukc.h +++ b/usr.sbin/config/ukc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ukc.h,v 1.8 2002/02/17 23:01:19 maja Exp $ */ +/* $OpenBSD: ukc.h,v 1.9 2002/03/23 13:30:24 espie Exp $ */ /* * Copyright (c) 1999-2001 Mats O Jansson. All rights reserved. @@ -53,7 +53,9 @@ #define I_NMBCLUSTERS 18 #define I_BUFCACHEPCT 19 #define I_NKMEMPG 20 -#define NLENTRIES 21 +#define I_SHMSEG 21 +#define I_SHMMAXPGS 22 +#define NLENTRIES 23 #ifdef UKC_MAIN struct nlist nl[] = { @@ -78,6 +80,8 @@ struct nlist nl[] = { { "_nmbclust" }, { "_bufcachepercent" }, { "_nkmempages" }, + { "_shmseg" }, + { "_shmmaxpgs" }, { NULL }, }; struct nlist knl[] = { @@ -102,6 +106,8 @@ struct nlist knl[] = { { "_nmbclust" }, { "_bufcachepercent" }, { "_nkmempages" }, + { "_shmseg" }, + { "_shmmaxpgs" }, { NULL }, }; int maxdev = 0; @@ -137,7 +143,7 @@ int more(); void pnum(int); void pdevnam(short); void pdev(short); -int number(char *, int *); +int number(const char *, int *); int device(char *, int *, short *, short *); int attr(char *, int *); void modify(char *, int *); diff --git a/usr.sbin/config/ukcutil.c b/usr.sbin/config/ukcutil.c index acb76d4222b..c71cfc694a0 100644 --- a/usr.sbin/config/ukcutil.c +++ b/usr.sbin/config/ukcutil.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ukcutil.c,v 1.8 2001/12/10 23:15:34 deraadt Exp $ */ +/* $OpenBSD: ukcutil.c,v 1.9 2002/03/23 13:30:24 espie 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.8 2001/12/10 23:15:34 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: ukcutil.c,v 1.9 2002/03/23 13:30:24 espie Exp $"; #endif #include <sys/types.h> @@ -253,7 +253,7 @@ pdev(devno) int number(c, val) - char *c; + const char *c; int *val; { u_int num = 0; |