From 363328cec784cefd433e9c015be27e5f5795c2b6 Mon Sep 17 00:00:00 2001 From: Visa Hankala Date: Tue, 29 Jan 2019 14:07:16 +0000 Subject: Add a dedicated sysctl(2) node for witness(4). The new node contains the subsystem's main control variable, kern.witness.watch. It is aliased by the old name, kern.witnesswatch. The alias will be removed in the future. OK anton@ mpi@ --- sbin/sysctl/sysctl.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'sbin/sysctl') diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c index 8bd235d9226..cd2be30f80e 100644 --- a/sbin/sysctl/sysctl.c +++ b/sbin/sysctl/sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sysctl.c,v 1.239 2018/12/10 13:35:54 landry Exp $ */ +/* $OpenBSD: sysctl.c,v 1.240 2019/01/29 14:07:15 visa Exp $ */ /* $NetBSD: sysctl.c,v 1.9 1995/09/30 07:12:50 thorpej Exp $ */ /* @@ -130,6 +130,7 @@ struct ctlname machdepname[] = CTL_MACHDEP_NAMES; #endif struct ctlname ddbname[] = CTL_DDB_NAMES; struct ctlname audioname[] = CTL_KERN_AUDIO_NAMES; +struct ctlname witnessname[] = CTL_KERN_WITNESS_NAMES; char names[BUFSIZ]; int lastused; @@ -214,6 +215,7 @@ void print_sensor(struct sensor *); int sysctl_chipset(char *, char **, int *, int, int *); #endif int sysctl_audio(char *, char **, int *, int, int *); +int sysctl_witness(char *, char **, int *, int, int *); void vfsinit(void); char *equ = "="; @@ -502,6 +504,11 @@ parse(char *string, int flags) if (len < 0) return; break; + case KERN_WITNESS: + len = sysctl_witness(string, &bufp, mib, flags, &type); + if (len < 0) + return; + break; } break; @@ -1717,6 +1724,7 @@ struct list shmlist = { shmname, KERN_SHMINFO_MAXID }; struct list watchdoglist = { watchdogname, KERN_WATCHDOG_MAXID }; struct list tclist = { tcname, KERN_TIMECOUNTER_MAXID }; struct list audiolist = { audioname, KERN_AUDIO_MAXID }; +struct list witnesslist = { witnessname, KERN_WITNESS_MAXID }; /* * handle vfs namei cache statistics @@ -2719,6 +2727,25 @@ sysctl_audio(char *string, char **bufpp, int mib[], int flags, int *typep) return (3); } +/* + * Handle witness support + */ +int +sysctl_witness(char *string, char **bufpp, int mib[], int flags, int *typep) +{ + int indx; + + if (*bufpp == NULL) { + listall(string, &witnesslist); + return (-1); + } + if ((indx = findname(string, "third", bufpp, &witnesslist)) == -1) + return (-1); + mib[2] = indx; + *typep = witnesslist.list[indx].ctl_type; + return (3); +} + /* * Scan a list of names searching for a particular name. */ -- cgit v1.2.3