All of lore.kernel.org
 help / color / mirror / Atom feed
* wireless ioctl compat
@ 2004-01-08  5:25 Clint Adams
  2004-01-08 14:12 ` Clint Adams
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Clint Adams @ 2004-01-08  5:25 UTC (permalink / raw)
  To: ultralinux

32-bit wireless tools don't currently work on sparc64.  With the
following patch, some of the ioctls work.
SIOCSIWESSID and SIOCGIWESSID do not; the latter results in a buffer
size error.

I have very little idea what I'm doing and don't know how to fix that.

--- linux-2.6.0/arch/sparc64/kernel/ioctl32.c	2003-12-17 21:59:36.000000000 -0500
+++ wioctl/arch/sparc64/kernel/ioctl32.c	2004-01-07 23:28:56.000000000 -0500
@@ -20,6 +20,7 @@
 #include <asm/openpromio.h>
 #include <asm/audioio.h>
 #include <asm/watchdog.h>
+#include <linux/wireless.h>
 
 /* Use this to get at 32-bit user passed pointers. 
  * See sys_sparc32.c for description about it.
@@ -1144,6 +1145,49 @@
 COMPATIBLE_IOCTL(DM_TARGET_STATUS)
 COMPATIBLE_IOCTL(DM_TARGET_WAIT)
 #endif
+
+/* wireless */
+COMPATIBLE_IOCTL(SIOCSIWCOMMIT)
+COMPATIBLE_IOCTL(SIOCGIWNAME)
+COMPATIBLE_IOCTL(SIOCSIWNWID)
+COMPATIBLE_IOCTL(SIOCGIWNWID)
+COMPATIBLE_IOCTL(SIOCSIWFREQ)
+COMPATIBLE_IOCTL(SIOCGIWFREQ)
+COMPATIBLE_IOCTL(SIOCSIWMODE)
+COMPATIBLE_IOCTL(SIOCGIWMODE)
+COMPATIBLE_IOCTL(SIOCSIWSENS)
+COMPATIBLE_IOCTL(SIOCGIWSENS)
+COMPATIBLE_IOCTL(SIOCGIWRANGE)
+COMPATIBLE_IOCTL(SIOCGIWPRIV)
+COMPATIBLE_IOCTL(SIOCGIWSTATS)
+COMPATIBLE_IOCTL(SIOCSIWSPY)
+COMPATIBLE_IOCTL(SIOCGIWSPY)
+COMPATIBLE_IOCTL(SIOCSIWTHRSPY)
+COMPATIBLE_IOCTL(SIOCGIWTHRSPY)
+COMPATIBLE_IOCTL(SIOCSIWAP)
+COMPATIBLE_IOCTL(SIOCGIWAP)
+COMPATIBLE_IOCTL(SIOCGIWAPLIST)
+COMPATIBLE_IOCTL(SIOCSIWSCAN)
+COMPATIBLE_IOCTL(SIOCGIWSCAN)
+COMPATIBLE_IOCTL(SIOCSIWESSID)
+COMPATIBLE_IOCTL(SIOCGIWESSID)
+COMPATIBLE_IOCTL(SIOCSIWNICKN)
+COMPATIBLE_IOCTL(SIOCGIWNICKN)
+COMPATIBLE_IOCTL(SIOCSIWRATE)
+COMPATIBLE_IOCTL(SIOCGIWRATE)
+COMPATIBLE_IOCTL(SIOCSIWRTS)
+COMPATIBLE_IOCTL(SIOCGIWRTS)
+COMPATIBLE_IOCTL(SIOCSIWFRAG)
+COMPATIBLE_IOCTL(SIOCGIWFRAG)
+COMPATIBLE_IOCTL(SIOCSIWTXPOW)
+COMPATIBLE_IOCTL(SIOCGIWTXPOW)
+COMPATIBLE_IOCTL(SIOCSIWRETRY)
+COMPATIBLE_IOCTL(SIOCGIWRETRY)
+COMPATIBLE_IOCTL(SIOCSIWENCODE)
+COMPATIBLE_IOCTL(SIOCGIWENCODE)
+COMPATIBLE_IOCTL(SIOCSIWPOWER)
+COMPATIBLE_IOCTL(SIOCGIWPOWER)
+
 /* And these ioctls need translation */
 /* NCPFS */
 HANDLE_IOCTL(NCP_IOC_NCPREQUEST_32, do_ncp_ncprequest)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: wireless ioctl compat
  2004-01-08  5:25 wireless ioctl compat Clint Adams
@ 2004-01-08 14:12 ` Clint Adams
  2004-01-13 23:42 ` David S. Miller
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Clint Adams @ 2004-01-08 14:12 UTC (permalink / raw)
  To: ultralinux

> 32-bit wireless tools don't currently work on sparc64.  With the
> following patch, some of the ioctls work.
> SIOCSIWESSID and SIOCGIWESSID do not; the latter results in a buffer
> size error.

This is my second attempt; it has the same problem.  Can anyone help?

--- 2.6.1-rc2/arch/sparc64/kernel/ioctl32.c	2003-12-17 21:59:36.000000000 -0500
+++ wioctl/arch/sparc64/kernel/ioctl32.c	2004-01-08 01:44:39.956489369 -0500
@@ -20,6 +20,7 @@
 #include <asm/openpromio.h>
 #include <asm/audioio.h>
 #include <asm/watchdog.h>
+#include <linux/wireless.h>
 
 /* Use this to get at 32-bit user passed pointers. 
  * See sys_sparc32.c for description about it.
@@ -1144,6 +1145,47 @@
 COMPATIBLE_IOCTL(DM_TARGET_STATUS)
 COMPATIBLE_IOCTL(DM_TARGET_WAIT)
 #endif
+
+/* wireless */
+COMPATIBLE_IOCTL(SIOCSIWCOMMIT)
+COMPATIBLE_IOCTL(SIOCGIWNAME)
+COMPATIBLE_IOCTL(SIOCSIWNWID)
+COMPATIBLE_IOCTL(SIOCGIWNWID)
+COMPATIBLE_IOCTL(SIOCSIWFREQ)
+COMPATIBLE_IOCTL(SIOCGIWFREQ)
+COMPATIBLE_IOCTL(SIOCSIWMODE)
+COMPATIBLE_IOCTL(SIOCGIWMODE)
+COMPATIBLE_IOCTL(SIOCSIWSENS)
+COMPATIBLE_IOCTL(SIOCGIWSENS)
+COMPATIBLE_IOCTL(SIOCGIWRANGE)
+COMPATIBLE_IOCTL(SIOCGIWPRIV)
+COMPATIBLE_IOCTL(SIOCGIWSTATS)
+COMPATIBLE_IOCTL(SIOCSIWSPY)
+COMPATIBLE_IOCTL(SIOCGIWSPY)
+COMPATIBLE_IOCTL(SIOCSIWTHRSPY)
+COMPATIBLE_IOCTL(SIOCGIWTHRSPY)
+COMPATIBLE_IOCTL(SIOCSIWAP)
+COMPATIBLE_IOCTL(SIOCGIWAP)
+COMPATIBLE_IOCTL(SIOCGIWAPLIST)
+COMPATIBLE_IOCTL(SIOCSIWSCAN)
+COMPATIBLE_IOCTL(SIOCGIWSCAN)
+COMPATIBLE_IOCTL(SIOCSIWNICKN)
+COMPATIBLE_IOCTL(SIOCGIWNICKN)
+COMPATIBLE_IOCTL(SIOCSIWRATE)
+COMPATIBLE_IOCTL(SIOCGIWRATE)
+COMPATIBLE_IOCTL(SIOCSIWRTS)
+COMPATIBLE_IOCTL(SIOCGIWRTS)
+COMPATIBLE_IOCTL(SIOCSIWFRAG)
+COMPATIBLE_IOCTL(SIOCGIWFRAG)
+COMPATIBLE_IOCTL(SIOCSIWTXPOW)
+COMPATIBLE_IOCTL(SIOCGIWTXPOW)
+COMPATIBLE_IOCTL(SIOCSIWRETRY)
+COMPATIBLE_IOCTL(SIOCGIWRETRY)
+COMPATIBLE_IOCTL(SIOCSIWENCODE)
+COMPATIBLE_IOCTL(SIOCGIWENCODE)
+COMPATIBLE_IOCTL(SIOCSIWPOWER)
+COMPATIBLE_IOCTL(SIOCGIWPOWER)
+
 /* And these ioctls need translation */
 /* NCPFS */
 HANDLE_IOCTL(NCP_IOC_NCPREQUEST_32, do_ncp_ncprequest)
diff -ur 2.6.1-rc2/fs/compat_ioctl.c wioctl/fs/compat_ioctl.c
--- 2.6.1-rc2/fs/compat_ioctl.c	2004-01-08 01:54:38.605875378 -0500
+++ wioctl/fs/compat_ioctl.c	2004-01-08 01:53:28.327517520 -0500
@@ -65,6 +65,7 @@
 #include <linux/ncp_fs.h>
 #include <linux/i2c.h>
 #include <linux/i2c-dev.h>
+#include <linux/wireless.h>
 
 #include <net/sock.h>          /* siocdevprivate_ioctl */
 #include <net/bluetooth/bluetooth.h>
@@ -2970,6 +2971,94 @@
 	return sys_ioctl(fd, cmd, (unsigned long)tdata);
 }
 
+struct  iw_point32
+{
+  compat_caddr_t       pointer;      /* Pointer to the data  (in user space) */
+  __u16         length;         /* number of fields or size in bytes */
+  __u16         flags;          /* Optional params */
+};
+
+union   iwreq_data32
+{
+        /* Config - generic */
+        char            name[IFNAMSIZ];
+        /* Name : used to verify the presence of  wireless extensions.
+         * Name of the protocol/provider... */
+
+        struct iw_point32 essid;          /* Extended network name */
+        struct iw_param nwid;           /* network id (or domain - the cell) */
+        struct iw_freq  freq;           /* frequency or channel :
+                                         * 0-1000 = channel
+                                         * > 1000 = frequency in Hz */
+
+        struct iw_param sens;           /* signal level threshold */
+        struct iw_param bitrate;        /* default bit rate */
+        struct iw_param txpower;        /* default transmit power */
+        struct iw_param rts;            /* RTS threshold threshold */
+        struct iw_param frag;           /* Fragmentation threshold */
+        __u32           mode;           /* Operation mode */
+        struct iw_param retry;          /* Retry limits & lifetime */
+
+        struct iw_point32 encoding;       /* Encoding stuff : tokens */
+        struct iw_param power;          /* PM duration/timeout */
+        struct iw_quality qual;         /* Quality part of statistics */
+
+        struct sockaddr ap_addr;        /* Access point address */
+        struct sockaddr addr;           /* Destination address (hw/mac) */
+
+        struct iw_param param;          /* Other small parameters */
+        struct iw_point32 data;           /* Other large parameters */
+};
+
+struct iwreq32
+{
+        union
+        {
+                char    ifrn_name[IFNAMSIZ];    /* if name, e.g. "eth0" */
+        } ifr_ifrn;
+
+        /* Data part (defined just above) */
+        union   iwreq_data32    u;
+};
+
+static int do_wireless_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
+{
+	struct iwreq kiwr;
+	struct iwreq *uiwr;
+	struct iwreq32 *iwr32 = (struct iwreq32 *) arg;
+	mm_segment_t old_fs;
+	u32 data;
+	void *datap;
+        int err;
+
+	switch (cmd) {
+	case SIOCSIWESSID:
+		if (copy_from_user(&kiwr, iwr32, sizeof(struct iwreq32)))
+			return -EFAULT;
+
+		old_fs = get_fs();
+		set_fs (KERNEL_DS);
+		err = sys_ioctl (fd, cmd, (unsigned long)&kiwr);
+		set_fs (old_fs);
+
+		return err;
+	case SIOCGIWESSID:
+		uiwr = compat_alloc_user_space(sizeof(*uiwr));
+		if (copy_in_user(&uiwr->ifr_ifrn.ifrn_name, &iwr32->ifr_ifrn.ifrn_name, IFNAMSIZ))
+			return -EFAULT;
+
+		if (get_user(data, &iwr32->u.essid.pointer))
+			return -EFAULT;
+
+		datap = compat_ptr(data);
+		if (put_user(datap, &uiwr->u.essid.pointer))
+			return -EFAULT;
+
+		return sys_ioctl (fd, cmd, (unsigned long)uiwr);
+	default:
+		return -EINVAL;
+	}
+}
 
 #undef CODE
 #endif
@@ -3134,5 +3223,8 @@
 HANDLE_IOCTL(I2C_RDWR, do_i2c_rdwr_ioctl)
 HANDLE_IOCTL(I2C_SMBUS, do_i2c_smbus_ioctl)
 
+HANDLE_IOCTL(SIOCSIWESSID, do_wireless_ioctl)
+HANDLE_IOCTL(SIOCGIWESSID, do_wireless_ioctl)
+
 #undef DECLARES
 #endif

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: wireless ioctl compat
  2004-01-08  5:25 wireless ioctl compat Clint Adams
  2004-01-08 14:12 ` Clint Adams
