Download raw body.
sysctl(2): unlock sysctl_video()
Like recently unlocked sysctl_audio(), it is the only KERN_VIDEO_RECORD.
`video_record_enable' is atomically accessed integer.
Index: sys/dev/video.c
===================================================================
RCS file: /cvs/src/sys/dev/video.c,v
diff -u -p -r1.57 video.c
--- sys/dev/video.c 2 Jul 2022 08:50:41 -0000 1.57
+++ sys/dev/video.c 22 Aug 2024 10:28:56 -0000
@@ -34,6 +34,11 @@
#include <uvm/uvm_extern.h>
+/*
+ * Locks used to protect data:
+ * a atomic
+ */
+
#ifdef VIDEO_DEBUG
int video_debug = 1;
#define DPRINTF(l, x...) do { if ((l) <= video_debug) printf(x); } while (0)
@@ -85,7 +90,7 @@ struct cfdriver video_cd = {
/*
* Global flag to control if video recording is enabled by kern.video.record.
*/
-int video_record_enable = 0;
+int video_record_enable = 0; /* [a] */
int
videoprobe(struct device *parent, void *match, void *aux)
@@ -216,7 +221,7 @@ videoread(dev_t dev, struct uio *uio, in
/* move no more than 1 frame to userland, as per specification */
size = ulmin(uio->uio_resid, sc->sc_fsize);
- if (!video_record_enable)
+ if (atomic_load_int(&video_record_enable) == 0)
bzero(sc->sc_fbuffer, size);
error = uiomove(sc->sc_fbuffer, size, uio);
sc->sc_frames_ready--;
@@ -354,7 +359,7 @@ videoioctl(dev_t dev, u_long cmd, caddr_
}
error = (sc->hw_if->dqbuf)(sc->hw_hdl,
(struct v4l2_buffer *)data);
- if (!video_record_enable)
+ if (atomic_load_int(&video_record_enable) == 0)
bzero(sc->sc_fbuffer_mmap + vb->m.offset, vb->length);
sc->sc_frames_ready--;
break;
Index: sys/kern/kern_sysctl.c
===================================================================
RCS file: /cvs/src/sys/kern/kern_sysctl.c,v
diff -u -p -r1.442 kern_sysctl.c
--- sys/kern/kern_sysctl.c 20 Aug 2024 13:29:25 -0000 1.442
+++ sys/kern/kern_sysctl.c 22 Aug 2024 10:28:57 -0000
@@ -455,11 +455,6 @@ kern_sysctl_dirs(int top_name, int *name
return witness_sysctl(name, namelen, oldp, oldlenp,
newp, newlen);
#endif
-#if NVIDEO > 0
- case KERN_VIDEO:
- return (sysctl_video(name, namelen, oldp, oldlenp,
- newp, newlen));
-#endif
case KERN_CPUSTATS:
return (sysctl_cpustats(name, namelen, oldp, oldlenp,
newp, newlen));
@@ -487,6 +482,11 @@ kern_sysctl(int *name, u_int namelen, vo
#if NAUDIO > 0
case KERN_AUDIO:
return (sysctl_audio(name, namelen, oldp, oldlenp,
+ newp, newlen));
+#endif
+#if NVIDEO > 0
+ case KERN_VIDEO:
+ return (sysctl_video(name, namelen, oldp, oldlenp,
newp, newlen));
#endif
default:
sysctl(2): unlock sysctl_video()