linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Support for 32 bit iwpriv on 64 bits kernels
@ 2016-06-02 15:21 Dibyajyoti Ghosh
  2016-06-02 15:36 ` Johannes Berg
  0 siblings, 1 reply; 3+ messages in thread
From: Dibyajyoti Ghosh @ 2016-06-02 15:21 UTC (permalink / raw)
  To: Johannes Berg
  Cc: WiFi Mailing List, Dibyajyoti Ghosh, Ujjal Roy, Prasun Maiti

This patch adds pointer conversion from 32 bit to 64 bit and vice versa,
if the ioctl is issued from 32 bit iwpriv to 64 bit Kernel.

Signed-off-by: Dibyajyoti Ghosh <dibyajyotig@gmail.com>
---
 wireless_tools.29/iwpriv.c | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/wireless_tools.29/iwpriv.c b/wireless_tools.29/iwpriv.c
index 4172fe2..a0b1b02 100644
--- a/wireless_tools.29/iwpriv.c
+++ b/wireless_tools.29/iwpriv.c
@@ -243,6 +243,7 @@ iw_usage(void)
   fprintf(stderr, "Usage: iwpriv interface [private-command [private-arguments]]\n");
 }
 
+#include<stdio.h>
 /************************* SETTING ROUTINES **************************/
 
 /*------------------------------------------------------------------*/
@@ -259,12 +260,20 @@ set_private_cmd(int		skfd,		/* Socket */
 		int		priv_num)	/* Number of descriptions */
 {
   struct iwreq	wrq;
+  struct compat_iw_point {
+    __u64 pointer;
+    __u16 length;
+    __u16 flags;
+  };
   u_char	buffer[4096];	/* Only that big in v25 and later */
   int		i = 0;		/* Start with first command arg */
   int		k;		/* Index in private description table */
   int		temp;
   int		subcmd = 0;	/* sub-ioctl index */
   int		offset = 0;	/* Space for sub-ioctl index */
+  FILE		*in;
+  char 		buff[4];
+  int		kspace, uspace;
 
   /* Check if we have a token index.
    * Do it now so that sub-ioctl takes precedence, and so that we
@@ -457,6 +466,26 @@ set_private_cmd(int		skfd,		/* Socket */
 	}
     }
 
+  in = popen("getconf LONG_BIT", "r");
+  fgets(buff, sizeof(buff), in);
+  pclose(in);
+  kspace = atoi(buff);
+  uspace = sizeof(char *) * 8;
+
+  struct compat_iw_point *iwp_compat = (struct compat_iw_point *)&wrq.u.data;
+  __u16 len = wrq.u.data.length;
+  __u16 flags = wrq.u.data.flags;
+
+  /* If 32 bit app is running on 64 bit kernel
+   * convert 32 bit iw_point type payload to 64 bit
+   */
+  if(uspace == 32 && kspace == 64)
+    {
+      iwp_compat->pointer = (__u64)((__u32)wrq.u.data.pointer);
+      iwp_compat->length = len;
+      iwp_compat->flags = flags;
+    }
+
   /* Perform the private ioctl */
   if(ioctl(skfd, priv[k].cmd, &wrq) < 0)
     {
@@ -465,6 +494,18 @@ set_private_cmd(int		skfd,		/* Socket */
       return(-1);
     }
 
+  /* If 32 bit app is running on 64 bit kernel, convert the
+   * 64 bit result back to 32 bit to fit the app
+   */
+  if(uspace == 32 && kspace == 64)
+    {
+      flags = iwp_compat->flags;
+      len = iwp_compat->length;
+      wrq.u.data.pointer = (__u32)iwp_compat->pointer;
+      wrq.u.data.length = iwp_compat->length;
+      wrq.u.data.flags = iwp_compat->flags;
+    }
+
   /* If we have to get some data */
   if((priv[k].get_args & IW_PRIV_TYPE_MASK) &&
      (priv[k].get_args & IW_PRIV_SIZE_MASK))
-- 
1.9.1


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

end of thread, other threads:[~2016-06-03  7:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-02 15:21 [PATCH] Support for 32 bit iwpriv on 64 bits kernels Dibyajyoti Ghosh
2016-06-02 15:36 ` Johannes Berg
2016-06-03  7:31   ` Dibyajyoti Ghosh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).