PR-30566: Poll must not return <sys/errno.h> values.

Start with those places I can easily test.
This commit is contained in:
ws 2005-06-21 14:01:11 +00:00
parent b72e560799
commit 9d78e0cf36
18 changed files with 92 additions and 66 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: audio.c,v 1.196 2005/06/11 08:14:19 is Exp $ */
/* $NetBSD: audio.c,v 1.197 2005/06/21 14:01:11 ws Exp $ */
/*
* Copyright (c) 1991-1993 Regents of the University of California.
@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.196 2005/06/11 08:14:19 is Exp $");
__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.197 2005/06/21 14:01:11 ws Exp $");
#include "audio.h"
#if NAUDIO > 0
@ -1045,29 +1045,29 @@ int
audiopoll(dev_t dev, int events, struct proc *p)
{
struct audio_softc *sc;
int error;
int revents;
sc = audio_cd.cd_devs[AUDIOUNIT(dev)];
if (sc->sc_dying)
return EIO;
return POLLHUP;
sc->sc_refcnt++;
switch (AUDIODEV(dev)) {
case SOUND_DEVICE:
case AUDIO_DEVICE:
error = audio_poll(sc, events, p);
revents = audio_poll(sc, events, p);
break;
case AUDIOCTL_DEVICE:
case MIXER_DEVICE:
error = ENODEV;
revents = 0;
break;
default:
error = ENXIO;
revents = POLLERR;
break;
}
if (--sc->sc_refcnt < 0)
wakeup(&sc->sc_refcnt);
return error;
return revents;
}
int

View File

@ -1,4 +1,4 @@
/* $NetBSD: cons.c,v 1.55 2005/04/28 07:54:39 martin Exp $ */
/* $NetBSD: cons.c,v 1.56 2005/06/21 14:01:11 ws Exp $ */
/*
* Copyright (c) 1990, 1993
@ -78,7 +78,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: cons.c,v 1.55 2005/04/28 07:54:39 martin Exp $");
__KERNEL_RCSID(0, "$NetBSD: cons.c,v 1.56 2005/06/21 14:01:11 ws Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@ -86,6 +86,7 @@ __KERNEL_RCSID(0, "$NetBSD: cons.c,v 1.55 2005/04/28 07:54:39 martin Exp $");
#include <sys/systm.h>
#include <sys/buf.h>
#include <sys/ioctl.h>
#include <sys/poll.h>
#include <sys/tty.h>
#include <sys/file.h>
#include <sys/conf.h>
@ -268,7 +269,7 @@ cnpoll(dev_t dev, int events, struct proc *p)
*/
cdev = cn_redirect(&dev, 0, &error);
if (cdev == NULL)
return error;
return POLLHUP;
return ((*cdev->d_poll)(dev, events, p));
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: com.c,v 1.233 2005/06/12 21:10:47 tls Exp $ */
/* $NetBSD: com.c,v 1.234 2005/06/21 14:01:11 ws Exp $ */
/*-
* Copyright (c) 1998, 1999, 2004 The NetBSD Foundation, Inc.
@ -73,7 +73,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: com.c,v 1.233 2005/06/12 21:10:47 tls Exp $");
__KERNEL_RCSID(0, "$NetBSD: com.c,v 1.234 2005/06/21 14:01:11 ws Exp $");
#include "opt_com.h"
#include "opt_ddb.h"
@ -108,6 +108,7 @@ __KERNEL_RCSID(0, "$NetBSD: com.c,v 1.233 2005/06/12 21:10:47 tls Exp $");
#include <sys/systm.h>
#include <sys/ioctl.h>
#include <sys/select.h>
#include <sys/poll.h>
#include <sys/tty.h>
#include <sys/proc.h>
#include <sys/user.h>
@ -1022,7 +1023,7 @@ compoll(dev_t dev, int events, struct proc *p)
struct tty *tp = sc->sc_tty;
if (COM_ISALIVE(sc) == 0)
return (EIO);
return (POLLHUP);
return ((*tp->t_linesw->l_poll)(tp, events, p));
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: irframe.c,v 1.28 2003/10/21 06:22:46 simonb Exp $ */
/* $NetBSD: irframe.c,v 1.29 2005/06/21 14:01:12 ws Exp $ */
/*
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: irframe.c,v 1.28 2003/10/21 06:22:46 simonb Exp $");
__KERNEL_RCSID(0, "$NetBSD: irframe.c,v 1.29 2005/06/21 14:01:12 ws Exp $");
#include "irframe.h"
@ -386,9 +386,9 @@ irframepoll(dev_t dev, int events, struct proc *p)
sc = device_lookup(&irframe_cd, IRFRAMEUNIT(dev));
if (sc == NULL)
return (ENXIO);
return (POLLHUP);
if ((sc->sc_dev.dv_flags & DVF_ACTIVE) == 0 || !sc->sc_open)
return (EIO);
return (POLLHUP);
return (sc->sc_methods->im_poll(sc->sc_handle, events, p));
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: midi.c,v 1.40 2005/05/29 22:18:25 christos Exp $ */
/* $NetBSD: midi.c,v 1.41 2005/06/21 14:01:11 ws Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: midi.c,v 1.40 2005/05/29 22:18:25 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: midi.c,v 1.41 2005/06/21 14:01:11 ws Exp $");
#include "midi.h"
#include "sequencer.h"
@ -756,7 +756,7 @@ midipoll(dev_t dev, int events, struct proc *p)
DPRINTF(("midipoll: %p events=0x%x\n", sc, events));
if (sc->dying)
return EIO;
return POLLHUP;
s = splaudio();

View File

@ -1,4 +1,4 @@
/* $NetBSD: ucom.c,v 1.55 2005/05/30 04:21:39 christos Exp $ */
/* $NetBSD: ucom.c,v 1.56 2005/06/21 14:01:12 ws Exp $ */
/*
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.55 2005/05/30 04:21:39 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.56 2005/06/21 14:01:12 ws Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -568,16 +568,16 @@ ucompoll(dev_t dev, int events, usb_proc_ptr p)
{
struct ucom_softc *sc = ucom_cd.cd_devs[UCOMUNIT(dev)];
struct tty *tp = sc->sc_tty;
int error;
int revents;
if (sc->sc_dying)
return (EIO);
return (POLLHUP);
sc->sc_refcnt++;
error = ((*tp->t_linesw->l_poll)(tp, events, p));
revents = ((*tp->t_linesw->l_poll)(tp, events, p));
if (--sc->sc_refcnt < 0)
usb_detach_wakeup(USBDEV(sc->sc_dev));
return (error);
return (revents);
}
struct tty *

View File

@ -1,4 +1,4 @@
/* $NetBSD: ugen.c,v 1.74 2005/05/30 04:21:39 christos Exp $ */
/* $NetBSD: ugen.c,v 1.75 2005/06/21 14:01:12 ws Exp $ */
/*
* Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
@ -39,7 +39,7 @@
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ugen.c,v 1.74 2005/05/30 04:21:39 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: ugen.c,v 1.75 2005/06/21 14:01:12 ws Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -1341,20 +1341,20 @@ ugenpoll(dev_t dev, int events, usb_proc_ptr p)
USB_GET_SC(ugen, UGENUNIT(dev), sc);
if (sc->sc_dying)
return (EIO);
return (POLLHUP);
/* XXX always IN */
sce = &sc->sc_endpoints[UGENENDPOINT(dev)][IN];
if (sce == NULL)
return (EINVAL);
return (POLLERR);
#ifdef DIAGNOSTIC
if (!sce->edesc) {
printf("ugenpoll: no edesc\n");
return (EIO);
return (POLLERR);
}
if (!sce->pipeh) {
printf("ugenpoll: no pipe\n");
return (EIO);
return (POLLERR);
}
#endif
s = splusb();

