Fix our ioctl(2) implementation when the argument is "int". New

ioctls passing integer arguments should use the _IOWINT() macro.
This fixes a lot of ioctl's not working on sparc64, most notable
being keyboard/syscons ioctls.

Full ABI compatibility is provided, with the bonus of fixing the
handling of old ioctls on sparc64.

Reviewed by:	bde (with contributions)
Tested by:	emax, marius
MFC after:	1 week
This commit is contained in:
Ruslan Ermilov 2006-09-27 19:57:02 +00:00
parent 3ea944faa0
commit 9fddcc6661
27 changed files with 421 additions and 53 deletions

View File

@ -28,6 +28,7 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include "opt_compat.h"
#include "opt_kbd.h"
#include "opt_atkbd.h"
@ -851,6 +852,10 @@ atkbd_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg)
int error;
int s;
int i;
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
int ival;
#endif
s = spltty();
switch (cmd) {
@ -858,6 +863,13 @@ atkbd_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg)
case KDGKBMODE: /* get keyboard mode */
*(int *)arg = state->ks_mode;
break;
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
case _IO('K', 7):
ival = IOCPARM_IVAL(arg);
arg = (caddr_t)&ival;
/* FALLTHROUGH */
#endif
case KDSKBMODE: /* set keyboard mode */
switch (*(int *)arg) {
case K_XLATE:
@ -883,6 +895,13 @@ atkbd_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg)
case KDGETLED: /* get keyboard LED */
*(int *)arg = KBD_LED_VAL(kbd);
break;
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
case _IO('K', 66):
ival = IOCPARM_IVAL(arg);
arg = (caddr_t)&ival;
/* FALLTHROUGH */
#endif
case KDSETLED: /* set keyboard LED */
/* NOTE: lock key state in ks_state won't be changed */
if (*(int *)arg & ~LOCK_MASK) {
@ -912,6 +931,13 @@ atkbd_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg)
case KDGKBSTATE: /* get lock key state */
*(int *)arg = state->ks_state & LOCK_MASK;
break;
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
case _IO('K', 20):
ival = IOCPARM_IVAL(arg);
arg = (caddr_t)&ival;
/* FALLTHROUGH */
#endif
case KDSKBSTATE: /* set lock key state */
if (*(int *)arg & ~LOCK_MASK) {
splx(s);
@ -935,6 +961,13 @@ atkbd_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg)
}
return error;
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
case _IO('K', 67):
ival = IOCPARM_IVAL(arg);
arg = (caddr_t)&ival;
/* FALLTHROUGH */
#endif
case KDSETRAD: /* set keyboard repeat rate (old interface) */
splx(s);
if (!KBD_HAS_DEVICE(kbd))

View File

@ -913,6 +913,10 @@ digiioctl(struct tty *tp, u_long cmd, void *data, int flag, struct thread *td)
{
struct digi_softc *sc;
struct digi_p *port;
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
int ival;
#endif
port = tp->t_sc;
sc = port->sc;
@ -942,8 +946,15 @@ digiioctl(struct tty *tp, u_long cmd, void *data, int flag, struct thread *td)
}
}
return (0);
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
case _IO('e', 'C'):
ival = IOCPARM_IVAL(data);
data = &ival;
/* FALLTHROUGH */
#endif
case DIGIIO_RING:
port->send_ring = *(u_char *)data;
port->send_ring = (u_char)*(int *)data;
break;
default:
return (ENOTTY);

View File

@ -31,6 +31,7 @@
* $FreeBSD$
*/
#include "opt_compat.h"
#include "opt_kbd.h"
#include <sys/param.h>
@ -940,6 +941,9 @@ kbdmux_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg)
kbdmux_kbd_t *k;
keyboard_info_t *ki;
int error = 0, mode;
#ifdef COMPAT_FREEBSD6
int ival;
#endif
if (state == NULL)
return (ENXIO);
@ -1048,6 +1052,12 @@ kbdmux_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg)
KBDMUX_UNLOCK(state);
break;
#ifdef COMPAT_FREEBSD6
case _IO('K', 7):
ival = IOCPARM_IVAL(arg);
arg = (caddr_t)&ival;
/* FALLTHROUGH */
#endif
case KDSKBMODE: /* set keyboard mode */
KBDMUX_LOCK(state);
@ -1082,6 +1092,12 @@ kbdmux_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg)
KBDMUX_UNLOCK(state);
break;
#ifdef COMPAT_FREEBSD6
case _IO('K', 66):
ival = IOCPARM_IVAL(arg);
arg = (caddr_t)&ival;
/* FALLTHROUGH */
#endif
case KDSETLED: /* set keyboard LED */
KBDMUX_LOCK(state);
@ -1107,6 +1123,12 @@ kbdmux_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg)
KBDMUX_UNLOCK(state);
break;
#ifdef COMPAT_FREEBSD6
case _IO('K', 20):
ival = IOCPARM_IVAL(arg);
arg = (caddr_t)&ival;
/* FALLTHROUGH */
#endif
case KDSKBSTATE: /* set lock key state */
KBDMUX_LOCK(state);
@ -1128,6 +1150,13 @@ kbdmux_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg)
return (kbdmux_ioctl(kbd, KDSETLED, arg));
/* NOT REACHED */
#ifdef COMPAT_FREEBSD6
case _IO('K', 67):
cmd = KDSETRAD;
ival = IOCPARM_IVAL(arg);
arg = (caddr_t)&ival;
/* FALLTHROUGH */
#endif
case KDSETREPEAT: /* set keyboard repeat rate (new interface) */
case KDSETRAD: /* set keyboard repeat rate (old interface) */
KBDMUX_LOCK(state);

