diff options
author | rwatson <rwatson@FreeBSD.org> | 2005-09-12 19:59:12 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2005-09-12 19:59:12 +0000 |
commit | bc5e7eb1f38a043d52ed9129b2dcab1139a7ddef (patch) | |
tree | 6ed7e148c281195d68f232c576d0c2a3b2341ed3 /sys/fs/fifofs | |
parent | f9e069084cb5bb4b251bc75ad91b1ff1b165d2cc (diff) | |
download | FreeBSD-src-bc5e7eb1f38a043d52ed9129b2dcab1139a7ddef.zip FreeBSD-src-bc5e7eb1f38a043d52ed9129b2dcab1139a7ddef.tar.gz |
Introduce no-op nosup fifo kqueue filter and detach routine, which are
used when a read filter is requested on a write-only fifo descriptor, or
a write filter is requested on a read-only fifo descriptor. This
permits the filters to be registered, but never raises the event, which
causes kqueue behavior for fifos to more closely match similar semantics
for poll and select, which permit testing for the condition even though
the condition will never be raised, and is consistent with POSIX's notion
that a fifo has identical semantics to a one-way IPC channel created
using pipe() on most operating systems.
The fifo regression test suite can now run to completion on HEAD without
errors.
MFC after: 3 days
Diffstat (limited to 'sys/fs/fifofs')
-rw-r--r-- | sys/fs/fifofs/fifo_vnops.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/sys/fs/fifofs/fifo_vnops.c b/sys/fs/fifofs/fifo_vnops.c index 6a48905..6fca95e 100644 --- a/sys/fs/fifofs/fifo_vnops.c +++ b/sys/fs/fifofs/fifo_vnops.c @@ -94,11 +94,15 @@ static void filt_fifordetach(struct knote *kn); static int filt_fiforead(struct knote *kn, long hint); static void filt_fifowdetach(struct knote *kn); static int filt_fifowrite(struct knote *kn, long hint); +static void filt_fifodetach_notsup(struct knote *kn); +static int filt_fifo_notsup(struct knote *kn, long hint); static struct filterops fiforead_filtops = { 1, NULL, filt_fifordetach, filt_fiforead }; static struct filterops fifowrite_filtops = { 1, NULL, filt_fifowdetach, filt_fifowrite }; +static struct filterops fifo_notsup_filtops = + { 1, NULL, filt_fifodetach_notsup, filt_fifo_notsup }; struct vop_vector fifo_specops = { .vop_default = &default_vnodeops, @@ -435,6 +439,19 @@ filt_fifowrite(struct knote *kn, long hint) return (result); } +static void +filt_fifodetach_notsup(struct knote *kn) +{ + +} + +static int +filt_fifo_notsup(struct knote *kn, long hint) +{ + + return (0); +} + /* * Device close routine */ @@ -580,6 +597,22 @@ fifo_kqfilter_f(struct file *fp, struct knote *kn) struct sockbuf *sb; fi = 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: kn->kn_fop = &fiforead_filtops; @@ -685,4 +718,3 @@ fifo_write_f(struct file *fp, struct uio *uio, struct ucred *cred, int flags, st error = sosend(fip->fi_writesock, NULL, uio, 0, NULL, sflags, td); return (error); } - |