summary refs log tree commit diff stats
path: root/linux-user
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@amazon.com>2013-12-06 12:57:21 -0800
committerAnthony Liguori <aliguori@amazon.com>2013-12-06 12:57:21 -0800
commitcdac7a7184065467ba45ec83a9abfeeae060ce4b (patch)
tree1d7d262492874f0945716da1d85c5cb01c6d48e8 /linux-user
parenta55d121f4a932dcd19eb8164804cc98d5ea88e72 (diff)
parent0b959cf5e4cce08ed96bd7832447e1543cd3622f (diff)
downloadfocaccia-qemu-cdac7a7184065467ba45ec83a9abfeeae060ce4b.tar.gz
focaccia-qemu-cdac7a7184065467ba45ec83a9abfeeae060ce4b.zip
Merge remote-tracking branch 'rth/auxv-2' into staging
# By Richard Henderson
# Via Richard Henderson
* rth/auxv-2:
  linux-user: Use qemu_getauxval for AT_EXECFD
  util: Use qemu_getauxval in linux qemu_cache_utils_init
  tcg-s390: Use qemu_getauxval in query_facilities
  tcg-arm: Use qemu_getauxval
  tcg-ppc64: Use qemu_getauxval
  osdep: Create qemu_getauxval and qemu_init_auxval

Message-id: 1385757754-10702-1-git-send-email-rth@twiddle.net
Signed-off-by: Anthony Liguori <aliguori@amazon.com>
Diffstat (limited to 'linux-user')
-rw-r--r--linux-user/main.c35
1 files changed, 8 insertions, 27 deletions
diff --git a/linux-user/main.c b/linux-user/main.c
index 6b4ab0930e..54f71fe8f6 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -3663,26 +3663,6 @@ static int parse_args(int argc, char **argv)
     return optind;
 }
 
-static int get_execfd(char **envp)
-{
-    typedef struct {
-        long a_type;
-        long a_val;
-    } auxv_t;
-    auxv_t *auxv;
-
-    while (*envp++ != NULL) {
-        ;
-    }
-
-    for (auxv = (auxv_t *)envp; auxv->a_type != AT_NULL; auxv++) {
-        if (auxv->a_type == AT_EXECFD) {
-            return auxv->a_val;
-        }
-    }
-    return -1;
-}
-
 int main(int argc, char **argv, char **envp)
 {
     struct target_pt_regs regs1, *regs = &regs1;
@@ -3701,7 +3681,8 @@ int main(int argc, char **argv, char **envp)
 
     module_call_init(MODULE_INIT_QOM);
 
-    qemu_cache_utils_init(envp);
+    qemu_init_auxval(envp);
+    qemu_cache_utils_init();
 
     if ((envlist = envlist_create()) == NULL) {
         (void) fprintf(stderr, "Unable to allocate envlist\n");
@@ -3875,13 +3856,13 @@ int main(int argc, char **argv, char **envp)
     env->opaque = ts;
     task_settid(ts);
 
-    execfd = get_execfd(envp);
-    if (execfd < 0) {
+    execfd = qemu_getauxval(AT_EXECFD);
+    if (execfd == 0) {
         execfd = open(filename, O_RDONLY);
-    }
-    if (execfd < 0) {
-        printf("Error while loading %s: %s\n", filename, strerror(-execfd));
-        _exit(1);
+        if (execfd < 0) {
+            printf("Error while loading %s: %s\n", filename, strerror(errno));
+            _exit(1);
+        }
     }
 
     ret = loader_exec(execfd, filename, target_argv, target_environ, regs,