From: bluhm Date: Fri, 23 Apr 2021 07:21:02 +0000 (+0000) Subject: Remove the sysctl kern.allowdt code from kernel if dt(4) is not X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=a5bcf5ab3f88a5d90286acb004f1590314e8371d;p=openbsd Remove the sysctl kern.allowdt code from kernel if dt(4) is not configured. This will result in a "value is not available" error from sysctl when trying to enable dt on a kernel without support. The variable allowdt should be in the device, not in sysctl source. We don't need #ifdef for extern and prototypes. OK mpi@ --- diff --git a/sys/dev/dt/dt_dev.c b/sys/dev/dt/dt_dev.c index a78775ac779..1e59e22431d 100644 --- a/sys/dev/dt/dt_dev.c +++ b/sys/dev/dt/dt_dev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dt_dev.c,v 1.12 2021/03/26 21:17:10 bluhm Exp $ */ +/* $OpenBSD: dt_dev.c,v 1.13 2021/04/23 07:21:02 bluhm Exp $ */ /* * Copyright (c) 2019 Martin Pieuchot @@ -109,6 +109,8 @@ SIMPLEQ_HEAD(, dt_probe) dt_probe_list; /* [I] list of probes */ struct rwlock dt_lock = RWLOCK_INITIALIZER("dtlk"); volatile uint32_t dt_tracing = 0; /* [K] # of processes tracing */ +int allowdt; + void dtattach(struct device *, struct device *, void *); int dtopen(dev_t, int, int, struct proc *); int dtclose(dev_t, int, int, struct proc *); @@ -145,7 +147,6 @@ dtopen(dev_t dev, int flags, int mode, struct proc *p) { struct dt_softc *sc; int unit = minor(dev); - extern int allowdt; if (!allowdt) return EPERM; diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index 7125cbb2c04..2cdda78ae4a 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sysctl.c,v 1.389 2021/02/08 10:51:02 mpi Exp $ */ +/* $OpenBSD: kern_sysctl.c,v 1.390 2021/04/23 07:21:02 bluhm Exp $ */ /* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */ /*- @@ -114,24 +114,21 @@ #endif #include "audio.h" -#include "video.h" +#include "dt.h" #include "pf.h" +#include "video.h" extern struct forkstat forkstat; extern struct nchstats nchstats; extern int nselcoll, fscale; extern struct disklist_head disklist; extern fixpt_t ccpu; -extern long numvnodes; -#if NAUDIO > 0 +extern long numvnodes; +extern int allowdt; extern int audio_record_enable; -#endif -#if NVIDEO > 0 extern int video_record_enable; -#endif int allowkmem; -int allowdt; int sysctl_diskinit(int, struct proc *); int sysctl_proc_args(int *, u_int, void *, size_t *, struct proc *); @@ -142,12 +139,8 @@ int sysctl_proc_vmmap(int *, u_int, void *, size_t *, struct proc *); int sysctl_intrcnt(int *, u_int, void *, size_t *); int sysctl_sensors(int *, u_int, void *, size_t *, void *, size_t); int sysctl_cptime2(int *, u_int, void *, size_t *, void *, size_t); -#if NAUDIO > 0 int sysctl_audio(int *, u_int, void *, size_t *, void *, size_t); -#endif -#if NVIDEO > 0 int sysctl_video(int *, u_int, void *, size_t *, void *, size_t); -#endif int sysctl_cpustats(int *, u_int, void *, size_t *, void *, size_t); int sysctl_utc_offset(void *, size_t *, void *, size_t); @@ -479,10 +472,12 @@ kern_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, return (EPERM); securelevel = level; return (0); +#if NDT > 0 case KERN_ALLOWDT: if (securelevel > 0) return (sysctl_rdint(oldp, oldlenp, newp, allowdt)); return (sysctl_int(oldp, oldlenp, newp, newlen, &allowdt)); +#endif case KERN_ALLOWKMEM: if (securelevel > 0) return (sysctl_rdint(oldp, oldlenp, newp, allowkmem));