diff options
author | Visa Hankala <visa@cvs.openbsd.org> | 2019-12-31 13:48:33 +0000 |
---|---|---|
committer | Visa Hankala <visa@cvs.openbsd.org> | 2019-12-31 13:48:33 +0000 |
commit | e1d46407d705bb612ebbeebddbe85779b52a42a5 (patch) | |
tree | b128da7e2130d5eeae1d5918b1cc8692523d852b /sys | |
parent | a2985aa5fb51f9899868daaf2cde0dfa5a0f449f (diff) |
Use C99 designated initializers with struct filterops. In addition,
make the structs const so that the data are put in .rodata.
OK mpi@, deraadt@, anton@, bluhm@
Diffstat (limited to 'sys')
34 files changed, 423 insertions, 182 deletions
diff --git a/sys/arch/arm64/dev/apm.c b/sys/arch/arm64/dev/apm.c index 48fee1144af..85b2ea7c75a 100644 --- a/sys/arch/arm64/dev/apm.c +++ b/sys/arch/arm64/dev/apm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apm.c,v 1.1 2019/01/23 09:57:36 phessler Exp $ */ +/* $OpenBSD: apm.c,v 1.2 2019/12/31 13:48:31 visa Exp $ */ /*- * Copyright (c) 2001 Alexander Guy. All rights reserved. @@ -87,8 +87,12 @@ int filt_apmread(struct knote *kn, long hint); int apmkqfilter(dev_t dev, struct knote *kn); int apm_getdefaultinfo(struct apm_power_info *); -struct filterops apmread_filtops = - { 1, NULL, filt_apmrdetach, filt_apmread}; +const struct filterops apmread_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_apmrdetach, + .f_event = filt_apmread, +}; int (*get_apminfo)(struct apm_power_info *) = apm_getdefaultinfo; diff --git a/sys/arch/i386/i386/apm.c b/sys/arch/i386/i386/apm.c index aafcffdd3ac..99a1c2daf6b 100644 --- a/sys/arch/i386/i386/apm.c +++ b/sys/arch/i386/i386/apm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apm.c,v 1.120 2019/10/12 15:56:17 cheloha Exp $ */ +/* $OpenBSD: apm.c,v 1.121 2019/12/31 13:48:31 visa Exp $ */ /*- * Copyright (c) 1998-2001 Michael Shalayeff. All rights reserved. @@ -103,8 +103,11 @@ struct cfattach apm_ca = { void filt_apmrdetach(struct knote *kn); int filt_apmread(struct knote *kn, long hint); -struct filterops apmread_filtops = { - 1, NULL, filt_apmrdetach, filt_apmread +const struct filterops apmread_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_apmrdetach, + .f_event = filt_apmread, }; #define APM_RESUME_HOLDOFF 3 diff --git a/sys/arch/loongson/dev/apm.c b/sys/arch/loongson/dev/apm.c index a6736d69c51..f768c63cced 100644 --- a/sys/arch/loongson/dev/apm.c +++ b/sys/arch/loongson/dev/apm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apm.c,v 1.32 2017/03/27 18:24:08 deraadt Exp $ */ +/* $OpenBSD: apm.c,v 1.33 2019/12/31 13:48:31 visa Exp $ */ /*- * Copyright (c) 2001 Alexander Guy. All rights reserved. @@ -93,8 +93,12 @@ int apm_getdefaultinfo(struct apm_power_info *); int apm_suspend(int state); -struct filterops apmread_filtops = - { 1, NULL, filt_apmrdetach, filt_apmread}; +const struct filterops apmread_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_apmrdetach, + .f_event = filt_apmread, +}; int (*get_apminfo)(struct apm_power_info *) = apm_getdefaultinfo; diff --git a/sys/arch/macppc/dev/apm.c b/sys/arch/macppc/dev/apm.c index 92caa63e764..86eb7dc58fd 100644 --- a/sys/arch/macppc/dev/apm.c +++ b/sys/arch/macppc/dev/apm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apm.c,v 1.19 2016/12/05 15:04:15 fcambus Exp $ */ +/* $OpenBSD: apm.c,v 1.20 2019/12/31 13:48:31 visa Exp $ */ /*- * Copyright (c) 2001 Alexander Guy. All rights reserved. @@ -85,8 +85,12 @@ void filt_apmrdetach(struct knote *kn); int filt_apmread(struct knote *kn, long hint); int apmkqfilter(dev_t dev, struct knote *kn); -struct filterops apmread_filtops = - { 1, NULL, filt_apmrdetach, filt_apmread}; +const struct filterops apmread_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_apmrdetach, + .f_event = filt_apmread, +}; /* * Flags to control kernel display diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c index 7a6f2249af1..7db2b8874af 100644 --- a/sys/dev/acpi/acpi.c +++ b/sys/dev/acpi/acpi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpi.c,v 1.376 2019/12/31 10:05:32 mpi Exp $ */ +/* $OpenBSD: acpi.c,v 1.377 2019/12/31 13:48:31 visa Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com> * Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org> @@ -3449,8 +3449,11 @@ acpiioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) void acpi_filtdetach(struct knote *); int acpi_filtread(struct knote *, long); -struct filterops acpiread_filtops = { - 1, NULL, acpi_filtdetach, acpi_filtread +const struct filterops acpiread_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = acpi_filtdetach, + .f_event = acpi_filtread, }; int acpi_evindex; diff --git a/sys/dev/hotplug.c b/sys/dev/hotplug.c index 772c4e3a4c1..8f6042cbd9d 100644 --- a/sys/dev/hotplug.c +++ b/sys/dev/hotplug.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hotplug.c,v 1.17 2019/12/31 10:05:32 mpi Exp $ */ +/* $OpenBSD: hotplug.c,v 1.18 2019/12/31 13:48:31 visa Exp $ */ /* * Copyright (c) 2004 Alexander Yurchenko <grange@openbsd.org> * @@ -38,8 +38,12 @@ static struct selinfo hotplug_sel; void filt_hotplugrdetach(struct knote *); int filt_hotplugread(struct knote *, long); -struct filterops hotplugread_filtops = - { 1, NULL, filt_hotplugrdetach, filt_hotplugread}; +const struct filterops hotplugread_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_hotplugrdetach, + .f_event = filt_hotplugread, +}; #define EVQUEUE_NEXT(p) (p == HOTPLUG_MAXEVENTS - 1 ? 0 : p + 1) diff --git a/sys/dev/midi.c b/sys/dev/midi.c index 15713cecc51..7a96e87ccf5 100644 --- a/sys/dev/midi.c +++ b/sys/dev/midi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: midi.c,v 1.44 2019/12/22 19:11:45 cheloha Exp $ */ +/* $OpenBSD: midi.c,v 1.45 2019/12/31 13:48:31 visa Exp $ */ /* * Copyright (c) 2003, 2004 Alexandre Ratchov @@ -66,15 +66,21 @@ struct cfdriver midi_cd = { void filt_midiwdetach(struct knote *); int filt_midiwrite(struct knote *, long); -struct filterops midiwrite_filtops = { - 1, NULL, filt_midiwdetach, filt_midiwrite +const struct filterops midiwrite_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_midiwdetach, + .f_event = filt_midiwrite, }; void filt_midirdetach(struct knote *); int filt_midiread(struct knote *, long); -struct filterops midiread_filtops = { - 1, NULL, filt_midirdetach, filt_midiread +const struct filterops midiread_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_midirdetach, + .f_event = filt_midiread, }; void diff --git a/sys/dev/pci/drm/drm_drv.c b/sys/dev/pci/drm/drm_drv.c index 8751587526b..61403440a88 100644 --- a/sys/dev/pci/drm/drm_drv.c +++ b/sys/dev/pci/drm/drm_drv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: drm_drv.c,v 1.166 2019/12/30 10:09:48 jsg Exp $ */ +/* $OpenBSD: drm_drv.c,v 1.167 2019/12/31 13:48:31 visa Exp $ */ /*- * Copyright 2007-2009 Owain G. Ainsworth <oga@openbsd.org> * Copyright © 2008 Intel Corporation @@ -504,8 +504,12 @@ filt_drmkms(struct knote *kn, long hint) return (kn->kn_fflags != 0); } -struct filterops drm_filtops = - { 1, NULL, filt_drmdetach, filt_drmkms }; +const struct filterops drm_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_drmdetach, + .f_event = filt_drmkms, +}; int drmkqfilter(dev_t kdev, struct knote *kn) diff --git a/sys/dev/rnd.c b/sys/dev/rnd.c index 1ed87557db3..97a1320f5a5 100644 --- a/sys/dev/rnd.c +++ b/sys/dev/rnd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rnd.c,v 1.199 2018/04/28 15:44:59 jasper Exp $ */ +/* $OpenBSD: rnd.c,v 1.200 2019/12/31 13:48:31 visa Exp $ */ /* * Copyright (c) 2011 Theo de Raadt. @@ -241,10 +241,19 @@ int filt_randomwrite(struct knote *, long); static void _rs_seed(u_char *, size_t); static void _rs_clearseed(const void *p, size_t s); -struct filterops randomread_filtops = - { 1, NULL, filt_randomdetach, filt_randomread }; -struct filterops randomwrite_filtops = - { 1, NULL, filt_randomdetach, filt_randomwrite }; +const struct filterops randomread_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_randomdetach, + .f_event = filt_randomread, +}; + +const struct filterops randomwrite_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_randomdetach, + .f_event = filt_randomwrite, +}; static inline struct rand_event * rnd_get(void) diff --git a/sys/dev/usb/ugen.c b/sys/dev/usb/ugen.c index 9f05bef1065..1b103430ddf 100644 --- a/sys/dev/usb/ugen.c +++ b/sys/dev/usb/ugen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ugen.c,v 1.99 2018/11/14 17:00:33 mpi Exp $ */ +/* $OpenBSD: ugen.c,v 1.100 2019/12/31 13:48:31 visa Exp $ */ /* $NetBSD: ugen.c,v 1.63 2002/11/26 18:49:48 christos Exp $ */ /* $FreeBSD: src/sys/dev/usb/ugen.c,v 1.26 1999/11/17 22:33:41 n_hibma Exp $ */ @@ -1328,14 +1328,26 @@ filt_ugenread_isoc(struct knote *kn, long hint) return (1); } -struct filterops ugenread_intr_filtops = - { 1, NULL, filt_ugenrdetach, filt_ugenread_intr }; +const struct filterops ugenread_intr_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_ugenrdetach, + .f_event = filt_ugenread_intr, +}; -struct filterops ugenread_isoc_filtops = - { 1, NULL, filt_ugenrdetach, filt_ugenread_isoc }; +const struct filterops ugenread_isoc_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_ugenrdetach, + .f_event = filt_ugenread_isoc, +}; -struct filterops ugen_seltrue_filtops = - { 1, NULL, filt_ugenrdetach, filt_seltrue }; +const struct filterops ugen_seltrue_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_ugenrdetach, + .f_event = filt_seltrue, +}; int ugenkqfilter(dev_t dev, struct knote *kn) diff --git a/sys/dev/usb/uhid.c b/sys/dev/usb/uhid.c index 440677deeaf..9cadd22ad35 100644 --- a/sys/dev/usb/uhid.c +++ b/sys/dev/usb/uhid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uhid.c,v 1.74 2019/12/19 12:04:38 reyk Exp $ */ +/* $OpenBSD: uhid.c,v 1.75 2019/12/31 13:48:31 visa Exp $ */ /* $NetBSD: uhid.c,v 1.57 2003/03/11 16:44:00 augustss Exp $ */ /* @@ -456,11 +456,19 @@ filt_uhidread(struct knote *kn, long hint) return (kn->kn_data > 0); } -struct filterops uhidread_filtops = - { 1, NULL, filt_uhidrdetach, filt_uhidread }; +const struct filterops uhidread_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_uhidrdetach, + .f_event = filt_uhidread, +}; -struct filterops uhid_seltrue_filtops = - { 1, NULL, filt_uhidrdetach, filt_seltrue }; +const struct filterops uhid_seltrue_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_uhidrdetach, + .f_event = filt_seltrue, +}; int uhidkqfilter(dev_t dev, struct knote *kn) diff --git a/sys/dev/vscsi.c b/sys/dev/vscsi.c index 647c2b531ac..765b62d4c5b 100644 --- a/sys/dev/vscsi.c +++ b/sys/dev/vscsi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vscsi.c,v 1.43 2019/12/31 10:05:32 mpi Exp $ */ +/* $OpenBSD: vscsi.c,v 1.44 2019/12/31 13:48:31 visa Exp $ */ /* * Copyright (c) 2008 David Gwynne <dlg@openbsd.org> @@ -116,11 +116,11 @@ void vscsi_ccb_put(void *, void *); void filt_vscsidetach(struct knote *); int filt_vscsiread(struct knote *, long); -struct filterops vscsi_filtops = { - 1, - NULL, - filt_vscsidetach, - filt_vscsiread +const struct filterops vscsi_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_vscsidetach, + .f_event = filt_vscsiread, }; diff --git a/sys/dev/wscons/wsevent.c b/sys/dev/wscons/wsevent.c index 1b21796da9c..883d70d96b5 100644 --- a/sys/dev/wscons/wsevent.c +++ b/sys/dev/wscons/wsevent.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wsevent.c,v 1.21 2019/08/08 02:19:18 cheloha Exp $ */ +/* $OpenBSD: wsevent.c,v 1.22 2019/12/31 13:48:31 visa Exp $ */ /* $NetBSD: wsevent.c,v 1.16 2003/08/07 16:31:29 agc Exp $ */ /* @@ -89,10 +89,10 @@ void filt_wseventdetach(struct knote *); int filt_wseventread(struct knote *, long); const struct filterops wsevent_filtops = { - 1, - NULL, - filt_wseventdetach, - filt_wseventread + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_wseventdetach, + .f_event = filt_wseventread, }; /* diff --git a/sys/isofs/cd9660/cd9660_vnops.c b/sys/isofs/cd9660/cd9660_vnops.c index c05b3dc5941..7860c71032d 100644 --- a/sys/isofs/cd9660/cd9660_vnops.c +++ b/sys/isofs/cd9660/cd9660_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cd9660_vnops.c,v 1.79 2019/08/05 08:35:59 anton Exp $ */ +/* $OpenBSD: cd9660_vnops.c,v 1.80 2019/12/31 13:48:32 visa Exp $ */ /* $NetBSD: cd9660_vnops.c,v 1.42 1997/10/16 23:56:57 christos Exp $ */ /*- @@ -958,12 +958,26 @@ int filt_cd9660read(struct knote *kn, long hint); int filt_cd9660write(struct knote *kn, long hint); int filt_cd9660vnode(struct knote *kn, long hint); -struct filterops cd9660read_filtops = - { 1, NULL, filt_cd9660detach, filt_cd9660read }; -struct filterops cd9660write_filtops = - { 1, NULL, filt_cd9660detach, filt_cd9660write }; -struct filterops cd9660vnode_filtops = - { 1, NULL, filt_cd9660detach, filt_cd9660vnode }; +const struct filterops cd9660read_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_cd9660detach, + .f_event = filt_cd9660read, +}; + +const struct filterops cd9660write_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_cd9660detach, + .f_event = filt_cd9660write, +}; + +const struct filterops cd9660vnode_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_cd9660detach, + .f_event = filt_cd9660vnode, +}; int cd9660_kqfilter(void *v) diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c index fd6876626b2..92ee7adcf57 100644 --- a/sys/kern/kern_event.c +++ b/sys/kern/kern_event.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_event.c,v 1.111 2019/12/29 07:14:06 visa Exp $ */ +/* $OpenBSD: kern_event.c,v 1.112 2019/12/31 13:48:32 visa Exp $ */ /*- * Copyright (c) 1999,2000,2001 Jonathan Lemon <jlemon@FreeBSD.org> @@ -98,14 +98,33 @@ void filt_timerdetach(struct knote *kn); int filt_timer(struct knote *kn, long hint); void filt_seltruedetach(struct knote *kn); -struct filterops kqread_filtops = - { 1, NULL, filt_kqdetach, filt_kqueue }; -struct filterops proc_filtops = - { 0, filt_procattach, filt_procdetach, filt_proc }; -struct filterops file_filtops = - { 1, filt_fileattach, NULL, NULL }; -struct filterops timer_filtops = - { 0, filt_timerattach, filt_timerdetach, filt_timer }; +const struct filterops kqread_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_kqdetach, + .f_event = filt_kqueue, +}; + +const struct filterops proc_filtops = { + .f_isfd = 0, + .f_attach = filt_procattach, + .f_detach = filt_procdetach, + .f_event = filt_proc, +}; + +const struct filterops file_filtops = { + .f_isfd = 1, + .f_attach = filt_fileattach, + .f_detach = NULL, + .f_event = NULL, +}; + +const struct filterops timer_filtops = { + .f_isfd = 0, + .f_attach = filt_timerattach, + .f_detach = filt_timerdetach, + .f_event = filt_timer, +}; struct pool knote_pool; struct pool kqueue_pool; @@ -114,15 +133,10 @@ int kq_timeoutmax = (4 * 1024); #define KN_HASH(val, mask) (((val) ^ (val >> 8)) & (mask)) -extern struct filterops sig_filtops; -#ifdef notyet -extern struct filterops aio_filtops; -#endif - /* * Table for for all system-defined filters. */ -struct filterops *sysfilt_ops[] = { +const struct filterops *const sysfilt_ops[] = { &file_filtops, /* EVFILT_READ */ &file_filtops, /* EVFILT_WRITE */ NULL, /*&aio_filtops,*/ /* EVFILT_AIO */ @@ -415,8 +429,12 @@ filt_seltruedetach(struct knote *kn) /* Nothing to do */ } -const struct filterops seltrue_filtops = - { 1, NULL, filt_seltruedetach, filt_seltrue }; +const struct filterops seltrue_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_seltruedetach, + .f_event = filt_seltrue, +}; int seltrue_kqfilter(dev_t dev, struct knote *kn) @@ -602,7 +620,7 @@ int kqueue_register(struct kqueue *kq, struct kevent *kev, struct proc *p) { struct filedesc *fdp = kq->kq_fdp; - struct filterops *fops = NULL; + const struct filterops *fops = NULL; struct file *fp = NULL; struct knote *kn = NULL; int s, error = 0; diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index 1db70dbcbfd..776ef7382bf 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sig.c,v 1.237 2019/12/19 17:40:11 mpi Exp $ */ +/* $OpenBSD: kern_sig.c,v 1.238 2019/12/31 13:48:32 visa Exp $ */ /* $NetBSD: kern_sig.c,v 1.54 1996/04/22 01:38:32 christos Exp $ */ /* @@ -75,8 +75,12 @@ int filt_sigattach(struct knote *kn); void filt_sigdetach(struct knote *kn); int filt_signal(struct knote *kn, long hint); -struct filterops sig_filtops = - { 0, filt_sigattach, filt_sigdetach, filt_signal }; +const struct filterops sig_filtops = { + .f_isfd = 0, + .f_attach = filt_sigattach, + .f_detach = filt_sigdetach, + .f_event = filt_signal, +}; void proc_stop(struct proc *p, int); void proc_stop_sweep(void *); diff --git a/sys/kern/subr_log.c b/sys/kern/subr_log.c index 6f5d2be7b44..aead8b3b7e8 100644 --- a/sys/kern/subr_log.c +++ b/sys/kern/subr_log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_log.c,v 1.60 2019/12/24 12:56:07 bluhm Exp $ */ +/* $OpenBSD: subr_log.c,v 1.61 2019/12/31 13:48:32 visa Exp $ */ /* $NetBSD: subr_log.c,v 1.11 1996/03/30 22:24:44 christos Exp $ */ /* @@ -88,8 +88,12 @@ struct file *syslogf; void filt_logrdetach(struct knote *kn); int filt_logread(struct knote *kn, long hint); -struct filterops logread_filtops = - { 1, NULL, filt_logrdetach, filt_logread}; +const struct filterops logread_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_logrdetach, + .f_event = filt_logread, +}; int dosendsyslog(struct proc *, const char *, size_t, int, enum uio_seg); void logtick(void *); diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c index 2229aee7cf7..295ff28ac32 100644 --- a/sys/kern/sys_pipe.c +++ b/sys/kern/sys_pipe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sys_pipe.c,v 1.105 2019/12/27 09:29:50 anton Exp $ */ +/* $OpenBSD: sys_pipe.c,v 1.106 2019/12/31 13:48:32 visa Exp $ */ /* * Copyright (c) 1996 John S. Dyson @@ -74,10 +74,19 @@ void filt_pipedetach(struct knote *kn); int filt_piperead(struct knote *kn, long hint); int filt_pipewrite(struct knote *kn, long hint); -struct filterops pipe_rfiltops = - { 1, NULL, filt_pipedetach, filt_piperead }; -struct filterops pipe_wfiltops = - { 1, NULL, filt_pipedetach, filt_pipewrite }; +const struct filterops pipe_rfiltops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_pipedetach, + .f_event = filt_piperead, +}; + +const struct filterops pipe_wfiltops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_pipedetach, + .f_event = filt_pipewrite, +}; /* * Default pipe buffer size(s), this can be kind-of large now because pipe diff --git a/sys/kern/tty.c b/sys/kern/tty.c index a21f7f2741f..d73714f77d8 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.c,v 1.148 2019/07/19 00:17:15 cheloha Exp $ */ +/* $OpenBSD: tty.c,v 1.149 2019/12/31 13:48:32 visa Exp $ */ /* $NetBSD: tty.c,v 1.68.4.2 1996/06/06 16:04:52 thorpej Exp $ */ /*- @@ -1062,10 +1062,19 @@ ttpoll(dev_t device, int events, struct proc *p) return (revents); } -struct filterops ttyread_filtops = - { 1, NULL, filt_ttyrdetach, filt_ttyread }; -struct filterops ttywrite_filtops = - { 1, NULL, filt_ttywdetach, filt_ttywrite }; +const struct filterops ttyread_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_ttyrdetach, + .f_event = filt_ttyread, +}; + +const struct filterops ttywrite_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_ttywdetach, + .f_event = filt_ttywrite, +}; int ttkqfilter(dev_t dev, struct knote *kn) diff --git a/sys/kern/tty_pty.c b/sys/kern/tty_pty.c index 6c0ba70d018..e30b7cebe5d 100644 --- a/sys/kern/tty_pty.c +++ b/sys/kern/tty_pty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty_pty.c,v 1.94 2019/07/19 00:17:16 cheloha Exp $ */ +/* $OpenBSD: tty_pty.c,v 1.95 2019/12/31 13:48:32 visa Exp $ */ /* $NetBSD: tty_pty.c,v 1.33.4.1 1996/06/02 09:08:11 mrg Exp $ */ /* @@ -717,10 +717,19 @@ filt_ptcwrite(struct knote *kn, long hint) return (kn->kn_data > 0); } -struct filterops ptcread_filtops = - { 1, NULL, filt_ptcrdetach, filt_ptcread }; -struct filterops ptcwrite_filtops = - { 1, NULL, filt_ptcwdetach, filt_ptcwrite }; +const struct filterops ptcread_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_ptcrdetach, + .f_event = filt_ptcread, +}; + +const struct filterops ptcwrite_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_ptcwdetach, + .f_event = filt_ptcwrite, +}; int ptckqfilter(dev_t dev, struct knote *kn) diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index a61d407030d..58d78fbd5d4 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_socket.c,v 1.237 2019/12/12 16:33:02 visa Exp $ */ +/* $OpenBSD: uipc_socket.c,v 1.238 2019/12/31 13:48:32 visa Exp $ */ /* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */ /* @@ -72,12 +72,26 @@ void filt_sowdetach(struct knote *kn); int filt_sowrite(struct knote *kn, long hint); int filt_solisten(struct knote *kn, long hint); -struct filterops solisten_filtops = - { 1, NULL, filt_sordetach, filt_solisten }; -struct filterops soread_filtops = - { 1, NULL, filt_sordetach, filt_soread }; -struct filterops sowrite_filtops = - { 1, NULL, filt_sowdetach, filt_sowrite }; +const struct filterops solisten_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_sordetach, + .f_event = filt_solisten, +}; + +const struct filterops soread_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_sordetach, + .f_event = filt_soread, +}; + +const struct filterops sowrite_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_sowdetach, + .f_event = filt_sowrite, +}; #ifndef SOMINCONN diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c index 92fbd818636..a8ca01b337a 100644 --- a/sys/kern/vfs_default.c +++ b/sys/kern/vfs_default.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_default.c,v 1.45 2019/12/27 22:17:01 bluhm Exp $ */ +/* $OpenBSD: vfs_default.c,v 1.46 2019/12/31 13:48:32 visa Exp $ */ /* * Portions of this code are: @@ -185,8 +185,12 @@ vop_generic_islocked(void *v) return (0); } -struct filterops generic_filtops = - { 1, NULL, filt_generic_detach, filt_generic_readwrite }; +const struct filterops generic_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_generic_detach, + .f_event = filt_generic_readwrite, +}; int vop_generic_kqfilter(void *v) diff --git a/sys/miscfs/fifofs/fifo_vnops.c b/sys/miscfs/fifofs/fifo_vnops.c index 947badf3a91..d71b917214f 100644 --- a/sys/miscfs/fifofs/fifo_vnops.c +++ b/sys/miscfs/fifofs/fifo_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fifo_vnops.c,v 1.69 2019/12/12 16:33:02 visa Exp $ */ +/* $OpenBSD: fifo_vnops.c,v 1.70 2019/12/31 13:48:32 visa Exp $ */ /* $NetBSD: fifo_vnops.c,v 1.18 1996/03/16 23:52:42 christos Exp $ */ /* @@ -107,10 +107,19 @@ int filt_fiforead(struct knote *kn, long hint); void filt_fifowdetach(struct knote *kn); int filt_fifowrite(struct knote *kn, long hint); -struct filterops fiforead_filtops = - { 1, NULL, filt_fifordetach, filt_fiforead }; -struct filterops fifowrite_filtops = - { 1, NULL, filt_fifowdetach, filt_fifowrite }; +const struct filterops fiforead_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_fifordetach, + .f_event = filt_fiforead, +}; + +const struct filterops fifowrite_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_fifowdetach, + .f_event = filt_fifowrite, +}; /* * Open called to set up a new instance of a fifo or diff --git a/sys/miscfs/fuse/fuse_device.c b/sys/miscfs/fuse/fuse_device.c index 334a5e6f37b..14a78e92370 100644 --- a/sys/miscfs/fuse/fuse_device.c +++ b/sys/miscfs/fuse/fuse_device.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fuse_device.c,v 1.29 2018/06/27 13:58:22 helg Exp $ */ +/* $OpenBSD: fuse_device.c,v 1.30 2019/12/31 13:48:32 visa Exp $ */ /* * Copyright (c) 2012-2013 Sylvestre Gallon <ccna.syl@gmail.com> * @@ -70,17 +70,17 @@ int filt_fuse_read(struct knote *, long); void filt_fuse_rdetach(struct knote *); const static struct filterops fuse_rd_filtops = { - 1, - NULL, - filt_fuse_rdetach, - filt_fuse_read + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_fuse_rdetach, + .f_event = filt_fuse_read, }; const static struct filterops fuse_seltrue_filtops = { - 1, - NULL, - filt_fuse_rdetach, - filt_seltrue + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_fuse_rdetach, + .f_event = filt_seltrue, }; #ifdef FUSE_DEBUG diff --git a/sys/miscfs/fuse/fuse_vnops.c b/sys/miscfs/fuse/fuse_vnops.c index 6bf5aad757d..d96daac441f 100644 --- a/sys/miscfs/fuse/fuse_vnops.c +++ b/sys/miscfs/fuse/fuse_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fuse_vnops.c,v 1.55 2019/08/05 08:35:59 anton Exp $ */ +/* $OpenBSD: fuse_vnops.c,v 1.56 2019/12/31 13:48:32 visa Exp $ */ /* * Copyright (c) 2012-2013 Sylvestre Gallon <ccna.syl@gmail.com> * @@ -110,12 +110,26 @@ struct vops fusefs_vops = { .vop_advlock = fusefs_advlock, }; -struct filterops fusefsread_filtops = - { 1, NULL, filt_fusefsdetach, filt_fusefsread }; -struct filterops fusefswrite_filtops = - { 1, NULL, filt_fusefsdetach, filt_fusefswrite }; -struct filterops fusefsvnode_filtops = - { 1, NULL, filt_fusefsdetach, filt_fusefsvnode }; +const struct filterops fusefsread_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_fusefsdetach, + .f_event = filt_fusefsread, +}; + +const struct filterops fusefswrite_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_fusefsdetach, + .f_event = filt_fusefswrite, +}; + +const struct filterops fusefsvnode_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_fusefsdetach, + .f_event = filt_fusefsvnode, +}; int fusefs_kqfilter(void *v) diff --git a/sys/msdosfs/msdosfs_vnops.c b/sys/msdosfs/msdosfs_vnops.c index f5e2cfd3784..1a308023410 100644 --- a/sys/msdosfs/msdosfs_vnops.c +++ b/sys/msdosfs/msdosfs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: msdosfs_vnops.c,v 1.126 2019/08/05 08:35:59 anton Exp $ */ +/* $OpenBSD: msdosfs_vnops.c,v 1.127 2019/12/31 13:48:32 visa Exp $ */ /* $NetBSD: msdosfs_vnops.c,v 1.63 1997/10/17 11:24:19 ws Exp $ */ /*- @@ -1959,12 +1959,26 @@ struct vops msdosfs_vops = { .vop_revoke = vop_generic_revoke, }; -struct filterops msdosfsread_filtops = - { 1, NULL, filt_msdosfsdetach, filt_msdosfsread }; -struct filterops msdosfswrite_filtops = - { 1, NULL, filt_msdosfsdetach, filt_msdosfswrite }; -struct filterops msdosfsvnode_filtops = - { 1, NULL, filt_msdosfsdetach, filt_msdosfsvnode }; +const struct filterops msdosfsread_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_msdosfsdetach, + .f_event = filt_msdosfsread, +}; + +const struct filterops msdosfswrite_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_msdosfsdetach, + .f_event = filt_msdosfswrite, +}; + +const struct filterops msdosfsvnode_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_msdosfsdetach, + .f_event = filt_msdosfsvnode, +}; int msdosfs_kqfilter(void *v) diff --git a/sys/net/bpf.c b/sys/net/bpf.c index 365ce900860..6c23b4581b7 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bpf.c,v 1.182 2019/10/21 23:02:05 sashan Exp $ */ +/* $OpenBSD: bpf.c,v 1.183 2019/12/31 13:48:32 visa Exp $ */ /* $NetBSD: bpf.c,v 1.33 1997/02/21 23:59:35 thorpej Exp $ */ /* @@ -1170,8 +1170,12 @@ bpfpoll(dev_t dev, int events, struct proc *p) return (revents); } -struct filterops bpfread_filtops = - { 1, NULL, filt_bpfrdetach, filt_bpfread }; +const struct filterops bpfread_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_bpfrdetach, + .f_event = filt_bpfread, +}; int bpfkqfilter(dev_t dev, struct knote *kn) diff --git a/sys/net/if_pppx.c b/sys/net/if_pppx.c index 0bd206b1e8d..9bdbee78e6a 100644 --- a/sys/net/if_pppx.c +++ b/sys/net/if_pppx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_pppx.c,v 1.69 2019/11/08 07:16:29 dlg Exp $ */ +/* $OpenBSD: if_pppx.c,v 1.70 2019/12/31 13:48:32 visa Exp $ */ /* * Copyright (c) 2010 Claudio Jeker <claudio@openbsd.org> @@ -185,21 +185,21 @@ void pppxattach(int); void filt_pppx_rdetach(struct knote *); int filt_pppx_read(struct knote *, long); -struct filterops pppx_rd_filtops = { - 1, - NULL, - filt_pppx_rdetach, - filt_pppx_read +const struct filterops pppx_rd_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_pppx_rdetach, + .f_event = filt_pppx_read, }; void filt_pppx_wdetach(struct knote *); int filt_pppx_write(struct knote *, long); -struct filterops pppx_wr_filtops = { - 1, - NULL, - filt_pppx_wdetach, - filt_pppx_write +const struct filterops pppx_wr_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_pppx_wdetach, + .f_event = filt_pppx_write, }; struct pppx_dev * diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c index c1339ad5ce4..f508954bae8 100644 --- a/sys/net/if_tun.c +++ b/sys/net/if_tun.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_tun.c,v 1.195 2019/11/26 06:23:30 dlg Exp $ */ +/* $OpenBSD: if_tun.c,v 1.196 2019/12/31 13:48:32 visa Exp $ */ /* $NetBSD: if_tun.c,v 1.24 1996/05/07 02:40:48 thorpej Exp $ */ /* @@ -153,11 +153,19 @@ void filt_tunrdetach(struct knote *); void filt_tunwdetach(struct knote *); void tun_link_state(struct tun_softc *); -struct filterops tunread_filtops = - { 1, NULL, filt_tunrdetach, filt_tunread}; +const struct filterops tunread_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_tunrdetach, + .f_event = filt_tunread, +}; -struct filterops tunwrite_filtops = - { 1, NULL, filt_tunwdetach, filt_tunwrite}; +const struct filterops tunwrite_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_tunwdetach, + .f_event = filt_tunwrite, +}; LIST_HEAD(tun_list, tun_softc); diff --git a/sys/net/switchctl.c b/sys/net/switchctl.c index 7a8f746cc87..a3b51481bd5 100644 --- a/sys/net/switchctl.c +++ b/sys/net/switchctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: switchctl.c,v 1.17 2019/12/19 12:04:38 reyk Exp $ */ +/* $OpenBSD: switchctl.c,v 1.18 2019/12/31 13:48:32 visa Exp $ */ /* * Copyright (c) 2016 Kazuya GODA <goda@openbsd.org> @@ -59,11 +59,18 @@ int filt_switch_write(struct knote *, long); int switch_dev_output(struct switch_softc *, struct mbuf *); void switch_dev_wakeup(struct switch_softc *); -struct filterops switch_rd_filtops = { - 1, NULL, filt_switch_rdetach, filt_switch_read +const struct filterops switch_rd_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_switch_rdetach, + .f_event = filt_switch_read, }; -struct filterops switch_wr_filtops = { - 1, NULL, filt_switch_wdetach, filt_switch_write + +const struct filterops switch_wr_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_switch_wdetach, + .f_event = filt_switch_write, }; struct switch_softc * diff --git a/sys/nfs/nfs_kq.c b/sys/nfs/nfs_kq.c index 0ccbe14ccb3..67cad81b4b5 100644 --- a/sys/nfs/nfs_kq.c +++ b/sys/nfs/nfs_kq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_kq.c,v 1.26 2019/12/05 10:41:57 mpi Exp $ */ +/* $OpenBSD: nfs_kq.c,v 1.27 2019/12/31 13:48:32 visa Exp $ */ /* $NetBSD: nfs_kq.c,v 1.7 2003/10/30 01:43:10 simonb Exp $ */ /*- @@ -249,10 +249,19 @@ filt_nfsvnode(struct knote *kn, long hint) return (kn->kn_fflags != 0); } -static const struct filterops nfsread_filtops = - { 1, NULL, filt_nfsdetach, filt_nfsread }; -static const struct filterops nfsvnode_filtops = - { 1, NULL, filt_nfsdetach, filt_nfsvnode }; +static const struct filterops nfsread_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_nfsdetach, + .f_event = filt_nfsread, +}; + +static const struct filterops nfsvnode_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_nfsdetach, + .f_event = filt_nfsvnode, +}; int nfs_kqfilter(void *v) diff --git a/sys/sys/event.h b/sys/sys/event.h index 909367aea33..0597021c114 100644 --- a/sys/sys/event.h +++ b/sys/sys/event.h @@ -1,4 +1,4 @@ -/* $OpenBSD: event.h,v 1.31 2019/12/12 16:31:06 visa Exp $ */ +/* $OpenBSD: event.h,v 1.32 2019/12/31 13:48:32 visa Exp $ */ /*- * Copyright (c) 1999,2000,2001 Jonathan Lemon <jlemon@FreeBSD.org> @@ -185,6 +185,8 @@ struct knote { struct proc; +extern const struct filterops sig_filtops; + extern void knote(struct klist *list, long hint); extern void knote_activate(struct knote *); extern void knote_remove(struct proc *p, struct klist *list); diff --git a/sys/tmpfs/tmpfs_vnops.c b/sys/tmpfs/tmpfs_vnops.c index 857fcb47771..ba3963a14ea 100644 --- a/sys/tmpfs/tmpfs_vnops.c +++ b/sys/tmpfs/tmpfs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tmpfs_vnops.c,v 1.36 2019/08/05 08:35:59 anton Exp $ */ +/* $OpenBSD: tmpfs_vnops.c,v 1.37 2019/12/31 13:48:32 visa Exp $ */ /* $NetBSD: tmpfs_vnops.c,v 1.100 2012/11/05 17:27:39 dholland Exp $ */ /* @@ -2587,12 +2587,26 @@ int filt_tmpfsread(struct knote *kn, long hint); int filt_tmpfswrite(struct knote *kn, long hint); int filt_tmpfsvnode(struct knote *kn, long hint); -struct filterops tmpfsread_filtops = - { 1, NULL, filt_tmpfsdetach, filt_tmpfsread }; -struct filterops tmpfswrite_filtops = - { 1, NULL, filt_tmpfsdetach, filt_tmpfswrite }; -struct filterops tmpfsvnode_filtops = - { 1, NULL, filt_tmpfsdetach, filt_tmpfsvnode }; +const struct filterops tmpfsread_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_tmpfsdetach, + .f_event = filt_tmpfsread, +}; + +const struct filterops tmpfswrite_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_tmpfsdetach, + .f_event = filt_tmpfswrite, +}; + +const struct filterops tmpfsvnode_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_tmpfsdetach, + .f_event = filt_tmpfsvnode, +}; int tmpfs_kqfilter(void *v) diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c index 1956cf99155..01530c80902 100644 --- a/sys/ufs/ufs/ufs_vnops.c +++ b/sys/ufs/ufs/ufs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ufs_vnops.c,v 1.146 2019/08/05 08:35:59 anton Exp $ */ +/* $OpenBSD: ufs_vnops.c,v 1.147 2019/12/31 13:48:32 visa Exp $ */ /* $NetBSD: ufs_vnops.c,v 1.18 1996/05/11 18:28:04 mycroft Exp $ */ /* @@ -1892,12 +1892,26 @@ bad: return (error); } -struct filterops ufsread_filtops = - { 1, NULL, filt_ufsdetach, filt_ufsread }; -struct filterops ufswrite_filtops = - { 1, NULL, filt_ufsdetach, filt_ufswrite }; -struct filterops ufsvnode_filtops = - { 1, NULL, filt_ufsdetach, filt_ufsvnode }; +const struct filterops ufsread_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_ufsdetach, + .f_event = filt_ufsread, +}; + +const struct filterops ufswrite_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_ufsdetach, + .f_event = filt_ufswrite, +}; + +const struct filterops ufsvnode_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_ufsdetach, + .f_event = filt_ufsvnode, +}; int ufs_kqfilter(void *v) |