summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/loongson/loongson/conf.c8
-rw-r--r--sys/kern/kern_event.c32
-rw-r--r--sys/sys/conf.h23
-rw-r--r--sys/sys/event.h3
4 files changed, 48 insertions, 18 deletions
diff --git a/sys/arch/loongson/loongson/conf.c b/sys/arch/loongson/loongson/conf.c
index 3a6857b3e04..52241f3e726 100644
--- a/sys/arch/loongson/loongson/conf.c
+++ b/sys/arch/loongson/loongson/conf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.c,v 1.7 2010/07/03 03:59:16 krw Exp $ */
+/* $OpenBSD: conf.c,v 1.8 2010/07/28 21:44:41 nicm Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -86,12 +86,6 @@ int nblkdev = sizeof (bdevsw) / sizeof (bdevsw[0]);
* Character devices.
*/
-/* open, close, write, ioctl */
-#define cdev_lpt_init(c,n) { \
- dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \
- dev_init(c,n,write), dev_init(c,n,ioctl), (dev_type_stop((*))) enodev, \
- 0, seltrue, (dev_type_mmap((*))) enodev }
-
#define mmread mmrw
#define mmwrite mmrw
dev_type_read(mmrw);
diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c
index 9c94d337b31..6538129fa1f 100644
--- a/sys/kern/kern_event.c
+++ b/sys/kern/kern_event.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_event.c,v 1.36 2010/05/18 22:26:09 tedu Exp $ */
+/* $OpenBSD: kern_event.c,v 1.37 2010/07/28 21:44:41 nicm Exp $ */
/*-
* Copyright (c) 1999,2000,2001 Jonathan Lemon <jlemon@FreeBSD.org>
@@ -95,6 +95,7 @@ void filt_timerexpire(void *knx);
int filt_timerattach(struct knote *kn);
void filt_timerdetach(struct knote *kn);
int filt_timer(struct knote *kn, long hint);
+void filt_seltruedetach(struct knote *kn);
struct filterops kqread_filtops =
{ 1, NULL, filt_kqdetach, filt_kqueue };
@@ -377,6 +378,35 @@ filt_seltrue(struct knote *kn, long hint)
return (1);
}
+/*
+ * This provides full kqfilter entry for device switch tables, which
+ * has same effect as filter using filt_seltrue() as filter method.
+ */
+void
+filt_seltruedetach(struct knote *kn)
+{
+ /* Nothing to do */
+}
+
+const struct filterops seltrue_filtops =
+ { 1, NULL, filt_seltruedetach, filt_seltrue };
+
+int
+seltrue_kqfilter(dev_t dev, struct knote *kn)
+{
+ switch (kn->kn_filter) {
+ case EVFILT_READ:
+ case EVFILT_WRITE:
+ kn->kn_fop = &seltrue_filtops;
+ break;
+ default:
+ return (EINVAL);
+ }
+
+ /* Nothing more to do */
+ return (0);
+}
+
int
sys_kqueue(struct proc *p, void *v, register_t *retval)
{
diff --git a/sys/sys/conf.h b/sys/sys/conf.h
index b735b76e768..e8c88ed2ab3 100644
--- a/sys/sys/conf.h
+++ b/sys/sys/conf.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.h,v 1.105 2010/07/21 23:40:26 nicm Exp $ */
+/* $OpenBSD: conf.h,v 1.106 2010/07/28 21:44:41 nicm Exp $ */
/* $NetBSD: conf.h,v 1.33 1996/05/03 20:03:32 christos Exp $ */
/*-
@@ -184,13 +184,15 @@ extern struct cdevsw cdevsw[];
#define cdev_disk_init(c,n) { \
dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
dev_init(c,n,write), dev_init(c,n,ioctl), (dev_type_stop((*))) enodev, \
- 0, seltrue, (dev_type_mmap((*))) enodev, D_DISK, 0 }
+ 0, seltrue, (dev_type_mmap((*))) enodev, \
+ D_DISK, D_KQFILTER, seltrue_kqfilter }
/* open, close, read, write, ioctl */
#define cdev_tape_init(c,n) { \
dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
dev_init(c,n,write), dev_init(c,n,ioctl), (dev_type_stop((*))) enodev, \
- 0, seltrue, (dev_type_mmap((*))) enodev, D_TAPE }
+ 0, seltrue, (dev_type_mmap((*))) enodev, \
+ D_TAPE, D_KQFILTER, seltrue_kqfilter }
/* open, close, read, write, ioctl, stop, tty */
#define cdev_tty_init(c,n) { \
@@ -243,7 +245,8 @@ extern struct cdevsw cdevsw[];
#define cdev_mm_init(c,n) { \
dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
dev_init(c,n,write), dev_init(c,n,ioctl), \
- (dev_type_stop((*))) enodev, 0, seltrue, dev_init(c,n,mmap) }
+ (dev_type_stop((*))) enodev, 0, seltrue, dev_init(c,n,mmap), \
+ 0, D_KQFILTER, seltrue_kqfilter }
/* open, close, read, write, ioctl, mmap */
#define cdev_crypto_init(c,n) { \
@@ -366,7 +369,7 @@ extern struct cdevsw cdevsw[];
dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
(dev_type_write((*))) enodev, (dev_type_ioctl((*))) enodev, \
(dev_type_stop((*))) enodev, 0, seltrue, \
- (dev_type_mmap((*))) enodev, 0 }
+ (dev_type_mmap((*))) enodev, 0, D_KQFILTER, seltrue_kqfilter }
/* open, close, read, write, ioctl, stop, tty, poll, mmap, kqfilter */
#define cdev_wsdisplay_init(c,n) { \
@@ -448,20 +451,22 @@ void randomattach(void);
#define cdev_spkr_init(c,n) { \
dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \
dev_init(c,n,write), dev_init(c,n,ioctl), (dev_type_stop((*))) enodev, \
- 0, seltrue, (dev_type_mmap((*))) enodev }
+ 0, seltrue, (dev_type_mmap((*))) enodev, \
+ 0, D_KQFILTER, seltrue_kqfilter }
/* open, close, write, ioctl */
#define cdev_lpt_init(c,n) { \
dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \
dev_init(c,n,write), dev_init(c,n,ioctl), (dev_type_stop((*))) enodev, \
- 0, seltrue, (dev_type_mmap((*))) enodev }
+ 0, seltrue, (dev_type_mmap((*))) enodev, \
+ 0, D_KQFILTER, seltrue_kqfilter }
/* open, close, read, ioctl, mmap */
#define cdev_bktr_init(c, n) { \
dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
(dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
- (dev_type_stop((*))) enodev, 0, seltrue, \
- dev_init(c,n,mmap) }
+ (dev_type_stop((*))) enodev, 0, seltrue, dev_init(c,n,mmap), \
+ 0, D_KQFILTER, seltrue_kqfilter }
/* open, close, read, ioctl, poll, kqfilter */
#define cdev_hotplug_init(c,n) { \
diff --git a/sys/sys/event.h b/sys/sys/event.h
index 0076d1b590c..c528d669e8f 100644
--- a/sys/sys/event.h
+++ b/sys/sys/event.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: event.h,v 1.13 2008/11/05 09:20:17 dlg Exp $ */
+/* $OpenBSD: event.h,v 1.14 2010/07/28 21:44:41 nicm Exp $ */
/*-
* Copyright (c) 1999,2000,2001 Jonathan Lemon <jlemon@FreeBSD.org>
@@ -172,6 +172,7 @@ extern void knote_fdclose(struct proc *p, int fd);
extern int kqueue_register(struct kqueue *kq,
struct kevent *kev, struct proc *p);
extern int filt_seltrue(struct knote *kn, long hint);
+extern int seltrue_kqfilter(dev_t, struct knote *);
extern void klist_invalidate(struct klist *);
#else /* !_KERNEL */