diff options
author | 2010-07-08 20:15:01 +0000 | |
---|---|---|
committer | 2010-07-08 20:15:01 +0000 | |
commit | 877e2aa865a8ae5ead3814fd98b80f124629a541 (patch) | |
tree | 4395364c5ccf732090fe428af2a0ca7b8da87c39 | |
parent | remove some unused netinet6 code (diff) | |
download | wireguard-openbsd-877e2aa865a8ae5ead3814fd98b80f124629a541.tar.xz wireguard-openbsd-877e2aa865a8ae5ead3814fd98b80f124629a541.zip |
Devices which don't have read or write functionality should not return
enodev to poll, because this returns an errno of 19 in revents. Oops.
Use seltrue where needed, and use a new selfalse function for those which
don't know if the next op will be non-blocking
Mostly discussed with guenther and miod
-rw-r--r-- | sys/kern/sys_generic.c | 10 | ||||
-rw-r--r-- | sys/sys/conf.h | 44 | ||||
-rw-r--r-- | sys/sys/systm.h | 3 |
3 files changed, 32 insertions, 25 deletions
diff --git a/sys/kern/sys_generic.c b/sys/kern/sys_generic.c index 279e514eb26..73e30f60fa7 100644 --- a/sys/kern/sys_generic.c +++ b/sys/kern/sys_generic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sys_generic.c,v 1.68 2010/04/11 17:46:13 kettenis Exp $ */ +/* $OpenBSD: sys_generic.c,v 1.69 2010/07/08 20:15:03 deraadt Exp $ */ /* $NetBSD: sys_generic.c,v 1.24 1996/03/29 00:25:32 cgd Exp $ */ /* @@ -63,7 +63,6 @@ #include <uvm/uvm_extern.h> int selscan(struct proc *, fd_set *, fd_set *, int, int, register_t *); -int seltrue(dev_t, int, struct proc *); void pollscan(struct proc *, struct pollfd *, u_int, register_t *); int pollout(struct pollfd *, struct pollfd *, u_int); @@ -680,6 +679,13 @@ seltrue(dev_t dev, int events, struct proc *p) return (events & (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM)); } +int +selfalse(dev_t dev, int events, struct proc *p) +{ + + return (0); +} + /* * Record a select request. */ diff --git a/sys/sys/conf.h b/sys/sys/conf.h index 859881a28d8..c8e6b770d3f 100644 --- a/sys/sys/conf.h +++ b/sys/sys/conf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.h,v 1.98 2010/07/03 03:59:17 krw Exp $ */ +/* $OpenBSD: conf.h,v 1.99 2010/07/08 20:15:01 deraadt Exp $ */ /* $NetBSD: conf.h,v 1.33 1996/05/03 20:03:32 christos Exp $ */ /*- @@ -249,13 +249,13 @@ extern struct cdevsw cdevsw[]; #define cdev_crypto_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, (dev_type_poll((*))) enodev, (dev_type_mmap((*))) enodev } + 0, selfalse, (dev_type_mmap((*))) enodev } /* open, close, read, write, ioctl */ #define cdev_systrace_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, (dev_type_poll((*))) enodev, (dev_type_mmap((*))) enodev } + 0, selfalse, (dev_type_mmap((*))) enodev } /* open, close, read, write, ioctl, tty, poll, kqfilter */ #define cdev_ptc_init(c,n) { \ @@ -268,7 +268,7 @@ extern struct cdevsw cdevsw[]; #define cdev_ptm_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, (dev_type_poll((*))) enodev, (dev_type_mmap((*))) enodev } + 0, selfalse, (dev_type_mmap((*))) enodev } /* open, close, read, ioctl, poll, kqfilter XXX should be a generic device */ #define cdev_log_init(c,n) { \ @@ -282,7 +282,7 @@ extern struct cdevsw cdevsw[]; dev_init(c,n,open), (dev_type_close((*))) enodev, \ (dev_type_read((*))) enodev, (dev_type_write((*))) enodev, \ (dev_type_ioctl((*))) enodev, (dev_type_stop((*))) enodev, \ - 0, (dev_type_poll((*))) enodev, (dev_type_mmap((*))) enodev } + 0, selfalse, (dev_type_mmap((*))) enodev } /* open, close, read, write, ioctl, poll, kqfilter -- XXX should be generic device */ #define cdev_tun_init(c,n) { \ @@ -310,28 +310,28 @@ extern struct cdevsw cdevsw[]; #define cdev_lkm_init(c,n) { \ dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \ (dev_type_write((*))) enodev, dev_init(c,n,ioctl), \ - (dev_type_stop((*))) enodev, 0, (dev_type_poll((*))) enodev, \ + (dev_type_stop((*))) enodev, 0, selfalse, \ (dev_type_mmap((*))) enodev } /* open, close, ioctl */ #define cdev_ch_init(c,n) { \ dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \ (dev_type_write((*))) enodev, dev_init(c,n,ioctl), \ - (dev_type_stop((*))) enodev, 0, (dev_type_poll((*))) enodev, \ + (dev_type_stop((*))) enodev, 0, selfalse, \ (dev_type_mmap((*))) enodev } /* open, close, ioctl */ #define cdev_uk_init(c,n) { \ dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \ (dev_type_write((*))) enodev, dev_init(c,n,ioctl), \ - (dev_type_stop((*))) enodev, 0, (dev_type_poll((*))) enodev, \ + (dev_type_stop((*))) enodev, 0, selfalse, \ (dev_type_mmap((*))) enodev } /* open, close, ioctl, mmap */ #define cdev_fb_init(c,n) { \ dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \ (dev_type_write((*))) enodev, dev_init(c,n,ioctl), \ - (dev_type_stop((*))) enodev, 0, (dev_type_poll((*))) enodev, \ + (dev_type_stop((*))) enodev, 0, selfalse, \ dev_init(c,n,mmap) } /* open, close, read, write, ioctl, poll, kqfilter */ @@ -352,7 +352,7 @@ extern struct cdevsw cdevsw[]; dev_init(c,n,open), (dev_type_close((*))) enodev, \ (dev_type_read((*))) enodev, (dev_type_write((*))) enodev, \ (dev_type_ioctl((*))) enodev, (dev_type_stop((*))) nullop, \ - 0, (dev_type_poll((*))) enodev, (dev_type_mmap((*))) enodev } + 0, selfalse, (dev_type_mmap((*))) enodev } /* open, close, read, write, ioctl, poll, nokqfilter */ #define cdev_nnpfs_init(c, n) { \ @@ -394,13 +394,13 @@ void randomattach(void); #define cdev_ulpt_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, (dev_type_poll((*))) enodev, (dev_type_mmap((*))) enodev } + 0, selfalse, (dev_type_mmap((*))) enodev } /* open, close, ioctl */ #define cdev_pf_init(c,n) { \ dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \ (dev_type_write((*))) enodev, dev_init(c,n,ioctl), \ - (dev_type_stop((*))) enodev, 0, (dev_type_poll((*))) enodev, \ + (dev_type_stop((*))) enodev, 0, selfalse, \ (dev_type_mmap((*))) enodev } /* open, close, read, write, ioctl, poll, nokqfilter */ @@ -420,28 +420,28 @@ void randomattach(void); #define cdev_pci_init(c,n) { \ dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \ (dev_type_write((*))) enodev, dev_init(c,n,ioctl), \ - (dev_type_stop((*))) enodev, 0, (dev_type_poll((*))) enodev, \ + (dev_type_stop((*))) enodev, 0, selfalse, \ (dev_type_mmap((*))) enodev } /* open, close, init */ #define cdev_iop_init(c,n) { \ dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \ (dev_type_write((*))) enodev, dev_init(c,n,ioctl), \ - (dev_type_stop((*))) enodev, 0, (dev_type_poll((*))) enodev, \ + (dev_type_stop((*))) enodev, 0, selfalse, \ (dev_type_mmap((*))) enodev } /* open, close, ioctl */ #define cdev_radio_init(c,n) { \ dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \ (dev_type_write((*))) enodev, dev_init(c,n,ioctl), \ - (dev_type_stop((*))) enodev, 0, (dev_type_poll((*))) enodev, \ + (dev_type_stop((*))) enodev, 0, selfalse, \ (dev_type_mmap((*))) enodev } /* open, close, ioctl, read, mmap */ #define cdev_video_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, (dev_type_poll((*))) enodev, \ + (dev_type_stop((*))) enodev, 0, selfalse, \ dev_init(c,n,mmap) } /* open, close, write, ioctl */ @@ -474,42 +474,42 @@ void randomattach(void); #define cdev_gpio_init(c,n) { \ dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \ (dev_type_write((*))) enodev, dev_init(c,n,ioctl), \ - (dev_type_stop((*))) enodev, 0, (dev_type_poll((*))) enodev, \ + (dev_type_stop((*))) enodev, 0, selfalse, \ (dev_type_mmap((*))) enodev } /* open, close, ioctl */ #define cdev_bio_init(c,n) { \ dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \ (dev_type_write((*))) enodev, dev_init(c,n,ioctl), \ - (dev_type_stop((*))) enodev, 0, (dev_type_poll((*))) enodev, \ + (dev_type_stop((*))) enodev, 0, selfalse, \ (dev_type_mmap((*))) enodev } /* open, close, ioctl */ #define cdev_bthub_init(c,n) { \ dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \ (dev_type_write((*))) enodev, dev_init(c,n,ioctl), \ - (dev_type_stop((*))) enodev, 0, (dev_type_poll((*))) enodev, \ + (dev_type_stop((*))) enodev, 0, selfalse, \ (dev_type_mmap((*))) enodev } /* open, close, ioctl, mmap */ #define cdev_agp_init(c,n) { \ dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \ (dev_type_write((*))) enodev, dev_init(c,n,ioctl), \ - (dev_type_stop((*))) enodev, 0, (dev_type_poll((*))) enodev, \ + (dev_type_stop((*))) enodev, 0, selfalse, \ dev_init(c,n,mmap) } /* open, close, read, ioctl, poll, mmap, nokqfilter */ #define cdev_drm_init(c,n) { \ dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \ (dev_type_write((*))) enodev, dev_init(c,n,ioctl), \ - (dev_type_stop((*))) enodev, 0, (dev_type_poll((*))) enodev, \ + (dev_type_stop((*))) enodev, 0, selfalse, \ dev_init(c,n,mmap), 0, D_CLONE } /* open, close, ioctl */ #define cdev_amdmsr_init(c,n) { \ dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \ (dev_type_write((*))) enodev, dev_init(c,n,ioctl), \ - (dev_type_stop((*))) enodev, 0, (dev_type_poll((*))) enodev, \ + (dev_type_stop((*))) enodev, 0, selfalse, \ (dev_type_mmap((*))) enodev } #endif diff --git a/sys/sys/systm.h b/sys/sys/systm.h index c69ddd23b17..6a13ae2c8da 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -1,4 +1,4 @@ -/* $OpenBSD: systm.h,v 1.80 2010/06/29 00:28:14 tedu Exp $ */ +/* $OpenBSD: systm.h,v 1.81 2010/07/08 20:15:01 deraadt Exp $ */ /* $NetBSD: systm.h,v 1.50 1996/06/09 04:55:09 briggs Exp $ */ /*- @@ -156,6 +156,7 @@ void vfs_opv_init_default(struct vnodeopv_desc *); void vfs_op_init(void); int seltrue(dev_t dev, int which, struct proc *); +int selfalse(dev_t dev, int which, struct proc *); void *hashinit(int, int, int, u_long *); int sys_nosys(struct proc *, void *, register_t *); |