PERFORCE change 164100 for review

Zhao Shuai zhaoshuai at FreeBSD.org
Thu Jun 11 12:51:02 UTC 2009


http://perforce.freebsd.org/chv.cgi?CH=164100

Change 164100 by zhaoshuai at zhaoshuai on 2009/06/11 12:50:07

	add fifo_kqfilter_f()

Affected files ...

.. //depot/projects/soc2009/fifo/sys/fs/fifofs/fifo_vnops.c#13 edit

Differences ...

==== //depot/projects/soc2009/fifo/sys/fs/fifofs/fifo_vnops.c#13 (text+ko) ====

@@ -91,6 +91,12 @@
 static vop_pathconf_t	fifo_pathconf;
 static vop_advlock_t	fifo_advlock;
 
+static void	filt_fifodetach_notsup(struct knote *kn);
+static int	filt_fifo_notsup(struct knote *kn, long hint);
+
+static struct filterops fifo_notsup_filtops = 
+	{ 1, NULL, filt_fifodetach_notsup, filt_fifo_notsup };
+
 struct vop_vector fifo_specops = {
 	.vop_default =		&default_vnodeops,
 	.vop_access =		VOP_EBADF,
@@ -484,9 +490,54 @@
 	}
 }
 
+/*
+ * Because fifos are now a file descriptor layer object, EVFILT_VNODE is not
+ * implemented.  Likely, fifo_kqfilter() should be removed, and
+ * fifo_kqfilter_f() should know how to forward the request to the underling
+ * vnode using f_vnode in the file descriptor here.
+ */
 static int
 fifo_kqfilter_f(struct file *fp, struct knote *kn)
 {
+	struct fifoinfo *fip = fp->f_data;
+
+	/*
+	 * If a filter is requested that is not supported by this file
+	 * descriptor, don't return an error, but also don't ever generate an
+	 * event.
+	 */
+	if ((kn->kn_filter == EVFILT_READ) && !(fp->f_flag & FREAD)) {
+		kn->kn_fop = &fifo_notsup_filtops;
+		return (0);
+	}
+	if ((kn->kn_filter == EVFILT_WRITE) && !(fp->f_flag & FWRITE)) {
+		kn->kn_fop = &fifo_notsup_filtops;
+		return (0);
+	}
+
+	switch (kn->kn_filter) {
+	case EVFILT_READ:
+		return (generic_pipe_kqfilter(fip->fi_rpipe, kn));
+
+	case EVFILT_WRITE:
+		return (generic_pipe_kqfilter(fip->fi_wpipe, kn));
+
+	default:
+		return (EINVAL);
+	}
+
+	return (0);
+}
+
+static void 
+filt_fifodetach_notsup(struct knote *kn)
+{
+
+}
+
+static int
+filt_fifo_notsup(struct knote *kn, long hint)
+{
 
 	return (0);
 }


More information about the p4-projects mailing list