summaryrefslogtreecommitdiffstats
path: root/sys/dev/wscons
diff options
context:
space:
mode:
authorvisa <visa@openbsd.org>2020-01-08 16:27:40 +0000
committervisa <visa@openbsd.org>2020-01-08 16:27:40 +0000
commit36b1b8b4dfaf3411193c17c2462937014292f2df (patch)
tree81f30bc60ac32c23151dd9b7753c67c177381297 /sys/dev/wscons
parentConvert infinite sleeps to tsleep_nsec(9). (diff)
downloadwireguard-openbsd-36b1b8b4dfaf3411193c17c2462937014292f2df.tar.xz
wireguard-openbsd-36b1b8b4dfaf3411193c17c2462937014292f2df.zip
Unify handling of ioctls FIOSETOWN/SIOCSPGRP/TIOCSPGRP and
FIOGETOWN/SIOCGPGRP/TIOCGPGRP. Do this by determining the meaning of the ID parameter inside the sigio code. Also add cases for FIOSETOWN and FIOGETOWN where there have been TIOCSPGRP and TIOCGPGRP before. These changes allow removing the ID translation from sys_fcntl() and sys_ioctl(). Idea from NetBSD OK mpi@, claudio@
Diffstat (limited to 'sys/dev/wscons')
-rw-r--r--sys/dev/wscons/wskbd.c10
-rw-r--r--sys/dev/wscons/wsmouse.c11
-rw-r--r--sys/dev/wscons/wsmux.c16
3 files changed, 20 insertions, 17 deletions
diff --git a/sys/dev/wscons/wskbd.c b/sys/dev/wscons/wskbd.c
index 120b0476afd..c834dfbee9a 100644
--- a/sys/dev/wscons/wskbd.c
+++ b/sys/dev/wscons/wskbd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wskbd.c,v 1.99 2019/08/08 02:19:18 cheloha Exp $ */
+/* $OpenBSD: wskbd.c,v 1.100 2020/01/08 16:27:40 visa Exp $ */
/* $NetBSD: wskbd.c,v 1.80 2005/05/04 01:52:16 augustss Exp $ */
/*
@@ -961,20 +961,20 @@ wskbd_do_ioctl_sc(struct wskbd_softc *sc, u_long cmd, caddr_t data, int flag,
sc->sc_base.me_evp->async = *(int *)data != 0;
return (0);
+ case FIOGETOWN:
case TIOCGPGRP:
evar = sc->sc_base.me_evp;
if (evar == NULL)
return (EINVAL);
- *(int *)data = -sigio_getown(&evar->sigio);
+ sigio_getown(&evar->sigio, cmd, data);
return (0);
+ case FIOSETOWN:
case TIOCSPGRP:
- if (*(int *)data < 0)
- return (EINVAL);
evar = sc->sc_base.me_evp;
if (evar == NULL)
return (EINVAL);
- return (sigio_setown(&evar->sigio, -*(int *)data));
+ return (sigio_setown(&evar->sigio, cmd, data));
}
/*
diff --git a/sys/dev/wscons/wsmouse.c b/sys/dev/wscons/wsmouse.c
index 97a086d7115..0f0d4da1c60 100644
--- a/sys/dev/wscons/wsmouse.c
+++ b/sys/dev/wscons/wsmouse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wsmouse.c,v 1.57 2019/08/19 21:19:38 bru Exp $ */
+/* $OpenBSD: wsmouse.c,v 1.58 2020/01/08 16:27:41 visa Exp $ */
/* $NetBSD: wsmouse.c,v 1.35 2005/02/27 00:27:52 perry Exp $ */
/*
@@ -483,6 +483,7 @@ wsmouse_do_ioctl(struct wsmouse_softc *sc, u_long cmd, caddr_t data, int flag,
switch (cmd) {
case FIOASYNC:
+ case FIOSETOWN:
case TIOCSPGRP:
if ((flag & FWRITE) == 0)
return (EACCES);
@@ -498,20 +499,20 @@ wsmouse_do_ioctl(struct wsmouse_softc *sc, u_long cmd, caddr_t data, int flag,
sc->sc_base.me_evp->async = *(int *)data != 0;
return (0);
+ case FIOGETOWN:
case TIOCGPGRP:
evar = sc->sc_base.me_evp;
if (evar == NULL)
return (EINVAL);
- *(int *)data = -sigio_getown(&evar->sigio);
+ sigio_getown(&evar->sigio, cmd, data);
return (0);
+ case FIOSETOWN:
case TIOCSPGRP:
- if (*(int *)data < 0)
- return (EINVAL);
evar = sc->sc_base.me_evp;
if (evar == NULL)
return (EINVAL);
- return (sigio_setown(&evar->sigio, -*(int *)data));
+ return (sigio_setown(&evar->sigio, cmd, data));
case WSMOUSEIO_GETPARAMS:
case WSMOUSEIO_SETPARAMS:
diff --git a/sys/dev/wscons/wsmux.c b/sys/dev/wscons/wsmux.c
index 20239aafca7..ede38d63714 100644
--- a/sys/dev/wscons/wsmux.c
+++ b/sys/dev/wscons/wsmux.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wsmux.c,v 1.48 2019/05/22 19:13:34 anton Exp $ */
+/* $OpenBSD: wsmux.c,v 1.49 2020/01/08 16:27:41 visa Exp $ */
/* $NetBSD: wsmux.c,v 1.37 2005/04/30 03:47:12 augustss Exp $ */
/*
@@ -501,21 +501,23 @@ wsmux_do_ioctl(struct device *dv, u_long cmd, caddr_t data, int flag,
return (EINVAL);
evar->async = *(int *)data != 0;
return (0);
+ case FIOGETOWN:
case TIOCGPGRP:
- DPRINTF(("%s: TIOCGPGRP\n", sc->sc_base.me_dv.dv_xname));
+ DPRINTF(("%s: getown (%lu)\n", sc->sc_base.me_dv.dv_xname,
+ cmd));
evar = sc->sc_base.me_evp;
if (evar == NULL)
return (EINVAL);
- *(int *)data = -sigio_getown(&evar->sigio);
+ sigio_getown(&evar->sigio, cmd, data);
return (0);
+ case FIOSETOWN:
case TIOCSPGRP:
- DPRINTF(("%s: TIOCSPGRP\n", sc->sc_base.me_dv.dv_xname));
- if (*(int *)data < 0)
- return (EINVAL);
+ DPRINTF(("%s: setown (%lu)\n", sc->sc_base.me_dv.dv_xname,
+ cmd));
evar = sc->sc_base.me_evp;
if (evar == NULL)
return (EINVAL);
- return (sigio_setown(&evar->sigio, -*(int *)data));
+ return (sigio_setown(&evar->sigio, cmd, data));
default:
DPRINTF(("%s: unknown\n", sc->sc_base.me_dv.dv_xname));
break;