> Date: Wed, 20 May 2020 11:42:32 +0200
> From: Martin Pieuchot <[email protected]>
>
> Diff below fixes an incoherency between poll(2) and kqueue(2) when it
> comes to non-character devices. It makes spec_kqfilter() behaves like
> spec_poll(): returns "true" when applied to any non-character device.
>
> ok?
That is a change in behaviour. What do other BSDs do in this case?
I think the new behaviour makes sense, but it could reveal some nasty
bugs in cases where code accidantily uses kqueue(2) with a file
descriptor for a block device.
To achieve your goal, d_kqfilter() will become non-optional in the
future isn't it?
> Index: kern/spec_vnops.c
> ===================================================================
> RCS file: /cvs/src/sys/kern/spec_vnops.c,v
> retrieving revision 1.100
> diff -u -p -r1.100 spec_vnops.c
> --- kern/spec_vnops.c 20 Jan 2020 23:21:55 -0000 1.100
> +++ kern/spec_vnops.c 20 May 2020 09:36:48 -0000
> @@ -386,11 +386,9 @@ spec_poll(void *v)
> dev_t dev;
>
> switch (ap->a_vp->v_type) {
> -
> default:
> return (ap->a_events &
> (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM));
> -
> case VCHR:
> dev = ap->a_vp->v_rdev;
> return (*cdevsw[major(dev)].d_poll)(dev, ap->a_events, ap->a_p);
> @@ -400,12 +398,17 @@ int
> spec_kqfilter(void *v)
> {
> struct vop_kqfilter_args *ap = v;
> -
> dev_t dev;
>
> dev = ap->a_vp->v_rdev;
> - if (cdevsw[major(dev)].d_kqfilter)
> - return (*cdevsw[major(dev)].d_kqfilter)(dev, ap->a_kn);
> +
> + switch (ap->a_vp->v_type) {
> + default:
> + return seltrue_kqfilter(dev, ap->a_kn);
> + case VCHR:
> + if (cdevsw[major(dev)].d_kqfilter)
> + return (*cdevsw[major(dev)].d_kqfilter)(dev, ap->a_kn);
> + }
> return (EOPNOTSUPP);
> }
>
>
>