2011-10-06 07:19:32 +04:00
|
|
|
/* $NetBSD: netbsd32_ioctl.c,v 1.64 2011/10/06 03:19:32 macallan Exp $ */
|
1998-08-26 14:20:33 +04:00
|
|
|
|
|
|
|
/*
|
2001-08-25 19:06:02 +04:00
|
|
|
* Copyright (c) 1998, 2001 Matthew R. Green
|
1998-08-26 14:20:33 +04:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
|
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
|
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2002-01-03 05:29:39 +03:00
|
|
|
* handle ioctl conversions from netbsd32 -> 64-bit kernel
|
1998-08-26 14:20:33 +04:00
|
|
|
*/
|
|
|
|
|
2001-11-13 05:07:52 +03:00
|
|
|
#include <sys/cdefs.h>
|
2011-10-06 07:19:32 +04:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: netbsd32_ioctl.c,v 1.64 2011/10/06 03:19:32 macallan Exp $");
|
2001-11-13 05:07:52 +03:00
|
|
|
|
1998-08-26 14:20:33 +04:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
2000-08-19 18:38:18 +04:00
|
|
|
#include <sys/filedesc.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/file.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/socketvar.h>
|
1998-08-26 14:20:33 +04:00
|
|
|
#include <sys/audioio.h>
|
|
|
|
#include <sys/disklabel.h>
|
|
|
|
#include <sys/dkio.h>
|
|
|
|
#include <sys/sockio.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/ttycom.h>
|
|
|
|
#include <sys/mount.h>
|
|
|
|
#include <sys/syscallargs.h>
|
2007-03-20 14:02:18 +03:00
|
|
|
#include <sys/ktrace.h>
|
2008-03-22 00:54:58 +03:00
|
|
|
#include <sys/kmem.h>
|
2010-09-24 17:12:53 +04:00
|
|
|
#include <sys/envsys.h>
|
2011-08-27 23:25:35 +04:00
|
|
|
#include <sys/wdog.h>
|
1998-08-26 14:20:33 +04:00
|
|
|
|
2001-06-19 04:36:21 +04:00
|
|
|
#ifdef __sparc__
|
2001-09-19 22:10:32 +04:00
|
|
|
#include <dev/sun/fbio.h>
|
1998-08-26 14:20:33 +04:00
|
|
|
#include <machine/openpromio.h>
|
2001-06-19 04:36:21 +04:00
|
|
|
#endif
|
1998-08-26 14:20:33 +04:00
|
|
|
|
|
|
|
#include <net/if.h>
|
|
|
|
#include <net/route.h>
|
|
|
|
|
2011-08-30 18:22:22 +04:00
|
|
|
#include <net/bpf.h>
|
1998-08-26 14:20:33 +04:00
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <netinet/in_var.h>
|
|
|
|
#include <netinet/igmp.h>
|
|
|
|
#include <netinet/igmp_var.h>
|
|
|
|
#include <netinet/ip_mroute.h>
|
|
|
|
|
2007-05-30 04:00:59 +04:00
|
|
|
#include <compat/sys/sockio.h>
|
|
|
|
|
1999-03-25 19:22:49 +03:00
|
|
|
#include <compat/netbsd32/netbsd32.h>
|
|
|
|
#include <compat/netbsd32/netbsd32_ioctl.h>
|
|
|
|
#include <compat/netbsd32/netbsd32_syscallargs.h>
|
1998-08-26 14:20:33 +04:00
|
|
|
|
2010-09-19 13:46:59 +04:00
|
|
|
#include <dev/vndvar.h>
|
|
|
|
|
2000-07-09 17:39:31 +04:00
|
|
|
/* prototypes for the converters */
|
2005-12-24 23:45:08 +03:00
|
|
|
static inline void netbsd32_to_partinfo(struct netbsd32_partinfo *,
|
2004-01-15 17:36:28 +03:00
|
|
|
struct partinfo *, u_long);
|
2003-01-25 00:55:02 +03:00
|
|
|
#if 0
|
2005-12-24 23:45:08 +03:00
|
|
|
static inline void netbsd32_to_format_op(struct netbsd32_format_op *,
|
2004-01-15 17:36:28 +03:00
|
|
|
struct format_op *, u_long);
|
2003-01-25 00:55:02 +03:00
|
|
|
#endif
|
2009-12-09 07:50:47 +03:00
|
|
|
static inline void netbsd32_to_oifreq(struct netbsd32_oifreq *, struct oifreq *,
|
|
|
|
u_long cmd);
|
2005-12-24 23:45:08 +03:00
|
|
|
static inline void netbsd32_to_ifreq(struct netbsd32_ifreq *, struct ifreq *,
|
2004-01-15 17:36:28 +03:00
|
|
|
u_long cmd);
|
2011-02-01 03:53:22 +03:00
|
|
|
static inline void netbsd32_to_if_addrprefreq(
|
|
|
|
const struct netbsd32_if_addrprefreq *, struct if_addrprefreq *, u_long);
|
2005-12-24 23:45:08 +03:00
|
|
|
static inline void netbsd32_to_ifconf(struct netbsd32_ifconf *,
|
2004-01-15 17:36:28 +03:00
|
|
|
struct ifconf *, u_long);
|
2005-12-24 23:45:08 +03:00
|
|
|
static inline void netbsd32_to_ifmediareq(struct netbsd32_ifmediareq *,
|
2004-01-15 17:36:28 +03:00
|
|
|
struct ifmediareq *, u_long);
|
2005-12-24 23:45:08 +03:00
|
|
|
static inline void netbsd32_to_ifdrv(struct netbsd32_ifdrv *, struct ifdrv *,
|
2004-01-15 17:36:28 +03:00
|
|
|
u_long);
|
2005-12-24 23:45:08 +03:00
|
|
|
static inline void netbsd32_to_sioc_vif_req(struct netbsd32_sioc_vif_req *,
|
2004-01-15 17:36:28 +03:00
|
|
|
struct sioc_vif_req *, u_long);
|
2005-12-24 23:45:08 +03:00
|
|
|
static inline void netbsd32_to_sioc_sg_req(struct netbsd32_sioc_sg_req *,
|
2004-01-15 17:36:28 +03:00
|
|
|
struct sioc_sg_req *, u_long);
|
2005-12-24 23:45:08 +03:00
|
|
|
static inline void netbsd32_from_partinfo(struct partinfo *,
|
2004-01-15 17:36:28 +03:00
|
|
|
struct netbsd32_partinfo *, u_long);
|
2003-01-25 00:55:02 +03:00
|
|
|
#if 0
|
2005-12-24 23:45:08 +03:00
|
|
|
static inline void netbsd32_from_format_op(struct format_op *,
|
2004-01-15 17:36:28 +03:00
|
|
|
struct netbsd32_format_op *,
|
|
|
|
u_long);
|
2003-01-25 00:55:02 +03:00
|
|
|
#endif
|
2011-02-01 03:53:22 +03:00
|
|
|
static inline void netbsd32_from_if_addrprefreq(const struct if_addrprefreq *,
|
|
|
|
struct netbsd32_if_addrprefreq *,
|
|
|
|
u_long);
|
2005-12-24 23:45:08 +03:00
|
|
|
static inline void netbsd32_from_ifreq(struct ifreq *,
|
2004-01-15 17:36:28 +03:00
|
|
|
struct netbsd32_ifreq *, u_long);
|
2009-12-09 07:50:47 +03:00
|
|
|
static inline void netbsd32_from_oifreq(struct oifreq *,
|
|
|
|
struct netbsd32_oifreq *, u_long);
|
2005-12-24 23:45:08 +03:00
|
|
|
static inline void netbsd32_from_ifconf(struct ifconf *,
|
2004-01-15 17:36:28 +03:00
|
|
|
struct netbsd32_ifconf *, u_long);
|
2005-12-24 23:45:08 +03:00
|
|
|
static inline void netbsd32_from_ifmediareq(struct ifmediareq *,
|
2004-01-15 17:36:28 +03:00
|
|
|
struct netbsd32_ifmediareq *,
|
|
|
|
u_long);
|
2005-12-24 23:45:08 +03:00
|
|
|
static inline void netbsd32_from_ifdrv(struct ifdrv *,
|
2004-01-15 17:36:28 +03:00
|
|
|
struct netbsd32_ifdrv *, u_long);
|
2005-12-24 23:45:08 +03:00
|
|
|
static inline void netbsd32_from_sioc_vif_req(struct sioc_vif_req *,
|
2004-01-15 17:36:28 +03:00
|
|
|
struct netbsd32_sioc_vif_req *,
|
|
|
|
u_long);
|
2005-12-24 23:45:08 +03:00
|
|
|
static inline void netbsd32_from_sioc_sg_req(struct sioc_sg_req *,
|
2004-01-15 17:36:28 +03:00
|
|
|
struct netbsd32_sioc_sg_req *,
|
|
|
|
u_long);
|
2000-07-09 17:39:31 +04:00
|
|
|
|
2011-08-30 11:06:39 +04:00
|
|
|
/* wsdisplay stuff */
|
|
|
|
static inline void netbsd32_to_wsdisplay_addscreendata(
|
|
|
|
struct netbsd32_wsdisplay_addscreendata *,
|
|
|
|
struct wsdisplay_addscreendata *,
|
|
|
|
u_long);
|
|
|
|
|
2000-07-09 17:39:31 +04:00
|
|
|
/* convert to/from different structures */
|
|
|
|
|
2005-12-24 23:45:08 +03:00
|
|
|
static inline void
|
2007-12-08 21:35:53 +03:00
|
|
|
netbsd32_to_partinfo(struct netbsd32_partinfo *s32p, struct partinfo *p, u_long cmd)
|
1998-08-26 14:20:33 +04:00
|
|
|
{
|
|
|
|
|
2002-10-23 17:16:38 +04:00
|
|
|
p->disklab = (struct disklabel *)NETBSD32PTR64(s32p->disklab);
|
|
|
|
p->part = (struct partition *)NETBSD32PTR64(s32p->part);
|
1998-08-26 14:20:33 +04:00
|
|
|
}
|
|
|
|
|
2003-01-25 00:55:02 +03:00
|
|
|
#if 0
|
2005-12-24 23:45:08 +03:00
|
|
|
static inline void
|
2007-12-08 21:35:53 +03:00
|
|
|
netbsd32_to_format_op(struct netbsd32_format_op *s32p, struct format_op *p, u_long cmd)
|
1998-08-26 14:20:33 +04:00
|
|
|
{
|
|
|
|
|
2002-10-23 17:16:38 +04:00
|
|
|
p->df_buf = (char *)NETBSD32PTR64(s32p->df_buf);
|
1998-08-26 14:20:33 +04:00
|
|
|
p->df_count = s32p->df_count;
|
|
|
|
p->df_startblk = s32p->df_startblk;
|
|
|
|
memcpy(p->df_reg, s32p->df_reg, sizeof(s32p->df_reg));
|
|
|
|
}
|
2003-01-25 00:55:02 +03:00
|
|
|
#endif
|
1998-08-26 14:20:33 +04:00
|
|
|
|
2005-12-24 23:45:08 +03:00
|
|
|
static inline void
|
2007-12-08 21:35:53 +03:00
|
|
|
netbsd32_to_ifreq(struct netbsd32_ifreq *s32p, struct ifreq *p, u_long cmd)
|
1998-08-26 14:20:33 +04:00
|
|
|
{
|
|
|
|
|
2004-01-15 17:36:28 +03:00
|
|
|
memcpy(p, s32p, sizeof *s32p);
|
1998-08-26 14:20:33 +04:00
|
|
|
/*
|
|
|
|
* XXX
|
|
|
|
* struct ifreq says the same, but sometimes the ifr_data
|
|
|
|
* union member needs to be converted to 64 bits... this
|
|
|
|
* is very driver specific and so we ignore it for now..
|
|
|
|
*/
|
2004-01-15 17:36:28 +03:00
|
|
|
if (cmd == SIOCGIFDATA || cmd == SIOCZIFDATA)
|
2007-03-04 08:59:00 +03:00
|
|
|
p->ifr_data = (void *)NETBSD32PTR64(s32p->ifr_data);
|
1998-08-26 14:20:33 +04:00
|
|
|
}
|
|
|
|
|
2009-12-09 07:50:47 +03:00
|
|
|
static inline void
|
|
|
|
netbsd32_to_oifreq(struct netbsd32_oifreq *s32p, struct oifreq *p, u_long cmd)
|
|
|
|
{
|
|
|
|
|
|
|
|
memcpy(p, s32p, sizeof *s32p);
|
|
|
|
/*
|
|
|
|
* XXX
|
|
|
|
* struct ifreq says the same, but sometimes the ifr_data
|
|
|
|
* union member needs to be converted to 64 bits... this
|
|
|
|
* is very driver specific and so we ignore it for now..
|
|
|
|
*/
|
|
|
|
if (cmd == SIOCGIFDATA || cmd == SIOCZIFDATA)
|
|
|
|
p->ifr_data = (void *)NETBSD32PTR64(s32p->ifr_data);
|
|
|
|
}
|
|
|
|
|
2011-02-01 03:53:22 +03:00
|
|
|
static inline void
|
|
|
|
netbsd32_to_if_addrprefreq(const struct netbsd32_if_addrprefreq *ifap32,
|
|
|
|
struct if_addrprefreq *ifap, u_long cmd)
|
|
|
|
{
|
|
|
|
strlcpy(ifap->ifap_name, ifap32->ifap_name, sizeof(ifap->ifap_name));
|
|
|
|
ifap->ifap_preference = ifap32->ifap_preference;
|
|
|
|
memcpy(&ifap->ifap_addr, &ifap32->ifap_addr,
|
|
|
|
max(ifap32->ifap_addr.ss_len, _SS_MAXSIZE));
|
|
|
|
}
|
|
|
|
|
2005-12-24 23:45:08 +03:00
|
|
|
static inline void
|
2007-12-08 21:35:53 +03:00
|
|
|
netbsd32_to_ifconf(struct netbsd32_ifconf *s32p, struct ifconf *p, u_long cmd)
|
1998-08-26 14:20:33 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
p->ifc_len = s32p->ifc_len;
|
|
|
|
/* ifc_buf & ifc_req are the same size so this works */
|
2007-03-04 08:59:00 +03:00
|
|
|
p->ifc_buf = (void *)NETBSD32PTR64(s32p->ifc_buf);
|
1998-08-26 14:20:33 +04:00
|
|
|
}
|
|
|
|
|
2005-12-24 23:45:08 +03:00
|
|
|
static inline void
|
2007-12-08 21:35:53 +03:00
|
|
|
netbsd32_to_ifmediareq(struct netbsd32_ifmediareq *s32p, struct ifmediareq *p, u_long cmd)
|
1998-08-26 14:20:33 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
memcpy(p, s32p, sizeof *s32p);
|
2002-10-23 17:16:38 +04:00
|
|
|
p->ifm_ulist = (int *)NETBSD32PTR64(s32p->ifm_ulist);
|
1998-08-26 14:20:33 +04:00
|
|
|
}
|
|
|
|
|
2005-12-24 23:45:08 +03:00
|
|
|
static inline void
|
2007-12-08 21:35:53 +03:00
|
|
|
netbsd32_to_ifdrv(struct netbsd32_ifdrv *s32p, struct ifdrv *p, u_long cmd)
|
1998-08-26 14:20:33 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
memcpy(p, s32p, sizeof *s32p);
|
2002-10-23 17:16:38 +04:00
|
|
|
p->ifd_data = (void *)NETBSD32PTR64(s32p->ifd_data);
|
1998-08-26 14:20:33 +04:00
|
|
|
}
|
|
|
|
|
2005-12-24 23:45:08 +03:00
|
|
|
static inline void
|
2007-12-08 21:35:53 +03:00
|
|
|
netbsd32_to_sioc_vif_req(struct netbsd32_sioc_vif_req *s32p, struct sioc_vif_req *p, u_long cmd)
|
1998-08-26 14:20:33 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
p->vifi = s32p->vifi;
|
|
|
|
p->icount = (u_long)s32p->icount;
|
|
|
|
p->ocount = (u_long)s32p->ocount;
|
|
|
|
p->ibytes = (u_long)s32p->ibytes;
|
|
|
|
p->obytes = (u_long)s32p->obytes;
|
|
|
|
}
|
|
|
|
|
2005-12-24 23:45:08 +03:00
|
|
|
static inline void
|
2007-12-08 21:35:53 +03:00
|
|
|
netbsd32_to_sioc_sg_req(struct netbsd32_sioc_sg_req *s32p, struct sioc_sg_req *p, u_long cmd)
|
1998-08-26 14:20:33 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
p->src = s32p->src;
|
|
|
|
p->grp = s32p->grp;
|
|
|
|
p->pktcnt = (u_long)s32p->pktcnt;
|
|
|
|
p->bytecnt = (u_long)s32p->bytecnt;
|
|
|
|
p->wrong_if = (u_long)s32p->wrong_if;
|
|
|
|
}
|
|
|
|
|
2010-09-19 13:09:30 +04:00
|
|
|
static inline void
|
|
|
|
netbsd32_to_vnd_ioctl(struct netbsd32_vnd_ioctl *s32p, struct vnd_ioctl *p, u_long cmd)
|
|
|
|
{
|
|
|
|
|
|
|
|
p->vnd_file = (char *)NETBSD32PTR64(s32p->vnd_file);
|
|
|
|
p->vnd_flags = s32p->vnd_flags;
|
|
|
|
p->vnd_geom = s32p->vnd_geom;
|
|
|
|
p->vnd_osize = s32p->vnd_osize;
|
|
|
|
p->vnd_size = s32p->vnd_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
netbsd32_to_vnd_user(struct netbsd32_vnd_user *s32p, struct vnd_user *p, u_long cmd)
|
|
|
|
{
|
|
|
|
|
|
|
|
p->vnu_unit = s32p->vnu_unit;
|
|
|
|
p->vnu_dev = s32p->vnu_dev;
|
|
|
|
p->vnu_ino = s32p->vnu_ino;
|
|
|
|
}
|
|
|
|
|
2010-09-19 13:46:59 +04:00
|
|
|
static inline void
|
|
|
|
netbsd32_to_vnd_ioctl50(struct netbsd32_vnd_ioctl50 *s32p, struct vnd_ioctl50 *p, u_long cmd)
|
|
|
|
{
|
|
|
|
|
|
|
|
p->vnd_file = (char *)NETBSD32PTR64(s32p->vnd_file);
|
|
|
|
p->vnd_flags = s32p->vnd_flags;
|
|
|
|
p->vnd_geom = s32p->vnd_geom;
|
|
|
|
p->vnd_size = s32p->vnd_size;
|
|
|
|
}
|
|
|
|
|
2010-09-24 17:12:53 +04:00
|
|
|
static inline void
|
|
|
|
netbsd32_to_plistref(struct netbsd32_plistref *s32p, struct plistref *p, u_long cmd)
|
|
|
|
{
|
|
|
|
|
|
|
|
p->pref_plist = NETBSD32PTR64(s32p->pref_plist);
|
|
|
|
p->pref_len = s32p->pref_len;
|
|
|
|
}
|
|
|
|
|
2010-09-19 14:33:31 +04:00
|
|
|
static inline void
|
|
|
|
netbsd32_to_u_long(netbsd32_u_long *s32p, u_long *p, u_long cmd)
|
|
|
|
{
|
|
|
|
|
|
|
|
*p = (u_long)*s32p;
|
|
|
|
}
|
|
|
|
|
2011-08-27 23:25:35 +04:00
|
|
|
static inline void
|
|
|
|
netbsd32_to_wdog_conf(struct netbsd32_wdog_conf *s32p, struct wdog_conf *p, u_long cmd)
|
|
|
|
{
|
|
|
|
|
|
|
|
p->wc_names = (char *)NETBSD32PTR64(s32p->wc_names);
|
|
|
|
p->wc_count = s32p->wc_count;
|
|
|
|
}
|
|
|
|
|
2011-08-30 18:22:22 +04:00
|
|
|
static inline void
|
|
|
|
netbsd32_to_bpf_program(struct netbsd32_bpf_program *s32p, struct bpf_program *p, u_long cmd)
|
|
|
|
{
|
|
|
|
|
|
|
|
p->bf_insns = (void *)NETBSD32PTR64(s32p->bf_insns);
|
|
|
|
p->bf_len = s32p->bf_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
netbsd32_to_bpf_dltlist(struct netbsd32_bpf_dltlist *s32p, struct bpf_dltlist *p, u_long cmd)
|
|
|
|
{
|
|
|
|
|
|
|
|
p->bfl_list = (void *)NETBSD32PTR64(s32p->bfl_list);
|
|
|
|
p->bfl_len = s32p->bfl_len;
|
|
|
|
}
|
|
|
|
|
2011-08-30 11:06:39 +04:00
|
|
|
/* wsdisplay stuff */
|
|
|
|
static inline void
|
|
|
|
netbsd32_to_wsdisplay_addscreendata(struct netbsd32_wsdisplay_addscreendata *asd32,
|
|
|
|
struct wsdisplay_addscreendata *asd,
|
|
|
|
u_long cmd)
|
|
|
|
{
|
|
|
|
asd->screentype = (char *)NETBSD32PTR64(asd32->screentype);
|
|
|
|
asd->emul = (char *)NETBSD32PTR64(asd32->emul);
|
|
|
|
asd->idx = asd32->idx;
|
|
|
|
}
|
|
|
|
|
2011-08-30 11:54:15 +04:00
|
|
|
static inline void
|
|
|
|
netbsd32_to_ieee80211_nwkey(struct netbsd32_ieee80211_nwkey *nwk32,
|
|
|
|
struct ieee80211_nwkey *nwk,
|
|
|
|
u_long cmd)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
strncpy(nwk->i_name, nwk32->i_name, IFNAMSIZ);
|
|
|
|
nwk->i_wepon = nwk32->i_wepon;
|
|
|
|
nwk->i_defkid = nwk32->i_defkid;
|
|
|
|
for (i = 0; i < IEEE80211_WEP_NKID; i++) {
|
|
|
|
nwk->i_key[i].i_keylen = nwk32->i_key[i].i_keylen;
|
|
|
|
nwk->i_key[i].i_keydat =
|
|
|
|
NETBSD32PTR64(nwk32->i_key[i].i_keydat);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-28 05:46:39 +04:00
|
|
|
static inline void
|
|
|
|
netbsd32_to_wsdisplay_cursor(struct netbsd32_wsdisplay_cursor *c32,
|
|
|
|
struct wsdisplay_cursor *c,
|
|
|
|
u_long cmd)
|
|
|
|
{
|
|
|
|
c->which = c32->which;
|
|
|
|
c->enable = c32->enable;
|
|
|
|
c->pos.x = c32->pos.x;
|
|
|
|
c->pos.y = c32->pos.y;
|
|
|
|
c->hot.x = c32->hot.x;
|
|
|
|
c->hot.y = c32->hot.y;
|
|
|
|
c->size.x = c32->size.x;
|
|
|
|
c->size.y = c32->size.y;
|
|
|
|
c->cmap.index = c32->cmap.index;
|
|
|
|
c->cmap.count = c32->cmap.count;
|
|
|
|
c->cmap.red = NETBSD32PTR64(c32->cmap.red);
|
|
|
|
c->cmap.green = NETBSD32PTR64(c32->cmap.green);
|
|
|
|
c->cmap.blue = NETBSD32PTR64(c32->cmap.blue);
|
|
|
|
c->image = NETBSD32PTR64(c32->image);
|
|
|
|
c->mask = NETBSD32PTR64(c32->mask);
|
|
|
|
}
|
|
|
|
|
1998-08-26 14:20:33 +04:00
|
|
|
/*
|
2002-01-03 05:29:39 +03:00
|
|
|
* handle ioctl conversions from 64-bit kernel -> netbsd32
|
1998-08-26 14:20:33 +04:00
|
|
|
*/
|
|
|
|
|
2005-12-24 23:45:08 +03:00
|
|
|
static inline void
|
2007-12-08 21:35:53 +03:00
|
|
|
netbsd32_from_partinfo(struct partinfo *p, struct netbsd32_partinfo *s32p, u_long cmd)
|
2000-08-19 18:38:18 +04:00
|
|
|
{
|
|
|
|
|
2007-03-17 01:21:40 +03:00
|
|
|
NETBSD32PTR32(s32p->disklab, p->disklab);
|
|
|
|
NETBSD32PTR32(s32p->part, p->part);
|
2000-08-19 18:38:18 +04:00
|
|
|
}
|
|
|
|
|
2003-01-25 00:55:02 +03:00
|
|
|
#if 0
|
2005-12-24 23:45:08 +03:00
|
|
|
static inline void
|
2007-12-08 21:35:53 +03:00
|
|
|
netbsd32_from_format_op(struct format_op *p, struct netbsd32_format_op *s32p, u_long cmd)
|
1998-08-26 14:20:33 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
/* filled in */
|
|
|
|
#if 0
|
1999-03-25 19:22:49 +03:00
|
|
|
s32p->df_buf = (netbsd32_charp)p->df_buf;
|
1998-08-26 14:20:33 +04:00
|
|
|
#endif
|
|
|
|
s32p->df_count = p->df_count;
|
|
|
|
s32p->df_startblk = p->df_startblk;
|
|
|
|
memcpy(s32p->df_reg, p->df_reg, sizeof(p->df_reg));
|
|
|
|
}
|
2003-01-25 00:55:02 +03:00
|
|
|
#endif
|
1998-08-26 14:20:33 +04:00
|
|
|
|
2005-12-24 23:45:08 +03:00
|
|
|
static inline void
|
2007-12-08 21:35:53 +03:00
|
|
|
netbsd32_from_ifreq(struct ifreq *p, struct netbsd32_ifreq *s32p, u_long cmd)
|
1998-08-26 14:20:33 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX
|
|
|
|
* struct ifreq says the same, but sometimes the ifr_data
|
|
|
|
* union member needs to be converted to 64 bits... this
|
|
|
|
* is very driver specific and so we ignore it for now..
|
|
|
|
*/
|
2009-12-11 14:14:34 +03:00
|
|
|
memcpy(s32p, p, sizeof *s32p);
|
2009-12-09 07:50:47 +03:00
|
|
|
if (cmd == SIOCGIFDATA || cmd == SIOCZIFDATA)
|
|
|
|
NETBSD32PTR32(s32p->ifr_data, p->ifr_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
netbsd32_from_oifreq(struct oifreq *p, struct netbsd32_oifreq *s32p, u_long cmd)
|
|
|
|
{
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX
|
|
|
|
* struct ifreq says the same, but sometimes the ifr_data
|
|
|
|
* union member needs to be converted to 64 bits... this
|
|
|
|
* is very driver specific and so we ignore it for now..
|
|
|
|
*/
|
2009-12-11 14:14:34 +03:00
|
|
|
memcpy(s32p, p, sizeof *s32p);
|
2004-01-15 17:36:28 +03:00
|
|
|
if (cmd == SIOCGIFDATA || cmd == SIOCZIFDATA)
|
2007-03-17 01:21:40 +03:00
|
|
|
NETBSD32PTR32(s32p->ifr_data, p->ifr_data);
|
1998-08-26 14:20:33 +04:00
|
|
|
}
|
|
|
|
|
2011-02-01 03:53:22 +03:00
|
|
|
static inline void
|
|
|
|
netbsd32_from_if_addrprefreq(const struct if_addrprefreq *ifap,
|
|
|
|
struct netbsd32_if_addrprefreq *ifap32, u_long cmd)
|
|
|
|
{
|
|
|
|
strlcpy(ifap32->ifap_name, ifap->ifap_name, sizeof(ifap32->ifap_name));
|
|
|
|
ifap32->ifap_preference = ifap->ifap_preference;
|
|
|
|
memcpy(&ifap32->ifap_addr, &ifap->ifap_addr,
|
|
|
|
max(ifap->ifap_addr.ss_len, _SS_MAXSIZE));
|
|
|
|
}
|
|
|
|
|
2005-12-24 23:45:08 +03:00
|
|
|
static inline void
|
2007-12-08 21:35:53 +03:00
|
|
|
netbsd32_from_ifconf(struct ifconf *p, struct netbsd32_ifconf *s32p, u_long cmd)
|
1998-08-26 14:20:33 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
s32p->ifc_len = p->ifc_len;
|
|
|
|
/* ifc_buf & ifc_req are the same size so this works */
|
2007-03-17 01:21:40 +03:00
|
|
|
NETBSD32PTR32(s32p->ifc_buf, p->ifc_buf);
|
1998-08-26 14:20:33 +04:00
|
|
|
}
|
|
|
|
|
2005-12-24 23:45:08 +03:00
|
|
|
static inline void
|
2007-12-08 21:35:53 +03:00
|
|
|
netbsd32_from_ifmediareq(struct ifmediareq *p, struct netbsd32_ifmediareq *s32p, u_long cmd)
|
1998-08-26 14:20:33 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
memcpy(s32p, p, sizeof *p);
|
|
|
|
/* filled in? */
|
|
|
|
#if 0
|
1999-03-25 19:22:49 +03:00
|
|
|
s32p->ifm_ulist = (netbsd32_intp_t)p->ifm_ulist;
|
1998-08-26 14:20:33 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2005-12-24 23:45:08 +03:00
|
|
|
static inline void
|
2007-12-08 21:35:53 +03:00
|
|
|
netbsd32_from_ifdrv(struct ifdrv *p, struct netbsd32_ifdrv *s32p, u_long cmd)
|
1998-08-26 14:20:33 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
memcpy(s32p, p, sizeof *p);
|
|
|
|
/* filled in? */
|
|
|
|
#if 0
|
1999-03-25 19:22:49 +03:00
|
|
|
s32p->ifm_data = (netbsd32_u_longp_t)p->ifm_data;
|
1998-08-26 14:20:33 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2005-12-24 23:45:08 +03:00
|
|
|
static inline void
|
2007-12-08 21:35:53 +03:00
|
|
|
netbsd32_from_sioc_vif_req(struct sioc_vif_req *p, struct netbsd32_sioc_vif_req *s32p, u_long cmd)
|
1998-08-26 14:20:33 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
s32p->vifi = p->vifi;
|
1999-03-25 19:22:49 +03:00
|
|
|
s32p->icount = (netbsd32_u_long)p->icount;
|
|
|
|
s32p->ocount = (netbsd32_u_long)p->ocount;
|
|
|
|
s32p->ibytes = (netbsd32_u_long)p->ibytes;
|
|
|
|
s32p->obytes = (netbsd32_u_long)p->obytes;
|
1998-08-26 14:20:33 +04:00
|
|
|
}
|
|
|
|
|
2005-12-24 23:45:08 +03:00
|
|
|
static inline void
|
2007-12-08 21:35:53 +03:00
|
|
|
netbsd32_from_sioc_sg_req(struct sioc_sg_req *p, struct netbsd32_sioc_sg_req *s32p, u_long cmd)
|
1998-08-26 14:20:33 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
s32p->src = p->src;
|
|
|
|
s32p->grp = p->grp;
|
1999-03-25 19:22:49 +03:00
|
|
|
s32p->pktcnt = (netbsd32_u_long)p->pktcnt;
|
|
|
|
s32p->bytecnt = (netbsd32_u_long)p->bytecnt;
|
|
|
|
s32p->wrong_if = (netbsd32_u_long)p->wrong_if;
|
1998-08-26 14:20:33 +04:00
|
|
|
}
|
|
|
|
|
2010-09-19 13:09:30 +04:00
|
|
|
static inline void
|
|
|
|
netbsd32_from_vnd_ioctl(struct vnd_ioctl *p, struct netbsd32_vnd_ioctl *s32p, u_long cmd)
|
|
|
|
{
|
|
|
|
|
|
|
|
s32p->vnd_flags = p->vnd_flags;
|
|
|
|
s32p->vnd_geom = p->vnd_geom;
|
|
|
|
s32p->vnd_osize = p->vnd_osize;
|
|
|
|
s32p->vnd_size = p->vnd_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
netbsd32_from_vnd_user(struct vnd_user *p, struct netbsd32_vnd_user *s32p, u_long cmd)
|
|
|
|
{
|
|
|
|
|
|
|
|
s32p->vnu_unit = p->vnu_unit;
|
|
|
|
s32p->vnu_dev = p->vnu_dev;
|
|
|
|
s32p->vnu_ino = p->vnu_ino;
|
|
|
|
}
|
|
|
|
|
2010-09-19 13:46:59 +04:00
|
|
|
static inline void
|
|
|
|
netbsd32_from_vnd_ioctl50(struct vnd_ioctl50 *p, struct netbsd32_vnd_ioctl50 *s32p, u_long cmd)
|
|
|
|
{
|
|
|
|
|
|
|
|
s32p->vnd_flags = p->vnd_flags;
|
|
|
|
s32p->vnd_geom = p->vnd_geom;
|
|
|
|
s32p->vnd_size = p->vnd_size;
|
|
|
|
}
|
|
|
|
|
2010-09-24 17:12:53 +04:00
|
|
|
static inline void
|
|
|
|
netbsd32_from_plistref(struct plistref *p, struct netbsd32_plistref *s32p, u_long cmd)
|
|
|
|
{
|
|
|
|
|
|
|
|
NETBSD32PTR32(s32p->pref_plist, p->pref_plist);
|
|
|
|
s32p->pref_len = p->pref_len;
|
|
|
|
}
|
|
|
|
|
2011-08-27 23:25:35 +04:00
|
|
|
static inline void
|
|
|
|
netbsd32_from_wdog_conf(struct wdog_conf *p, struct netbsd32_wdog_conf *s32p, u_long cmd)
|
|
|
|
{
|
|
|
|
|
|
|
|
NETBSD32PTR32(s32p->wc_names, p->wc_names);
|
|
|
|
s32p->wc_count = p->wc_count;
|
|
|
|
}
|
|
|
|
|
2011-08-30 11:06:39 +04:00
|
|
|
/* wsdisplay stuff */
|
|
|
|
static inline void
|
|
|
|
netbsd32_from_wsdisplay_addscreendata(struct wsdisplay_addscreendata *asd,
|
|
|
|
struct netbsd32_wsdisplay_addscreendata *asd32,
|
|
|
|
u_long cmd)
|
|
|
|
{
|
|
|
|
NETBSD32PTR32(asd32->screentype, asd->screentype);
|
|
|
|
NETBSD32PTR32(asd32->emul, asd->emul);
|
|
|
|
asd32->idx = asd->idx;
|
|
|
|
}
|
|
|
|
|
2011-09-28 05:46:39 +04:00
|
|
|
static inline void
|
|
|
|
netbsd32_from_wsdisplay_cursor(struct wsdisplay_cursor *c,
|
|
|
|
struct netbsd32_wsdisplay_cursor *c32,
|
|
|
|
u_long cmd)
|
|
|
|
{
|
|
|
|
c32->which = c->which;
|
|
|
|
c32->enable = c->enable;
|
|
|
|
c32->pos.x = c->pos.x;
|
|
|
|
c32->pos.y = c->pos.y;
|
|
|
|
c32->hot.x = c->hot.x;
|
|
|
|
c32->hot.y = c->hot.y;
|
|
|
|
c32->size.x = c->size.x;
|
|
|
|
c32->size.y = c->size.y;
|
|
|
|
c32->cmap.index = c->cmap.index;
|
|
|
|
c32->cmap.count = c->cmap.count;
|
|
|
|
NETBSD32PTR32(c32->cmap.red, c->cmap.red);
|
|
|
|
NETBSD32PTR32(c32->cmap.green, c->cmap.green);
|
|
|
|
NETBSD32PTR32(c32->cmap.blue, c->cmap.blue);
|
|
|
|
NETBSD32PTR32(c32->image, c->image);
|
|
|
|
NETBSD32PTR32(c32->mask, c->mask);
|
|
|
|
}
|
|
|
|
|
2011-08-30 11:54:15 +04:00
|
|
|
static inline void
|
|
|
|
netbsd32_from_ieee80211_nwkey(struct ieee80211_nwkey *nwk,
|
|
|
|
struct netbsd32_ieee80211_nwkey *nwk32,
|
|
|
|
u_long cmd)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
strncpy(nwk32->i_name, nwk->i_name, IFNAMSIZ);
|
|
|
|
nwk32->i_wepon = nwk->i_wepon;
|
|
|
|
nwk32->i_defkid = nwk->i_defkid;
|
|
|
|
for (i = 0; i < IEEE80211_WEP_NKID; i++) {
|
|
|
|
nwk32->i_key[i].i_keylen = nwk->i_key[i].i_keylen;
|
|
|
|
NETBSD32PTR32(nwk32->i_key[i].i_keydat,
|
|
|
|
nwk->i_key[i].i_keydat);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-30 18:22:22 +04:00
|
|
|
static inline void
|
|
|
|
netbsd32_from_bpf_program(struct bpf_program *p, struct netbsd32_bpf_program *s32p, u_long cmd)
|
|
|
|
{
|
|
|
|
|
|
|
|
NETBSD32PTR32(s32p->bf_insns, p->bf_insns);
|
|
|
|
s32p->bf_len = p->bf_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
netbsd32_from_bpf_dltlist(struct bpf_dltlist *p, struct netbsd32_bpf_dltlist *s32p, u_long cmd)
|
|
|
|
{
|
|
|
|
|
|
|
|
NETBSD32PTR32(s32p->bfl_list, p->bfl_list);
|
|
|
|
s32p->bfl_len = p->bfl_len;
|
|
|
|
}
|
|
|
|
|
2010-09-19 14:33:31 +04:00
|
|
|
static inline void
|
|
|
|
netbsd32_from_u_long(u_long *p, netbsd32_u_long *s32p, u_long cmd)
|
|
|
|
{
|
|
|
|
|
|
|
|
*s32p = (netbsd32_u_long)*p;
|
|
|
|
}
|
|
|
|
|
1998-08-26 14:20:33 +04:00
|
|
|
/*
|
|
|
|
* main ioctl syscall.
|
|
|
|
*
|
|
|
|
* ok, here we are in the biggy. we have to do fix ups depending
|
|
|
|
* on the ioctl command before and afterwards.
|
|
|
|
*/
|
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
netbsd32_ioctl(struct lwp *l, const struct netbsd32_ioctl_args *uap, register_t *retval)
|
1998-08-26 14:20:33 +04:00
|
|
|
{
|
2007-12-21 02:02:38 +03:00
|
|
|
/* {
|
1998-08-26 14:20:33 +04:00
|
|
|
syscallarg(int) fd;
|
1999-03-25 19:22:49 +03:00
|
|
|
syscallarg(netbsd32_u_long) com;
|
|
|
|
syscallarg(netbsd32_voidp) data;
|
2007-12-21 02:02:38 +03:00
|
|
|
} */
|
2003-01-18 11:28:25 +03:00
|
|
|
struct proc *p = l->l_proc;
|
2000-08-19 18:38:18 +04:00
|
|
|
struct file *fp;
|
|
|
|
struct filedesc *fdp;
|
|
|
|
u_long com;
|
|
|
|
int error = 0;
|
2011-01-18 22:52:23 +03:00
|
|
|
size_t size;
|
|
|
|
size_t alloc_size32, size32;
|
2007-03-04 10:54:07 +03:00
|
|
|
void *data, *memp = NULL;
|
|
|
|
void *data32, *memp32 = NULL;
|
2011-01-18 22:52:23 +03:00
|
|
|
unsigned int fd;
|
2008-03-22 00:54:58 +03:00
|
|
|
fdfile_t *ff;
|
2000-08-19 18:38:18 +04:00
|
|
|
int tmp;
|
|
|
|
#define STK_PARAMS 128
|
|
|
|
u_long stkbuf[STK_PARAMS/sizeof(u_long)];
|
|
|
|
u_long stkbuf32[STK_PARAMS/sizeof(u_long)];
|
1998-08-26 14:20:33 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* we need to translate some commands (_IOW) before calling sys_ioctl,
|
2005-02-27 01:58:54 +03:00
|
|
|
* some after (_IOR), and some both (_IOWR).
|
1998-08-26 14:20:33 +04:00
|
|
|
*/
|
1999-12-30 18:40:45 +03:00
|
|
|
#if 0
|
|
|
|
{
|
2011-01-18 22:52:23 +03:00
|
|
|
const char * const dirs[8] = {
|
|
|
|
"NONE!", "VOID", "OUT", "VOID|OUT!", "IN", "VOID|IN!",
|
|
|
|
"INOUT", "VOID|IN|OUT!"
|
|
|
|
};
|
|
|
|
|
|
|
|
printf("netbsd32_ioctl(%d, %x, %x): "
|
|
|
|
"%s group %c base %d len %d\n",
|
|
|
|
SCARG(uap, fd), SCARG(uap, com), SCARG(uap, data).i32,
|
|
|
|
dirs[((SCARG(uap, com) & IOC_DIRMASK)>>29)],
|
|
|
|
IOCGROUP(SCARG(uap, com)), IOCBASECMD(SCARG(uap, com)),
|
|
|
|
IOCPARM_LEN(SCARG(uap, com)));
|
1999-12-30 18:40:45 +03:00
|
|
|
}
|
|
|
|
#endif
|
1998-08-26 14:20:33 +04:00
|
|
|
|
2011-01-18 22:52:23 +03:00
|
|
|
memp = NULL;
|
|
|
|
memp32 = NULL;
|
|
|
|
alloc_size32 = 0;
|
|
|
|
size32 = 0;
|
|
|
|
size = 0;
|
|
|
|
|
2000-08-19 18:38:18 +04:00
|
|
|
fdp = p->p_fd;
|
2008-03-22 00:54:58 +03:00
|
|
|
fd = SCARG(uap, fd);
|
|
|
|
if ((fp = fd_getfile(fd)) == NULL)
|
2000-08-19 18:38:18 +04:00
|
|
|
return (EBADF);
|
|
|
|
if ((fp->f_flag & (FREAD | FWRITE)) == 0) {
|
|
|
|
error = EBADF;
|
|
|
|
goto out;
|
|
|
|
}
|
1998-08-26 14:20:33 +04:00
|
|
|
|
2009-05-25 01:41:25 +04:00
|
|
|
ff = fdp->fd_dt->dt_ff[SCARG(uap, fd)];
|
2000-08-19 18:38:18 +04:00
|
|
|
switch (com = SCARG(uap, com)) {
|
2008-07-02 20:45:19 +04:00
|
|
|
case FIOCLEX:
|
|
|
|
ff->ff_exclose = true;
|
|
|
|
fdp->fd_exclose = true;
|
2000-08-19 18:38:18 +04:00
|
|
|
goto out;
|
1998-08-26 14:20:33 +04:00
|
|
|
|
2008-07-02 20:45:19 +04:00
|
|
|
case FIONCLEX:
|
|
|
|
ff->ff_exclose = false;
|
2000-08-19 18:38:18 +04:00
|
|
|
goto out;
|
1998-08-26 14:20:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2000-08-19 18:38:18 +04:00
|
|
|
* Interpret high order word to find amount of data to be
|
|
|
|
* copied to/from the user's address space.
|
1998-08-26 14:20:33 +04:00
|
|
|
*/
|
2000-08-19 18:38:18 +04:00
|
|
|
size32 = IOCPARM_LEN(com);
|
2011-01-18 22:52:23 +03:00
|
|
|
alloc_size32 = size32;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The disklabel is now padded to a multiple of 8 bytes however the old
|
|
|
|
* disklabel on 32bit platforms wasn't. This leaves a difference in
|
|
|
|
* size of 4 bytes between the two but are otherwise identical.
|
|
|
|
* To deal with this, we allocate enough space for the new disklabel
|
|
|
|
* but only copyin/out the smaller amount.
|
|
|
|
*/
|
|
|
|
if (IOCGROUP(com) == 'd') {
|
|
|
|
u_long ncom = com ^ (DIOCGDINFO ^ DIOCGDINFO32);
|
|
|
|
switch (ncom) {
|
|
|
|
case DIOCGDINFO:
|
|
|
|
case DIOCWDINFO:
|
|
|
|
case DIOCSDINFO:
|
|
|
|
case DIOCGDEFLABEL:
|
|
|
|
com = ncom;
|
|
|
|
if (IOCPARM_LEN(DIOCGDINFO32) < IOCPARM_LEN(DIOCGDINFO))
|
|
|
|
alloc_size32 = IOCPARM_LEN(DIOCGDINFO);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (alloc_size32 > IOCPARM_MAX) {
|
2000-08-19 18:38:18 +04:00
|
|
|
error = ENOTTY;
|
|
|
|
goto out;
|
|
|
|
}
|
2011-01-18 22:52:23 +03:00
|
|
|
if (alloc_size32 > sizeof(stkbuf)) {
|
|
|
|
memp32 = kmem_alloc(alloc_size32, KM_SLEEP);
|
2000-08-19 18:38:18 +04:00
|
|
|
data32 = memp32;
|
|
|
|
} else
|
2007-03-04 08:59:00 +03:00
|
|
|
data32 = (void *)stkbuf32;
|
2011-01-18 22:52:23 +03:00
|
|
|
if ((com >> IOCPARM_SHIFT) == 0) {
|
|
|
|
/* UNIX-style ioctl. */
|
|
|
|
data32 = SCARG_P32(uap, data);
|
|
|
|
} else {
|
|
|
|
if (com&IOC_IN) {
|
|
|
|
if (size32) {
|
|
|
|
error = copyin(SCARG_P32(uap, data), data32,
|
|
|
|
size32);
|
|
|
|
if (error) {
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* The data between size and alloc_size has
|
|
|
|
* not been overwritten. It shouldn't matter
|
|
|
|
* but let's clear that anyway.
|
|
|
|
*/
|
|
|
|
if (__predict_false(size32 < alloc_size32)) {
|
|
|
|
memset((char *)data32+size32, 0,
|
|
|
|
alloc_size32 - size32);
|
|
|
|
}
|
|
|
|
ktrgenio(fd, UIO_WRITE, SCARG_P32(uap, data),
|
|
|
|
size32, 0);
|
|
|
|
} else
|
|
|
|
*(void **)data32 = SCARG_P32(uap, data);
|
|
|
|
} else if ((com&IOC_OUT) && size32) {
|
|
|
|
/*
|
|
|
|
* Zero the buffer so the user always
|
|
|
|
* gets back something deterministic.
|
|
|
|
*/
|
|
|
|
memset(data32, 0, alloc_size32);
|
|
|
|
} else if (com&IOC_VOID) {
|
2007-03-19 00:38:32 +03:00
|
|
|
*(void **)data32 = SCARG_P32(uap, data);
|
2011-01-18 22:52:23 +03:00
|
|
|
}
|
|
|
|
}
|
1998-08-26 14:20:33 +04:00
|
|
|
|
|
|
|
/*
|
2000-08-19 18:38:18 +04:00
|
|
|
* convert various structures, pointers, and other objects that
|
|
|
|
* change size from 32 bit -> 64 bit, for all ioctl commands.
|
1998-08-26 14:20:33 +04:00
|
|
|
*/
|
|
|
|
switch (SCARG(uap, com)) {
|
2000-08-19 18:38:18 +04:00
|
|
|
case FIONBIO:
|
2008-03-22 00:54:58 +03:00
|
|
|
mutex_enter(&fp->f_lock);
|
2000-12-05 18:25:57 +03:00
|
|
|
if ((tmp = *(int *)data32) != 0)
|
2000-08-19 18:38:18 +04:00
|
|
|
fp->f_flag |= FNONBLOCK;
|
|
|
|
else
|
|
|
|
fp->f_flag &= ~FNONBLOCK;
|
2008-03-22 00:54:58 +03:00
|
|
|
mutex_exit(&fp->f_lock);
|
|
|
|
error = (*fp->f_ops->fo_ioctl)(fp, FIONBIO, (void *)&tmp);
|
1998-08-26 14:20:33 +04:00
|
|
|
break;
|
|
|
|
|
2000-08-19 18:38:18 +04:00
|
|
|
case FIOASYNC:
|
2008-03-22 00:54:58 +03:00
|
|
|
mutex_enter(&fp->f_lock);
|
2000-12-05 18:25:57 +03:00
|
|
|
if ((tmp = *(int *)data32) != 0)
|
2000-08-19 18:38:18 +04:00
|
|
|
fp->f_flag |= FASYNC;
|
|
|
|
else
|
|
|
|
fp->f_flag &= ~FASYNC;
|
2008-03-22 00:54:58 +03:00
|
|
|
mutex_exit(&fp->f_lock);
|
|
|
|
error = (*fp->f_ops->fo_ioctl)(fp, FIOASYNC, (void *)&tmp);
|
1998-08-26 14:20:33 +04:00
|
|
|
break;
|
|
|
|
|
2010-09-19 14:33:31 +04:00
|
|
|
case AUDIO_WSEEK32:
|
|
|
|
IOCTL_CONV_TO(AUDIO_WSEEK, u_long);
|
|
|
|
|
2000-08-19 18:38:18 +04:00
|
|
|
case DIOCGPART32:
|
|
|
|
IOCTL_STRUCT_CONV_TO(DIOCGPART, partinfo);
|
2003-01-25 00:55:02 +03:00
|
|
|
#if 0 /* not implemented by anything */
|
2000-08-19 18:38:18 +04:00
|
|
|
case DIOCRFORMAT32:
|
|
|
|
IOCTL_STRUCT_CONV_TO(DIOCRFORMAT, format_op);
|
|
|
|
case DIOCWFORMAT32:
|
|
|
|
IOCTL_STRUCT_CONV_TO(DIOCWFORMAT, format_op);
|
2003-01-25 00:55:02 +03:00
|
|
|
#endif
|
2000-08-19 18:38:18 +04:00
|
|
|
|
1998-08-26 14:20:33 +04:00
|
|
|
/*
|
|
|
|
* only a few ifreq syscalls need conversion and those are
|
|
|
|
* all driver specific... XXX
|
|
|
|
*/
|
|
|
|
#if 0
|
2000-08-19 18:38:18 +04:00
|
|
|
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 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);
|
2003-04-12 09:00:38 +04:00
|
|
|
case BIOCGETIF32:
|
|
|
|
IOCTL_STRUCT_CONV_TO(BIOCGETIF, ifreq);
|
2000-08-19 18:38:18 +04:00
|
|
|
case BIOCSETIF32:
|
|
|
|
IOCTL_STRUCT_CONV_TO(BIOCSETIF, ifreq);
|
|
|
|
case SIOCPHASE132:
|
|
|
|
IOCTL_STRUCT_CONV_TO(SIOCPHASE1, ifreq);
|
|
|
|
case SIOCPHASE232:
|
|
|
|
IOCTL_STRUCT_CONV_TO(SIOCPHASE2, ifreq);
|
1998-08-26 14:20:33 +04:00
|
|
|
#endif
|
|
|
|
|
2008-06-24 03:14:42 +04:00
|
|
|
case OOSIOCGIFCONF32:
|
|
|
|
IOCTL_STRUCT_CONV_TO(OOSIOCGIFCONF, ifconf);
|
2000-08-19 18:38:18 +04:00
|
|
|
case OSIOCGIFCONF32:
|
|
|
|
IOCTL_STRUCT_CONV_TO(OSIOCGIFCONF, ifconf);
|
|
|
|
case SIOCGIFCONF32:
|
|
|
|
IOCTL_STRUCT_CONV_TO(SIOCGIFCONF, ifconf);
|
1998-08-26 14:20:33 +04:00
|
|
|
|
2004-01-15 17:36:28 +03:00
|
|
|
case SIOCGIFFLAGS32:
|
|
|
|
IOCTL_STRUCT_CONV_TO(SIOCGIFFLAGS, ifreq);
|
|
|
|
case SIOCSIFFLAGS32:
|
|
|
|
IOCTL_STRUCT_CONV_TO(SIOCSIFFLAGS, ifreq);
|
|
|
|
|
2011-02-01 03:53:22 +03:00
|
|
|
case SIOCGIFADDRPREF32:
|
|
|
|
IOCTL_STRUCT_CONV_TO(SIOCGIFADDRPREF, if_addrprefreq);
|
|
|
|
case SIOCSIFADDRPREF32:
|
|
|
|
IOCTL_STRUCT_CONV_TO(SIOCSIFADDRPREF, if_addrprefreq);
|
|
|
|
|
|
|
|
|
2009-12-09 07:50:47 +03:00
|
|
|
case OSIOCGIFFLAGS32:
|
|
|
|
IOCTL_STRUCT_CONV_TO(OSIOCGIFFLAGS, oifreq);
|
|
|
|
case OSIOCSIFFLAGS32:
|
|
|
|
IOCTL_STRUCT_CONV_TO(OSIOCSIFFLAGS, oifreq);
|
|
|
|
|
2000-08-19 18:38:18 +04:00
|
|
|
case SIOCGIFMEDIA32:
|
|
|
|
IOCTL_STRUCT_CONV_TO(SIOCGIFMEDIA, ifmediareq);
|
1998-08-26 14:20:33 +04:00
|
|
|
|
2000-08-19 18:38:18 +04:00
|
|
|
case SIOCSDRVSPEC32:
|
|
|
|
IOCTL_STRUCT_CONV_TO(SIOCSDRVSPEC, ifdrv);
|
1998-08-26 14:20:33 +04:00
|
|
|
|
2000-08-19 18:38:18 +04:00
|
|
|
case SIOCGETVIFCNT32:
|
|
|
|
IOCTL_STRUCT_CONV_TO(SIOCGETVIFCNT, sioc_vif_req);
|
1998-08-26 14:20:33 +04:00
|
|
|
|
2000-08-19 18:38:18 +04:00
|
|
|
case SIOCGETSGCNT32:
|
|
|
|
IOCTL_STRUCT_CONV_TO(SIOCGETSGCNT, sioc_sg_req);
|
|
|
|
|
2010-09-19 13:09:30 +04:00
|
|
|
case VNDIOCSET32:
|
|
|
|
IOCTL_STRUCT_CONV_TO(VNDIOCSET, vnd_ioctl);
|
|
|
|
|
|
|
|
case VNDIOCCLR32:
|
|
|
|
IOCTL_STRUCT_CONV_TO(VNDIOCCLR, vnd_ioctl);
|
|
|
|
|
|
|
|
case VNDIOCGET32:
|
|
|
|
IOCTL_STRUCT_CONV_TO(VNDIOCGET, vnd_user);
|
|
|
|
|
2010-09-19 13:46:59 +04:00
|
|
|
case VNDIOCSET5032:
|
|
|
|
IOCTL_STRUCT_CONV_TO(VNDIOCSET50, vnd_ioctl50);
|
|
|
|
|
|
|
|
case VNDIOCCLR5032:
|
|
|
|
IOCTL_STRUCT_CONV_TO(VNDIOCCLR50, vnd_ioctl50);
|
|
|
|
|
2010-09-24 17:12:53 +04:00
|
|
|
case ENVSYS_GETDICTIONARY32:
|
|
|
|
IOCTL_STRUCT_CONV_TO(ENVSYS_GETDICTIONARY, plistref);
|
|
|
|
case ENVSYS_SETDICTIONARY32:
|
|
|
|
IOCTL_STRUCT_CONV_TO(ENVSYS_SETDICTIONARY, plistref);
|
|
|
|
case ENVSYS_REMOVEPROPS32:
|
|
|
|
IOCTL_STRUCT_CONV_TO(ENVSYS_REMOVEPROPS, plistref);
|
|
|
|
|
2011-08-27 23:25:35 +04:00
|
|
|
case WDOGIOC_GWDOGS32:
|
|
|
|
IOCTL_STRUCT_CONV_TO(WDOGIOC_GWDOGS, wdog_conf);
|
|
|
|
|
2011-08-30 18:22:22 +04:00
|
|
|
case BIOCSETF32:
|
|
|
|
IOCTL_STRUCT_CONV_TO(BIOCSETF, bpf_program);
|
|
|
|
case BIOCSTCPF32:
|
|
|
|
IOCTL_STRUCT_CONV_TO(BIOCSTCPF, bpf_program);
|
|
|
|
case BIOCSUDPF32:
|
|
|
|
IOCTL_STRUCT_CONV_TO(BIOCSUDPF, bpf_program);
|
|
|
|
case BIOCGDLTLIST32:
|
|
|
|
IOCTL_STRUCT_CONV_TO(BIOCGDLTLIST, bpf_dltlist);
|
|
|
|
|
2011-08-30 11:06:39 +04:00
|
|
|
case WSDISPLAYIO_ADDSCREEN32:
|
|
|
|
IOCTL_STRUCT_CONV_TO(WSDISPLAYIO_ADDSCREEN, wsdisplay_addscreendata);
|
|
|
|
|
2011-09-28 05:46:39 +04:00
|
|
|
case WSDISPLAYIO_GCURSOR32:
|
|
|
|
IOCTL_STRUCT_CONV_TO(WSDISPLAYIO_GCURSOR, wsdisplay_cursor);
|
|
|
|
case WSDISPLAYIO_SCURSOR32:
|
|
|
|
IOCTL_STRUCT_CONV_TO(WSDISPLAYIO_SCURSOR, wsdisplay_cursor);
|
|
|
|
|
2011-08-30 11:54:15 +04:00
|
|
|
case SIOCS80211NWKEY32:
|
2011-10-06 07:19:32 +04:00
|
|
|
IOCTL_STRUCT_CONV_TO(SIOCS80211NWKEY, ieee80211_nwkey);
|
2011-10-05 18:17:41 +04:00
|
|
|
case SIOCG80211NWKEY32:
|
|
|
|
IOCTL_STRUCT_CONV_TO(SIOCG80211NWKEY, ieee80211_nwkey);
|
2011-08-30 11:54:15 +04:00
|
|
|
|
2011-09-07 06:35:00 +04:00
|
|
|
case POWER_EVENT_RECVDICT32:
|
|
|
|
IOCTL_STRUCT_CONV_TO(POWER_EVENT_RECVDICT, plistref);
|
|
|
|
|
2000-08-19 18:38:18 +04:00
|
|
|
default:
|
2002-01-03 05:29:39 +03:00
|
|
|
#ifdef NETBSD32_MD_IOCTL
|
2005-12-11 15:16:03 +03:00
|
|
|
error = netbsd32_md_ioctl(fp, com, data32, l);
|
2002-01-03 05:29:39 +03:00
|
|
|
#else
|
2008-03-22 00:54:58 +03:00
|
|
|
error = (*fp->f_ops->fo_ioctl)(fp, com, data32);
|
2002-01-03 05:29:39 +03:00
|
|
|
#endif
|
1998-08-26 14:20:33 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-09-24 14:20:16 +04:00
|
|
|
if (error == EPASSTHROUGH)
|
|
|
|
error = ENOTTY;
|
|
|
|
|
2000-08-19 18:38:18 +04:00
|
|
|
/*
|
|
|
|
* Copy any data to user, size was
|
|
|
|
* already set and checked above.
|
|
|
|
*/
|
2007-03-20 14:02:18 +03:00
|
|
|
if (error == 0 && (com&IOC_OUT) && size32) {
|
2007-03-19 00:38:32 +03:00
|
|
|
error = copyout(data32, SCARG_P32(uap, data), size32);
|
2008-03-22 00:54:58 +03:00
|
|
|
ktrgenio(fd, UIO_READ, SCARG_P32(uap, data),
|
2007-08-15 16:07:23 +04:00
|
|
|
size32, error);
|
2007-03-20 14:02:18 +03:00
|
|
|
}
|
1998-08-26 14:20:33 +04:00
|
|
|
|
2011-01-18 22:52:23 +03:00
|
|
|
out:
|
2010-04-23 19:19:19 +04:00
|
|
|
/* If we allocated data, free it here. */
|
2000-08-19 18:38:18 +04:00
|
|
|
if (memp32)
|
2011-01-18 22:52:23 +03:00
|
|
|
kmem_free(memp32, alloc_size32);
|
2000-08-19 18:38:18 +04:00
|
|
|
if (memp)
|
2011-01-22 23:51:21 +03:00
|
|
|
kmem_free(memp, size);
|
2008-03-22 00:54:58 +03:00
|
|
|
fd_putfile(fd);
|
2000-08-19 18:38:18 +04:00
|
|
|
return (error);
|
1998-08-26 14:20:33 +04:00
|
|
|
}
|