From: Dibyajyoti Ghosh <dibyajyotig@gmail.com>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: WiFi Mailing List <linux-wireless@vger.kernel.org>,
Dibyajyoti Ghosh <dibyajyotig@gmail.com>,
Ujjal Roy <royujjal@gmail.com>,
Prasun Maiti <prasunmaiti87@gmail.com>
Subject: [PATCH] Support for 32 bit iwpriv on 64 bits kernels
Date: Thu, 2 Jun 2016 20:51:43 +0530 [thread overview]
Message-ID: <1464880903-13116-1-git-send-email-dibyajyotig@gmail.com> (raw)
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
next reply other threads:[~2016-06-02 15:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-02 15:21 Dibyajyoti Ghosh [this message]
2016-06-02 15:36 ` [PATCH] Support for 32 bit iwpriv on 64 bits kernels Johannes Berg
2016-06-03 7:31 ` Dibyajyoti Ghosh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1464880903-13116-1-git-send-email-dibyajyotig@gmail.com \
--to=dibyajyotig@gmail.com \
--cc=johannes@sipsolutions.net \
--cc=linux-wireless@vger.kernel.org \
--cc=prasunmaiti87@gmail.com \
--cc=royujjal@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).