summaryrefslogtreecommitdiffstats
path: root/sys/kern/sys_pipe.c
diff options
context:
space:
mode:
authorprovos <provos@openbsd.org>2001-03-01 20:54:32 +0000
committerprovos <provos@openbsd.org>2001-03-01 20:54:32 +0000
commitcc90df54b6a6a4bf9b7301960b97b330614c3fe6 (patch)
treecdbbbe05bdaec89f593cdb5956907a27f7ba7dd5 /sys/kern/sys_pipe.c
parentMan pages shouldn't Xr themselves; mpech@prosoft.org.lv. But eww, I don't like (diff)
downloadwireguard-openbsd-cc90df54b6a6a4bf9b7301960b97b330614c3fe6.tar.xz
wireguard-openbsd-cc90df54b6a6a4bf9b7301960b97b330614c3fe6.zip
port kqueue changes from freebsd, plus all required openbsd glue.
okay deraadt@, millert@ from jlemon@freebsd.org: extend kqueue down to the device layer, backwards compatible approach suggested by peter@freebsd.org
Diffstat (limited to 'sys/kern/sys_pipe.c')
-rw-r--r--sys/kern/sys_pipe.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c
index 28dfd3dc210..cfbb2efcd2e 100644
--- a/sys/kern/sys_pipe.c
+++ b/sys/kern/sys_pipe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sys_pipe.c,v 1.25 2000/11/16 20:02:17 provos Exp $ */
+/* $OpenBSD: sys_pipe.c,v 1.26 2001/03/01 20:54:33 provos Exp $ */
/*
* Copyright (c) 1996 John S. Dyson
@@ -67,21 +67,24 @@ int pipe_read __P((struct file *, off_t *, struct uio *, struct ucred *));
int pipe_write __P((struct file *, off_t *, struct uio *, struct ucred *));
int pipe_close __P((struct file *, struct proc *));
int pipe_select __P((struct file *, int which, struct proc *));
+int pipe_kqfilter __P((struct file *fp, struct knote *kn));
int pipe_ioctl __P((struct file *, u_long, caddr_t, struct proc *));
-static struct fileops pipeops =
- { pipe_read, pipe_write, pipe_ioctl, pipe_select, pipe_close };
+static struct fileops pipeops = {
+ pipe_read, pipe_write, pipe_ioctl, pipe_select, pipe_kqfilter,
+ pipe_close
+};
-int filt_pipeattach(struct knote *kn);
void filt_pipedetach(struct knote *kn);
int filt_piperead(struct knote *kn, long hint);
int filt_pipewrite(struct knote *kn, long hint);
-struct filterops pipe_rwfiltops[] = {
- { 1, filt_pipeattach, filt_pipedetach, filt_piperead },
- { 1, filt_pipeattach, filt_pipedetach, filt_pipewrite },
-};
+struct filterops pipe_rfiltops =
+ { 1, NULL, filt_pipedetach, filt_piperead };
+struct filterops pipe_wfiltops =
+ { 1, NULL, filt_pipedetach, filt_pipewrite };
+
/*
* Default pipe buffer size(s), this can be kind-of large now because pipe
* space is pageable. The pipe code will try to maintain locality of
@@ -758,10 +761,21 @@ pipeclose(cpipe)
#endif
int
-filt_pipeattach(struct knote *kn)
+pipe_kqfilter(struct file *fp, struct knote *kn)
{
struct pipe *rpipe = (struct pipe *)kn->kn_fp->f_data;
+ switch (kn->kn_filter) {
+ case EVFILT_READ:
+ kn->kn_fop = &pipe_rfiltops;
+ break;
+ case EVFILT_WRITE:
+ kn->kn_fop = &pipe_wfiltops;
+ break;
+ default:
+ return (1);
+ }
+
SLIST_INSERT_HEAD(&rpipe->pipe_sel.si_note, kn, kn_selnext);
return (0);
}