+ptsd_revoke_knotes(__unused int minor, struct tty *tp)
+{
+ tty_lock(tp);
+
+ ttwakeup(tp);
+ assert((tp->t_rsel.si_flags & SI_KNPOSTING) == 0);
+ KNOTE(&tp->t_rsel.si_note, NOTE_REVOKE);
+
+ ttwwakeup(tp);
+ assert((tp->t_wsel.si_flags & SI_KNPOSTING) == 0);
+ KNOTE(&tp->t_wsel.si_note, NOTE_REVOKE);
+
+ tty_unlock(tp);
+}
+
+/*
+ * kevent filter routines for the master side of a pty, a ptmx.
+ *
+ * Stuff the ptmx_ioctl structure into the hook for ptmx knotes. Use the
+ * embedded tty's lock for synchronization.
+ */
+
+int ptmx_kqfilter(dev_t dev, struct knote *kn);
+static void ptmx_kqops_detach(struct knote *);
+static int ptmx_kqops_event(struct knote *, long);
+static int ptmx_kqops_touch(struct knote *kn, struct kevent_qos_s *kev);
+static int ptmx_kqops_process(struct knote *kn, struct kevent_qos_s *kev);
+static int ptmx_kqops_common(struct knote *kn, struct kevent_qos_s *kev,
+ struct ptmx_ioctl *pti, struct tty *tp);
+
+SECURITY_READ_ONLY_EARLY(struct filterops) ptmx_kqops = {
+ .f_isfd = 1,
+ /* attach is handled by ptmx_kqfilter -- the dev node must be passed in */
+ .f_detach = ptmx_kqops_detach,
+ .f_event = ptmx_kqops_event,
+ .f_touch = ptmx_kqops_touch,
+ .f_process = ptmx_kqops_process,
+};
+
+static struct ptmx_ioctl *
+ptmx_knote_ioctl(struct knote *kn)