git: 48155c983c4b - stable/14 - kern: Make fileops and filterops tables const where possible
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 03 Dec 2024 02:17:13 UTC
The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=48155c983c4ba7158e738bd1d4b3144751bd1d86 commit 48155c983c4ba7158e738bd1d4b3144751bd1d86 Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2024-11-25 22:39:31 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2024-12-03 01:03:42 +0000 kern: Make fileops and filterops tables const where possible No functional change intended. MFC after: 1 week (cherry picked from commit ef9ffb8594eee294334ced627755bf5b46b48f9f) --- sys/arm/ti/ti_pruss.c | 2 +- sys/cam/scsi/scsi_pass.c | 2 +- sys/cam/scsi/scsi_target.c | 2 +- sys/compat/linuxkpi/common/include/linux/file.h | 2 +- sys/compat/linuxkpi/common/src/linux_compat.c | 6 +++--- sys/dev/beri/beri_ring.c | 4 ++-- sys/dev/cyapa/cyapa.c | 2 +- sys/dev/evdev/cdev.c | 2 +- sys/dev/evdev/uinput.c | 4 ++-- sys/dev/gpio/gpioc.c | 2 +- sys/dev/hid/hidraw.c | 2 +- sys/dev/netmap/netmap_freebsd.c | 4 ++-- sys/dev/qat/qat_common/adf_freebsd_dev_processes.c | 2 +- sys/dev/usb/usb_dev.c | 4 ++-- sys/fs/cuse/cuse.c | 4 ++-- sys/fs/devfs/devfs_vnops.c | 4 ++-- sys/fs/fuse/fuse_device.c | 4 ++-- sys/geom/geom_dev.c | 2 +- sys/kern/kern_descrip.c | 9 +++++---- sys/kern/kern_devctl.c | 2 +- sys/kern/kern_event.c | 18 +++++++++--------- sys/kern/kern_sig.c | 2 +- sys/kern/subr_log.c | 2 +- sys/kern/sys_eventfd.c | 6 +++--- sys/kern/sys_pipe.c | 8 ++++---- sys/kern/sys_procdesc.c | 4 ++-- sys/kern/sys_socket.c | 2 +- sys/kern/sys_timerfd.c | 4 ++-- sys/kern/tty.c | 4 ++-- sys/kern/tty_pts.c | 6 +++--- sys/kern/uipc_mqueue.c | 8 ++++---- sys/kern/uipc_sem.c | 2 +- sys/kern/uipc_shm.c | 2 +- sys/kern/uipc_socket.c | 6 +++--- sys/kern/vfs_aio.c | 4 ++-- sys/kern/vfs_subr.c | 8 ++++---- sys/kern/vfs_vnops.c | 2 +- sys/net/bpf.c | 4 ++-- sys/net/if_tuntap.c | 4 ++-- sys/security/audit/audit_pipe.c | 2 +- sys/sys/file.h | 12 ++++++------ sys/sys/mman.h | 2 +- sys/sys/pipe.h | 2 +- sys/x86/acpica/acpi_apm.c | 2 +- 44 files changed, 91 insertions(+), 90 deletions(-) diff --git a/sys/arm/ti/ti_pruss.c b/sys/arm/ti/ti_pruss.c index b6895a8a9cef..9f8bcedbdb05 100644 --- a/sys/arm/ti/ti_pruss.c +++ b/sys/arm/ti/ti_pruss.c @@ -789,7 +789,7 @@ ti_pruss_mmap(struct cdev *cdev, vm_ooffset_t offset, vm_paddr_t *paddr, return (0); } -static struct filterops ti_pruss_kq_read = { +static const struct filterops ti_pruss_kq_read = { .f_isfd = 1, .f_detach = ti_pruss_irq_kqread_detach, .f_event = ti_pruss_irq_kqevent, diff --git a/sys/cam/scsi/scsi_pass.c b/sys/cam/scsi/scsi_pass.c index ff48bed30e68..72035e1e0d0e 100644 --- a/sys/cam/scsi/scsi_pass.c +++ b/sys/cam/scsi/scsi_pass.c @@ -203,7 +203,7 @@ static struct cdevsw pass_cdevsw = { .d_name = "pass", }; -static struct filterops passread_filtops = { +static const struct filterops passread_filtops = { .f_isfd = 1, .f_detach = passreadfiltdetach, .f_event = passreadfilt diff --git a/sys/cam/scsi/scsi_target.c b/sys/cam/scsi/scsi_target.c index 6872e3a2a93b..278fcd908d7b 100644 --- a/sys/cam/scsi/scsi_target.c +++ b/sys/cam/scsi/scsi_target.c @@ -105,7 +105,7 @@ static d_poll_t targpoll; static d_kqfilter_t targkqfilter; static void targreadfiltdetach(struct knote *kn); static int targreadfilt(struct knote *kn, long hint); -static struct filterops targread_filtops = { +static const struct filterops targread_filtops = { .f_isfd = 1, .f_detach = targreadfiltdetach, .f_event = targreadfilt, diff --git a/sys/compat/linuxkpi/common/include/linux/file.h b/sys/compat/linuxkpi/common/include/linux/file.h index f94e3d89ced1..f6e988c2d88e 100644 --- a/sys/compat/linuxkpi/common/include/linux/file.h +++ b/sys/compat/linuxkpi/common/include/linux/file.h @@ -43,7 +43,7 @@ struct linux_file; #undef file -extern struct fileops linuxfileops; +extern const struct fileops linuxfileops; static inline struct linux_file * linux_fget(unsigned int fd) diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c b/sys/compat/linuxkpi/common/src/linux_compat.c index fe1a545c6a3a..1fc71c55469a 100644 --- a/sys/compat/linuxkpi/common/src/linux_compat.c +++ b/sys/compat/linuxkpi/common/src/linux_compat.c @@ -1113,13 +1113,13 @@ linux_file_kqfilter_write_event(struct knote *kn, long hint) return ((filp->f_kqflags & LINUX_KQ_FLAG_NEED_WRITE) ? 1 : 0); } -static struct filterops linux_dev_kqfiltops_read = { +static const struct filterops linux_dev_kqfiltops_read = { .f_isfd = 1, .f_detach = linux_file_kqfilter_detach, .f_event = linux_file_kqfilter_read_event, }; -static struct filterops linux_dev_kqfiltops_write = { +static const struct filterops linux_dev_kqfiltops_write = { .f_isfd = 1, .f_detach = linux_file_kqfilter_detach, .f_event = linux_file_kqfilter_write_event, @@ -1738,7 +1738,7 @@ linux_file_kcmp(struct file *fp1, struct file *fp2, struct thread *td) return (kcmp_cmp((uintptr_t)filp1->f_cdev, (uintptr_t)filp2->f_cdev)); } -struct fileops linuxfileops = { +const struct fileops linuxfileops = { .fo_read = linux_file_read, .fo_write = linux_file_write, .fo_truncate = invfo_truncate, diff --git a/sys/dev/beri/beri_ring.c b/sys/dev/beri/beri_ring.c index 6d48a411da38..eed002a3dfd6 100644 --- a/sys/dev/beri/beri_ring.c +++ b/sys/dev/beri/beri_ring.c @@ -366,14 +366,14 @@ beri_kqdetach(struct knote *kn) knlist_remove(&sc->beri_rsel.si_note, kn, 0); } -static struct filterops beri_read_filterops = { +static const struct filterops beri_read_filterops = { .f_isfd = 1, .f_attach = NULL, .f_detach = beri_kqdetach, .f_event = beri_kqread, }; -static struct filterops beri_write_filterops = { +static const struct filterops beri_write_filterops = { .f_isfd = 1, .f_attach = NULL, .f_detach = beri_kqdetach, diff --git a/sys/dev/cyapa/cyapa.c b/sys/dev/cyapa/cyapa.c index 307cd4d35b2e..50fa4faa560a 100644 --- a/sys/dev/cyapa/cyapa.c +++ b/sys/dev/cyapa/cyapa.c @@ -1100,7 +1100,7 @@ again: static void cyapafiltdetach(struct knote *); static int cyapafilt(struct knote *, long); -static struct filterops cyapa_filtops = { +static const struct filterops cyapa_filtops = { .f_isfd = 1, .f_detach = cyapafiltdetach, .f_event = cyapafilt diff --git a/sys/dev/evdev/cdev.c b/sys/dev/evdev/cdev.c index c9a8258a03a9..9fe1299a0937 100644 --- a/sys/dev/evdev/cdev.c +++ b/sys/dev/evdev/cdev.c @@ -91,7 +91,7 @@ static struct cdevsw evdev_cdevsw = { .d_name = "evdev", }; -static struct filterops evdev_cdev_filterops = { +static const struct filterops evdev_cdev_filterops = { .f_isfd = 1, .f_attach = NULL, .f_detach = evdev_kqdetach, diff --git a/sys/dev/evdev/uinput.c b/sys/dev/evdev/uinput.c index 3bf0e91b7360..9ac9fee8a157 100644 --- a/sys/dev/evdev/uinput.c +++ b/sys/dev/evdev/uinput.c @@ -93,13 +93,13 @@ static struct cdevsw uinput_cdevsw = { static struct cdev *uinput_cdev; -static struct evdev_methods uinput_ev_methods = { +static const struct evdev_methods uinput_ev_methods = { .ev_open = NULL, .ev_close = NULL, .ev_event = uinput_ev_event, }; -static struct filterops uinput_filterops = { +static const struct filterops uinput_filterops = { .f_isfd = 1, .f_attach = NULL, .f_detach = uinput_kqdetach, diff --git a/sys/dev/gpio/gpioc.c b/sys/dev/gpio/gpioc.c index 6fb79fa8d751..067a43617f11 100644 --- a/sys/dev/gpio/gpioc.c +++ b/sys/dev/gpio/gpioc.c @@ -152,7 +152,7 @@ static struct cdevsw gpioc_cdevsw = { .d_name = "gpioc", }; -static struct filterops gpioc_read_filterops = { +static const struct filterops gpioc_read_filterops = { .f_isfd = true, .f_attach = NULL, .f_detach = gpioc_kqdetach, diff --git a/sys/dev/hid/hidraw.c b/sys/dev/hid/hidraw.c index 6a05b633cfc8..618a6d2d5c31 100644 --- a/sys/dev/hid/hidraw.c +++ b/sys/dev/hid/hidraw.c @@ -172,7 +172,7 @@ static int hidraw_kqread(struct knote *, long); static void hidraw_kqdetach(struct knote *); static void hidraw_notify(struct hidraw_softc *); -static struct filterops hidraw_filterops_read = { +static const struct filterops hidraw_filterops_read = { .f_isfd = 1, .f_detach = hidraw_kqdetach, .f_event = hidraw_kqread, diff --git a/sys/dev/netmap/netmap_freebsd.c b/sys/dev/netmap/netmap_freebsd.c index 215b1f7bd09e..6448fdc74160 100644 --- a/sys/dev/netmap/netmap_freebsd.c +++ b/sys/dev/netmap/netmap_freebsd.c @@ -1397,13 +1397,13 @@ netmap_knwrite(struct knote *kn, long hint) return netmap_knrw(kn, hint, POLLOUT); } -static struct filterops netmap_rfiltops = { +static const struct filterops netmap_rfiltops = { .f_isfd = 1, .f_detach = netmap_knrdetach, .f_event = netmap_knread, }; -static struct filterops netmap_wfiltops = { +static const struct filterops netmap_wfiltops = { .f_isfd = 1, .f_detach = netmap_knwdetach, .f_event = netmap_knwrite, diff --git a/sys/dev/qat/qat_common/adf_freebsd_dev_processes.c b/sys/dev/qat/qat_common/adf_freebsd_dev_processes.c index a70f25d57dcb..661d5bd0f14e 100644 --- a/sys/dev/qat/qat_common/adf_freebsd_dev_processes.c +++ b/sys/dev/qat/qat_common/adf_freebsd_dev_processes.c @@ -85,7 +85,7 @@ static struct cdevsw adf_state_cdevsw = { .d_name = ADF_DEV_STATE_NAME, }; -static struct filterops adf_state_read_filterops = { +static const struct filterops adf_state_read_filterops = { .f_isfd = 1, .f_attach = NULL, .f_detach = adf_state_kqread_detach, diff --git a/sys/dev/usb/usb_dev.c b/sys/dev/usb/usb_dev.c index c58c3b5f64d5..a736a12fc4f4 100644 --- a/sys/dev/usb/usb_dev.c +++ b/sys/dev/usb/usb_dev.c @@ -1228,13 +1228,13 @@ usb_filter_read(struct knote *kn, long hint) return (m ? 1 : 0); } -static struct filterops usb_filtops_write = { +static const struct filterops usb_filtops_write = { .f_isfd = 1, .f_detach = usb_filter_detach, .f_event = usb_filter_write, }; -static struct filterops usb_filtops_read = { +static const struct filterops usb_filtops_read = { .f_isfd = 1, .f_detach = usb_filter_detach, .f_event = usb_filter_read, diff --git a/sys/fs/cuse/cuse.c b/sys/fs/cuse/cuse.c index 9ef234c35427..e32154654386 100644 --- a/sys/fs/cuse/cuse.c +++ b/sys/fs/cuse/cuse.c @@ -191,13 +191,13 @@ static void cuse_client_kqfilter_write_detach(struct knote *kn); static int cuse_client_kqfilter_read_event(struct knote *kn, long hint); static int cuse_client_kqfilter_write_event(struct knote *kn, long hint); -static struct filterops cuse_client_kqfilter_read_ops = { +static const struct filterops cuse_client_kqfilter_read_ops = { .f_isfd = 1, .f_detach = cuse_client_kqfilter_read_detach, .f_event = cuse_client_kqfilter_read_event, }; -static struct filterops cuse_client_kqfilter_write_ops = { +static const struct filterops cuse_client_kqfilter_write_ops = { .f_isfd = 1, .f_detach = cuse_client_kqfilter_write_detach, .f_event = cuse_client_kqfilter_write_event, diff --git a/sys/fs/devfs/devfs_vnops.c b/sys/fs/devfs/devfs_vnops.c index 9dcf3b235feb..7d17362df05e 100644 --- a/sys/fs/devfs/devfs_vnops.c +++ b/sys/fs/devfs/devfs_vnops.c @@ -68,7 +68,7 @@ static struct vop_vector devfs_vnodeops; static struct vop_vector devfs_specops; -static struct fileops devfs_ops_f; +static const struct fileops devfs_ops_f; #include <fs/devfs/devfs.h> #include <fs/devfs/devfs_int.h> @@ -2039,7 +2039,7 @@ devfs_cmp_f(struct file *fp1, struct file *fp2, struct thread *td) return (kcmp_cmp((uintptr_t)fp1->f_data, (uintptr_t)fp2->f_data)); } -static struct fileops devfs_ops_f = { +static const struct fileops devfs_ops_f = { .fo_read = devfs_read_f, .fo_write = devfs_write_f, .fo_truncate = devfs_truncate_f, diff --git a/sys/fs/fuse/fuse_device.c b/sys/fs/fuse/fuse_device.c index 88ebe702ec0a..5df9be59ce36 100644 --- a/sys/fs/fuse/fuse_device.c +++ b/sys/fs/fuse/fuse_device.c @@ -121,13 +121,13 @@ static int fuse_device_filt_read(struct knote *kn, long hint); static int fuse_device_filt_write(struct knote *kn, long hint); static void fuse_device_filt_detach(struct knote *kn); -struct filterops fuse_device_rfiltops = { +static const struct filterops fuse_device_rfiltops = { .f_isfd = 1, .f_detach = fuse_device_filt_detach, .f_event = fuse_device_filt_read, }; -struct filterops fuse_device_wfiltops = { +static const struct filterops fuse_device_wfiltops = { .f_isfd = 1, .f_event = fuse_device_filt_write, }; diff --git a/sys/geom/geom_dev.c b/sys/geom/geom_dev.c index f12236264d19..0b5cfdf77149 100644 --- a/sys/geom/geom_dev.c +++ b/sys/geom/geom_dev.c @@ -79,7 +79,7 @@ static d_kqfilter_t g_dev_kqfilter; static void gdev_filter_detach(struct knote *kn); static int gdev_filter_vnode(struct knote *kn, long hint); -static struct filterops gdev_filterops_vnode = { +static const struct filterops gdev_filterops_vnode = { .f_isfd = 1, .f_detach = gdev_filter_detach, .f_event = gdev_filter_vnode, diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 9036e3a25ab8..61cf7fc845a2 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -2861,7 +2861,8 @@ closef_nothread(struct file *fp) * called with bad data. */ void -finit(struct file *fp, u_int flag, short type, void *data, struct fileops *ops) +finit(struct file *fp, u_int flag, short type, void *data, + const struct fileops *ops) { fp->f_data = data; fp->f_flag = flag; @@ -2870,7 +2871,7 @@ finit(struct file *fp, u_int flag, short type, void *data, struct fileops *ops) } void -finit_vnode(struct file *fp, u_int flag, void *data, struct fileops *ops) +finit_vnode(struct file *fp, u_int flag, void *data, const struct fileops *ops) { fp->f_seqcount[UIO_READ] = 1; fp->f_seqcount[UIO_WRITE] = 1; @@ -5267,7 +5268,7 @@ badfo_fill_kinfo(struct file *fp, struct kinfo_file *kif, struct filedesc *fdp) return (0); } -struct fileops badfileops = { +const struct fileops badfileops = { .fo_read = badfo_readwrite, .fo_write = badfo_readwrite, .fo_truncate = badfo_truncate, @@ -5298,7 +5299,7 @@ path_close(struct file *fp, struct thread *td) return (0); } -struct fileops path_fileops = { +const struct fileops path_fileops = { .fo_read = badfo_readwrite, .fo_write = badfo_readwrite, .fo_truncate = badfo_truncate, diff --git a/sys/kern/kern_devctl.c b/sys/kern/kern_devctl.c index 602b82105525..d83bc380c2fe 100644 --- a/sys/kern/kern_devctl.c +++ b/sys/kern/kern_devctl.c @@ -126,7 +126,7 @@ static struct cdevsw dev_cdevsw = { static void filt_devctl_detach(struct knote *kn); static int filt_devctl_read(struct knote *kn, long hint); -static struct filterops devctl_rfiltops = { +static const struct filterops devctl_rfiltops = { .f_isfd = 1, .f_detach = filt_devctl_detach, .f_event = filt_devctl_read, diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c index fa96fbad20ce..dcb2c10ee1f5 100644 --- a/sys/kern/kern_event.c +++ b/sys/kern/kern_event.c @@ -127,7 +127,7 @@ static fo_stat_t kqueue_stat; static fo_close_t kqueue_close; static fo_fill_kinfo_t kqueue_fill_kinfo; -static struct fileops kqueueops = { +static const struct fileops kqueueops = { .fo_read = invfo_rdwr, .fo_write = invfo_rdwr, .fo_truncate = invfo_truncate, @@ -173,30 +173,30 @@ static int filt_user(struct knote *kn, long hint); static void filt_usertouch(struct knote *kn, struct kevent *kev, u_long type); -static struct filterops file_filtops = { +static const struct filterops file_filtops = { .f_isfd = 1, .f_attach = filt_fileattach, }; -static struct filterops kqread_filtops = { +static const struct filterops kqread_filtops = { .f_isfd = 1, .f_detach = filt_kqdetach, .f_event = filt_kqueue, }; /* XXX - move to kern_proc.c? */ -static struct filterops proc_filtops = { +static const struct filterops proc_filtops = { .f_isfd = 0, .f_attach = filt_procattach, .f_detach = filt_procdetach, .f_event = filt_proc, }; -static struct filterops timer_filtops = { +static const struct filterops timer_filtops = { .f_isfd = 0, .f_attach = filt_timerattach, .f_detach = filt_timerdetach, .f_event = filt_timer, .f_touch = filt_timertouch, }; -static struct filterops user_filtops = { +static const struct filterops user_filtops = { .f_attach = filt_userattach, .f_detach = filt_userdetach, .f_event = filt_user, @@ -327,14 +327,14 @@ filt_nullattach(struct knote *kn) return (ENXIO); }; -struct filterops null_filtops = { +static const struct filterops null_filtops = { .f_isfd = 0, .f_attach = filt_nullattach, }; /* XXX - make SYSINIT to add these, and move into respective modules. */ -extern struct filterops sig_filtops; -extern struct filterops fs_filtops; +extern const struct filterops sig_filtops; +extern const struct filterops fs_filtops; /* * Table for all system-defined filters. diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index 802231767762..6661f4cd6187 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -119,7 +119,7 @@ static void sigqueue_start(void); static void sigfastblock_setpend(struct thread *td, bool resched); static uma_zone_t ksiginfo_zone = NULL; -struct filterops sig_filtops = { +const struct filterops sig_filtops = { .f_isfd = 0, .f_attach = filt_sigattach, .f_detach = filt_sigdetach, diff --git a/sys/kern/subr_log.c b/sys/kern/subr_log.c index bb78e4a35451..5a6ebacb780c 100644 --- a/sys/kern/subr_log.c +++ b/sys/kern/subr_log.c @@ -77,7 +77,7 @@ static struct cdevsw log_cdevsw = { static int logkqread(struct knote *note, long hint); static void logkqdetach(struct knote *note); -static struct filterops log_read_filterops = { +static const struct filterops log_read_filterops = { .f_isfd = 1, .f_attach = NULL, .f_detach = logkqdetach, diff --git a/sys/kern/sys_eventfd.c b/sys/kern/sys_eventfd.c index 739dbf75b01e..20e73f9c6b1b 100644 --- a/sys/kern/sys_eventfd.c +++ b/sys/kern/sys_eventfd.c @@ -64,7 +64,7 @@ static fo_stat_t eventfd_stat; static fo_close_t eventfd_close; static fo_fill_kinfo_t eventfd_fill_kinfo; -static struct fileops eventfdops = { +static const struct fileops eventfdops = { .fo_read = eventfd_read, .fo_write = eventfd_write, .fo_truncate = invfo_truncate, @@ -85,13 +85,13 @@ static void filt_eventfddetach(struct knote *kn); static int filt_eventfdread(struct knote *kn, long hint); static int filt_eventfdwrite(struct knote *kn, long hint); -static struct filterops eventfd_rfiltops = { +static const struct filterops eventfd_rfiltops = { .f_isfd = 1, .f_detach = filt_eventfddetach, .f_event = filt_eventfdread }; -static struct filterops eventfd_wfiltops = { +static const struct filterops eventfd_wfiltops = { .f_isfd = 1, .f_detach = filt_eventfddetach, .f_event = filt_eventfdwrite diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c index c34c7b24a269..f2f1a42adf2b 100644 --- a/sys/kern/sys_pipe.c +++ b/sys/kern/sys_pipe.c @@ -154,7 +154,7 @@ static fo_chmod_t pipe_chmod; static fo_chown_t pipe_chown; static fo_fill_kinfo_t pipe_fill_kinfo; -struct fileops pipeops = { +const struct fileops pipeops = { .fo_read = pipe_read, .fo_write = pipe_write, .fo_truncate = pipe_truncate, @@ -177,17 +177,17 @@ static int filt_pipenotsup(struct knote *kn, long hint); static int filt_piperead(struct knote *kn, long hint); static int filt_pipewrite(struct knote *kn, long hint); -static struct filterops pipe_nfiltops = { +static const struct filterops pipe_nfiltops = { .f_isfd = 1, .f_detach = filt_pipedetach_notsup, .f_event = filt_pipenotsup }; -static struct filterops pipe_rfiltops = { +static const struct filterops pipe_rfiltops = { .f_isfd = 1, .f_detach = filt_pipedetach, .f_event = filt_piperead }; -static struct filterops pipe_wfiltops = { +static const struct filterops pipe_wfiltops = { .f_isfd = 1, .f_detach = filt_pipedetach, .f_event = filt_pipewrite diff --git a/sys/kern/sys_procdesc.c b/sys/kern/sys_procdesc.c index e8e0efd5bb00..dbf8e579530f 100644 --- a/sys/kern/sys_procdesc.c +++ b/sys/kern/sys_procdesc.c @@ -99,7 +99,7 @@ static fo_close_t procdesc_close; static fo_fill_kinfo_t procdesc_fill_kinfo; static fo_cmp_t procdesc_cmp; -static struct fileops procdesc_ops = { +static const struct fileops procdesc_ops = { .fo_read = invfo_rdwr, .fo_write = invfo_rdwr, .fo_truncate = invfo_truncate, @@ -484,7 +484,7 @@ procdesc_kqops_event(struct knote *kn, long hint) return (kn->kn_fflags != 0); } -static struct filterops procdesc_kqops = { +static const struct filterops procdesc_kqops = { .f_isfd = 1, .f_detach = procdesc_kqops_detach, .f_event = procdesc_kqops_event, diff --git a/sys/kern/sys_socket.c b/sys/kern/sys_socket.c index 58891b0de000..ca7ead961e68 100644 --- a/sys/kern/sys_socket.c +++ b/sys/kern/sys_socket.c @@ -99,7 +99,7 @@ static fo_aio_queue_t soo_aio_queue; static void soo_aio_cancel(struct kaiocb *job); -struct fileops socketops = { +const struct fileops socketops = { .fo_read = soo_read, .fo_write = soo_write, .fo_truncate = invfo_truncate, diff --git a/sys/kern/sys_timerfd.c b/sys/kern/sys_timerfd.c index 8ac5b845f7ac..ab7e048a2ab1 100644 --- a/sys/kern/sys_timerfd.c +++ b/sys/kern/sys_timerfd.c @@ -284,7 +284,7 @@ filt_timerfdread(struct knote *kn, long hint) return (tfd->tfd_count > 0); } -static struct filterops timerfd_rfiltops = { +static const struct filterops timerfd_rfiltops = { .f_isfd = 1, .f_detach = filt_timerfddetach, .f_event = filt_timerfdread, @@ -359,7 +359,7 @@ timerfd_fill_kinfo(struct file *fp, struct kinfo_file *kif, return (0); } -static struct fileops timerfdops = { +static const struct fileops timerfdops = { .fo_read = timerfd_read, .fo_write = invfo_rdwr, .fo_truncate = invfo_truncate, diff --git a/sys/kern/tty.c b/sys/kern/tty.c index b6e300321e9c..b1b3b268d0e9 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -751,13 +751,13 @@ tty_kqops_write_event(struct knote *kn, long hint __unused) } } -static struct filterops tty_kqops_read = { +static const struct filterops tty_kqops_read = { .f_isfd = 1, .f_detach = tty_kqops_read_detach, .f_event = tty_kqops_read_event, }; -static struct filterops tty_kqops_write = { +static const struct filterops tty_kqops_write = { .f_isfd = 1, .f_detach = tty_kqops_write_detach, .f_event = tty_kqops_write_event, diff --git a/sys/kern/tty_pts.c b/sys/kern/tty_pts.c index 4a3b3d77c89e..d629fa0e7593 100644 --- a/sys/kern/tty_pts.c +++ b/sys/kern/tty_pts.c @@ -488,12 +488,12 @@ pts_kqops_write_event(struct knote *kn, long hint) } } -static struct filterops pts_kqops_read = { +static const struct filterops pts_kqops_read = { .f_isfd = 1, .f_detach = pts_kqops_read_detach, .f_event = pts_kqops_read_event, }; -static struct filterops pts_kqops_write = { +static const struct filterops pts_kqops_write = { .f_isfd = 1, .f_detach = pts_kqops_write_detach, .f_event = pts_kqops_write_event, @@ -597,7 +597,7 @@ ptsdev_fill_kinfo(struct file *fp, struct kinfo_file *kif, struct filedesc *fdp) return (0); } -static struct fileops ptsdev_ops = { +static const struct fileops ptsdev_ops = { .fo_read = ptsdev_read, .fo_write = ptsdev_write, .fo_truncate = invfo_truncate, diff --git a/sys/kern/uipc_mqueue.c b/sys/kern/uipc_mqueue.c index 5fcabbac7923..7dd0f9796682 100644 --- a/sys/kern/uipc_mqueue.c +++ b/sys/kern/uipc_mqueue.c @@ -226,7 +226,7 @@ static uma_zone_t mqueue_zone; static uma_zone_t mvdata_zone; static uma_zone_t mqnoti_zone; static struct vop_vector mqfs_vnodeops; -static struct fileops mqueueops; +static const struct fileops mqueueops; static unsigned mqfs_osd_jail_slot; /* @@ -273,12 +273,12 @@ static void filt_mqdetach(struct knote *kn); static int filt_mqread(struct knote *kn, long hint); static int filt_mqwrite(struct knote *kn, long hint); -struct filterops mq_rfiltops = { +static const struct filterops mq_rfiltops = { .f_isfd = 1, .f_detach = filt_mqdetach, .f_event = filt_mqread, }; -struct filterops mq_wfiltops = { +static const struct filterops mq_wfiltops = { .f_isfd = 1, .f_detach = filt_mqdetach, .f_event = filt_mqwrite, @@ -2648,7 +2648,7 @@ mqf_fill_kinfo(struct file *fp, struct kinfo_file *kif, struct filedesc *fdp) return (0); } -static struct fileops mqueueops = { +static const struct fileops mqueueops = { .fo_read = invfo_rdwr, .fo_write = invfo_rdwr, .fo_truncate = invfo_truncate, diff --git a/sys/kern/uipc_sem.c b/sys/kern/uipc_sem.c index b4652e9106ac..35ca9a9fb06e 100644 --- a/sys/kern/uipc_sem.c +++ b/sys/kern/uipc_sem.c @@ -140,7 +140,7 @@ static fo_chown_t ksem_chown; static fo_fill_kinfo_t ksem_fill_kinfo; /* File descriptor operations. */ -static struct fileops ksem_ops = { +static const struct fileops ksem_ops = { .fo_read = invfo_rdwr, .fo_write = invfo_rdwr, .fo_truncate = invfo_truncate, diff --git a/sys/kern/uipc_shm.c b/sys/kern/uipc_shm.c index f51998d0ed00..dad9fb23250f 100644 --- a/sys/kern/uipc_shm.c +++ b/sys/kern/uipc_shm.c @@ -150,7 +150,7 @@ static fo_fallocate_t shm_fallocate; static fo_fspacectl_t shm_fspacectl; /* File descriptor operations. */ -struct fileops shm_ops = { +const struct fileops shm_ops = { .fo_read = shm_read, .fo_write = shm_write, .fo_truncate = shm_truncate, diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 4ecd69d509ed..162c489ea6fe 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -191,17 +191,17 @@ static int filt_soempty(struct knote *kn, long hint); static int inline hhook_run_socket(struct socket *so, void *hctx, int32_t h_id); fo_kqfilter_t soo_kqfilter; -static struct filterops soread_filtops = { +static const struct filterops soread_filtops = { .f_isfd = 1, .f_detach = filt_sordetach, .f_event = filt_soread, }; -static struct filterops sowrite_filtops = { +static const struct filterops sowrite_filtops = { .f_isfd = 1, .f_detach = filt_sowdetach, .f_event = filt_sowrite, }; -static struct filterops soempty_filtops = { +static const struct filterops soempty_filtops = { .f_isfd = 1, .f_detach = filt_sowdetach, .f_event = filt_soempty, diff --git a/sys/kern/vfs_aio.c b/sys/kern/vfs_aio.c index fd6682ef03b0..c5b0c7896a17 100644 --- a/sys/kern/vfs_aio.c +++ b/sys/kern/vfs_aio.c @@ -347,13 +347,13 @@ static int filt_lio(struct knote *kn, long hint); static uma_zone_t kaio_zone, aiocb_zone, aiolio_zone; /* kqueue filters for aio */ -static struct filterops aio_filtops = { +static const struct filterops aio_filtops = { .f_isfd = 0, .f_attach = filt_aioattach, .f_detach = filt_aiodetach, .f_event = filt_aio, }; -static struct filterops lio_filtops = { +static const struct filterops lio_filtops = { .f_isfd = 0, .f_attach = filt_lioattach, .f_detach = filt_liodetach, diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 747cdf722cc9..404c51b7db77 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -6409,7 +6409,7 @@ static int filt_fsattach(struct knote *kn); static void filt_fsdetach(struct knote *kn); static int filt_fsevent(struct knote *kn, long hint); -struct filterops fs_filtops = { +const struct filterops fs_filtops = { .f_isfd = 0, .f_attach = filt_fsattach, .f_detach = filt_fsdetach, @@ -6489,17 +6489,17 @@ static int filt_vfsread(struct knote *kn, long hint); static int filt_vfswrite(struct knote *kn, long hint); static int filt_vfsvnode(struct knote *kn, long hint); static void filt_vfsdetach(struct knote *kn); -static struct filterops vfsread_filtops = { +static const struct filterops vfsread_filtops = { .f_isfd = 1, .f_detach = filt_vfsdetach, .f_event = filt_vfsread }; -static struct filterops vfswrite_filtops = { +static const struct filterops vfswrite_filtops = { .f_isfd = 1, .f_detach = filt_vfsdetach, .f_event = filt_vfswrite }; -static struct filterops vfsvnode_filtops = { +static const struct filterops vfsvnode_filtops = { .f_isfd = 1, .f_detach = filt_vfsdetach, .f_event = filt_vfsvnode diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 53a2ddf94862..c28d6e66853f 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -108,7 +108,7 @@ static fo_mmap_t vn_mmap; static fo_fallocate_t vn_fallocate; static fo_fspacectl_t vn_fspacectl; -struct fileops vnops = { +const struct fileops vnops = { .fo_read = vn_io_fault, .fo_write = vn_io_fault, .fo_truncate = vn_truncate, diff --git a/sys/net/bpf.c b/sys/net/bpf.c index c0631591a10e..8a68f65a80f7 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -251,13 +251,13 @@ static struct cdevsw bpf_cdevsw = { .d_kqfilter = bpfkqfilter, }; -static struct filterops bpfread_filtops = { +static const struct filterops bpfread_filtops = { .f_isfd = 1, .f_detach = filt_bpfdetach, .f_event = filt_bpfread, }; -static struct filterops bpfwrite_filtops = { +static const struct filterops bpfwrite_filtops = { .f_isfd = 1, .f_detach = filt_bpfdetach, .f_event = filt_bpfwrite, diff --git a/sys/net/if_tuntap.c b/sys/net/if_tuntap.c index 0dee2260973d..a0275a7471e5 100644 --- a/sys/net/if_tuntap.c +++ b/sys/net/if_tuntap.c @@ -253,14 +253,14 @@ static int tunkqread(struct knote *, long); static int tunkqwrite(struct knote *, long); static void tunkqdetach(struct knote *); -static struct filterops tun_read_filterops = { +static const struct filterops tun_read_filterops = { .f_isfd = 1, .f_attach = NULL, .f_detach = tunkqdetach, .f_event = tunkqread, }; -static struct filterops tun_write_filterops = { +static const struct filterops tun_write_filterops = { .f_isfd = 1, .f_attach = NULL, .f_detach = tunkqdetach, diff --git a/sys/security/audit/audit_pipe.c b/sys/security/audit/audit_pipe.c index 926865b499d1..c50287321cbd 100644 --- a/sys/security/audit/audit_pipe.c +++ b/sys/security/audit/audit_pipe.c @@ -239,7 +239,7 @@ static struct cdevsw audit_pipe_cdevsw = { static int audit_pipe_kqread(struct knote *note, long hint); static void audit_pipe_kqdetach(struct knote *note); -static struct filterops audit_pipe_read_filterops = { +static const struct filterops audit_pipe_read_filterops = { .f_isfd = 1, .f_attach = NULL, .f_detach = audit_pipe_kqdetach, diff --git a/sys/sys/file.h b/sys/sys/file.h index c1439b9bbaac..da96f3e332fc 100644 --- a/sys/sys/file.h +++ b/sys/sys/file.h @@ -248,10 +248,10 @@ struct xfile { #ifdef _KERNEL -extern struct fileops vnops; -extern struct fileops badfileops; -extern struct fileops path_fileops; -extern struct fileops socketops; +extern const struct fileops vnops; +extern const struct fileops badfileops; +extern const struct fileops path_fileops; +extern const struct fileops socketops; extern int maxfiles; /* kernel limit on number of open files */ extern int maxfilesperproc; /* per process limit on number of open files */ @@ -283,8 +283,8 @@ fo_kqfilter_t vn_kqfilter_opath; int vn_fill_kinfo_vnode(struct vnode *vp, struct kinfo_file *kif); int file_kcmp_generic(struct file *fp1, struct file *fp2, struct thread *td); -void finit(struct file *, u_int, short, void *, struct fileops *); -void finit_vnode(struct file *, u_int, void *, struct fileops *); +void finit(struct file *, u_int, short, void *, const struct fileops *); +void finit_vnode(struct file *, u_int, void *, const struct fileops *); int fgetvp(struct thread *td, int fd, cap_rights_t *rightsp, struct vnode **vpp); int fgetvp_exec(struct thread *td, int fd, cap_rights_t *rightsp, diff --git a/sys/sys/mman.h b/sys/sys/mman.h index 36973b941e61..d444f02d3c89 100644 --- a/sys/sys/mman.h +++ b/sys/sys/mman.h @@ -312,7 +312,7 @@ bool shm_largepage(struct shmfd *shmfd); void shm_remove_prison(struct prison *pr); int shm_get_path(struct vm_object *obj, char *path, size_t sz); -extern struct fileops shm_ops; +extern const struct fileops shm_ops; #define MAP_32BIT_MAX_ADDR ((vm_offset_t)1 << 31) diff --git a/sys/sys/pipe.h b/sys/sys/pipe.h index 0f35316432eb..a83ea800c677 100644 --- a/sys/sys/pipe.h +++ b/sys/sys/pipe.h @@ -52,7 +52,7 @@ * See sys_pipe.c for info on what these limits mean. */ extern long maxpipekva; -extern struct fileops pipeops; +extern const struct fileops pipeops; #endif /* diff --git a/sys/x86/acpica/acpi_apm.c b/sys/x86/acpica/acpi_apm.c index 4e880c3e5411..e7e4b0f1a546 100644 --- a/sys/x86/acpica/acpi_apm.c +++ b/sys/x86/acpica/acpi_apm.c @@ -61,7 +61,7 @@ static d_poll_t apmpoll; static d_kqfilter_t apmkqfilter; static void apmreadfiltdetach(struct knote *kn); static int apmreadfilt(struct knote *kn, long hint); -static struct filterops apm_readfiltops = { +static const struct filterops apm_readfiltops = { .f_isfd = 1, .f_detach = apmreadfiltdetach, .f_event = apmreadfilt,