View File

@ -30,6 +30,7 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include "opt_compat.h"
#include "opt_syscons.h"
#include <sys/param.h>
@ -482,6 +483,10 @@ sc_vid_ioctl(struct tty *tp, u_long cmd, caddr_t data, int flag, struct thread *
video_adapter_info_t adp_info;
int error;
int s;
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
int ival;
#endif
scp = SC_STAT(tp->t_dev);
if (scp == NULL) /* tp == SC_MOUSE */
@ -584,6 +589,13 @@ sc_vid_ioctl(struct tty *tp, u_long cmd, caddr_t data, int flag, struct thread *
case FBIO_FINDMODE:
return fb_ioctl(adp, FBIO_FINDMODE, data);
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
case _IO('c', 104):
ival = IOCPARM_IVAL(data);
data = (caddr_t)&ival;
/* FALLTHROUGH */
#endif
case CONS_SETWINORG: /* set frame buffer window origin */
case FBIO_SETWINORG:
if (scp != scp->sc->cur_scp)
@ -675,8 +687,15 @@ sc_vid_ioctl(struct tty *tp, u_long cmd, caddr_t data, int flag, struct thread *
return sc_set_graphics_mode(scp, tp, cmd & 0xff);
#endif /* SC_NO_MODE_CHANGE */
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
case _IO('K', 10):
ival = IOCPARM_IVAL(data);
data = (caddr_t)&ival;
/* FALLTHROUGH */
#endif
case KDSETMODE: /* set current mode of this (virtual) console */
switch (*(intptr_t *)data) {
switch (*(int *)data) {
case KD_TEXT: /* switch to TEXT (known) mode */
/*
* If scp->mode is of graphics modes, we don't know which
@ -804,8 +823,15 @@ sc_vid_ioctl(struct tty *tp, u_long cmd, caddr_t data, int flag, struct thread *
*data = ISGRAPHSC(scp) ? KD_GRAPHICS : KD_TEXT;
return 0;
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
case _IO('K', 13):
ival = IOCPARM_IVAL(data);
data = (caddr_t)&ival;
/* FALLTHROUGH */
#endif
case KDSBORDER: /* set border color of this (virtual) console */
scp->border = *(intptr_t *)data;
scp->border = *(int *)data;
if (scp == scp->sc->cur_scp)
sc_set_border(scp, scp->border);
return 0;

View File

@ -32,6 +32,7 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include "opt_compat.h"
#include "opt_syscons.h"
#include "opt_splash.h"
#include "opt_ddb.h"
@ -680,6 +681,10 @@ scioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td)
sc_softc_t *sc;
scr_stat *scp;
int s;
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
int ival;
#endif
tp = dev->si_tty;
@ -980,6 +985,13 @@ scioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td)
bcopy(&scp->smode, data, sizeof(struct vt_mode));
return 0;
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
case _IO('v', 4):
ival = IOCPARM_IVAL(data);
data = (caddr_t)&ival;
/* FALLTHROUGH */
#endif
case VT_RELDISP: /* screen switcher ioctl */
s = spltty();
/*
@ -996,7 +1008,7 @@ scioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td)
return EPERM;
}
error = EINVAL;
switch(*(intptr_t *)data) {
switch(*(int *)data) {
case VT_FALSE: /* user refuses to release screen, abort */
if ((error = finish_vt_rel(scp, FALSE, &s)) == 0)
DPRINTF(5, ("%s%d: VT_FALSE\n", SC_DRIVER_NAME, sc->unit));
@ -1025,8 +1037,15 @@ scioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td)
}
return EINVAL;
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
case _IO('v', 5):
ival = IOCPARM_IVAL(data);
data = (caddr_t)&ival;
/* FALLTHROUGH */
#endif
case VT_ACTIVATE: /* switch to screen *data */
i = (*(intptr_t *)data == 0) ? scp->index : (*(intptr_t *)data - 1);
i = (*(int *)data == 0) ? scp->index : (*(int *)data - 1);
s = spltty();
error = sc_clean_up(sc->cur_scp);
splx(s);
@ -1034,8 +1053,15 @@ scioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td)
return error;
return sc_switch_scr(sc, i);
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
case _IO('v', 6):
ival = IOCPARM_IVAL(data);
data = (caddr_t)&ival;
/* FALLTHROUGH */
#endif
case VT_WAITACTIVE: /* wait for switch to occur */
i = (*(intptr_t *)data == 0) ? scp->index : (*(intptr_t *)data - 1);
i = (*(int *)data == 0) ? scp->index : (*(int *)data - 1);
if ((i < sc->first_vty) || (i >= sc->first_vty + sc->vtys))
return EINVAL;
s = spltty();
@ -1087,6 +1113,13 @@ scioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td)
#endif
return 0;
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
case _IO('K', 20):
ival = IOCPARM_IVAL(data);
data = (caddr_t)&ival;
/* FALLTHROUGH */
#endif
case KDSKBSTATE: /* set keyboard state (locks) */
if (*(int *)data & ~LOCK_MASK)
return EINVAL;
@ -1109,14 +1142,28 @@ scioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td)
error = ENODEV;
return error;
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
case _IO('K', 67):
ival = IOCPARM_IVAL(data);
data = (caddr_t)&ival;
/* FALLTHROUGH */
#endif
case KDSETRAD: /* set keyboard repeat & delay rates (old) */
if (*(int *)data & ~0x7f)
return EINVAL;
error = kbd_ioctl(sc->kbd, cmd, data);
error = kbd_ioctl(sc->kbd, KDSETRAD, data);
if (error == ENOIOCTL)
error = ENODEV;
return error;
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
case _IO('K', 7):
ival = IOCPARM_IVAL(data);
data = (caddr_t)&ival;
/* FALLTHROUGH */
#endif
case KDSKBMODE: /* set keyboard mode */
switch (*(int *)data) {
case K_XLATE: /* switch to XLT ascii mode */
@ -1124,7 +1171,7 @@ scioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td)
case K_CODE: /* switch to CODE mode */
scp->kbd_mode = *(int *)data;
if (scp == sc->cur_scp)
kbd_ioctl(sc->kbd, cmd, data);
kbd_ioctl(sc->kbd, KDSKBMODE, data);
return 0;
default:
return EINVAL;
@ -1141,6 +1188,13 @@ scioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td)
error = ENODEV;
return error;
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
case _IO('K', 8):
ival = IOCPARM_IVAL(data);
data = (caddr_t)&ival;
/* FALLTHROUGH */
#endif
case KDMKTONE: /* sound the bell */
if (*(int*)data)
sc_bell(scp, (*(int*)data)&0xffff,
@ -1149,6 +1203,13 @@ scioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td)
sc_bell(scp, scp->bell_pitch, scp->bell_duration);
return 0;
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
case _IO('K', 63):
ival = IOCPARM_IVAL(data);
data = (caddr_t)&ival;
/* FALLTHROUGH */
#endif
case KIOCSOUND: /* make tone (*data) hz */
if (scp == sc->cur_scp) {
if (*(int *)data)
@ -1166,6 +1227,13 @@ scioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td)
}
return 0;
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
case _IO('K', 66):
ival = IOCPARM_IVAL(data);
data = (caddr_t)&ival;
/* FALLTHROUGH */
#endif
case KDSETLED: /* set keyboard LED status */
if (*(int *)data & ~LED_MASK) /* FIXME: LOCK_MASK? */
return EINVAL;
@ -1188,6 +1256,13 @@ scioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td)
error = ENODEV;
return error;
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
case _IO('c', 110):
ival = IOCPARM_IVAL(data);
data = (caddr_t)&ival;
/* FALLTHROUGH */
#endif
case CONS_SETKBD: /* set the new keyboard */
{
keyboard_t *newkbd;

View File

@ -27,6 +27,7 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include "opt_compat.h"
#include "opt_kbd.h"
#include <sys/param.h>
@ -425,6 +426,9 @@ sunkbd_ioctl(keyboard_t *kbd, u_long cmd, caddr_t data)
{
struct sunkbd_softc *sc;
int error;
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5)
int ival;
#endif
sc = (struct sunkbd_softc *)kbd;
error = 0;
@ -432,6 +436,12 @@ sunkbd_ioctl(keyboard_t *kbd, u_long cmd, caddr_t data)
case KDGKBMODE:
*(int *)data = sc->sc_mode;
break;
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5)
case _IO('K', 7):
ival = IOCPARM_IVAL(data);
data = (caddr_t)&ival;
/* FALLTHROUGH */
#endif
case KDSKBMODE:
switch (*(int *)data) {
case K_XLATE:
@ -456,6 +466,12 @@ sunkbd_ioctl(keyboard_t *kbd, u_long cmd, caddr_t data)
case KDGETLED:
*(int *)data = KBD_LED_VAL(kbd);
break;
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5)
case _IO('K', 66):
ival = IOCPARM_IVAL(data);
data = (caddr_t)&ival;
/* FALLTHROUGH */
#endif
case KDSETLED:
if (*(int *)data & ~LOCK_MASK) {
error = EINVAL;
@ -478,6 +494,12 @@ sunkbd_ioctl(keyboard_t *kbd, u_long cmd, caddr_t data)
case KDGKBSTATE:
*(int *)data = sc->sc_state & LOCK_MASK;
break;
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5)
case _IO('K', 20):
ival = IOCPARM_IVAL(data);
data = (caddr_t)&ival;
/* FALLTHROUGH */
#endif
case KDSKBSTATE:
if (*(int *)data & ~LOCK_MASK) {
error = EINVAL;
@ -485,7 +507,8 @@ sunkbd_ioctl(keyboard_t *kbd, u_long cmd, caddr_t data)
}
sc->sc_state &= ~LOCK_MASK;
sc->sc_state |= *(int *)data;
break;
/* set LEDs and quit */
return (sunkbd_ioctl(kbd, KDSETLED, data));
case KDSETREPEAT:
case KDSETRAD:
break;

