aboutsummaryrefslogtreecommitdiffstats
path: root/linux-user/syscall.c
AgeCommit message (Collapse)AuthorFilesLines
2012-02-10linux-user: brk() debuggingPaul Brook1-7/+9
Fix format type mismatches in do_brk debug printfs. Signed-off-by: Paul Brook <paul@codesourcery.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2012-02-10linux-user: fail execve() if env/args too bigUlrich Hecht1-0/+9
If the host's page size is equal to or smaller than the target's, native execve() will fail appropriately with E2BIG if called with too big an environment for the target to handle. It may falsely succeed, however, if the host's page size is bigger, and feed the executed target process an environment that is too big for it to handle, at which point QEMU barfs and exits, confusing procmail's autoconf script and causing the build to fail. This patch makes sure that execve() will return E2BIG if the environment is too large for the target. Signed-off-by: Ulrich Hecht <uli@suse.de> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2012-02-02linux-user: Implement *listxattr syscallsPeter Maydell1-1/+35
Implement listxattr, flistxattr and llistxattr syscalls. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2012-02-02linux-user/syscall.c: Implement f and l versions of set/get/removexattrPeter Maydell1-9/+70
Implement the f and l versions (operate on fd, don't follow links) of the setxattr, getxattr and removexattr syscalls. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2012-02-02linux-user: Allow NULL value pointer in setxattr and getxattrPeter Maydell1-6/+18
It's valid to pass a NULL value pointer to setxattr, so don't fail this case EFAULT. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2012-02-02linux-user: fix wait* syscall status returnsAlexander Graf1-2/+2
When calling wait4 or waitpid with a status pointer and WNOHANG, the syscall can potentially not modify the status pointer input. Now if we have guest code like: int status = 0; waitpid(pid, &status, WNOHANG); if (status) <breakage> then we have to make sure that in case status did not change we actually return the guest's initialized status variable instead of our own uninitialized. We fail to do so today, as we proxy everything through an uninitialized status variable which for me ended up always containing the last error code. This patch fixes some test cases when building yast2-core in OBS for ARM. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2012-02-02linux-user: fix QEMU_STRACE=1 segfaultAlexander Graf1-0/+3
While debugging some issues with QEMU_STRACE I stumbled over segmentation faults that were pretty reproducible. Turns out we tried to treat a normal return value as errno, resulting in an access over array boundaries for the resolution. Fix this by allowing failure to resolve invalid errnos into strings. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2012-02-02linux-user: add SO_PEERCRED support for getsockoptAkos PASZTORY1-1/+33
Signed-off-by: Akos PASZTORY <akos.pasztory@gmail.com> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2012-02-02linux-user: fake /proc/self/auxvAlexander Graf1-0/+30
Gtk tries to read /proc/self/auxv to find its auxv table instead of taking it from its own program memory space. However, when running with linux-user, we see the host's auxv which clearly exposes wrong information. so let's instead expose the guest memory backed auxv tables via /proc/self/auxv as well. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2012-02-02linux-user: fake /proc/self/statAlexander Graf1-0/+26
The boehm gc finds the program's stack starting pointer by checking /proc/self/stat. Unfortunately, so far it reads qemu's stack pointer which clearly is wrong. So let's instead fake the file so the guest program sees the right address. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2012-02-02linux-user: fake /proc/self/mapsAlexander Graf1-0/+15
glibc's pthread_attr_getstack tries to find the stack range from /proc/self/maps. Unfortunately, /proc is usually the host's /proc which means linux-user guests see qemu's stack there. Fake the file with a constructed maps entry that exposes the guest's stack range. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2012-02-02linux-user: add open() hijack infrastructureAlexander Graf1-3/+49
There are a number of files in /proc that expose host information to the guest program. This patch adds infrastructure to override the open() syscall for guest programs to enable us to on the fly generate guest sensible files. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2011-12-06linux-user/syscall.c: Don't skip stracing for fcntl64 failure casePeter Maydell1-2/+4
In an fcntl64 failure path, we were returning directly rather than simply breaking out of the switch statement. This skips the strace code for printing the syscall return value, so don't do that. Acked-by: Alexander Graf <agraf@suse.de> Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-12-06fix typo: delete redundant semicolonDong Xu Wang1-1/+1
Double semicolons should be single. Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-11-09configure: fix detection for xattr.h on modern distributionsAvi Kivity1-1/+1
Modern distributions place xattr.h in /usr/include/sys, and fold libattr.so into libc. They also don't have an ENOATTR. Make configure detect this, and add a qemu-xattr.h file that directs the #include to the right place. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-27linux-user: implement reboot syscallAlexander Graf1-1/+7
For OBS, we're running a full cross-guest inside of a VM. When a build is done there, we reboot the guest as shutdown mechanism. Unfortunately, reboot is not implemented in linux-user. So this mechanism fails, spilling unpretty warnings. This patch implements sys_reboot() emulation. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2011-10-27linux-user: fix openatAlexander Graf1-13/+1
When running openat using qemu-arm, we stumbled over invalid permissions on the created files. The reason for this is that the mode parameter gets treates as an O_... flag, which it isn't - it's a permission bitmask. This patch removes the needless translation of the mode parameter, rendering permission passing of openat() to work with linux-user. Reported-by: Dirk Mueller <dmueller@suse.de> Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2011-10-27linux-user: fix abi_(u)long, target_ulong mismatchMatthias Braun1-124/+126
abi_(u)long might be different from target_ulong, so don't use tswapl but introduce a new tswapal Signed-off-by: Matthias Braun <matze@braunis.de> Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2011-09-26Merge remote-tracking branch 'riku/linux-user-for-upstream' into stagingAnthony Liguori1-3/+60
2011-09-16Remove blanks before \n in output stringsStefan Weil1-1/+1
Those blanks violate the coding conventions, see scripts/checkpatch.pl. Blanks missing after colons in the changed lines were added. This patch does not try to fix tabs, long lines and other problems in the changed lines, therefore checkpatch.pl reports many violations. Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-09-09Fix include statements for qemu-common.hStefan Weil1-2/+1
* qemu-common.h is not a system include file, so it should be included with "" instead of <>. Otherwise incremental builds might fail because only local include files are checked for changes. * linux-user/syscall.c included the file twice. Cc: Riku Voipio <riku.voipio@iki.fi> Cc: Jan Kiszka <jan.kiszka@siemens.com> Acked-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-09-09linux-user: Implement setxattr/getxattr/removexattr syscallsAn-Cheng Huang1-3/+51
This patch implements the setxattr, getxattr, and removexattr syscalls if CONFIG_ATTR is enabled. Note that since libattr uses indirect syscalls for these, this change depends on the fix for indirect syscall handling on MIPS. Signed-off-by: Riku Voipio <riku.voipio@linaro.org> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: An-Cheng Huang <ancheng@ubnt.com>
2011-09-09linux-user: Fix initialization of the heap contents when allocating new pagesCédric VINCENT1-0/+9
Technically the new mmapped pages are already initialized to zero since they are anonymous, however we have to take care with the contents that come from the remaining part of the previous page: it may contains garbage data due to a previous heap usage (grown then shrunken). This patch completes commit 55f08c84. The problem could be reproduced when emulating the build process of Perl 5.12.3 on ARMedSlack 13.37: make[1]: Entering directory `/tmp/perl-5.12.3/cpan/Compress-Raw-Bzip2' cc -c -I. -fno-strict-aliasing -pipe -fstack-protector \ -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 \ -O2 -DVERSION=\"2.024\" -DXS_VERSION=\"2.024\" -fPIC "-I../.." \ -DBZ_NO_STDIO decompress.c decompress.c: In function 'BZ2_decompress': decompress.c:621:1: internal compiler error: Segmentation fault Signed-off-by: Riku Voipio <riku.voipio@linaro.org> Signed-off-by: Laurent ALFONSI <laurent.alfonsi@st.com> Signed-off-by: Cédric VINCENT <cedric.vincent@st.com>
2011-08-20Use glib memory allocation and free functionsAnthony Liguori1-4/+4
qemu_malloc/qemu_free no longer exist after this commit. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-07-25Wrap recv to avoid warningsBlue Swirl1-1/+1
Avoid warnings like these by wrapping recv(): CC slirp/ip_icmp.o /src/qemu/slirp/ip_icmp.c: In function 'icmp_receive': /src/qemu/slirp/ip_icmp.c:418:5: error: passing argument 2 of 'recv' from incompatible pointer type [-Werror] /usr/local/lib/gcc/i686-mingw32msvc/4.6.0/../../../../i686-mingw32msvc/include/winsock2.h:547:32: note: expected 'char *' but argument is of type 'struct icmp *' Remove also casts used to avoid warnings. Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-07-13linux-user: make MIPS and ARM eabi use same argument reorderingRiku Voipio1-20/+18
MIPS uses similar calling convention than ARM eabi, where when using 64-bit values some registers are skipped. This patch makes MIPS and ARM eabi share the argument reordering code. This affects ftruncate64, creating insane sized fails (or just failing). Cc: Wesley W. Terpstra <terpstra@debian.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2011-07-12mips: rlimit codes are not the sameWesley W. Terpstra1-3/+42
The codes for get/setrlimit differ between linux target platforms. This patch adds conversion. This is important else programs (rsyslog, python, ...) can go into a near infinite loop trying to close all the file descriptors from 0 to -1. Signed-off-by: Wesley W. Terpstra <terpstra@debian.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2011-07-12mips: rlimit incorrectly converts valuesWesley W. Terpstra1-5/+17
Byte swap was applied in the wrong order with testing for RLIM_INFINITY. On mips bigendian from an amd64 system this results in infinity being misinterpretted as 2^31-1. This is a serious bug because it causes setrlimit stack size to kill all child processes. This means (for example) that 'make' can run no children. The mechanism of failure: 1. parent sets stack size rlimit to 'infinity' 2. qemu screws this value up 3. child process fetches stack size as a large (but non-infinite) value 4. qemu tries to allocate stack before execution 5. stack allocation fails (too big) and child process dies Signed-off-by: Wesley W. Terpstra <terpstra@debian.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2011-07-11linux-user/syscall.c: Enforce pselect6 sigset size restrictionsPeter Maydell1-0/+5
Enforce the same restriction on the size of the sigset passed to pselect6 as the Linux kernel does. This is both correct and silences a gcc 4.6 warning about a write-only variable. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2011-07-11linux-user: Implement prlimit64 syscallPeter Maydell1-0/+43
Implement the prlimit64 syscall. Slightly modified to apply upstream -Riku Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2011-06-21linux-user: Fix sync_file_range on 32bit mipsRiku Voipio1-0/+5
As noticed while looking at "Bump do_syscall() up to 8 syscall arguments" patch, sync_file_range uses a pad argument on 32bit mips. Deal with it by reading the correct arguments when on mips. Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2011-06-21linux-user: Bump do_syscall() up to 8 syscall argumentsPeter Maydell1-3/+5
On 32 bit MIPS a few syscalls have 7 arguments, and so to call them via NR_syscall the guest needs to be able to pass 8 arguments to do_syscall(). Raise the number of arguments do_syscall() takes accordingly. This fixes some gcc 4.6 compiler warnings about arg7 and arg8 variables being set and never used. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2011-06-21linux-user: syscall should use sanitized arg1Juan Quintela1-2/+2
Looking at the other architectures, we should be using "how" not "arg1". Signed-off-by: Juan Quintela <quintela@redhat.com> [peter.maydell@linaro.org: remove unnecessary initialisation of how] Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2011-06-21syscall: really return ret codeJuan Quintela1-4/+4
We assign ret with the error code, but then return 0 unconditionally. Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2011-06-21linux-user: add pselect6 syscall supportMike Frysinger1-19/+130
Some architectures (like Blackfin) only implement pselect6 (and skip select/newselect). So add support for it. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2011-06-21linux-user: Fix the computation of the requested heap sizevincent1-8/+29
There were several remaining bugs in the previous implementation of do_brk(): 1. the value of "new_alloc_size" was one page too large when the requested brk was aligned on a host page boundary. 2. no new pages should be (re-)allocated when the requested brk is in the range of the pages that were already allocated previsouly (for the same purpose). Technically these pages are never unmapped in the current implementation. The problem/fix can be reproduced/validated with the test-suite above: #include <unistd.h> /* syscall(2), */ #include <sys/syscall.h> /* SYS_brk, */ #include <stdio.h> /* puts(3), */ #include <stdlib.h> /* exit(3), EXIT_*, */ #include <stdint.h> /* uint*_t, */ #include <sys/mman.h> /* mmap(2), MAP_*, */ #include <string.h> /* memset(3), */ int main() { int exit_status = EXIT_SUCCESS; uint8_t *current_brk = 0; uint8_t *initial_brk; uint8_t *new_brk; uint8_t *old_brk; int failure = 0; int i; void test_brk(int increment, int expected_result) { new_brk = (uint8_t *)syscall(SYS_brk, current_brk + increment); if ((new_brk == current_brk) == expected_result) failure = 1; current_brk = (uint8_t *)syscall(SYS_brk, 0); } void test_result() { if (!failure) puts("OK"); else { puts("failure"); exit_status = EXIT_FAILURE; } } void test_title(const char *title) { failure = 0; printf("%-45s : ", title); fflush(stdout); } test_title("Initialization"); test_brk(0, 1); initial_brk = current_brk; test_result(); test_title("Don't overlap \"brk\" pages"); test_brk(HOST_PAGE_SIZE, 1); test_brk(HOST_PAGE_SIZE, 1); test_result(); /* Preparation for the test "Re-allocated heap is initialized". */ old_brk = current_brk - HOST_PAGE_SIZE; memset(old_brk, 0xFF, HOST_PAGE_SIZE); test_title("Don't allocate the same \"brk\" page twice"); test_brk(-HOST_PAGE_SIZE, 1); test_brk(HOST_PAGE_SIZE, 1); test_result(); test_title("Re-allocated \"brk\" pages are initialized"); for (i = 0; i < HOST_PAGE_SIZE; i++) { if (old_brk[i] != 0) { printf("(index = %d, value = 0x%x) ", i, old_brk[i]); failure = 1; break; } } test_result(); test_title("Don't allocate \"brk\" pages over \"mmap\" pages"); new_brk = mmap(current_brk, HOST_PAGE_SIZE / 2, PROT_READ, MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0); if (new_brk == (void *) -1) puts("unknown"); else { test_brk(HOST_PAGE_SIZE, 0); test_result(); } test_title("All \"brk\" pages are writable (please wait)"); if (munmap(current_brk, HOST_PAGE_SIZE / 2) != 0) puts("unknown"); else { while (current_brk - initial_brk < 2*1024*1024*1024UL) { old_brk = current_brk; test_brk(HOST_PAGE_SIZE, -1); if (old_brk == current_brk) break; for (i = 0; i < HOST_PAGE_SIZE; i++) old_brk[i] = 0xAA; } puts("OK"); } test_title("Maximum size of the heap > 16MB"); failure = (current_brk - initial_brk) < 16*1024*1024; test_result(); exit(exit_status); } Changes introduced in patch v2: * extend the "brk" test-suite embedded within the commit message; * heap contents have to be initialized to zero, this bug was exposed by "tst-calloc.c" from the GNU C library; * don't [try to] allocate a new host page if the new "brk" is equal to the latest allocated host page ("brk_page"); and * print some debug information when DEBUGF_BRK is defined. Signed-off-by: Cédric VINCENT <cedric.vincent@st.com> Reviewed-by: Christophe Guillon <christophe.guillon@st.com> Cc: Riku Voipio <riku.voipio@iki.fi> Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2011-06-21linux-user: Don't use MAP_FIXED in do_brk()Peter Maydell1-9/+20
Since mmap() with MAP_FIXED will map over the top of existing mappings, it's a bad idea to use it to implement brk(), because brk() with a large size is likely to overwrite important things like qemu itself or the host libc. So we drop MAP_FIXED and handle "mapped but at different address" as an error case instead. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2011-05-20s390x: s390x-linux-user supportUlrich Hecht1-4/+12
This patch adds support for running s390x binaries in the linux-user emulation code. Signed-off-by: Ulrich Hecht <uli@suse.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2011-05-08linux-user: Replace deprecated functionStefan Weil1-1/+1
Function bzero is deprecated, so replace it by function memset. Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-05-02Don't zero out buffer in sched_getaffinityMike McCormack1-12/+1
The kernel doesn't fill the buffer provided to sched_getaffinity with zero bytes, so neither should QEMU. Signed-off-by: Mike McCormack <mj.mccormack@samsung.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2011-05-02Fix buffer overrun in sched_getaffinityMike McCormack1-1/+1
Zeroing of the cpu array should start from &cpus[kernel_ret] not &cpus[num_zeros_to_fill]. This fixes a crash in EFL's edje_cc running under qemu-arm. Signed-off-by: Mike McCormack <mj.mccormack@samsung.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Acked-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2011-04-26linux-user: untie syscalls from UID16Riku Voipio1-9/+39
Quite a number of uid/gid related syscalls are only defined on systems with USE_UID16 defined. This is apperently based on the idea that these system calls would never be called on non-UID16 systems. Make these syscalls available for all architectures that define them. drop alpha hack to support selected UID16 syscalls. MIPS and PowerPC were also defined as UID16, to get uid/gid syscalls available, drop this error as well. Change QEMU to reflect this. Cc: Ulrich Hecht <uli@suse.de> Cc: Richard Henderson <rth@twiddle.net> Cc: Alexander Graf <agraf@suse.de> Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2011-04-26linux-user: add s390x to llseek listAlexander Graf1-1/+2
We keep a list of host architectures that do llseek with the same syscall as lseek. S390x is one of them, so let's add it to the list. Original-patch-by: Ulrich Hecht <uli@suse.de> Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2011-04-26linux-user: add ioctl(SIOCGIWNAME, ...) support.Laurent Vivier1-1/+1
Allow to run properly following program from linux-user: /* cc -o wifi wifi.c */ #include <stdio.h> #include <sys/ioctl.h> #include <sys/types.h> #include <sys/socket.h> #include <linux/wireless.h> #include <netinet/in.h> #include <arpa/inet.h> #include <string.h> 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 <laurent@vivier.eu> Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2011-04-26linux-user: convert ioctl(SIOCGIFCONF, ...) result.Laurent Vivier1-1/+95
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[v2] linux-user: bigger default stackRiku Voipio1-5/+2
PTHREAD_STACK_MIN (16KB) is somewhat inadequate for a new stack for new QEMU threads. Set new limit to 256K which should be enough, yet doesn't increase memory pressure significantly. Signed-off-by: Riku Voipio <riku.voipio@nokia.com> Reviewed-by: Nathan Froyd <froydnj@codesourcery.com>
2011-03-22linux-user: Fix unlock_user() call in return from poll()Peter Maydell1-3/+1
Correct the broken attempt to calculate the third argument to unlock_user() in the code path which unlocked the pollfd array on return from poll() and ppoll() emulation. (This only caused a problem if unlock_user() wasn't a no-op, eg if DEBUG_REMAP is defined.) Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2011-03-06linux-user: Fix large seeks by 32 bit guest on 64 bit hostPeter Maydell1-6/+10
When emulating a 32 bit Linux user-mode program on a 64 bit target we implement the llseek syscall in terms of lseek. Correct a bug which meant we were silently casting the result of host lseek() to a 32 bit integer as it passed through get_errno() and thus throwing away the top half. We also don't try to store the result back to userspace unless the seek succeeded; this matches the kernel behaviour. Thanks to Eoghan Sherry for identifying the problem and suggesting a solution. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2011-02-17linux-user: Support the epoll syscallsPeter Maydell1-0/+107
Support the epoll family of syscalls: epoll_create(), epoll_create1(), epoll_ctl(), epoll_wait() and epoll_pwait(). Note that epoll_create1() and epoll_pwait() are later additions, so we have to test separately in configure for their presence. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
2011-02-09linux-user: implement sched_{g,s}etaffinityMike Frysinger1-0/+67
Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Riku Voipio <riku.voipio@nokia.com>