qemu-e2k/linux-user
Laurent Vivier 059c2f2cd7 linux-user: convert ioctl(SIOCGIFCONF, ...) result.
The result needs to be converted as it is stored in an array of struct
ifreq and sizeof(struct ifreq) differs according to target and host
alignment rules.

This patch allows to execute correctly the following program on arm
and m68k:

 #include <stdio.h>
 #include <sys/ioctl.h>
 #include <net/if.h>
 #include <alloca.h>
 #include <string.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>

int main(void)
{
    int s, ret;
    struct ifconf ifc;
    int i;

    memset( &ifc, 0, sizeof( struct ifconf ) );
    ifc.ifc_len = 8 * sizeof(struct ifreq);
    ifc.ifc_buf = alloca(ifc.ifc_len);

    s = socket( AF_INET, SOCK_DGRAM, 0 );
    if (s < 0) {
        perror("Cannot open socket");
        return 1;
    }
    ret = ioctl( s, SIOCGIFCONF, &ifc );
    if (s < 0) {
        perror("ioctl() failed");
        return 1;
    }

    for (i = 0; i < ifc.ifc_len / sizeof(struct ifreq) ; i ++) {
        struct sockaddr_in *s;
        s = (struct sockaddr_in*)&ifc.ifc_req[i].ifr_addr;
        printf("%s\n", ifc.ifc_req[i].ifr_name);
        printf("%s\n", inet_ntoa(s->sin_addr));
    }
}

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2011-04-26 10:15:40 +03:00
..
alpha
arm linux-user/arm/nwfpe: rename REG_PC to ARM_REG_PC 2011-04-25 22:15:31 +02:00
cris
i386
m68k
microblaze
mips
mips64
mipsn32
ppc
sh4
sparc
sparc64
unicore32
x86_64
cpu-uname.c
cpu-uname.h
elfload.c unicore32: necessary modifications for other files to support unicore32 2011-04-12 18:49:05 +00:00
errno_defs.h
flat.h
flatload.c
ioctls.h linux-user: convert ioctl(SIOCGIFCONF, ...) result. 2011-04-26 10:15:40 +03:00
linux_loop.h
linuxload.c
m68k-sim.c
main.c unicore32: necessary modifications for other files to support unicore32 2011-04-12 18:49:05 +00:00
mmap.c
qemu-types.h
qemu.h unicore32: necessary modifications for other files to support unicore32 2011-04-12 18:49:05 +00:00
signal.c
socket.h
strace.c linux-user: improve traces 2011-04-26 10:15:40 +03:00
strace.list linux-user: improve traces 2011-04-26 10:15:40 +03:00
syscall_defs.h unicore32: necessary modifications for other files to support unicore32 2011-04-12 18:49:05 +00:00
syscall_types.h
syscall.c linux-user: convert ioctl(SIOCGIFCONF, ...) result. 2011-04-26 10:15:40 +03:00
target_flat.h
uaccess.c
vm86.c