View File

@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
* HID spec: http://www.usb.org/developers/devclass_docs/HID1_11.pdf
*/
#include "opt_compat.h"
#include "opt_kbd.h"
#include "opt_ukbd.h"
@ -1159,6 +1160,10 @@ ukbd_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg)
ukbd_state_t *state = kbd->kb_data;
int s;
int i;
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
int ival;
#endif
s = splusb();
switch (cmd) {
@ -1166,6 +1171,13 @@ ukbd_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg)
case KDGKBMODE: /* get keyboard mode */
*(int *)arg = state->ks_mode;
break;
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
case _IO('K', 7):
ival = IOCPARM_IVAL(arg);
arg = (caddr_t)&ival;
/* FALLTHROUGH */
#endif
case KDSKBMODE: /* set keyboard mode */
switch (*(int *)arg) {
case K_XLATE:
@ -1191,6 +1203,13 @@ ukbd_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg)
case KDGETLED: /* get keyboard LED */
*(int *)arg = KBD_LED_VAL(kbd);
break;
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
case _IO('K', 66):
ival = IOCPARM_IVAL(arg);
arg = (caddr_t)&ival;
/* FALLTHROUGH */
#endif
case KDSETLED: /* set keyboard LED */
/* NOTE: lock key state in ks_state won't be changed */
if (*(int *)arg & ~LOCK_MASK) {
@ -1215,6 +1234,13 @@ ukbd_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg)
case KDGKBSTATE: /* get lock key state */
*(int *)arg = state->ks_state & LOCK_MASK;
break;
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
case _IO('K', 20):
ival = IOCPARM_IVAL(arg);
arg = (caddr_t)&ival;
/* FALLTHROUGH */
#endif
case KDSKBSTATE: /* set lock key state */
if (*(int *)arg & ~LOCK_MASK) {
splx(s);
@ -1241,6 +1267,13 @@ ukbd_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg)
kbd->kb_delay2 = ((int *)arg)[1];
return 0;
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
case _IO('K', 67):
ival = IOCPARM_IVAL(arg);
arg = (caddr_t)&ival;
/* FALLTHROUGH */
#endif
case KDSETRAD: /* set keyboard repeat rate (old interface) */
splx(s);
return set_typematic(kbd, *(int *)arg);

