[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 18/43] bsd-user: save the path to the qemu emulator
From: |
imp |
Subject: |
[PATCH v2 18/43] bsd-user: save the path to the qemu emulator |
Date: |
Thu, 26 Aug 2021 15:11:36 -0600 |
From: Warner Losh <imp@bsdimp.com>
Save the path to the qemu emulator. This will be used later when we have
a more complete implementation of exec.
Signed-off-by: Stacey Son <sson@FreeBSD.org>
Signed-off-by: Warner Losh <imp@bsdimp.com>
Acked-by: Richard Henderson <richard.henderson@linaro.org>
---
bsd-user/main.c | 21 +++++++++++++++++++++
bsd-user/qemu.h | 1 +
2 files changed, 22 insertions(+)
diff --git a/bsd-user/main.c b/bsd-user/main.c
index 3a23e63cf8..f7e1df5da5 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -43,6 +43,8 @@
#include "host-os.h"
+#include <sys/sysctl.h>
+
int singlestep;
unsigned long mmap_min_addr;
uintptr_t guest_base;
@@ -52,6 +54,7 @@ unsigned long reserved_va;
static const char *interp_prefix = CONFIG_QEMU_INTERP_PREFIX;
const char *qemu_uname_release;
enum BSDType bsd_type;
+char qemu_proc_pathname[PATH_MAX]; /* full path to exeutable */
/*
* XXX: on x86 MAP_GROWSDOWN only works if ESP <= address + 32, so
@@ -336,6 +339,22 @@ void init_task_state(TaskState *ts)
ts->sigqueue_table[i].next = NULL;
}
+static void save_proc_pathname(char *argv0)
+{
+ int mib[4];
+ size_t len;
+
+ mib[0] = CTL_KERN;
+ mib[1] = KERN_PROC;
+ mib[2] = KERN_PROC_PATHNAME;
+ mib[3] = -1;
+
+ len = sizeof(qemu_proc_pathname);
+ if (sysctl(mib, 4, qemu_proc_pathname, &len, NULL, 0)) {
+ perror("sysctl");
+ }
+}
+
int main(int argc, char **argv)
{
const char *filename;
@@ -360,6 +379,8 @@ int main(int argc, char **argv)
usage();
}
+ save_proc_pathname(argv[0]);
+
error_init(argv[0]);
module_call_init(MODULE_INIT_TRACE);
qemu_init_cpu_list();
diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
index cf248ad3df..6c4ec61d76 100644
--- a/bsd-user/qemu.h
+++ b/bsd-user/qemu.h
@@ -207,6 +207,7 @@ void mmap_fork_start(void);
void mmap_fork_end(int child);
/* main.c */
+extern char qemu_proc_pathname[];
extern unsigned long x86_stack_size;
/* user access */
--
2.32.0
- [PATCH v2 10/43] bsd-user: implement path searching, (continued)
- [PATCH v2 10/43] bsd-user: implement path searching, imp, 2021/08/26
- [PATCH v2 11/43] bsd-user: Eliminate elf personality, imp, 2021/08/26
- [PATCH v2 12/43] bsd-user: remove a.out support, imp, 2021/08/26
- [PATCH v2 14/43] bsd-user: elfload: simplify bswap a bit., imp, 2021/08/26
- [PATCH v2 15/43] bsd-user: assume pthreads and support of __thread, imp, 2021/08/26
- [PATCH v2 13/43] bsd-user: TARGET_NGROUPS unused in this file, remove, imp, 2021/08/26
- [PATCH v2 17/43] bsd-user: Include host-os.h from main, imp, 2021/08/26
- [PATCH v2 16/43] bsd-user: add host-os.h, imp, 2021/08/26
- [PATCH v2 18/43] bsd-user: save the path to the qemu emulator,
imp <=
- [PATCH v2 19/43] bsd-user: start to move target CPU functions to target_arch*, imp, 2021/08/26
- [PATCH v2 22/43] bsd-user: Include more things in qemu.h, imp, 2021/08/26
- [PATCH v2 28/43] bsd-user: Add system independent stack, data and text limiting, imp, 2021/08/26
- [PATCH v2 20/43] bsd-user: Move per-cpu code into target_arch_cpu.h, imp, 2021/08/26
- [PATCH v2 24/43] bsd-user: Create target specific vmparam.h, imp, 2021/08/26
- [PATCH v2 26/43] bsd-user: *BSD specific siginfo defintions, imp, 2021/08/26
- [PATCH v2 21/43] bsd-user: pull in target_arch_thread.h update target_arch_elf.h, imp, 2021/08/26
- [PATCH v2 32/43] bsd-user: Make cpu_model and cpu_type visible to all of main.c, imp, 2021/08/26