I took a shot at fixing this the correct way by adding kqueue support
to cd9660. Hopefully I'm on the right track here with this diff based on
what I saw for ufs.
Index: cd9660_vnops.c
===================================================================
RCS file: /cvs/src/sys/isofs/cd9660/cd9660_vnops.c,v
retrieving revision 1.70
diff -u -p -r1.70 cd9660_vnops.c
--- cd9660_vnops.c 10 Feb 2015 21:56:09 -0000 1.70
+++ cd9660_vnops.c 31 May 2015 13:30:22 -0000
@@ -83,6 +83,10 @@ struct isoreaddir {
int iso_uiodir(struct isoreaddir *, struct dirent *, off_t);
int iso_shipdir(struct isoreaddir *);
+int cd9660_kqfilter(void *);
+void filt_cd9660detach(struct knote *);
+int filt_cd9660read(struct knote *, long);
+int filt_cd9660vnode(struct knote *, long);
/*
* Setattr call. Only allowed for block and character special devices.
@@ -808,6 +812,80 @@ cd9660_pathconf(void *v)
return (error);
}
+struct filterops cd9660read_filtops =
+ { 1, NULL, filt_cd9660detach, filt_cd9660read };
+struct filterops cd9660vnode_filtops =
+ { 1, NULL, filt_cd9660detach, filt_cd9660vnode };
+
+int
+cd9660_kqfilter(void *v)
+{
+ struct vop_kqfilter_args *ap = v;
+ struct vnode *vp = ap->a_vp;
+ struct knote *kn = ap->a_kn;
+
+ switch (kn->kn_filter) {
+ case EVFILT_READ:
+ kn->kn_fop = &cd9660read_filtops;
+ break;
+ case EVFILT_VNODE:
+ kn->kn_fop = &cd9660vnode_filtops;
+ break;
+ default:
+ return (EINVAL);
+ }
+
+ kn->kn_hook = (caddr_t)vp;
+
+ SLIST_INSERT_HEAD(&vp->v_selectinfo.si_note, kn, kn_selnext);
+
+ return (0);
+}
+
+void
+filt_cd9660detach(struct knote *kn)
+{
+ struct vnode *vp = (struct vnode *)kn->kn_hook;
+
+ SLIST_REMOVE(&vp->v_selectinfo.si_note, kn, knote, kn_selnext);
+}
+
+int
+filt_cd9660read(struct knote *kn, long hint)
+{
+ struct vnode *vp = (struct vnode *)kn->kn_hook;
+ struct iso_node *ip = VTOI(vp);
+
+ /*
+ * filesystem is gone, so set the EOF flag and schedule
+ * the knote for deletion.
+ */
+ if (hint == NOTE_REVOKE) {
+ kn->kn_flags |= (EV_EOF | EV_ONESHOT);
+ return (1);
+ }
+
+ kn->kn_data = ip->i_size - kn->kn_fp->f_offset;
+ if (kn->kn_data == 0 && kn->kn_sfflags & NOTE_EOF) {
+ kn->kn_fflags |= NOTE_EOF;
+ return (1);
+ }
+
+ return (kn->kn_data != 0);
+}
+
+int
+filt_cd9660vnode(struct knote *kn, long hint)
+{
+ if (kn->kn_sfflags & hint)
+ kn->kn_fflags |= hint;
+ if (hint == NOTE_REVOKE) {
+ kn->kn_flags |= EV_EOF;
+ return (1);
+ }
+ return (kn->kn_fflags != 0);
+}
+
/*
* Global vfs data structures for isofs
*/
@@ -841,6 +919,7 @@ struct vops cd9660_vops = {
.vop_write = cd9660_write,
.vop_ioctl = cd9660_ioctl,
.vop_poll = cd9660_poll,
+ .vop_kqfilter = cd9660_kqfilter,
.vop_revoke = cd9660_revoke,
.vop_fsync = cd9660_fsync,
.vop_remove = cd9660_remove,