View File

@ -31,6 +31,7 @@
* $FreeBSD$
*/
#include "opt_compat.h"
#include "opt_kbd.h"
#include <sys/param.h>
@ -1092,6 +1093,9 @@ vkbd_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg)
{
vkbd_state_t *state = (vkbd_state_t *) kbd->kb_data;
int i;
#ifdef COMPAT_FREEBSD6
int ival;
#endif
VKBD_LOCK(state);
@ -1100,6 +1104,12 @@ vkbd_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg)
*(int *)arg = state->ks_mode;
break;
#ifdef COMPAT_FREEBSD6
case _IO('K', 7):
ival = IOCPARM_IVAL(arg);
arg = (caddr_t)&ival;
/* FALLTHROUGH */
#endif
case KDSKBMODE: /* set keyboard mode */
switch (*(int *)arg) {
case K_XLATE:
@ -1130,6 +1140,12 @@ vkbd_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg)
*(int *)arg = KBD_LED_VAL(kbd);
break;
#ifdef COMPAT_FREEBSD6
case _IO('K', 66):
ival = IOCPARM_IVAL(arg);
arg = (caddr_t)&ival;
/* FALLTHROUGH */
#endif
case KDSETLED: /* set keyboard LED */
/* NOTE: lock key state in ks_state won't be changed */
if (*(int *)arg & ~LOCK_MASK) {
@ -1155,6 +1171,12 @@ vkbd_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg)
*(int *)arg = state->ks_state & LOCK_MASK;
break;
#ifdef COMPAT_FREEBSD6
case _IO('K', 20):
ival = IOCPARM_IVAL(arg);
arg = (caddr_t)&ival;
/* FALLTHROUGH */
#endif
case KDSKBSTATE: /* set lock key state */
if (*(int *)arg & ~LOCK_MASK) {
VKBD_UNLOCK(state);
@ -1174,6 +1196,12 @@ vkbd_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg)
vkbd_status_changed(state);
break;
#ifdef COMPAT_FREEBSD6
case _IO('K', 67):
ival = IOCPARM_IVAL(arg);
arg = (caddr_t)&ival;
/* FALLTHROUGH */
#endif
case KDSETRAD: /* set keyboard repeat rate (old interface) */
kbd->kb_delay1 = typematic_delay(*(int *)arg);
kbd->kb_delay2 = typematic_rate(*(int *)arg);