@ 2004-01-13 23:42 ` David S. Miller
  2004-01-14 16:14 ` Clint Adams
  2004-01-14 19:39 ` David S. Miller
  3 siblings, 0 replies; 5+ messages in thread
From: David S. Miller @ 2004-01-13 23:42 UTC (permalink / raw)
  To: ultralinux

On Thu, 8 Jan 2004 09:12:49 -0500
Clint Adams <schizo@debian.org> wrote:

> > 32-bit wireless tools don't currently work on sparc64.  With the
> > following patch, some of the ioctls work.
> > SIOCSIWESSID and SIOCGIWESSID do not; the latter results in a buffer
> > size error.
> 
> This is my second attempt; it has the same problem.  Can anyone help?

Give this a try.

=== fs/compat_ioctl.c 1.13 vs edited ==--- 1.13/fs/compat_ioctl.c	Mon Dec 29 13:37:42 2003
+++ edited/fs/compat_ioctl.c	Tue Jan 13 15:44:23 2004
@@ -65,6 +65,7 @@
 #include <linux/ncp_fs.h>
 #include <linux/i2c.h>
 #include <linux/i2c-dev.h>
+#include <linux/wireless.h>
 
 #include <net/sock.h>          /* siocdevprivate_ioctl */
 #include <net/bluetooth/bluetooth.h>
@@ -2970,6 +2971,48 @@
 	return sys_ioctl(fd, cmd, (unsigned long)tdata);
 }
 
+struct compat_iw_point {
+	compat_caddr_t pointer;
+	__u16 length;
+	__u16 flags;
+};
+
+static int do_wireless_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
+{
+	struct iwreq *iwr, *iwr_u;
+	struct iw_point *iwp;
+	struct compat_iw_point *iwp_u;
+	compat_caddr_t pointer;
+	__u16 length, flags;
+
+	iwr_u = (struct iwreq *) compat_ptr(arg);
+	iwp_u = (struct compat_iw_point *) &iwr_u->u.data;
+	iwr = compat_alloc_user_space(sizeof(*iwr));
+	if (iwr = NULL)
+		return -ENOMEM;
+
+	iwp = &iwr->u.data;
+
+	if (verify_area(VERIFY_WRITE, iwr, sizeof(*iwr)))
+		return -EFAULT;
+
+	if (__copy_in_user(&iwr->ifr_ifrn.ifrn_name[0],
+			   &iwr_u->ifr_ifrn.ifrn_name[0],
+			   sizeof(iwr->ifr_ifrn.ifrn_name)))
+		return -EFAULT;
+
+	if (__get_user(pointer, &iwp_u->pointer) ||
+	    __get_user(length, &iwp_u->length) ||
+	    __get_user(flags, &iwp_u->flags))
+		return -EFAULT;
+
+	if (__put_user(compat_ptr(pointer), &iwp->pointer) ||
+	    __put_user(length, &iwp->length) ||
+	    __put_user(flags, &iwp->flags))
+		return -EFAULT;
+
+	return sys_ioctl(fd, cmd, (unsigned long) iwr);
+}
 
 #undef CODE
 #endif
@@ -3133,6 +3176,20 @@
 HANDLE_IOCTL(I2C_FUNCS, w_long)
 HANDLE_IOCTL(I2C_RDWR, do_i2c_rdwr_ioctl)
 HANDLE_IOCTL(I2C_SMBUS, do_i2c_smbus_ioctl)
+/* wireless */
+HANDLE_IOCTL(SIOCGIWRANGE, do_wireless_ioctl)
+HANDLE_IOCTL(SIOCSIWSPY, do_wireless_ioctl)
+HANDLE_IOCTL(SIOCGIWSPY, do_wireless_ioctl)
+HANDLE_IOCTL(SIOCSIWTHRSPY, do_wireless_ioctl)
+HANDLE_IOCTL(SIOCGIWTHRSPY, do_wireless_ioctl)
+HANDLE_IOCTL(SIOCGIWAPLIST, do_wireless_ioctl)
+HANDLE_IOCTL(SIOCGIWSCAN, do_wireless_ioctl)
+HANDLE_IOCTL(SIOCSIWESSID, do_wireless_ioctl)
+HANDLE_IOCTL(SIOCGIWESSID, do_wireless_ioctl)
+HANDLE_IOCTL(SIOCSIWNICKN, do_wireless_ioctl)
+HANDLE_IOCTL(SIOCGIWNICKN, do_wireless_ioctl)
+HANDLE_IOCTL(SIOCSIWENCODE, do_wireless_ioctl)
+HANDLE_IOCTL(SIOCGIWENCODE, do_wireless_ioctl)
 
 #undef DECLARES
 #endif
=== include/linux/compat_ioctl.h 1.12 vs edited ==--- 1.12/include/linux/compat_ioctl.h	Tue Jan 13 15:04:20 2004
+++ edited/include/linux/compat_ioctl.h	Tue Jan 13 15:44:46 2004
@@ -686,3 +686,34 @@
 COMPATIBLE_IOCTL(I2C_PEC)
 COMPATIBLE_IOCTL(I2C_RETRIES)
 COMPATIBLE_IOCTL(I2C_TIMEOUT)
+/* wireless */
+COMPATIBLE_IOCTL(SIOCSIWCOMMIT)
+COMPATIBLE_IOCTL(SIOCGIWNAME)
+COMPATIBLE_IOCTL(SIOCSIWNWID)
+COMPATIBLE_IOCTL(SIOCGIWNWID)
+COMPATIBLE_IOCTL(SIOCSIWFREQ)
+COMPATIBLE_IOCTL(SIOCGIWFREQ)
+COMPATIBLE_IOCTL(SIOCSIWMODE)
+COMPATIBLE_IOCTL(SIOCGIWMODE)
+COMPATIBLE_IOCTL(SIOCSIWSENS)
+COMPATIBLE_IOCTL(SIOCGIWSENS)
+COMPATIBLE_IOCTL(SIOCSIWRANGE)
+COMPATIBLE_IOCTL(SIOCSIWPRIV)
+COMPATIBLE_IOCTL(SIOCGIWPRIV)
+COMPATIBLE_IOCTL(SIOCSIWSTATS)
+COMPATIBLE_IOCTL(SIOCGIWSTATS)
+COMPATIBLE_IOCTL(SIOCSIWAP)
+COMPATIBLE_IOCTL(SIOCGIWAP)
+COMPATIBLE_IOCTL(SIOCSIWSCAN)
+COMPATIBLE_IOCTL(SIOCSIWRATE)
+COMPATIBLE_IOCTL(SIOCGIWRATE)
+COMPATIBLE_IOCTL(SIOCSIWRTS)
+COMPATIBLE_IOCTL(SIOCGIWRTS)
+COMPATIBLE_IOCTL(SIOCSIWFRAG)
+COMPATIBLE_IOCTL(SIOCGIWFRAG)
+COMPATIBLE_IOCTL(SIOCSIWTXPOW)
+COMPATIBLE_IOCTL(SIOCGIWTXPOW)
+COMPATIBLE_IOCTL(SIOCSIWRETRY)
+COMPATIBLE_IOCTL(SIOCGIWRETRY)
+COMPATIBLE_IOCTL(SIOCSIWPOWER)
+COMPATIBLE_IOCTL(SIOCGIWPOWER)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: wireless ioctl compat
  2004-01-08  5:25 wireless ioctl compat Clint Adams
  2004-01-08 14:12 ` Clint Adams
  2004-01-13 23:42 ` David S. Miller
@ 2004-01-14 16:14 ` Clint Adams
  2004-01-14 19:39 ` David S. Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Clint Adams @ 2004-01-14 16:14 UTC (permalink / raw)
  To: ultralinux

> Give this a try.

Thanks.  What I have observed thus far is that
a) 32-bit iwconfig segfaults (in memcpy) unless run under strace,
   in which case it seems to function normally.
b) 32-bit SIOCSIWESSID works, but 32-bit SIOCGIWESSID does not.

Any ideas?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: wireless ioctl compat
  2004-01-08  5:25 wireless ioctl compat Clint Adams
                   ` (2 preceding siblings ...)
  2004-01-14 16:14 ` Clint Adams
@ 2004-01-14 19:39 ` David S. Miller
  3 siblings, 0 replies; 5+ messages in thread
From: David S. Miller @ 2004-01-14 19:39 UTC (permalink / raw)
  To: ultralinux

On Wed, 14 Jan 2004 11:14:19 -0500
Clint Adams <schizo@debian.org> wrote:

> > Give this a try.
> 
> Thanks.  What I have observed thus far is that
> a) 32-bit iwconfig segfaults (in memcpy) unless run under strace,
>    in which case it seems to function normally.
> b) 32-bit SIOCSIWESSID works, but 32-bit SIOCGIWESSID does not.
> 
> Any ideas?

I'll look into it later today, thanks for the report.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-01-14 19:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-08  5:25 wireless ioctl compat Clint Adams
2004-01-08 14:12 ` Clint Adams
2004-01-13 23:42 ` David S. Miller
2004-01-14 16:14 ` Clint Adams
2004-01-14 19:39 ` David S. Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.