View File

@ -1,4 +1,4 @@
/* $NetBSD: uhid.c,v 1.63 2005/03/02 11:37:27 mycroft Exp $ */
/* $NetBSD: uhid.c,v 1.64 2005/06/21 14:01:12 ws Exp $ */
/*
* Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: uhid.c,v 1.63 2005/03/02 11:37:27 mycroft Exp $");
__KERNEL_RCSID(0, "$NetBSD: uhid.c,v 1.64 2005/06/21 14:01:12 ws Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -574,7 +574,7 @@ uhidpoll(dev_t dev, int events, usb_proc_ptr p)
USB_GET_SC(uhid, UHIDUNIT(dev), sc);
if (sc->sc_dying)
return (EIO);
return (POLLHUP);
s = splusb();
if (events & (POLLOUT | POLLWRNORM))

View File

@ -1,4 +1,4 @@
/* $NetBSD: usb.c,v 1.81 2005/01/24 01:30:38 joff Exp $ */
/* $NetBSD: usb.c,v 1.82 2005/06/21 14:01:12 ws Exp $ */
/*
* Copyright (c) 1998, 2002 The NetBSD Foundation, Inc.
@ -44,7 +44,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.81 2005/01/24 01:30:38 joff Exp $");
__KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.82 2005/06/21 14:01:12 ws Exp $");
#include "ohci.h"
#include "uhci.h"
@ -593,7 +593,7 @@ usbpoll(dev_t dev, int events, usb_proc_ptr p)
return (revents);
} else {
return (ENXIO);
return (0);
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: uscanner.c,v 1.48 2005/05/11 10:02:29 augustss Exp $ */
/* $NetBSD: uscanner.c,v 1.49 2005/06/21 14:01:12 ws Exp $ */
/*
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: uscanner.c,v 1.48 2005/05/11 10:02:29 augustss Exp $");
__KERNEL_RCSID(0, "$NetBSD: uscanner.c,v 1.49 2005/06/21 14:01:12 ws Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -707,7 +707,7 @@ uscannerpoll(dev_t dev, int events, usb_proc_ptr p)
USB_GET_SC(uscanner, USCANNERUNIT(dev), sc);
if (sc->sc_dying)
return (EIO);
return (POLLHUP);
/*
* We have no easy way of determining if a read will

View File

@ -1,4 +1,4 @@
/* $NetBSD: wsdisplay.c,v 1.83 2005/05/29 21:56:35 christos Exp $ */
/* $NetBSD: wsdisplay.c,v 1.84 2005/06/21 14:01:13 ws Exp $ */
/*
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: wsdisplay.c,v 1.83 2005/05/29 21:56:35 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: wsdisplay.c,v 1.84 2005/06/21 14:01:13 ws Exp $");
#include "opt_wsdisplay_border.h"
#include "opt_wsdisplay_compat.h"
@ -45,6 +45,7 @@ __KERNEL_RCSID(0, "$NetBSD: wsdisplay.c,v 1.83 2005/05/29 21:56:35 christos Exp
#include <sys/conf.h>
#include <sys/device.h>
#include <sys/ioctl.h>
#include <sys/poll.h>
#include <sys/kernel.h>
#include <sys/proc.h>
#include <sys/malloc.h>
@ -906,10 +907,10 @@ wsdisplaypoll(dev_t dev, int events, struct proc *p)
return (0);
if ((scr = sc->sc_scr[WSDISPLAYSCREEN(dev)]) == NULL)
return (ENXIO);
return (POLLHUP);
if (!WSSCREEN_HAS_TTY(scr))
return (ENODEV);
return (POLLERR);
tp = scr->scr_tty;
return ((*tp->t_linesw->l_poll)(tp, events, p));

View File

@ -1,4 +1,4 @@
/* $NetBSD: wskbd.c,v 1.82 2005/05/29 21:56:35 christos Exp $ */
/* $NetBSD: wskbd.c,v 1.83 2005/06/21 14:01:13 ws Exp $ */
/*
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
@ -79,7 +79,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: wskbd.c,v 1.82 2005/05/29 21:56:35 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: wskbd.c,v 1.83 2005/06/21 14:01:13 ws Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@ -93,6 +93,7 @@ __KERNEL_RCSID(0, "$NetBSD: wskbd.c,v 1.82 2005/05/29 21:56:35 christos Exp $");
#include <sys/conf.h>
#include <sys/device.h>
#include <sys/ioctl.h>
#include <sys/poll.h>
#include <sys/kernel.h>
#include <sys/proc.h>
#include <sys/syslog.h>
@ -1194,7 +1195,7 @@ wskbdpoll(dev_t dev, int events, struct proc *p)
struct wskbd_softc *sc = wskbd_cd.cd_devs[minor(dev)];
if (sc->sc_base.me_evp == NULL)
return (EINVAL);
return (POLLERR);
return (wsevent_poll(sc->sc_base.me_evp, events, p));
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: wsmouse.c,v 1.35 2005/02/27 00:27:52 perry Exp $ */
/* $NetBSD: wsmouse.c,v 1.36 2005/06/21 14:01:13 ws Exp $ */
/*
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
@ -75,7 +75,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: wsmouse.c,v 1.35 2005/02/27 00:27:52 perry Exp $");
__KERNEL_RCSID(0, "$NetBSD: wsmouse.c,v 1.36 2005/06/21 14:01:13 ws Exp $");
#include "wsmouse.h"
#include "wsdisplay.h"
@ -84,6 +84,7 @@ __KERNEL_RCSID(0, "$NetBSD: wsmouse.c,v 1.35 2005/02/27 00:27:52 perry Exp $");
#include <sys/param.h>
#include <sys/conf.h>
#include <sys/ioctl.h>
#include <sys/poll.h>
#include <sys/fcntl.h>
#include <sys/kernel.h>
#include <sys/proc.h>
@ -612,7 +613,7 @@ wsmousepoll(dev_t dev, int events, struct proc *p)
struct wsmouse_softc *sc = wsmouse_cd.cd_devs[minor(dev)];
if (sc->sc_base.me_evp == NULL)
return (EINVAL);
return (POLLERR);
return (wsevent_poll(sc->sc_base.me_evp, events, p));
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: wsmux.c,v 1.37 2005/04/30 03:47:12 augustss Exp $ */
/* $NetBSD: wsmux.c,v 1.38 2005/06/21 14:01:13 ws Exp $ */
/*
* Copyright (c) 1998, 2005 The NetBSD Foundation, Inc.
@ -44,7 +44,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: wsmux.c,v 1.37 2005/04/30 03:47:12 augustss Exp $");
__KERNEL_RCSID(0, "$NetBSD: wsmux.c,v 1.38 2005/06/21 14:01:13 ws Exp $");
#include "wsdisplay.h"
#include "wsmux.h"
@ -54,6 +54,7 @@ __KERNEL_RCSID(0, "$NetBSD: wsmux.c,v 1.37 2005/04/30 03:47:12 augustss Exp $");
#include <sys/param.h>
#include <sys/conf.h>
#include <sys/ioctl.h>
#include <sys/poll.h>
#include <sys/fcntl.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
@ -577,14 +578,14 @@ wsmuxpoll(dev_t dev, int events, struct proc *p)
if (WSMUXCTL(minr)) {
/* control device */
return (EINVAL);
return (0);
}
if (sc->sc_base.me_evp == NULL) {
#ifdef DIAGNOSTIC
printf("wsmuxpoll: not open\n");
#endif
return (EACCES);
return (POLLHUP);
}
return (wsevent_poll(sc->sc_base.me_evp, events, p));