View File

@ -65,27 +65,45 @@ procfs_ioctl(PFS_IOCTL_ARGS)
struct procfs_status32 *ps32;
#endif
int error, flags, sig;
#ifdef COMPAT_FREEBSD6
int ival;
#endif
PROC_LOCK(p);
error = 0;
switch (cmd) {
#if defined(COMPAT_FREEBSD5) || defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
case _IOC(IOC_IN, 'p', 1, 0):
#endif
#ifdef COMPAT_FREEBSD6
case _IO('p', 1):
ival = IOCPARM_IVAL(data);
data = &ival;
#endif
case PIOCBIS:
p->p_stops |= *(uintptr_t *)data;
p->p_stops |= *(unsigned int *)data;
break;
#if defined(COMPAT_FREEBSD5) || defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
case _IOC(IOC_IN, 'p', 2, 0):
#endif
#ifdef COMPAT_FREEBSD6
case _IO('p', 2):
ival = IOCPARM_IVAL(data);
data = &ival;
#endif
case PIOCBIC:
p->p_stops &= ~*(uintptr_t *)data;
p->p_stops &= ~*(unsigned int *)data;
break;
#if defined(COMPAT_FREEBSD5) || defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
case _IOC(IOC_IN, 'p', 3, 0):
#endif
#ifdef COMPAT_FREEBSD6
case _IO('p', 3):
ival = IOCPARM_IVAL(data);
data = &ival;
#endif
case PIOCSFL:
flags = *(uintptr_t *)data;
flags = *(unsigned int *)data;
if (flags & PF_ISUGID && (error = suser(td)) != 0)
break;
p->p_pfsflags = flags;
@ -131,11 +149,16 @@ procfs_ioctl(PFS_IOCTL_ARGS)
#endif
#if defined(COMPAT_FREEBSD5) || defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
case _IOC(IOC_IN, 'p', 5, 0):
#endif
#ifdef COMPAT_FREEBSD6
case _IO('p', 5):
ival = IOCPARM_IVAL(data);
data = &ival;
#endif
case PIOCCONT:
if (p->p_step == 0)
break;
sig = *(uintptr_t *)data;
sig = *(unsigned int *)data;
if (sig != 0 && !_SIG_VALID(sig)) {
error = EINVAL;
break;

View File

@ -524,9 +524,9 @@ int
ioctl(struct thread *td, struct ioctl_args *uap)
{
u_long com;
int error;
int arg, error;
u_int size;
caddr_t data, memp;
caddr_t data;
if (uap->com > 0xffffffff) {
printf(
@ -548,20 +548,24 @@ ioctl(struct thread *td, struct ioctl_args *uap)
#else
((com & (IOC_IN | IOC_OUT)) && size == 0) ||
#endif
((com & IOC_VOID) && size > 0))
((com & IOC_VOID) && size > 0 && size != sizeof(int)))
return (ENOTTY);
if (size > 0) {
memp = malloc((u_long)size, M_IOCTLOPS, M_WAITOK);
data = memp;
} else {
memp = NULL;
if (!(com & IOC_VOID))
data = malloc((u_long)size, M_IOCTLOPS, M_WAITOK);
else {
/* Integer argument. */
arg = (intptr_t)uap->data;
data = (void *)&arg;
size = 0;
}
} else
data = (void *)&uap->data;
}
if (com & IOC_IN) {
error = copyin(uap->data, data, (u_int)size);
if (error) {
free(memp, M_IOCTLOPS);
free(data, M_IOCTLOPS);
return (error);
}
} else if (com & IOC_OUT) {
@ -577,8 +581,8 @@ ioctl(struct thread *td, struct ioctl_args *uap)
if (error == 0 && (com & IOC_OUT))
error = copyout(data, uap->data, (u_int)size);
if (memp != NULL)
free(memp, M_IOCTLOPS);
if (size > 0)
free(data, M_IOCTLOPS);
return (error);
}

View File

@ -641,6 +641,10 @@ ptcioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td
{
struct tty *tp = dev->si_tty;
struct pt_desc *pt = dev->si_drv1;
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
int ival;
#endif
switch (cmd) {
@ -710,6 +714,13 @@ ptcioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td
ndflush(&tp->t_outq, tp->t_outq.c_cc);
break;
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
case _IO('t', 95):
ival = IOCPARM_IVAL(data);
data = (caddr_t)&ival;
/* FALLTHROUGH */
#endif
case TIOCSIG:
if (*(unsigned int *)data >= NSIG ||
*(unsigned int *)data == 0)

View File

@ -573,6 +573,10 @@ ptcioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td
{
struct tty *tp = dev->si_tty;
struct ptsc *pt = dev->si_drv1;
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
int ival;
#endif
switch (cmd) {
@ -627,6 +631,13 @@ ptcioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td
ndflush(&tp->t_outq, tp->t_outq.c_cc);
break;
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
case _IO('t', 95):
ival = IOCPARM_IVAL(data);
data = (caddr_t)&ival;
/* FALLTHROUGH */
#endif
case TIOCSIG:
if (*(unsigned int *)data >= NSIG ||
*(unsigned int *)data == 0)

View File

@ -10,6 +10,7 @@ SRCS+= opt_compat.h
.if !defined(KERNBUILDDIR)
opt_compat.h:
echo "#define COMPAT_43 1" > opt_compat.h
echo "#define COMPAT_FREEBSD6 1" >> opt_compat.h
.endif
.include <bsd.kmod.mk>

View File

@ -5,9 +5,12 @@
.PATH: ${.CURDIR}/../../net
KMOD= if_tap
SRCS= if_tap.c opt_inet.h vnode_if.h
SRCS= if_tap.c opt_compat.h opt_inet.h vnode_if.h
.if !defined(KERNBUILDDIR)
opt_compat.h:
echo "#define COMPAT_FREEBSD6 1" > ${.TARGET}
opt_inet.h:
echo "#define INET 1" > opt_inet.h
.endif

View File

@ -4,9 +4,12 @@
.PATH: ${.CURDIR}/../../dev/kbdmux
KMOD= kbdmux
SRCS= kbdmux.c opt_kbd.h bus_if.h device_if.h
SRCS= kbdmux.c opt_compat.h opt_kbd.h bus_if.h device_if.h
.if !defined(KERNBUILDDIR)
opt_compat.h:
echo "#define COMPAT_FREEBSD6 1" > ${.TARGET}
opt_kbd.h:
echo "#define KBD_INSTALL_CDEV 1" > ${.TARGET}
.endif

View File

@ -32,6 +32,7 @@ opt_compat.h:
echo "#define COMPAT_43 1" > ${.TARGET}
echo "#define COMPAT_FREEBSD4 1" >> ${.TARGET}
echo "#define COMPAT_FREEBSD5 1" >> ${.TARGET}
echo "#define COMPAT_FREEBSD6 1" >> ${.TARGET}
.if ${MACHINE_ARCH} == "amd64"
echo "#define COMPAT_IA32 1" >> ${.TARGET}
echo "#define COMPAT_LINUX32 1" >> ${.TARGET}

View File

@ -3,9 +3,13 @@
.PATH: ${.CURDIR}/../../dev/usb
KMOD= ukbd
SRCS= bus_if.h device_if.h opt_usb.h opt_kbd.h opt_ukbd.h usbdevs.h ukbd.c
SRCS= bus_if.h device_if.h opt_compat.h opt_usb.h opt_kbd.h opt_ukbd.h \
usbdevs.h ukbd.c
.if !defined(KERNBUILDDIR)
opt_compat.h:
echo "#define COMPAT_FREEBSD6 1" > ${.TARGET}
opt_kbd.h:
echo "#define KBD_INSTALL_CDEV 1" > ${.TARGET}
.endif

View File

@ -4,9 +4,12 @@
.PATH: ${.CURDIR}/../../dev/vkbd
KMOD= vkbd
SRCS= vkbd.c opt_kbd.h
SRCS= vkbd.c opt_compat.h opt_kbd.h
.if !defined(KERNBUILDDIR)
opt_compat.h:
echo "#define COMPAT_FREEBSD6 1" > ${.TARGET}
opt_kbd.h:
echo "#define KBD_INSTALL_CDEV 1" > ${.TARGET}
.endif

View File

@ -35,6 +35,7 @@
* $Id: if_tap.c,v 0.21 2000/07/23 21:46:02 max Exp $
*/
#include "opt_compat.h"
#include "opt_inet.h"
#include <sys/param.h>
@ -612,6 +613,10 @@ tapioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td
struct tapinfo *tapp = NULL;
int s;
int f;
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
defined(COMPAT_FREEBSD4)
int ival;
#endif
switch (cmd) {
case TAPSIFINFO:
@ -686,8 +691,15 @@ tapioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td
bcopy(&ifp->if_flags, data, sizeof(ifp->if_flags));
break;
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
defined(COMPAT_FREEBSD4)
case _IO('V', 0):
ival = IOCPARM_IVAL(data);
data = (caddr_t)&ival;
/* FALLTHROUGH */
#endif
case VMIO_SIOCSIFFLAGS: /* VMware/VMnet SIOCSIFFLAGS */
f = *(intptr_t *)data;
f = *(int *)data;
f &= 0x0fff;
f &= ~IFF_CANTCHANGE;
f |= IFF_UP;

View File

@ -57,7 +57,7 @@ struct tapinfo {
#define TAPGIFINFO _IOR('t', 92, struct tapinfo)
/* VMware ioctl's */
#define VMIO_SIOCSIFFLAGS _IO('V', 0)
#define VMIO_SIOCSIFFLAGS _IOWINT('V', 0)
#define VMIO_SIOCSKEEP _IO('V', 1)
#define VMIO_SIOCSIFBR _IO('V', 2)
#define VMIO_SIOCSLADRF _IO('V', 3)

View File

@ -28,6 +28,7 @@
* $FreeBSD$
*/
#include "opt_compat.h"
#include "opt_kbd.h"
#include <sys/param.h>
@ -704,6 +705,10 @@ pckbd_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg)
pckbd_state_t *state = kbd->kb_data;
int s;
int i;
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
int ival;
#endif
s = spltty();
switch (cmd) {
@ -711,6 +716,13 @@ pckbd_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg)
case KDGKBMODE: /* get keyboard mode */
*(int *)arg = state->ks_mode;
break;
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
case _IO('K', 7):
ival = IOCPARM_IVAL(arg);
arg = (caddr_t)&ival;
/* FALLTHROUGH */
#endif
case KDSKBMODE: /* set keyboard mode */
switch (*(int *)arg) {
case K_XLATE:
@ -736,6 +748,13 @@ pckbd_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg)
case KDGETLED: /* get keyboard LED */
*(int *)arg = KBD_LED_VAL(kbd);
break;
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
case _IO('K', 66):
ival = IOCPARM_IVAL(arg);
arg = (caddr_t)&ival;
/* FALLTHROUGH */
#endif
case KDSETLED: /* set keyboard LED */
/* NOTE: lock key state in ks_state won't be changed */
if (*(int *)arg & ~LOCK_MASK) {
@ -756,6 +775,13 @@ pckbd_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg)
case KDGKBSTATE: /* get lock key state */
*(int *)arg = state->ks_state & LOCK_MASK;
break;
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
case _IO('K', 20):
ival = IOCPARM_IVAL(arg);
arg = (caddr_t)&ival;
/* FALLTHROUGH */
#endif
case KDSKBSTATE: /* set lock key state */
if (*(int *)arg & ~LOCK_MASK) {
splx(s);

View File

@ -51,10 +51,10 @@
#define KD_TEXT1 2 /* set text mode !restore fonts */
#define KD_PIXEL 3 /* set pixel mode */
#define KDGETMODE _IOR('K', 9, int)
#define KDSETMODE _IO('K', 10 /*, int */)
#define KDSETMODE _IOWINT('K', 10)
/* set border color */
#define KDSBORDER _IO('K', 13 /*, int */)
#define KDSBORDER _IOWINT('K', 13)
/* set up raster(pixel) text mode */
struct _scr_size {
@ -255,10 +255,10 @@ typedef struct vid_info vid_info_t;
#define CONS_FINDMODE _IOWR('c', 103, video_info_t)
/* set the frame buffer window origin (equivalent to FBIO_SETWINORG) */
#define CONS_SETWINORG _IO('c', 104 /*, u_int */)
#define CONS_SETWINORG _IOWINT('c', 104)
/* use the specified keyboard */
#define CONS_SETKBD _IO('c', 110 /*, int */)
#define CONS_SETKBD _IOWINT('c', 110)
/* release the current keyboard */
#define CONS_RELKBD _IO('c', 111)
@ -320,13 +320,13 @@ typedef struct vt_mode vtmode_t;
#define VT_FALSE 0
#define VT_TRUE 1
#define VT_ACKACQ 2
#define VT_RELDISP _IO('v', 4 /*, int */)
#define VT_RELDISP _IOWINT('v', 4)
/* activate the specified vty */
#define VT_ACTIVATE _IO('v', 5 /*, int */)
#define VT_ACTIVATE _IOWINT('v', 5)
/* wait until the specified vty is activate */
#define VT_WAITACTIVE _IO('v', 6 /*, int */)
#define VT_WAITACTIVE _IOWINT('v', 6)
/* get the currently active vty */
#define VT_GETACTIVE _IOR('v', 7, int)

View File

@ -59,7 +59,7 @@ enum {
#define DIGIIO_REINIT _IO('e', 'A')
#define DIGIIO_DEBUG _IOW('e', 'B', int)
#define DIGIIO_RING _IO('e', 'C')
#define DIGIIO_RING _IOWINT('e', 'C')
#define DIGIIO_MODEL _IOR('e', 'D', enum digi_model)
#define DIGIIO_IDENT _IOW('e', 'E', char *)
#define DIGIIO_SETALTPIN _IOW('e', 'F', int)

View File

@ -48,17 +48,25 @@
#define IOC_OUT 0x40000000 /* copy out parameters */
#define IOC_IN 0x80000000 /* copy in parameters */
#define IOC_INOUT (IOC_IN|IOC_OUT)
#define IOC_DIRMASK 0xe0000000 /* mask for IN/OUT/VOID */
#define IOC_DIRMASK (IOC_VOID|IOC_OUT|IOC_IN)
#define _IOC(inout,group,num,len) \
((unsigned long)(inout | ((len & IOCPARM_MASK) << 16) | ((group) << 8) | (num)))
#define _IO(g,n) _IOC(IOC_VOID, (g), (n), 0)
#define _IOWINT(g,n) _IOC(IOC_VOID, (g), (n), sizeof(int))
#define _IOR(g,n,t) _IOC(IOC_OUT, (g), (n), sizeof(t))
#define _IOW(g,n,t) _IOC(IOC_IN, (g), (n), sizeof(t))
/* this should be _IORW, but stdio got there first */
#define _IOWR(g,n,t) _IOC(IOC_INOUT, (g), (n), sizeof(t))
#ifndef _KERNEL
#ifdef _KERNEL
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
#define IOCPARM_IVAL(x) ((int)(intptr_t)(void *)*(caddr_t *)(void *)(x))
#endif
#else
#include <sys/cdefs.h>

View File

@ -15,16 +15,16 @@
#define K_XLATE 1 /* keyboard returns ascii */
#define K_CODE 2 /* keyboard returns keycodes */
#define KDGKBMODE _IOR('K', 6, int)
#define KDSKBMODE _IO('K', 7 /*, int */)
#define KDSKBMODE _IOWINT('K', 7)
/* make tone */
#define KDMKTONE _IO('K', 8 /*, int */)
#define KDMKTONE _IOWINT('K', 8)
/* see console.h for the definitions of the following ioctls */
#ifdef notdef
#define KDGETMODE _IOR('K', 9, int)
#define KDSETMODE _IO('K', 10 /*, int */)
#define KDSBORDER _IO('K', 13 /*, int */)
#define KDSETMODE _IOWINT('K', 10)
#define KDSBORDER _IOWINT('K', 13)
#endif
/* get/set keyboard lock state */
@ -34,14 +34,14 @@
#define ALKED 8 /* AltGr locked */
#define LOCK_MASK (CLKED | NLKED | SLKED | ALKED)
#define KDGKBSTATE _IOR('K', 19, int)
#define KDSKBSTATE _IO('K', 20 /*, int */)
#define KDSKBSTATE _IOWINT('K', 20)
/* enable/disable I/O access */
#define KDENABIO _IO('K', 60)
#define KDDISABIO _IO('K', 61)
/* make sound */
#define KIOCSOUND _IO('K', 63 /*, int */)
#define KIOCSOUND _IOWINT('K', 63)
/* get keyboard model */
#define KB_OTHER 0 /* keyboard not known */
@ -55,10 +55,10 @@
#define LED_SCR 4 /* Scroll lock LED */
#define LED_MASK (LED_CAP | LED_NUM | LED_SCR)
#define KDGETLED _IOR('K', 65, int)
#define KDSETLED _IO('K', 66 /*, int */)
#define KDSETLED _IOWINT('K', 66)
/* set keyboard repeat rate (obsolete, use KDSETREPEAT below) */
#define KDSETRAD _IO('K', 67 /*, int */)
#define KDSETRAD _IOWINT('K', 67)
struct keyboard_info {
int kb_index; /* kbdio index# */

View File

@ -49,12 +49,12 @@ struct procfs_status {
unsigned long val; /* Any extra data */
};
# define PIOCBIS _IO('p', 1) /* Set event flag */
# define PIOCBIC _IO('p', 2) /* Clear event flag */
# define PIOCSFL _IO('p', 3) /* Set flags */
# define PIOCBIS _IOWINT('p', 1) /* Set event flag */
# define PIOCBIC _IOWINT('p', 2) /* Clear event flag */
# define PIOCSFL _IOWINT('p', 3) /* Set flags */
/* wait for proc to stop */
# define PIOCWAIT _IOR('p', 4, struct procfs_status)
# define PIOCCONT _IO('p', 5) /* Continue a process */
# define PIOCCONT _IOWINT('p', 5) /* Continue a process */
/* Get proc status */
# define PIOCSTATUS _IOR('p', 6, struct procfs_status)
# define PIOCGFL _IOR('p', 7, unsigned int) /* Get flags */

View File

@ -123,7 +123,7 @@ struct winsize {
#define TIOCSCTTY _IO('t', 97) /* become controlling tty */
/* 97-90 tun; some conflicts */
#define TIOCEXT _IOW('t', 96, int) /* pty: external processing */
#define TIOCSIG _IO('t', 95) /* pty: generate signal */
#define TIOCSIG _IOWINT('t', 95) /* pty: generate signal */
#define TIOCDRAIN _IO('t', 94) /* wait till output drained */
/* 92-90 tap; some conflicts */
#define TIOCMSDTRWAIT _IOW('t', 91, int) /* modem: set wait on close */