Fix netbsd32_ioctls.

This commit is contained in:
eeh 2000-08-19 14:38:18 +00:00
parent ca3e065825
commit 1e8c5f2119
3 changed files with 359 additions and 264 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32_ioctl.c,v 1.6 2000/07/09 13:39:31 mrg Exp $ */ /* $NetBSD: netbsd32_ioctl.c,v 1.7 2000/08/19 14:38:18 eeh Exp $ */
/* /*
* Copyright (c) 1998 Matthew R. Green * Copyright (c) 1998 Matthew R. Green
@ -34,6 +34,11 @@
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
#include <sys/filedesc.h>
#include <sys/ioctl.h>
#include <sys/file.h>
#include <sys/proc.h>
#include <sys/socketvar.h>
#include <sys/audioio.h> #include <sys/audioio.h>
#include <sys/disklabel.h> #include <sys/disklabel.h>
#include <sys/dkio.h> #include <sys/dkio.h>
@ -63,25 +68,25 @@
/* prototypes for the converters */ /* prototypes for the converters */
static __inline void static __inline void
netbsd32_to_fbcmap(struct netbsd32_fbcmap *, struct fbcmap *); netbsd32_to_fbcmap(struct netbsd32_fbcmap *, struct fbcmap *, u_long);
static __inline void static __inline void
netbsd32_to_fbcursor(struct netbsd32_fbcursor *, struct fbcursor *); netbsd32_to_fbcursor(struct netbsd32_fbcursor *, struct fbcursor *, u_long);
static __inline void static __inline void
netbsd32_to_opiocdesc(struct netbsd32_opiocdesc *, struct opiocdesc *); netbsd32_to_opiocdesc(struct netbsd32_opiocdesc *, struct opiocdesc *, u_long);
static __inline void static __inline void
netbsd32_to_partinfo(struct netbsd32_partinfo *, struct partinfo *); netbsd32_to_partinfo(struct netbsd32_partinfo *, struct partinfo *, u_long);
static __inline void static __inline void
netbsd32_to_format_op(struct netbsd32_format_op *, struct format_op *); netbsd32_to_format_op(struct netbsd32_format_op *, struct format_op *, u_long);
static __inline void static __inline void
netbsd32_to_ifconf(struct netbsd32_ifconf *, struct ifconf *); netbsd32_to_ifconf(struct netbsd32_ifconf *, struct ifconf *, u_long);
static __inline void static __inline void
netbsd32_to_ifmediareq(struct netbsd32_ifmediareq *, struct ifmediareq *); netbsd32_to_ifmediareq(struct netbsd32_ifmediareq *, struct ifmediareq *, u_long);
static __inline void static __inline void
netbsd32_to_ifdrv(struct netbsd32_ifdrv *, struct ifdrv *); netbsd32_to_ifdrv(struct netbsd32_ifdrv *, struct ifdrv *, u_long);
static __inline void static __inline void
netbsd32_to_sioc_vif_req(struct netbsd32_sioc_vif_req *, struct sioc_vif_req *); netbsd32_to_sioc_vif_req(struct netbsd32_sioc_vif_req *, struct sioc_vif_req *, u_long);
static __inline void static __inline void
netbsd32_to_sioc_sg_req(struct netbsd32_sioc_sg_req *, struct sioc_sg_req *); netbsd32_to_sioc_sg_req(struct netbsd32_sioc_sg_req *, struct sioc_sg_req *, u_long);
static __inline void static __inline void
netbsd32_from_fbcmap(struct fbcmap *, struct netbsd32_fbcmap *); netbsd32_from_fbcmap(struct fbcmap *, struct netbsd32_fbcmap *);
@ -90,6 +95,8 @@ netbsd32_from_fbcursor(struct fbcursor *, struct netbsd32_fbcursor *);
static __inline void static __inline void
netbsd32_from_opiocdesc(struct opiocdesc *, struct netbsd32_opiocdesc *); netbsd32_from_opiocdesc(struct opiocdesc *, struct netbsd32_opiocdesc *);
static __inline void static __inline void
netbsd32_from_partinfo(struct partinfo *, struct netbsd32_partinfo *);
static __inline void
netbsd32_from_format_op(struct format_op *, struct netbsd32_format_op *); netbsd32_from_format_op(struct format_op *, struct netbsd32_format_op *);
static __inline void static __inline void
netbsd32_from_ifconf(struct ifconf *, struct netbsd32_ifconf *); netbsd32_from_ifconf(struct ifconf *, struct netbsd32_ifconf *);
@ -105,9 +112,10 @@ netbsd32_from_sioc_sg_req(struct sioc_sg_req *, struct netbsd32_sioc_sg_req *);
/* convert to/from different structures */ /* convert to/from different structures */
static __inline void static __inline void
netbsd32_to_fbcmap(s32p, p) netbsd32_to_fbcmap(s32p, p, cmd)
struct netbsd32_fbcmap *s32p; struct netbsd32_fbcmap *s32p;
struct fbcmap *p; struct fbcmap *p;
u_long cmd;
{ {
p->index = s32p->index; p->index = s32p->index;
@ -118,25 +126,27 @@ netbsd32_to_fbcmap(s32p, p)
} }
static __inline void static __inline void
netbsd32_to_fbcursor(s32p, p) netbsd32_to_fbcursor(s32p, p, cmd)
struct netbsd32_fbcursor *s32p; struct netbsd32_fbcursor *s32p;
struct fbcursor *p; struct fbcursor *p;
u_long cmd;
{ {
p->set = s32p->set; p->set = s32p->set;
p->enable = s32p->enable; p->enable = s32p->enable;
p->pos = s32p->pos; p->pos = s32p->pos;
p->hot = s32p->hot; p->hot = s32p->hot;
netbsd32_to_fbcmap(&s32p->cmap, &p->cmap); netbsd32_to_fbcmap(&s32p->cmap, &p->cmap, cmd);
p->size = s32p->size; p->size = s32p->size;
p->image = (char *)(u_long)s32p->image; p->image = (char *)(u_long)s32p->image;
p->mask = (char *)(u_long)s32p->mask; p->mask = (char *)(u_long)s32p->mask;
} }
static __inline void static __inline void
netbsd32_to_opiocdesc(s32p, p) netbsd32_to_opiocdesc(s32p, p, cmd)
struct netbsd32_opiocdesc *s32p; struct netbsd32_opiocdesc *s32p;
struct opiocdesc *p; struct opiocdesc *p;
u_long cmd;
{ {
p->op_nodeid = s32p->op_nodeid; p->op_nodeid = s32p->op_nodeid;
@ -147,9 +157,10 @@ netbsd32_to_opiocdesc(s32p, p)
} }
static __inline void static __inline void
netbsd32_to_partinfo(s32p, p) netbsd32_to_partinfo(s32p, p, cmd)
struct netbsd32_partinfo *s32p; struct netbsd32_partinfo *s32p;
struct partinfo *p; struct partinfo *p;
u_long cmd;
{ {
p->disklab = (struct disklabel *)(u_long)s32p->disklab; p->disklab = (struct disklabel *)(u_long)s32p->disklab;
@ -157,9 +168,10 @@ netbsd32_to_partinfo(s32p, p)
} }
static __inline void static __inline void
netbsd32_to_format_op(s32p, p) netbsd32_to_format_op(s32p, p, cmd)
struct netbsd32_format_op *s32p; struct netbsd32_format_op *s32p;
struct format_op *p; struct format_op *p;
u_long cmd;
{ {
p->df_buf = (char *)(u_long)s32p->df_buf; p->df_buf = (char *)(u_long)s32p->df_buf;
@ -187,9 +199,10 @@ netbsd32_to_ifreq(s32p, p, cmd)
#endif #endif
static __inline void static __inline void
netbsd32_to_ifconf(s32p, p) netbsd32_to_ifconf(s32p, p, cmd)
struct netbsd32_ifconf *s32p; struct netbsd32_ifconf *s32p;
struct ifconf *p; struct ifconf *p;
u_long cmd;
{ {
p->ifc_len = s32p->ifc_len; p->ifc_len = s32p->ifc_len;
@ -198,9 +211,10 @@ netbsd32_to_ifconf(s32p, p)
} }
static __inline void static __inline void
netbsd32_to_ifmediareq(s32p, p) netbsd32_to_ifmediareq(s32p, p, cmd)
struct netbsd32_ifmediareq *s32p; struct netbsd32_ifmediareq *s32p;
struct ifmediareq *p; struct ifmediareq *p;
u_long cmd;
{ {
memcpy(p, s32p, sizeof *s32p); memcpy(p, s32p, sizeof *s32p);
@ -208,9 +222,10 @@ netbsd32_to_ifmediareq(s32p, p)
} }
static __inline void static __inline void
netbsd32_to_ifdrv(s32p, p) netbsd32_to_ifdrv(s32p, p, cmd)
struct netbsd32_ifdrv *s32p; struct netbsd32_ifdrv *s32p;
struct ifdrv *p; struct ifdrv *p;
u_long cmd;
{ {
memcpy(p, s32p, sizeof *s32p); memcpy(p, s32p, sizeof *s32p);
@ -218,9 +233,10 @@ netbsd32_to_ifdrv(s32p, p)
} }
static __inline void static __inline void
netbsd32_to_sioc_vif_req(s32p, p) netbsd32_to_sioc_vif_req(s32p, p, cmd)
struct netbsd32_sioc_vif_req *s32p; struct netbsd32_sioc_vif_req *s32p;
struct sioc_vif_req *p; struct sioc_vif_req *p;
u_long cmd;
{ {
p->vifi = s32p->vifi; p->vifi = s32p->vifi;
@ -231,9 +247,10 @@ netbsd32_to_sioc_vif_req(s32p, p)
} }
static __inline void static __inline void
netbsd32_to_sioc_sg_req(s32p, p) netbsd32_to_sioc_sg_req(s32p, p, cmd)
struct netbsd32_sioc_sg_req *s32p; struct netbsd32_sioc_sg_req *s32p;
struct sioc_sg_req *p; struct sioc_sg_req *p;
u_long cmd;
{ {
p->src = s32p->src; p->src = s32p->src;
@ -295,6 +312,16 @@ netbsd32_from_opiocdesc(p, s32p)
s32p->op_buf = (netbsd32_charp)(u_long)p->op_buf; s32p->op_buf = (netbsd32_charp)(u_long)p->op_buf;
} }
static __inline void
netbsd32_from_partinfo(p, s32p)
struct partinfo *p;
struct netbsd32_partinfo *s32p;
{
s32p->disklab = (netbsd32_disklabel_tp_t)(u_long)p->disklab;
s32p->part = s32p->part;
}
static __inline void static __inline void
netbsd32_from_format_op(p, s32p) netbsd32_from_format_op(p, s32p)
struct format_op *p; struct format_op *p;
@ -409,9 +436,17 @@ netbsd32_ioctl(p, v, retval)
syscallarg(netbsd32_u_long) com; syscallarg(netbsd32_u_long) com;
syscallarg(netbsd32_voidp) data; syscallarg(netbsd32_voidp) data;
} */ *uap = v; } */ *uap = v;
struct sys_ioctl_args ua; struct file *fp;
void *data = NULL; struct filedesc *fdp;
int rv; u_long com;
int error = 0;
u_int size, size32;
caddr_t data, memp = NULL;
caddr_t data32, memp32 = NULL;
int tmp;
#define STK_PARAMS 128
u_long stkbuf[STK_PARAMS/sizeof(u_long)];
u_long stkbuf32[STK_PARAMS/sizeof(u_long)];
/* /*
* we need to translate some commands (_IOW) before calling sys_ioctl, * we need to translate some commands (_IOW) before calling sys_ioctl,
@ -430,219 +465,261 @@ printf("netbsd32_ioctl(%d, %x, %x): %s group %c base %d len %d\n",
} }
#endif #endif
fdp = p->p_fd;
if ((u_int)SCARG(uap, fd) >= fdp->fd_nfiles ||
(fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL ||
(fp->f_iflags & FIF_WANTCLOSE) != 0)
return (EBADF);
FILE_USE(fp);
if ((fp->f_flag & (FREAD | FWRITE)) == 0) {
error = EBADF;
goto out;
}
switch (com = SCARG(uap, com)) {
case FIONCLEX:
fdp->fd_ofileflags[SCARG(uap, fd)] &= ~UF_EXCLOSE;
goto out;
case FIOCLEX:
fdp->fd_ofileflags[SCARG(uap, fd)] |= UF_EXCLOSE;
goto out;
}
/*
* Interpret high order word to find amount of data to be
* copied to/from the user's address space.
*/
size32 = IOCPARM_LEN(com);
if (size32 > IOCPARM_MAX) {
error = ENOTTY;
goto out;
}
memp = NULL;
if (size32 > sizeof(stkbuf)) {
memp32 = (caddr_t)malloc((u_long)size32, M_IOCTLOPS, M_WAITOK);
data32 = memp32;
} else
data32 = (caddr_t)stkbuf32;
if (com&IOC_IN) {
if (size32) {
error = copyin((caddr_t)(u_long)SCARG(uap, data),
data32, size32);
if (error) {
if (memp32)
free(memp32, M_IOCTLOPS);
goto out;
}
} else
*(caddr_t *)data32 = (caddr_t)(u_long)SCARG(uap, data);
} else if ((com&IOC_OUT) && size32)
/*
* Zero the buffer so the user always
* gets back something deterministic.
*/
memset(data32, 0, size32);
else if (com&IOC_VOID)
*(caddr_t *)data = (caddr_t)(u_long)SCARG(uap, data);
/* we define some handy macros here... */ /* we define some handy macros here... */
#define IOCTL_STRUCT_CONV_TO(type) \ #define IOCTL_STRUCT_CONV_TO(cmd, type) \
data = malloc(sizeof(struct type), M_TEMP, M_WAITOK); \ com = cmd; \
__CONCAT(netbsd32_to_, type)((struct __CONCAT(netbsd32_, type) *) \ size = IOCPARM_LEN(com); \
(u_long)SCARG(uap, data), data) if (size > sizeof(stkbuf)) \
data = memp = malloc(size, M_IOCTLOPS, M_WAITOK); \
#define IOCTL_STRUCT_CONV_CMD_TO(type, cmd) \ else \
data = malloc(sizeof(struct type), M_TEMP, M_WAITOK); \ data = (caddr_t)stkbuf; \
__CONCAT(netbsd32_to_, type)((struct __CONCAT(netbsd32_, type) *) \ __CONCAT(netbsd32_to_, type)((struct __CONCAT(netbsd32_, type) *) \
(u_long)SCARG(uap, data), data, cmd) data32, (struct type *)data, com); \
error = (*fp->f_ops->fo_ioctl)(fp, com, data, p); \
#define IOCTL_STRUCT_CONV_FROM(type) \ __CONCAT(netbsd32_from_, type)((struct type *)data, \
__CONCAT(netbsd32_from_, type)(data, \ (struct __CONCAT(netbsd32_, type) *)data32); \
(struct __CONCAT(netbsd32_, type) *) (u_long)SCARG(uap, data)) break
#define IOCTL_STRUCT_CONV_CMD_FROM(type, cmd) \
__CONCAT(netbsd32_from_, type)(data, \
(struct __CONCAT(netbsd32_, type) *) (u_long)SCARG(uap, data), cmd)
/* /*
* convert various structures, pointers, and other objects that * convert various structures, pointers, and other objects that
* change size from 32 bit -> 64 bit, for all ioctl commands. * change size from 32 bit -> 64 bit, for all ioctl commands.
*/ */
switch (SCARG(uap, com)) { switch (SCARG(uap, com)) {
case FBIOPUTCMAP: case FIONBIO:
case FBIOGETCMAP: if ((tmp = *(int *)data) != 0)
IOCTL_STRUCT_CONV_TO(fbcmap); fp->f_flag |= FNONBLOCK;
else
fp->f_flag &= ~FNONBLOCK;
error = (*fp->f_ops->fo_ioctl)(fp, FIONBIO, (caddr_t)&tmp, p);
break; break;
case FBIOSCURSOR: case FIOASYNC:
case FBIOGCURSOR: if ((tmp = *(int *)data) != 0)
IOCTL_STRUCT_CONV_TO(fbcursor); fp->f_flag |= FASYNC;
else
fp->f_flag &= ~FASYNC;
error = (*fp->f_ops->fo_ioctl)(fp, FIOASYNC, (caddr_t)&tmp, p);
break; break;
case OPIOCGET: case FIOSETOWN:
case OPIOCSET: tmp = *(int *)data;
case OPIOCNEXTPROP: if (fp->f_type == DTYPE_SOCKET) {
IOCTL_STRUCT_CONV_TO(opiocdesc); ((struct socket *)fp->f_data)->so_pgid = tmp;
error = 0;
break;
}
if (tmp <= 0) {
tmp = -tmp;
} else {
struct proc *p1 = pfind(tmp);
if (p1 == 0) {
error = ESRCH;
break;
}
tmp = p1->p_pgrp->pg_id;
}
error = (*fp->f_ops->fo_ioctl)
(fp, TIOCSPGRP, (caddr_t)&tmp, p);
break; break;
case DIOCGPART: case FIOGETOWN:
IOCTL_STRUCT_CONV_TO(partinfo); if (fp->f_type == DTYPE_SOCKET) {
error = 0;
*(int *)data = ((struct socket *)fp->f_data)->so_pgid;
break;
}
error = (*fp->f_ops->fo_ioctl)(fp, TIOCGPGRP, data, p);
*(int *)data = -*(int *)data;
break; break;
case DIOCRFORMAT: /*
case DIOCWFORMAT: * Here are calls that need explicit conversion.
IOCTL_STRUCT_CONV_TO(format_op); */
break; case FBIOPUTCMAP32:
IOCTL_STRUCT_CONV_TO(FBIOPUTCMAP, fbcmap);
case FBIOGETCMAP32:
IOCTL_STRUCT_CONV_TO(FBIOGETCMAP, fbcmap);
case FBIOSCURSOR32:
IOCTL_STRUCT_CONV_TO(FBIOSCURSOR, fbcursor);
case FBIOGCURSOR32:
IOCTL_STRUCT_CONV_TO(FBIOGCURSOR, fbcursor);
case OPIOCGET32:
IOCTL_STRUCT_CONV_TO(OPIOCGET, opiocdesc);
case OPIOCSET32:
IOCTL_STRUCT_CONV_TO(OPIOCSET, opiocdesc);
case OPIOCNEXTPROP32:
IOCTL_STRUCT_CONV_TO(OPIOCNEXTPROP, opiocdesc);
case DIOCGPART32:
IOCTL_STRUCT_CONV_TO(DIOCGPART, partinfo);
case DIOCRFORMAT32:
IOCTL_STRUCT_CONV_TO(DIOCRFORMAT, format_op);
case DIOCWFORMAT32:
IOCTL_STRUCT_CONV_TO(DIOCWFORMAT, format_op);
/* /*
* only a few ifreq syscalls need conversion and those are * only a few ifreq syscalls need conversion and those are
* all driver specific... XXX * all driver specific... XXX
*/ */
#if 0 #if 0
case SIOCGADDRROM: case SIOCGADDRROM3232:
case SIOCGCHIPID: IOCTL_STRUCT_CONV_TO(SIOCGADDRROM32, ifreq);
case SIOCSIFADDR: case SIOCGCHIPID32:
case OSIOCGIFADDR: IOCTL_STRUCT_CONV_TO(SIOCGCHIPID, ifreq);
case SIOCGIFADDR: case SIOCSIFADDR32:
case SIOCSIFDSTADDR: IOCTL_STRUCT_CONV_TO(SIOCSIFADDR, ifreq);
case OSIOCGIFDSTADDR: case OSIOCGIFADDR32:
case SIOCGIFDSTADDR: IOCTL_STRUCT_CONV_TO(OSIOCGIFADDR, ifreq);
case SIOCSIFFLAGS: case SIOCGIFADDR32:
case SIOCGIFFLAGS: IOCTL_STRUCT_CONV_TO(SIOCGIFADDR, ifreq);
case OSIOCGIFBRDADDR: case SIOCSIFDSTADDR32:
case SIOCGIFBRDADDR: IOCTL_STRUCT_CONV_TO(SIOCSIFDSTADDR, ifreq);
case SIOCSIFBRDADDR: case OSIOCGIFDSTADDR32:
case OSIOCGIFNETMASK: IOCTL_STRUCT_CONV_TO(OSIOCGIFDSTADDR, ifreq);
case SIOCGIFNETMASK: case SIOCGIFDSTADDR32:
case SIOCSIFNETMASK: IOCTL_STRUCT_CONV_TO(SIOCGIFDSTADDR, ifreq);
case SIOCGIFMETRIC: case SIOCSIFFLAGS32:
case SIOCSIFMETRIC: IOCTL_STRUCT_CONV_TO(SIOCSIFFLAGS, ifreq);
case SIOCDIFADDR: case SIOCGIFFLAGS32:
case SIOCADDMULTI: IOCTL_STRUCT_CONV_TO(SIOCGIFFLAGS, ifreq);
case SIOCDELMULTI: case OSIOCGIFBRDADDR32:
case SIOCSIFMEDIA: IOCTL_STRUCT_CONV_TO(OSIOCGIFBRDADDR, ifreq);
case SIOCSIFMTU: case SIOCGIFBRDADDR32:
case SIOCGIFMTU: IOCTL_STRUCT_CONV_TO(SIOCGIFBRDADDR, ifreq);
case SIOCSIFASYNCMAP: case SIOCSIFBRDADDR32:
case SIOCGIFASYNCMAP: IOCTL_STRUCT_CONV_TO(SIOCSIFBRDADDR, ifreq);
/* case BIOCGETIF: READ ONLY */ case OSIOCGIFNETMASK32:
case BIOCSETIF: IOCTL_STRUCT_CONV_TO(OSIOCGIFNETMASK, ifreq);
case SIOCPHASE1: case SIOCGIFNETMASK32:
case SIOCPHASE2: IOCTL_STRUCT_CONV_TO(SIOCGIFNETMASK, ifreq);
IOCTL_STRUCT_CONV_CMD_TO(ifreq, SCARG(uap, cmd)); case SIOCSIFNETMASK32:
break; IOCTL_STRUCT_CONV_TO(SIOCSIFNETMASK, ifreq);
case SIOCGIFMETRIC32:
IOCTL_STRUCT_CONV_TO(SIOCGIFMETRIC, ifreq);
case SIOCSIFMETRIC32:
IOCTL_STRUCT_CONV_TO(SIOCSIFMETRIC, ifreq);
case SIOCDIFADDR32:
IOCTL_STRUCT_CONV_TO(SIOCDIFADDR, ifreq);
case SIOCADDMULTI32:
IOCTL_STRUCT_CONV_TO(SIOCADDMULTI, ifreq);
case SIOCDELMULTI32:
IOCTL_STRUCT_CONV_TO(SIOCDELMULTI, ifreq);
case SIOCSIFMEDIA32:
IOCTL_STRUCT_CONV_TO(SIOCSIFMEDIA, ifreq);
case SIOCSIFMTU32:
IOCTL_STRUCT_CONV_TO(SIOCSIFMTU, ifreq);
case SIOCGIFMTU32:
IOCTL_STRUCT_CONV_TO(SIOCGIFMTU, ifreq);
case SIOCSIFASYNCMAP32:
IOCTL_STRUCT_CONV_TO(SIOCSIFASYNCMAP, ifreq);
case SIOCGIFASYNCMAP32:
IOCTL_STRUCT_CONV_TO(SIOCGIFASYNCMAP, ifreq);
/* IOCTL_STRUCT_CONV_TO(BIOCGETIF, ifreq); READ ONLY */
case BIOCSETIF32:
IOCTL_STRUCT_CONV_TO(BIOCSETIF, ifreq);
case SIOCPHASE132:
IOCTL_STRUCT_CONV_TO(SIOCPHASE1, ifreq);
case SIOCPHASE232:
IOCTL_STRUCT_CONV_TO(SIOCPHASE2, ifreq);
#endif #endif
case OSIOCGIFCONF: case OSIOCGIFCONF32:
case SIOCGIFCONF: IOCTL_STRUCT_CONV_TO(OSIOCGIFCONF, ifconf);
IOCTL_STRUCT_CONV_TO(ifconf); case SIOCGIFCONF32:
break; IOCTL_STRUCT_CONV_TO(SIOCGIFCONF, ifconf);
case SIOCGIFMEDIA: case SIOCGIFMEDIA32:
IOCTL_STRUCT_CONV_TO(ifmediareq); IOCTL_STRUCT_CONV_TO(SIOCGIFMEDIA, ifmediareq);
break;
case SIOCSDRVSPEC: case SIOCSDRVSPEC32:
IOCTL_STRUCT_CONV_TO(ifdrv); IOCTL_STRUCT_CONV_TO(SIOCSDRVSPEC, ifdrv);
break;
case SIOCGETVIFCNT: case SIOCGETVIFCNT32:
IOCTL_STRUCT_CONV_TO(sioc_vif_req); IOCTL_STRUCT_CONV_TO(SIOCGETVIFCNT, sioc_vif_req);
break;
case SIOCGETSGCNT: case SIOCGETSGCNT32:
IOCTL_STRUCT_CONV_TO(sioc_sg_req); IOCTL_STRUCT_CONV_TO(SIOCGETSGCNT, sioc_sg_req);
break;
default:
error = (*fp->f_ops->fo_ioctl)(fp, com, data32, p);
break;
} }
/* /*
* if we malloced a new data segment, plug it into the * Copy any data to user, size was
* syscall args, otherwise copy incoming one as a void * already set and checked above.
* pointer. also copy the rest of the syscall args...
*/ */
if (data) if (error == 0 && (com&IOC_OUT) && size32)
SCARG(&ua, data) = data; error = copyout(data32, (caddr_t)(u_long)SCARG(uap, data), size32);
else
NETBSD32TOP_UAP(data, void);
NETBSD32TO64_UAP(fd);
NETBSD32TOX_UAP(com, u_long);
/* call the real ioctl */
rv = sys_ioctl(p, &ua, retval);
/*
* convert _back_ to 32 bit the results of the command.
*/
switch (SCARG(uap, com)) {
case FBIOGETCMAP:
IOCTL_STRUCT_CONV_FROM(fbcmap);
break;
case FBIOGCURSOR:
IOCTL_STRUCT_CONV_FROM(fbcursor);
break;
case OPIOCGET:
case OPIOCNEXTPROP:
IOCTL_STRUCT_CONV_FROM(opiocdesc);
break;
case DIOCRFORMAT:
case DIOCWFORMAT:
IOCTL_STRUCT_CONV_FROM(format_op);
break;
/*
* only a few ifreq syscalls need conversion and those are
* all driver specific... XXX
*/
#if 0
case SIOCGADDRROM:
case SIOCGCHIPID:
case SIOCSIFADDR:
case OSIOCGIFADDR:
case SIOCGIFADDR:
case SIOCSIFDSTADDR:
case OSIOCGIFDSTADDR:
case SIOCGIFDSTADDR:
case SIOCSIFFLAGS:
case SIOCGIFFLAGS:
case OSIOCGIFBRDADDR:
case SIOCGIFBRDADDR:
case SIOCSIFBRDADDR:
case OSIOCGIFNETMASK:
case SIOCGIFNETMASK:
case SIOCSIFNETMASK:
case SIOCGIFMETRIC:
case SIOCSIFMETRIC:
case SIOCDIFADDR:
case SIOCADDMULTI:
case SIOCDELMULTI:
case SIOCSIFMEDIA:
case SIOCSIFMTU:
case SIOCGIFMTU:
case SIOCSIFASYNCMAP:
case SIOCGIFASYNCMAP:
/* case BIOCGETIF: READ ONLY */
case BIOCSETIF:
case SIOCPHASE1:
case SIOCPHASE2:
IOCTL_STRUCT_CONV_CMD_FROM(ifreq, SCARG(uap, cmd));
break;
#endif
case OSIOCGIFCONF:
case SIOCGIFCONF:
IOCTL_STRUCT_CONV_FROM(ifconf);
break;
case SIOCGIFMEDIA:
IOCTL_STRUCT_CONV_FROM(ifmediareq);
break;
case SIOCSDRVSPEC:
IOCTL_STRUCT_CONV_FROM(ifdrv);
break;
case SIOCGETVIFCNT:
IOCTL_STRUCT_CONV_FROM(sioc_vif_req);
break;
case SIOCGETSGCNT:
IOCTL_STRUCT_CONV_FROM(sioc_sg_req);
break;
}
/* if we malloced data, free it here */ /* if we malloced data, free it here */
if (data) if (memp32)
free(data, M_TEMP); free(memp32, M_IOCTLOPS);
if (memp)
free(memp, M_IOCTLOPS);
/* done! */ out:
return (rv); FILE_UNUSE(fp, p);
return (error);
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32_ioctl.h,v 1.3 1999/03/25 16:22:49 mrg Exp $ */ /* $NetBSD: netbsd32_ioctl.h,v 1.4 2000/08/19 14:38:18 eeh Exp $ */
/* /*
* Copyright (c) 1998 Matthew R. Green * Copyright (c) 1998 Matthew R. Green
@ -41,9 +41,9 @@ struct netbsd32_fbcmap {
netbsd32_u_charp green; /* green color map elements */ netbsd32_u_charp green; /* green color map elements */
netbsd32_u_charp blue; /* blue color map elements */ netbsd32_u_charp blue; /* blue color map elements */
}; };
#if 0 #if 1
#define FBIOPUTCMAP _IOW('F', 3, struct fbcmap) #define FBIOPUTCMAP32 _IOW('F', 3, struct netbsd32_fbcmap)
#define FBIOGETCMAP _IOW('F', 4, struct fbcmap) #define FBIOGETCMAP32 _IOW('F', 4, struct netbsd32_fbcmap)
#endif #endif
struct netbsd32_fbcursor { struct netbsd32_fbcursor {
@ -56,9 +56,9 @@ struct netbsd32_fbcursor {
netbsd32_charp image; /* cursor's image bits */ netbsd32_charp image; /* cursor's image bits */
netbsd32_charp mask; /* cursor's mask bits */ netbsd32_charp mask; /* cursor's mask bits */
}; };
#if 0 #if 1
#define FBIOSCURSOR _IOW('F', 24, struct fbcursor) #define FBIOSCURSOR32 _IOW('F', 24, struct netbsd32_fbcursor)
#define FBIOGCURSOR _IOWR('F', 25, struct fbcursor) #define FBIOGCURSOR32 _IOWR('F', 25, struct netbsd32_fbcursor)
#endif #endif
/* from arch/sparc/include/openpromio.h */ /* from arch/sparc/include/openpromio.h */
@ -69,10 +69,10 @@ struct netbsd32_opiocdesc {
int op_buflen; /* length of op_buf (value-result) */ int op_buflen; /* length of op_buf (value-result) */
netbsd32_charp op_buf; /* pointer to field value */ netbsd32_charp op_buf; /* pointer to field value */
}; };
#if 0 #if 1
#define OPIOCGET _IOWR('O', 1, struct opiocdesc) /* get openprom field */ #define OPIOCGET32 _IOWR('O', 1, struct netbsd32_opiocdesc) /* get openprom field */
#define OPIOCSET _IOW('O', 2, struct opiocdesc) /* set openprom field */ #define OPIOCSET32 _IOW('O', 2, struct netbsd32_opiocdesc) /* set openprom field */
#define OPIOCNEXTPROP _IOWR('O', 3, struct opiocdesc) /* get next property */ #define OPIOCNEXTPROP32 _IOWR('O', 3, struct netbsd32_opiocdesc) /* get next property */
#endif #endif
/* from <sys/audioio.h> */ /* from <sys/audioio.h> */
@ -87,8 +87,8 @@ struct netbsd32_partinfo {
netbsd32_disklabel_tp_t disklab; netbsd32_disklabel_tp_t disklab;
netbsd32_partition_tp_t part; netbsd32_partition_tp_t part;
}; };
#if 0 #if 1
#define DIOCGPART _IOW('d', 104, struct partinfo) /* get partition */ #define DIOCGPART32 _IOW('d', 104, struct netbsd32_partinfo) /* get partition */
#endif #endif
struct netbsd32_format_op { struct netbsd32_format_op {
@ -97,9 +97,9 @@ struct netbsd32_format_op {
daddr_t df_startblk; daddr_t df_startblk;
int df_reg[8]; /* result */ int df_reg[8]; /* result */
}; };
#if 0 #if 1
#define DIOCRFORMAT _IOWR('d', 105, struct format_op) #define DIOCRFORMAT32 _IOWR('d', 105, struct netbsd32_format_op)
#define DIOCWFORMAT _IOWR('d', 106, struct format_op) #define DIOCWFORMAT32 _IOWR('d', 106, struct netbsd32_format_op)
#endif #endif
/* can wait! */ /* can wait! */
@ -206,41 +206,41 @@ struct netbsd32_ifreq {
#define ifr_media ifr_ifru.ifru_metric /* media options (overload) */ #define ifr_media ifr_ifru.ifru_metric /* media options (overload) */
#define ifr_data ifr_ifru.ifru_data /* for use by interface */ #define ifr_data ifr_ifru.ifru_data /* for use by interface */
}; };
#if 0 #if 1
/* from <dev/pci/if_devar.h> */ /* from <dev/pci/if_devar.h> */
#define SIOCGADDRROM _IOW('i', 240, struct ifreq) /* get 128 bytes of ROM */ #define SIOCGADDRROM32 _IOW('i', 240, struct netbsd32_ifreq) /* get 128 bytes of ROM */
#define SIOCGCHIPID _IOWR('i', 241, struct ifreq) /* get chipid */ #define SIOCGCHIPID32 _IOWR('i', 241, struct netbsd32_ifreq) /* get chipid */
/* from <sys/sockio.h> */ /* from <sys/sockio.h> */
#define SIOCSIFADDR _IOW('i', 12, struct ifreq) /* set ifnet address */ #define SIOCSIFADDR32 _IOW('i', 12, struct netbsd32_ifreq) /* set ifnet address */
#define OSIOCGIFADDR _IOWR('i', 13, struct ifreq) /* get ifnet address */ #define OSIOCGIFADDR32 _IOWR('i', 13, struct netbsd32_ifreq) /* get ifnet address */
#define SIOCGIFADDR _IOWR('i', 33, struct ifreq) /* get ifnet address */ #define SIOCGIFADDR32 _IOWR('i', 33, struct netbsd32_ifreq) /* get ifnet address */
#define SIOCSIFDSTADDR _IOW('i', 14, struct ifreq) /* set p-p address */ #define SIOCSIFDSTADDR32 _IOW('i', 14, struct netbsd32_ifreq) /* set p-p address */
#define OSIOCGIFDSTADDR _IOWR('i', 15, struct ifreq) /* get p-p address */ #define OSIOCGIFDSTADDR32 _IOWR('i', 15, struct netbsd32_ifreq) /* get p-p address */
#define SIOCGIFDSTADDR _IOWR('i', 34, struct ifreq) /* get p-p address */ #define SIOCGIFDSTADDR32 _IOWR('i', 34, struct netbsd32_ifreq) /* get p-p address */
#define SIOCSIFFLAGS _IOW('i', 16, struct ifreq) /* set ifnet flags */ #define SIOCSIFFLAGS32 _IOW('i', 16, struct netbsd32_ifreq) /* set ifnet flags */
#define SIOCGIFFLAGS _IOWR('i', 17, struct ifreq) /* get ifnet flags */ #define SIOCGIFFLAGS32 _IOWR('i', 17, struct netbsd32_ifreq) /* get ifnet flags */
#define OSIOCGIFBRDADDR _IOWR('i', 18, struct ifreq) /* get broadcast addr */ #define OSIOCGIFBRDADDR32 _IOWR('i', 18, struct netbsd32_ifreq) /* get broadcast addr */
#define SIOCGIFBRDADDR _IOWR('i', 35, struct ifreq) /* get broadcast addr */ #define SIOCGIFBRDADDR32 _IOWR('i', 35, struct netbsd32_ifreq) /* get broadcast addr */
#define SIOCSIFBRDADDR _IOW('i', 19, struct ifreq) /* set broadcast addr */ #define SIOCSIFBRDADDR32 _IOW('i', 19, struct netbsd32_ifreq) /* set broadcast addr */
#define OSIOCGIFNETMASK _IOWR('i', 21, struct ifreq) /* get net addr mask */ #define OSIOCGIFNETMASK32 _IOWR('i', 21, struct netbsd32_ifreq) /* get net addr mask */
#define SIOCGIFNETMASK _IOWR('i', 37, struct ifreq) /* get net addr mask */ #define SIOCGIFNETMASK32 _IOWR('i', 37, struct netbsd32_ifreq) /* get net addr mask */
#define SIOCSIFNETMASK _IOW('i', 22, struct ifreq) /* set net addr mask */ #define SIOCSIFNETMASK32 _IOW('i', 22, struct netbsd32_ifreq) /* set net addr mask */
#define SIOCGIFMETRIC _IOWR('i', 23, struct ifreq) /* get IF metric */ #define SIOCGIFMETRIC32 _IOWR('i', 23, struct netbsd32_ifreq) /* get IF metric */
#define SIOCSIFMETRIC _IOW('i', 24, struct ifreq) /* set IF metric */ #define SIOCSIFMETRIC32 _IOW('i', 24, struct netbsd32_ifreq) /* set IF metric */
#define SIOCDIFADDR _IOW('i', 25, struct ifreq) /* delete IF addr */ #define SIOCDIFADDR32 _IOW('i', 25, struct netbsd32_ifreq) /* delete IF addr */
#define SIOCADDMULTI _IOW('i', 49, struct ifreq) /* add m'cast addr */ #define SIOCADDMULTI32 _IOW('i', 49, struct netbsd32_ifreq) /* add m'cast addr */
#define SIOCDELMULTI _IOW('i', 50, struct ifreq) /* del m'cast addr */ #define SIOCDELMULTI32 _IOW('i', 50, struct netbsd32_ifreq) /* del m'cast addr */
#define SIOCSIFMEDIA _IOWR('i', 53, struct ifreq) /* set net media */ #define SIOCSIFMEDIA32 _IOWR('i', 53, struct netbsd32_ifreq) /* set net media */
#define SIOCSIFMTU _IOW('i', 127, struct ifreq) /* set ifnet mtu */ #define SIOCSIFMTU32 _IOW('i', 127, struct netbsd32_ifreq) /* set ifnet mtu */
#define SIOCGIFMTU _IOWR('i', 126, struct ifreq) /* get ifnet mtu */ #define SIOCGIFMTU32 _IOWR('i', 126, struct netbsd32_ifreq) /* get ifnet mtu */
#define SIOCSIFASYNCMAP _IOW('i', 125, struct ifreq) /* set ppp asyncmap */ #define SIOCSIFASYNCMAP32 _IOW('i', 125, struct netbsd32_ifreq) /* set ppp asyncmap */
#define SIOCGIFASYNCMAP _IOWR('i', 124, struct ifreq) /* get ppp asyncmap */ #define SIOCGIFASYNCMAP32 _IOWR('i', 124, struct netbsd32_ifreq) /* get ppp asyncmap */
/* from <net/bpf.h> */ /* from <net/bpf.h> */
#define BIOCGETIF _IOR('B',107, struct ifreq) #define BIOCGETIF32 _IOR('B',107, struct netbsd32_ifreq)
#define BIOCSETIF _IOW('B',108, struct ifreq) #define BIOCSETIF32 _IOW('B',108, struct netbsd32_ifreq)
/* from <netatalk/phase2.h> */ /* from <netatalk/phase2.h> */
#define SIOCPHASE1 _IOW('i', 100, struct ifreq) /* AppleTalk phase 1 */ #define SIOCPHASE1_32 _IOW('i', 100, struct netbsd32_ifreq) /* AppleTalk phase 1 */
#define SIOCPHASE2 _IOW('i', 101, struct ifreq) /* AppleTalk phase 2 */ #define SIOCPHASE2_32 _IOW('i', 101, struct netbsd32_ifreq) /* AppleTalk phase 2 */
#endif #endif
/* from <net/if.h> */ /* from <net/if.h> */
@ -253,10 +253,10 @@ struct netbsd32_ifconf {
#define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */ #define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */
#define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */ #define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */
}; };
#if 0 #if 1
/* from <sys/sockio.h> */ /* from <sys/sockio.h> */
#define OSIOCGIFCONF _IOWR('i', 20, struct ifconf) /* get ifnet list */ #define OSIOCGIFCONF32 _IOWR('i', 20, struct netbsd32_ifconf) /* get ifnet list */
#define SIOCGIFCONF _IOWR('i', 36, struct ifconf) /* get ifnet list */ #define SIOCGIFCONF32 _IOWR('i', 36, struct netbsd32_ifconf) /* get ifnet list */
#endif #endif
/* from <net/if.h> */ /* from <net/if.h> */
@ -270,9 +270,9 @@ struct netbsd32_ifmediareq {
array */ array */
netbsd32_intp ifm_ulist; /* media words */ netbsd32_intp ifm_ulist; /* media words */
}; };
#if 0 #if 1
/* from <sys/sockio.h> */ /* from <sys/sockio.h> */
#define SIOCGIFMEDIA _IOWR('i', 54, struct ifmediareq) /* get net media */ #define SIOCGIFMEDIA32 _IOWR('i', 54, struct netbsd32_ifmediareq) /* get net media */
#endif #endif
/* from <net/if.h> */ /* from <net/if.h> */
@ -282,9 +282,9 @@ struct netbsd32_ifdrv {
size_t ifd_len; size_t ifd_len;
void *ifd_data; void *ifd_data;
}; };
#if 0 #if 1
/* from <sys/sockio.h> */ /* from <sys/sockio.h> */
#define SIOCSDRVSPEC _IOW('i', 123, struct ifdrv) /* set driver-specific */ #define SIOCSDRVSPEC32 _IOW('i', 123, struct netbsd32_ifdrv) /* set driver-specific */
#endif #endif
/* from <netinet/ip_mroute.h> */ /* from <netinet/ip_mroute.h> */
@ -295,9 +295,9 @@ struct netbsd32_sioc_vif_req {
netbsd32_u_long ibytes; /* input byte count on vif */ netbsd32_u_long ibytes; /* input byte count on vif */
netbsd32_u_long obytes; /* output byte count on vif */ netbsd32_u_long obytes; /* output byte count on vif */
}; };
#if 0 #if 1
/* from <sys/sockio.h> */ /* from <sys/sockio.h> */
#define SIOCGETVIFCNT _IOWR('u', 51, struct sioc_vif_req)/* vif pkt cnt */ #define SIOCGETVIFCNT32 _IOWR('u', 51, struct netbsd32_sioc_vif_req)/* vif pkt cnt */
#endif #endif
struct netbsd32_sioc_sg_req { struct netbsd32_sioc_sg_req {
@ -307,7 +307,7 @@ struct netbsd32_sioc_sg_req {
u_long bytecnt; u_long bytecnt;
u_long wrong_if; u_long wrong_if;
}; };
#if 0 #if 1
/* from <sys/sockio.h> */ /* from <sys/sockio.h> */
#define SIOCGETSGCNT _IOWR('u', 52, struct sioc_sg_req) /* sg pkt cnt */ #define SIOCGETSGCNT32 _IOWR('u', 52, struct netbsd32_sioc_sg_req) /* sg pkt cnt */
#endif #endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32_netbsd.c,v 1.35 2000/08/03 20:41:14 thorpej Exp $ */ /* $NetBSD: netbsd32_netbsd.c,v 1.36 2000/08/19 14:38:19 eeh Exp $ */
/* /*
* Copyright (c) 1998 Matthew R. Green * Copyright (c) 1998 Matthew R. Green
@ -3777,6 +3777,24 @@ netbsd32_ntp_adjtime(p, v, retval)
} }
return error; return error;
} }
#else
int
netbsd32_ntp_gettime(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
return(ENOSYS);
}
int
netbsd32_ntp_adjtime(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
return (ENOSYS);
}
#endif #endif
int int