View File

@ -1,4 +1,4 @@
/* $NetBSD: tty_conf.c,v 1.46 2005/06/04 22:45:12 uwe Exp $ */
/* $NetBSD: tty_conf.c,v 1.47 2005/06/21 14:01:13 ws Exp $ */
/*-
* Copyright (c) 1982, 1986, 1991, 1993
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: tty_conf.c,v 1.46 2005/06/04 22:45:12 uwe Exp $");
__KERNEL_RCSID(0, "$NetBSD: tty_conf.c,v 1.47 2005/06/21 14:01:13 ws Exp $");
#include "opt_compat_freebsd.h"
#include "opt_compat_43.h"
@ -46,6 +46,7 @@ __KERNEL_RCSID(0, "$NetBSD: tty_conf.c,v 1.46 2005/06/04 22:45:12 uwe Exp $");
#include <sys/systm.h>
#include <sys/buf.h>
#include <sys/ioctl.h>
#include <sys/poll.h>
#include <sys/proc.h>
#include <sys/tty.h>
#include <sys/ioctl.h>
@ -177,6 +178,24 @@ ttynullioctl(tp, cmd, data, flags, p)
return (EPASSTHROUGH);
}
/*
* Return error to line discipline
* specific poll call.
*/
/*ARGSUSED*/
int
ttyerrpoll(tp, events, p)
struct tty *tp;
int events;
struct proc *p;
{
#ifdef lint
tp = tp; events = events; p = p;
#endif
return (POLLERR);
}
/*
* Register a line discipline, optionally providing a
* specific discipline number for compatibility, -1 allocates

View File

@ -1,4 +1,4 @@
/* $NetBSD: tty_pty.c,v 1.84 2005/05/29 22:24:15 christos Exp $ */
/* $NetBSD: tty_pty.c,v 1.85 2005/06/21 14:01:13 ws Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: tty_pty.c,v 1.84 2005/05/29 22:24:15 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: tty_pty.c,v 1.85 2005/06/21 14:01:13 ws Exp $");
#include "opt_compat_sunos.h"
#include "opt_ptm.h"
@ -477,7 +477,7 @@ ptspoll(dev, events, p)
struct tty *tp = pti->pt_tty;
if (tp->t_oproc == 0)
return (EIO);
return (POLLHUP);
return ((*tp->t_linesw->l_poll)(tp, events, p));
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: spec_vnops.c,v 1.80 2005/02/26 22:59:00 perry Exp $ */
/* $NetBSD: spec_vnops.c,v 1.81 2005/06/21 14:01:13 ws Exp $ */
/*
* Copyright (c) 1989, 1993
@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.80 2005/02/26 22:59:00 perry Exp $");
__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.81 2005/06/21 14:01:13 ws Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@ -46,6 +46,7 @@ __KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.80 2005/02/26 22:59:00 perry Exp $"
#include <sys/stat.h>
#include <sys/errno.h>
#include <sys/ioctl.h>
#include <sys/poll.h>
#include <sys/file.h>
#include <sys/disklabel.h>
#include <sys/lockf.h>
@ -509,7 +510,7 @@ spec_poll(v)
dev = ap->a_vp->v_rdev;
cdev = cdevsw_lookup(dev);
if (cdev == NULL)
return (ENXIO);
return (POLLERR);
return (*cdev->d_poll)(dev, ap->a_events, ap->a_p);
default:

View File

@ -1,4 +1,4 @@
/* $NetBSD: conf.h,v 1.118 2005/06/04 22:45:11 uwe Exp $ */
/* $NetBSD: conf.h,v 1.119 2005/06/21 14:01:13 ws Exp $ */
/*-
* Copyright (c) 1990, 1993
@ -183,8 +183,8 @@ struct linesw *ttyldisc_lookup(const char *);
#define ttyerrio ((int (*)(struct tty *, struct uio *, int))enodev)
#define ttyerrinput ((int (*)(int, struct tty *))enodev)
#define ttyerrstart ((int (*)(struct tty *))enodev)
#define ttyerrpoll ((int (*)(struct tty *, int, struct proc *))enodev)
int ttyerrpoll (struct tty *, int, struct proc *);
int ttynullioctl(struct tty *, u_long, caddr_t, int, struct proc *);
#endif