diff options
author | Robert Nagy <robert@cvs.openbsd.org> | 2022-11-07 14:25:45 +0000 |
---|---|---|
committer | Robert Nagy <robert@cvs.openbsd.org> | 2022-11-07 14:25:45 +0000 |
commit | a4caaf1da89425cb4f34c560a3196c84b8e11459 (patch) | |
tree | 277b68a3e16b4d9e6985d09372a441c2a87a9a59 /sys | |
parent | d797fdb68ca9b59a1b715b466fa8efba0a219363 (diff) |
introduce a new kern.autoconf_serial sysctl that can be used by userland
to monitor state changes of the kernel device tree
input from dnd ok dlg@, deraadt@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/kern_sysctl.c | 4 | ||||
-rw-r--r-- | sys/kern/subr_autoconf.c | 9 | ||||
-rw-r--r-- | sys/sys/sysctl.h | 6 |
3 files changed, 15 insertions, 4 deletions
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index abf9cf0ded7..ff42ebb5129 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sysctl.c,v 1.407 2022/11/05 19:29:46 cheloha Exp $ */ +/* $OpenBSD: kern_sysctl.c,v 1.408 2022/11/07 14:25:44 robert Exp $ */ /* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */ /*- @@ -126,6 +126,7 @@ extern long numvnodes; extern int allowdt; extern int audio_record_enable; extern int video_record_enable; +extern int autoconf_serial; int allowkmem; @@ -341,6 +342,7 @@ const struct sysctl_bounded_args kern_vars[] = { #ifdef PTRACE {KERN_GLOBAL_PTRACE, &global_ptrace, 0, 1}, #endif + {KERN_AUTOCONF_SERIAL, &autoconf_serial, SYSCTL_INT_READONLY}, }; int diff --git a/sys/kern/subr_autoconf.c b/sys/kern/subr_autoconf.c index a35b2224724..41633140dc6 100644 --- a/sys/kern/subr_autoconf.c +++ b/sys/kern/subr_autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_autoconf.c,v 1.96 2022/04/07 09:37:32 tb Exp $ */ +/* $OpenBSD: subr_autoconf.c,v 1.97 2022/11/07 14:25:44 robert Exp $ */ /* $NetBSD: subr_autoconf.c,v 1.21 1996/04/04 06:06:18 cgd Exp $ */ /* @@ -107,6 +107,11 @@ struct mutex autoconf_attdet_mtx = MUTEX_INITIALIZER(IPL_HIGH); int autoconf_attdet; /* + * Versioned state of the devices tree so that changes can be detected. + */ +unsigned int autoconf_serial = 0; + +/* * Initialize autoconfiguration data structures. This occurs before console * initialization as that might require use of this subsystem. Furthermore * this means that malloc et al. isn't yet available. @@ -419,6 +424,7 @@ config_attach(struct device *parent, void *match, void *aux, cfprint_t print) mtx_enter(&autoconf_attdet_mtx); if (--autoconf_attdet == 0) wakeup(&autoconf_attdet); + autoconf_serial++; mtx_leave(&autoconf_attdet_mtx); return (dev); } @@ -642,6 +648,7 @@ done: mtx_enter(&autoconf_attdet_mtx); if (++autoconf_attdet == 0) wakeup(&autoconf_attdet); + autoconf_serial++; mtx_leave(&autoconf_attdet_mtx); return (rv); } diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h index 84564782931..4fa5afdf6c8 100644 --- a/sys/sys/sysctl.h +++ b/sys/sys/sysctl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sysctl.h,v 1.230 2022/11/05 19:29:46 cheloha Exp $ */ +/* $OpenBSD: sysctl.h,v 1.231 2022/11/07 14:25:44 robert Exp $ */ /* $NetBSD: sysctl.h,v 1.16 1996/04/09 20:55:36 cgd Exp $ */ /* @@ -192,7 +192,8 @@ struct ctlname { #define KERN_UTC_OFFSET 88 /* int: adjust RTC time to UTC */ #define KERN_VIDEO 89 /* struct: video properties */ #define KERN_CLOCKINTR 90 /* node: clockintr */ -#define KERN_MAXID 91 /* number of valid kern ids */ +#define KERN_AUTOCONF_SERIAL 91 /* int: kernel device tree state serial */ +#define KERN_MAXID 92 /* number of valid kern ids */ #define CTL_KERN_NAMES { \ { 0, 0 }, \ @@ -286,6 +287,7 @@ struct ctlname { { "utc_offset", CTLTYPE_INT }, \ { "video", CTLTYPE_STRUCT }, \ { "clockintr", CTLTYPE_NODE }, \ + { "autoconf_serial", CTLTYPE_INT }, \ } /* |