diff options
author | Mats O Jansson <maja@cvs.openbsd.org> | 2002-02-17 23:01:20 +0000 |
---|---|---|
committer | Mats O Jansson <maja@cvs.openbsd.org> | 2002-02-17 23:01:20 +0000 |
commit | b569c5852f5e4f0aa2ddc260601cd6dfad2c2c91 (patch) | |
tree | fcfc95b1bb2edb77f0e6206eefb803df7f40bd69 | |
parent | 7beb673ee2a6f26cb92ffbcee12d36dd3f705fd8 (diff) |
Patch from Daniel Lucq <daniel@lucq.org>
The patch allows you to change the value of NMBCLUSTERS, BUFCACHEPERCENT
and NKMEMPAGES using the config command, instead of recompiling the kernel.
This is the userland part of the patch. I have compiled it on i386, sparc64,
alpha and macppc. -moj ok art@ maja@
-rw-r--r-- | usr.sbin/config/cmd.c | 90 | ||||
-rw-r--r-- | usr.sbin/config/cmd.h | 5 | ||||
-rw-r--r-- | usr.sbin/config/config.8 | 11 | ||||
-rw-r--r-- | usr.sbin/config/ukc.c | 16 | ||||
-rw-r--r-- | usr.sbin/config/ukc.h | 13 |
5 files changed, 127 insertions, 8 deletions
diff --git a/usr.sbin/config/cmd.c b/usr.sbin/config/cmd.c index 915eea8f64e..17f989fbcff 100644 --- a/usr.sbin/config/cmd.c +++ b/usr.sbin/config/cmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd.c,v 1.6 2001/12/05 10:11:23 deraadt Exp $ */ +/* $OpenBSD: cmd.c,v 1.7 2002/02/17 23:01:19 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.6 2001/12/05 10:11:23 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: cmd.c,v 1.7 2002/02/17 23:01:19 maja Exp $"; #endif #include <sys/types.h> @@ -64,6 +64,9 @@ cmd_table_t cmd_table[] = { {"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"}, {NULL, NULL, NULL, NULL} }; @@ -293,3 +296,86 @@ Xtimezone(cmd) } return (CMD_CONT); } +int +Xnmbclusters(cmd) + cmd_t *cmd; +{ + int *pnmbclusters,num; + + if (nl[I_NMBCLUSTERS].n_type != 0) { + ukc_mod_kernel = 1; + + pnmbclusters = (int *)adjust((caddr_t)(nl[I_NMBCLUSTERS]. + n_value)); + + if (strlen(cmd->args) == 0) { + printf("nmbclusters = %d\n", *pnmbclusters); + } else { + if (number(cmd->args, &num) == 0) { + *pnmbclusters = num; + printf("nmbclusters = %d\n", *pnmbclusters); + } else + printf("Unknown argument\n"); + } + } else + printf("\ +This kernel does not support modification of NMBCLUSTERS.\n"); + + return (CMD_CONT); +} + +int +Xbufcachepct(cmd) + 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"); + + return (CMD_CONT); +} + +int +Xnkmempg(cmd) + 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"); + + return (CMD_CONT); +} diff --git a/usr.sbin/config/cmd.h b/usr.sbin/config/cmd.h index dc354b6e94c..556fdac0cac 100644 --- a/usr.sbin/config/cmd.h +++ b/usr.sbin/config/cmd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd.h,v 1.4 2002/02/16 21:28:01 millert Exp $ */ +/* $OpenBSD: cmd.h,v 1.5 2002/02/17 23:01:19 maja Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -72,6 +72,9 @@ int Xshow(cmd_t *); int Xexit(cmd_t *); int Xquit(cmd_t *); int Xtimezone(cmd_t *); +int Xnmbclusters(cmd_t *); +int Xbufcachepct(cmd_t *); +int Xnkmempg(cmd_t *); #endif /* _CMD_H */ diff --git a/usr.sbin/config/config.8 b/usr.sbin/config/config.8 index 3e2796707b9..f89fdcb227e 100644 --- a/usr.sbin/config/config.8 +++ b/usr.sbin/config/config.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: config.8,v 1.26 2002/02/07 22:45:42 aaron Exp $ +.\" $OpenBSD: config.8,v 1.27 2002/02/17 23:01:19 maja Exp $ .\" $NetBSD: config.8,v 1.10 1996/08/31 20:58:16 mycroft Exp $ .\" .\" Copyright (c) 1980, 1991, 1993 @@ -348,6 +348,15 @@ Change the .Va tz timezone structure. Without arguments, displays its current value. +.It Ic nmbclust Op Ar number +Change the NMBCLUSTERS value. +Without arguments, displays its current value. +.It Ic cachepct Op Ar number +Change the BUFCACHEPERCENT value. +Without arguments, displays its current value. +.It Ic nkmempg Op Ar number +Change the NKMEMPAGES 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 8d0db1cdb97..fbbef65b7e7 100644 --- a/usr.sbin/config/ukc.c +++ b/usr.sbin/config/ukc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ukc.c,v 1.7 2002/02/16 21:28:01 millert Exp $ */ +/* $OpenBSD: ukc.c,v 1.8 2002/02/17 23:01:19 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.7 2002/02/16 21:28:01 millert Exp $"; +static char rcsid[] = "$OpenBSD: ukc.c,v 1.8 2002/02/17 23:01:19 maja Exp $"; #endif #include <sys/types.h> @@ -140,6 +140,18 @@ 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"); + init(); if (uflag) { diff --git a/usr.sbin/config/ukc.h b/usr.sbin/config/ukc.h index ef82f1e5501..b8893d2f812 100644 --- a/usr.sbin/config/ukc.h +++ b/usr.sbin/config/ukc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ukc.h,v 1.7 2002/02/16 21:28:01 millert Exp $ */ +/* $OpenBSD: ukc.h,v 1.8 2002/02/17 23:01:19 maja Exp $ */ /* * Copyright (c) 1999-2001 Mats O Jansson. All rights reserved. @@ -50,7 +50,10 @@ #define P_PDEVNAMES 15 #define I_PDEVSIZE 16 #define S_PDEVINIT 17 -#define NLENTRIES 18 +#define I_NMBCLUSTERS 18 +#define I_BUFCACHEPCT 19 +#define I_NKMEMPG 20 +#define NLENTRIES 21 #ifdef UKC_MAIN struct nlist nl[] = { @@ -72,6 +75,9 @@ struct nlist nl[] = { { "_pdevnames" }, { "_pdevnames_size" }, { "_pdevinit" }, + { "_nmbclust" }, + { "_bufcachepercent" }, + { "_nkmempages" }, { NULL }, }; struct nlist knl[] = { @@ -93,6 +99,9 @@ struct nlist knl[] = { { "_pdevnames" }, { "_pdevnames_size" }, { "_pdevinit" }, + { "_nmbclust" }, + { "_bufcachepercent" }, + { "_nkmempages" }, { NULL }, }; int maxdev = 0; |