[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH for 6.2 49/49] bsd-user: Add '-0 argv0' option to bsd-user/main.c
From: |
Warner Losh |
Subject: |
[PATCH for 6.2 49/49] bsd-user: Add '-0 argv0' option to bsd-user/main.c |
Date: |
Sat, 7 Aug 2021 15:42:42 -0600 |
From: Colin Percival <cperciva@tarsnap.com>
Previously it was impossible to emulate a program with a file name
different from its argv[0]. With this change, you can run
qemu -0 fakename realname args
which runs the program "realname" with an argv of "fakename args".
Signed-off-by: Colin Percival <cperciva@tarsnap.com>
Signed-off-by: Warner Losh <imp@bsdimp.com>
---
bsd-user/main.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/bsd-user/main.c b/bsd-user/main.c
index 1de5dc189b..c3ecdaf824 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -284,6 +284,7 @@ int main(int argc, char **argv)
char **target_environ, **wrk;
envlist_t *envlist = NULL;
bsd_type = HOST_DEFAULT_BSD_TYPE;
+ char * argv0 = NULL;
adjust_ssize();
@@ -405,6 +406,8 @@ int main(int argc, char **argv)
do_strace = 1;
} else if (!strcmp(r, "trace")) {
trace_opt_parse(optarg);
+ } else if (!strcmp(r, "0")) {
+ argv0 = argv[optind++];
} else {
usage();
}
@@ -428,6 +431,8 @@ int main(int argc, char **argv)
usage();
}
filename = argv[optind];
+ if (argv0)
+ argv[optind] = argv0;
if (!trace_init_backends()) {
exit(1);
--
2.32.0
- Re: [PATCH for 6.2 45/49] bsd-user: Make guest_base an unsigned long, (continued)
- [PATCH for 6.2 46/49] bsd-user: move qemu_log to later in the file, Warner Losh, 2021/08/07
- [PATCH for 6.2 48/49] bsd-user: Implement cpu_copy() helper routine, Warner Losh, 2021/08/07
- [PATCH for 6.2 43/49] bsd-user: elfload.c style catch up patch, Warner Losh, 2021/08/07
- [PATCH for 6.2 44/49] bsd-user: Refactor load_elf_sections and is_target_elf_binary, Warner Losh, 2021/08/07
- [PATCH for 6.2 49/49] bsd-user: Add '-0 argv0' option to bsd-user/main.c,
Warner Losh <=
- [PATCH for 6.2 47/49] bsd-user: Implement interlock for atomic operations, Warner Losh, 2021/08/07