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
@ -34,6 +34,11 @@
#include <sys/param.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/disklabel.h>
#include <sys/dkio.h>
@ -63,25 +68,25 @@
/* prototypes for the converters */
static __inline void
netbsd32_to_fbcmap(struct netbsd32_fbcmap *, struct fbcmap *);
netbsd32_to_fbcmap(struct netbsd32_fbcmap *, struct fbcmap *, u_long);
static __inline void
netbsd32_to_fbcursor(struct netbsd32_fbcursor *, struct fbcursor *);
netbsd32_to_fbcursor(struct netbsd32_fbcursor *, struct fbcursor *, u_long);
static __inline void
netbsd32_to_opiocdesc(struct netbsd32_opiocdesc *, struct opiocdesc *);
netbsd32_to_opiocdesc(struct netbsd32_opiocdesc *, struct opiocdesc *, u_long);
static __inline void
netbsd32_to_partinfo(struct netbsd32_partinfo *, struct partinfo *);
netbsd32_to_partinfo(struct netbsd32_partinfo *, struct partinfo *, u_long);
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
netbsd32_to_ifconf(struct netbsd32_ifconf *, struct ifconf *);
netbsd32_to_ifconf(struct netbsd32_ifconf *, struct ifconf *, u_long);
static __inline void
netbsd32_to_ifmediareq(struct netbsd32_ifmediareq *, struct ifmediareq *);
netbsd32_to_ifmediareq(struct netbsd32_ifmediareq *, struct ifmediareq *, u_long);
static __inline void
netbsd32_to_ifdrv(struct netbsd32_ifdrv *, struct ifdrv *);
netbsd32_to_ifdrv(struct netbsd32_ifdrv *, struct ifdrv *, u_long);
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
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
netbsd32_from_fbcmap(struct fbcmap *, struct netbsd32_fbcmap *);
@ -90,6 +95,8 @@ netbsd32_from_fbcursor(struct fbcursor *, struct netbsd32_fbcursor *);
static __inline void
netbsd32_from_opiocdesc(struct opiocdesc *, struct netbsd32_opiocdesc *);
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 *);
static __inline void
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 */
static __inline void
netbsd32_to_fbcmap(s32p, p)
netbsd32_to_fbcmap(s32p, p, cmd)
struct netbsd32_fbcmap *s32p;
struct fbcmap *p;
u_long cmd;
{
p->index = s32p->index;
@ -118,25 +126,27 @@ netbsd32_to_fbcmap(s32p, p)
}
static __inline void
netbsd32_to_fbcursor(s32p, p)
netbsd32_to_fbcursor(s32p, p, cmd)
struct netbsd32_fbcursor *s32p;
struct fbcursor *p;
u_long cmd;
{
p->set = s32p->set;
p->enable = s32p->enable;
p->pos = s32p->pos;
p->hot = s32p->hot;
netbsd32_to_fbcmap(&s32p->cmap, &p->cmap);
netbsd32_to_fbcmap(&s32p->cmap, &p->cmap, cmd);
p->size = s32p->size;
p->image = (char *)(u_long)s32p->image;
p->mask = (char *)(u_long)s32p->mask;
}
static __inline void
netbsd32_to_opiocdesc(s32p, p)
netbsd32_to_opiocdesc(s32p, p, cmd)
struct netbsd32_opiocdesc *s32p;
struct opiocdesc *p;
u_long cmd;
{
p->op_nodeid = s32p->op_nodeid;
@ -147,9 +157,10 @@ netbsd32_to_opiocdesc(s32p, p)
}
static __inline void
netbsd32_to_partinfo(s32p, p)
netbsd32_to_partinfo(s32p, p, cmd)
struct netbsd32_partinfo *s32p;
struct partinfo *p;
u_long cmd;
{
p->disklab = (struct disklabel *)(u_long)s32p->disklab;
@ -157,9 +168,10 @@ netbsd32_to_partinfo(s32p, p)
}
static __inline void
netbsd32_to_format_op(s32p, p)
netbsd32_to_format_op(s32p, p, cmd)
struct netbsd32_format_op *s32p;
struct format_op *p;
u_long cmd;
{
p->df_buf = (char *)(u_long)s32p->df_buf;
@ -187,9 +199,10 @@ netbsd32_to_ifreq(s32p, p, cmd)
#endif
static __inline void
netbsd32_to_ifconf(s32p, p)
netbsd32_to_ifconf(s32p, p, cmd)
struct netbsd32_ifconf *s32p;
struct ifconf *p;
u_long cmd;
{
p->ifc_len = s32p->ifc_len;
@ -198,9 +211,10 @@ netbsd32_to_ifconf(s32p, p)
}
static __inline void
netbsd32_to_ifmediareq(s32p, p)
netbsd32_to_ifmediareq(s32p, p, cmd)
struct netbsd32_ifmediareq *s32p;
struct ifmediareq *p;
u_long cmd;
{
memcpy(p, s32p, sizeof *s32p);
@ -208,9 +222,10 @@ netbsd32_to_ifmediareq(s32p, p)
}
static __inline void
netbsd32_to_ifdrv(s32p, p)
netbsd32_to_ifdrv(s32p, p, cmd)
struct netbsd32_ifdrv *s32p;
struct ifdrv *p;
u_long cmd;
{
memcpy(p, s32p, sizeof *s32p);
@ -218,9 +233,10 @@ netbsd32_to_ifdrv(s32p, p)
}
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 sioc_vif_req *p;
u_long cmd;
{
p->vifi = s32p->vifi;
@ -231,9 +247,10 @@ netbsd32_to_sioc_vif_req(s32p, p)
}
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 sioc_sg_req *p;
u_long cmd;
{
p->src = s32p->src;
@ -295,6 +312,16 @@ netbsd32_from_opiocdesc(p, s32p)
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
netbsd32_from_format_op(p, s32p)
struct format_op *p;
@ -409,9 +436,17 @@ netbsd32_ioctl(p, v, retval)
syscallarg(netbsd32_u_long) com;
syscallarg(netbsd32_voidp) data;
} */ *uap = v;
struct sys_ioctl_args ua;
void *data = NULL;
int rv;
struct file *fp;
struct filedesc *fdp;
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,
@ -430,219 +465,261 @@ printf("netbsd32_ioctl(%d, %x, %x): %s group %c base %d len %d\n",
}
#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... */
#define IOCTL_STRUCT_CONV_TO(type) \
data = malloc(sizeof(struct type), M_TEMP, M_WAITOK); \
__CONCAT(netbsd32_to_, type)((struct __CONCAT(netbsd32_, type) *) \
(u_long)SCARG(uap, data), data)
#define IOCTL_STRUCT_CONV_CMD_TO(type, cmd) \
data = malloc(sizeof(struct type), M_TEMP, M_WAITOK); \
__CONCAT(netbsd32_to_, type)((struct __CONCAT(netbsd32_, type) *) \
(u_long)SCARG(uap, data), data, cmd)
#define IOCTL_STRUCT_CONV_FROM(type) \
__CONCAT(netbsd32_from_, type)(data, \
(struct __CONCAT(netbsd32_, type) *) (u_long)SCARG(uap, data))
#define IOCTL_STRUCT_CONV_CMD_FROM(type, cmd) \
__CONCAT(netbsd32_from_, type)(data, \
(struct __CONCAT(netbsd32_, type) *) (u_long)SCARG(uap, data), cmd)
#define IOCTL_STRUCT_CONV_TO(cmd, type) \
com = cmd; \
size = IOCPARM_LEN(com); \
if (size > sizeof(stkbuf)) \
data = memp = malloc(size, M_IOCTLOPS, M_WAITOK); \
else \
data = (caddr_t)stkbuf; \
__CONCAT(netbsd32_to_, type)((struct __CONCAT(netbsd32_, type) *) \
data32, (struct type *)data, com); \
error = (*fp->f_ops->fo_ioctl)(fp, com, data, p); \
__CONCAT(netbsd32_from_, type)((struct type *)data, \
(struct __CONCAT(netbsd32_, type) *)data32); \
break
/*
* convert various structures, pointers, and other objects that
* change size from 32 bit -> 64 bit, for all ioctl commands.
*/
switch (SCARG(uap, com)) {
case FBIOPUTCMAP:
case FBIOGETCMAP:
IOCTL_STRUCT_CONV_TO(fbcmap);
case FIONBIO:
if ((tmp = *(int *)data) != 0)
fp->f_flag |= FNONBLOCK;
else
fp->f_flag &= ~FNONBLOCK;
error = (*fp->f_ops->fo_ioctl)(fp, FIONBIO, (caddr_t)&tmp, p);
break;
case FBIOSCURSOR:
case FBIOGCURSOR:
IOCTL_STRUCT_CONV_TO(fbcursor);
case FIOASYNC:
if ((tmp = *(int *)data) != 0)
fp->f_flag |= FASYNC;
else
fp->f_flag &= ~FASYNC;
error = (*fp->f_ops->fo_ioctl)(fp, FIOASYNC, (caddr_t)&tmp, p);
break;
case OPIOCGET:
case OPIOCSET:
case OPIOCNEXTPROP:
IOCTL_STRUCT_CONV_TO(opiocdesc);
case FIOSETOWN:
tmp = *(int *)data;
if (fp->f_type == DTYPE_SOCKET) {
((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;
case DIOCGPART:
IOCTL_STRUCT_CONV_TO(partinfo);
case FIOGETOWN:
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;
case DIOCRFORMAT:
case DIOCWFORMAT:
IOCTL_STRUCT_CONV_TO(format_op);
break;
/*
* Here are calls that need explicit conversion.
*/
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
* 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_TO(ifreq, SCARG(uap, cmd));
break;
case SIOCGADDRROM3232:
IOCTL_STRUCT_CONV_TO(SIOCGADDRROM32, ifreq);
case SIOCGCHIPID32:
IOCTL_STRUCT_CONV_TO(SIOCGCHIPID, ifreq);
case SIOCSIFADDR32:
IOCTL_STRUCT_CONV_TO(SIOCSIFADDR, ifreq);
case OSIOCGIFADDR32:
IOCTL_STRUCT_CONV_TO(OSIOCGIFADDR, ifreq);
case SIOCGIFADDR32:
IOCTL_STRUCT_CONV_TO(SIOCGIFADDR, ifreq);
case SIOCSIFDSTADDR32:
IOCTL_STRUCT_CONV_TO(SIOCSIFDSTADDR, ifreq);
case OSIOCGIFDSTADDR32:
IOCTL_STRUCT_CONV_TO(OSIOCGIFDSTADDR, ifreq);
case SIOCGIFDSTADDR32:
IOCTL_STRUCT_CONV_TO(SIOCGIFDSTADDR, ifreq);
case SIOCSIFFLAGS32:
IOCTL_STRUCT_CONV_TO(SIOCSIFFLAGS, ifreq);
case SIOCGIFFLAGS32:
IOCTL_STRUCT_CONV_TO(SIOCGIFFLAGS, ifreq);
case OSIOCGIFBRDADDR32:
IOCTL_STRUCT_CONV_TO(OSIOCGIFBRDADDR, ifreq);
case SIOCGIFBRDADDR32:
IOCTL_STRUCT_CONV_TO(SIOCGIFBRDADDR, ifreq);
case SIOCSIFBRDADDR32:
IOCTL_STRUCT_CONV_TO(SIOCSIFBRDADDR, ifreq);
case OSIOCGIFNETMASK32:
IOCTL_STRUCT_CONV_TO(OSIOCGIFNETMASK, ifreq);
case SIOCGIFNETMASK32:
IOCTL_STRUCT_CONV_TO(SIOCGIFNETMASK, ifreq);
case SIOCSIFNETMASK32:
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
case OSIOCGIFCONF:
case SIOCGIFCONF:
IOCTL_STRUCT_CONV_TO(ifconf);
break;
case OSIOCGIFCONF32:
IOCTL_STRUCT_CONV_TO(OSIOCGIFCONF, ifconf);
case SIOCGIFCONF32:
IOCTL_STRUCT_CONV_TO(SIOCGIFCONF, ifconf);
case SIOCGIFMEDIA:
IOCTL_STRUCT_CONV_TO(ifmediareq);
break;
case SIOCGIFMEDIA32:
IOCTL_STRUCT_CONV_TO(SIOCGIFMEDIA, ifmediareq);
case SIOCSDRVSPEC:
IOCTL_STRUCT_CONV_TO(ifdrv);
break;
case SIOCSDRVSPEC32:
IOCTL_STRUCT_CONV_TO(SIOCSDRVSPEC, ifdrv);
case SIOCGETVIFCNT:
IOCTL_STRUCT_CONV_TO(sioc_vif_req);
break;
case SIOCGETVIFCNT32:
IOCTL_STRUCT_CONV_TO(SIOCGETVIFCNT, sioc_vif_req);
case SIOCGETSGCNT:
IOCTL_STRUCT_CONV_TO(sioc_sg_req);
break;
case SIOCGETSGCNT32:
IOCTL_STRUCT_CONV_TO(SIOCGETSGCNT, sioc_sg_req);
default:
error = (*fp->f_ops->fo_ioctl)(fp, com, data32, p);
break;
}
/*
* if we malloced a new data segment, plug it into the
* syscall args, otherwise copy incoming one as a void
* pointer. also copy the rest of the syscall args...
* Copy any data to user, size was
* already set and checked above.
*/
if (data)
SCARG(&ua, data) = data;
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 (error == 0 && (com&IOC_OUT) && size32)
error = copyout(data32, (caddr_t)(u_long)SCARG(uap, data), size32);
/* if we malloced data, free it here */
if (data)
free(data, M_TEMP);
if (memp32)
free(memp32, M_IOCTLOPS);
if (memp)
free(memp, M_IOCTLOPS);
/* done! */
return (rv);
out:
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
@ -41,9 +41,9 @@ struct netbsd32_fbcmap {
netbsd32_u_charp green; /* green color map elements */
netbsd32_u_charp blue; /* blue color map elements */
};
#if 0
#define FBIOPUTCMAP _IOW('F', 3, struct fbcmap)
#define FBIOGETCMAP _IOW('F', 4, struct fbcmap)
#if 1
#define FBIOPUTCMAP32 _IOW('F', 3, struct netbsd32_fbcmap)
#define FBIOGETCMAP32 _IOW('F', 4, struct netbsd32_fbcmap)
#endif
struct netbsd32_fbcursor {
@ -56,9 +56,9 @@ struct netbsd32_fbcursor {
netbsd32_charp image; /* cursor's image bits */
netbsd32_charp mask; /* cursor's mask bits */
};
#if 0
#define FBIOSCURSOR _IOW('F', 24, struct fbcursor)
#define FBIOGCURSOR _IOWR('F', 25, struct fbcursor)
#if 1
#define FBIOSCURSOR32 _IOW('F', 24, struct netbsd32_fbcursor)
#define FBIOGCURSOR32 _IOWR('F', 25, struct netbsd32_fbcursor)
#endif
/* from arch/sparc/include/openpromio.h */
@ -69,10 +69,10 @@ struct netbsd32_opiocdesc {
int op_buflen; /* length of op_buf (value-result) */
netbsd32_charp op_buf; /* pointer to field value */
};
#if 0
#define OPIOCGET _IOWR('O', 1, struct opiocdesc) /* get openprom field */
#define OPIOCSET _IOW('O', 2, struct opiocdesc) /* set openprom field */
#define OPIOCNEXTPROP _IOWR('O', 3, struct opiocdesc) /* get next property */
#if 1
#define OPIOCGET32 _IOWR('O', 1, struct netbsd32_opiocdesc) /* get openprom field */
#define OPIOCSET32 _IOW('O', 2, struct netbsd32_opiocdesc) /* set openprom field */
#define OPIOCNEXTPROP32 _IOWR('O', 3, struct netbsd32_opiocdesc) /* get next property */
#endif
/* from <sys/audioio.h> */
@ -87,8 +87,8 @@ struct netbsd32_partinfo {
netbsd32_disklabel_tp_t disklab;
netbsd32_partition_tp_t part;
};
#if 0
#define DIOCGPART _IOW('d', 104, struct partinfo) /* get partition */
#if 1
#define DIOCGPART32 _IOW('d', 104, struct netbsd32_partinfo) /* get partition */
#endif
struct netbsd32_format_op {
@ -97,9 +97,9 @@ struct netbsd32_format_op {
daddr_t df_startblk;
int df_reg[8]; /* result */
};
#if 0
#define DIOCRFORMAT _IOWR('d', 105, struct format_op)
#define DIOCWFORMAT _IOWR('d', 106, struct format_op)
#if 1
#define DIOCRFORMAT32 _IOWR('d', 105, struct netbsd32_format_op)
#define DIOCWFORMAT32 _IOWR('d', 106, struct netbsd32_format_op)
#endif
/* can wait! */
@ -206,41 +206,41 @@ struct netbsd32_ifreq {
#define ifr_media ifr_ifru.ifru_metric /* media options (overload) */
#define ifr_data ifr_ifru.ifru_data /* for use by interface */
};
#if 0
#if 1
/* from <dev/pci/if_devar.h> */
#define SIOCGADDRROM _IOW('i', 240, struct ifreq) /* get 128 bytes of ROM */
#define SIOCGCHIPID _IOWR('i', 241, struct ifreq) /* get chipid */
#define SIOCGADDRROM32 _IOW('i', 240, struct netbsd32_ifreq) /* get 128 bytes of ROM */
#define SIOCGCHIPID32 _IOWR('i', 241, struct netbsd32_ifreq) /* get chipid */
/* from <sys/sockio.h> */
#define SIOCSIFADDR _IOW('i', 12, struct ifreq) /* set ifnet address */
#define OSIOCGIFADDR _IOWR('i', 13, struct ifreq) /* get ifnet address */
#define SIOCGIFADDR _IOWR('i', 33, struct ifreq) /* get ifnet address */
#define SIOCSIFDSTADDR _IOW('i', 14, struct ifreq) /* set p-p address */
#define OSIOCGIFDSTADDR _IOWR('i', 15, struct ifreq) /* get p-p address */
#define SIOCGIFDSTADDR _IOWR('i', 34, struct ifreq) /* get p-p address */
#define SIOCSIFFLAGS _IOW('i', 16, struct ifreq) /* set ifnet flags */
#define SIOCGIFFLAGS _IOWR('i', 17, struct ifreq) /* get ifnet flags */
#define OSIOCGIFBRDADDR _IOWR('i', 18, struct ifreq) /* get broadcast addr */
#define SIOCGIFBRDADDR _IOWR('i', 35, struct ifreq) /* get broadcast addr */
#define SIOCSIFBRDADDR _IOW('i', 19, struct ifreq) /* set broadcast addr */
#define OSIOCGIFNETMASK _IOWR('i', 21, struct ifreq) /* get net addr mask */
#define SIOCGIFNETMASK _IOWR('i', 37, struct ifreq) /* get net addr mask */
#define SIOCSIFNETMASK _IOW('i', 22, struct ifreq) /* set net addr mask */
#define SIOCGIFMETRIC _IOWR('i', 23, struct ifreq) /* get IF metric */
#define SIOCSIFMETRIC _IOW('i', 24, struct ifreq) /* set IF metric */
#define SIOCDIFADDR _IOW('i', 25, struct ifreq) /* delete IF addr */
#define SIOCADDMULTI _IOW('i', 49, struct ifreq) /* add m'cast addr */
#define SIOCDELMULTI _IOW('i', 50, struct ifreq) /* del m'cast addr */
#define SIOCSIFMEDIA _IOWR('i', 53, struct ifreq) /* set net media */
#define SIOCSIFMTU _IOW('i', 127, struct ifreq) /* set ifnet mtu */
#define SIOCGIFMTU _IOWR('i', 126, struct ifreq) /* get ifnet mtu */
#define SIOCSIFASYNCMAP _IOW('i', 125, struct ifreq) /* set ppp asyncmap */
#define SIOCGIFASYNCMAP _IOWR('i', 124, struct ifreq) /* get ppp asyncmap */
#define SIOCSIFADDR32 _IOW('i', 12, struct netbsd32_ifreq) /* set ifnet address */
#define OSIOCGIFADDR32 _IOWR('i', 13, struct netbsd32_ifreq) /* get ifnet address */
#define SIOCGIFADDR32 _IOWR('i', 33, struct netbsd32_ifreq) /* get ifnet address */
#define SIOCSIFDSTADDR32 _IOW('i', 14, struct netbsd32_ifreq) /* set p-p address */
#define OSIOCGIFDSTADDR32 _IOWR('i', 15, struct netbsd32_ifreq) /* get p-p address */
#define SIOCGIFDSTADDR32 _IOWR('i', 34, struct netbsd32_ifreq) /* get p-p address */
#define SIOCSIFFLAGS32 _IOW('i', 16, struct netbsd32_ifreq) /* set ifnet flags */
#define SIOCGIFFLAGS32 _IOWR('i', 17, struct netbsd32_ifreq) /* get ifnet flags */
#define OSIOCGIFBRDADDR32 _IOWR('i', 18, struct netbsd32_ifreq) /* get broadcast addr */
#define SIOCGIFBRDADDR32 _IOWR('i', 35, struct netbsd32_ifreq) /* get broadcast addr */
#define SIOCSIFBRDADDR32 _IOW('i', 19, struct netbsd32_ifreq) /* set broadcast addr */
#define OSIOCGIFNETMASK32 _IOWR('i', 21, struct netbsd32_ifreq) /* get net addr mask */
#define SIOCGIFNETMASK32 _IOWR('i', 37, struct netbsd32_ifreq) /* get net addr mask */
#define SIOCSIFNETMASK32 _IOW('i', 22, struct netbsd32_ifreq) /* set net addr mask */
#define SIOCGIFMETRIC32 _IOWR('i', 23, struct netbsd32_ifreq) /* get IF metric */
#define SIOCSIFMETRIC32 _IOW('i', 24, struct netbsd32_ifreq) /* set IF metric */
#define SIOCDIFADDR32 _IOW('i', 25, struct netbsd32_ifreq) /* delete IF addr */
#define SIOCADDMULTI32 _IOW('i', 49, struct netbsd32_ifreq) /* add m'cast addr */
#define SIOCDELMULTI32 _IOW('i', 50, struct netbsd32_ifreq) /* del m'cast addr */
#define SIOCSIFMEDIA32 _IOWR('i', 53, struct netbsd32_ifreq) /* set net media */
#define SIOCSIFMTU32 _IOW('i', 127, struct netbsd32_ifreq) /* set ifnet mtu */
#define SIOCGIFMTU32 _IOWR('i', 126, struct netbsd32_ifreq) /* get ifnet mtu */
#define SIOCSIFASYNCMAP32 _IOW('i', 125, struct netbsd32_ifreq) /* set ppp asyncmap */
#define SIOCGIFASYNCMAP32 _IOWR('i', 124, struct netbsd32_ifreq) /* get ppp asyncmap */
/* from <net/bpf.h> */
#define BIOCGETIF _IOR('B',107, struct ifreq)
#define BIOCSETIF _IOW('B',108, struct ifreq)
#define BIOCGETIF32 _IOR('B',107, struct netbsd32_ifreq)
#define BIOCSETIF32 _IOW('B',108, struct netbsd32_ifreq)
/* from <netatalk/phase2.h> */
#define SIOCPHASE1 _IOW('i', 100, struct ifreq) /* AppleTalk phase 1 */
#define SIOCPHASE2 _IOW('i', 101, struct ifreq) /* AppleTalk phase 2 */
#define SIOCPHASE1_32 _IOW('i', 100, struct netbsd32_ifreq) /* AppleTalk phase 1 */
#define SIOCPHASE2_32 _IOW('i', 101, struct netbsd32_ifreq) /* AppleTalk phase 2 */
#endif
/* from <net/if.h> */
@ -253,10 +253,10 @@ struct netbsd32_ifconf {
#define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */
#define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */
};
#if 0
#if 1
/* from <sys/sockio.h> */
#define OSIOCGIFCONF _IOWR('i', 20, struct ifconf) /* get ifnet list */
#define SIOCGIFCONF _IOWR('i', 36, struct ifconf) /* get ifnet list */
#define OSIOCGIFCONF32 _IOWR('i', 20, struct netbsd32_ifconf) /* get ifnet list */
#define SIOCGIFCONF32 _IOWR('i', 36, struct netbsd32_ifconf) /* get ifnet list */
#endif
/* from <net/if.h> */
@ -270,9 +270,9 @@ struct netbsd32_ifmediareq {
array */
netbsd32_intp ifm_ulist; /* media words */
};
#if 0
#if 1
/* 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
/* from <net/if.h> */
@ -282,9 +282,9 @@ struct netbsd32_ifdrv {
size_t ifd_len;
void *ifd_data;
};
#if 0
#if 1
/* 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
/* 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 obytes; /* output byte count on vif */
};
#if 0
#if 1
/* 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
struct netbsd32_sioc_sg_req {
@ -307,7 +307,7 @@ struct netbsd32_sioc_sg_req {
u_long bytecnt;
u_long wrong_if;
};
#if 0
#if 1
/* 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

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
@ -3777,6 +3777,24 @@ netbsd32_ntp_adjtime(p, v, retval)
}
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
int