From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=40321 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q4iRp-0007IX-21 for qemu-devel@nongnu.org; Tue, 29 Mar 2011 19:35:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q4iRn-0002ke-H6 for qemu-devel@nongnu.org; Tue, 29 Mar 2011 19:35:40 -0400 Received: from smtp6-g21.free.fr ([212.27.42.6]:52947) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q4iRm-0002jm-R3 for qemu-devel@nongnu.org; Tue, 29 Mar 2011 19:35:39 -0400 From: Laurent Vivier Date: Wed, 30 Mar 2011 01:35:23 +0200 Message-Id: <1301441723-19926-1-git-send-email-laurent@vivier.eu> Subject: [Qemu-devel] [PATCH] linux-user: add ioctl(SIOCGIWNAME, ...) support. List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Riku Voipio , Laurent Vivier Allow to run properly following program from linux-user: /* cc -o wifi wifi.c */ #include #include #include #include #include #include #include #include int main(int argc, char **argv) { int ret; struct ifreq req; struct sockaddr_in *addr; int s; if (argc != 2) { fprintf(stderr, "Need an interface name (like wlan0)\n"); return 1; } s = socket( AF_INET, SOCK_DGRAM, 0 ); if (s < 0) { perror("Cannot open socket"); return 1; } strncpy(req.ifr_name, argv[1], sizeof(req.ifr_name)); ret = ioctl( s, SIOCGIWNAME, &req ); if (ret < 0) { fprintf(stderr, "No wireless extension\n"); return 1; } printf("%s\n", req.ifr_name); printf("%s\n", req.ifr_newname); return 0; } $ ./wifi eth0 No wireless extension $ ./wifi wlan0 wlan0 IEEE 802.11bg Signed-off-by: Laurent Vivier --- linux-user/ioctls.h | 1 + linux-user/syscall.c | 2 +- linux-user/syscall_defs.h | 3 +++ 3 files changed, 5 insertions(+), 1 deletions(-) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index ab15b86..42b3ae3 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -122,6 +122,7 @@ IOCTL(SIOCDRARP, IOC_W, MK_PTR(MK_STRUCT(STRUCT_arpreq))) IOCTL(SIOCSRARP, IOC_W, MK_PTR(MK_STRUCT(STRUCT_arpreq))) IOCTL(SIOCGRARP, IOC_R, MK_PTR(MK_STRUCT(STRUCT_arpreq))) + IOCTL(SIOCGIWNAME, IOC_W | IOC_R, MK_PTR(MK_STRUCT(STRUCT_char_ifreq))) IOCTL(CDROMPAUSE, 0, TYPE_NULL) IOCTL(CDROMSTART, 0, TYPE_NULL) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index ce375e7..c24776e 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -59,7 +59,7 @@ int __clone2(int (*fn)(void *), void *child_stack_base, //#include #include #include -#include +#include #include #ifdef TARGET_GPROF #include diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 702652c..8ee59f9 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -762,6 +762,9 @@ struct target_pollfd { #define TARGET_SIOCADDDLCI 0x8980 /* Create new DLCI device */ #define TARGET_SIOCDELDLCI 0x8981 /* Delete DLCI device */ +/* From */ + +#define TARGET_SIOCGIWNAME 0x8B01 /* get name == wireless protocol */ /* From */ -- 1.7.1