diff options
author | Colin Percival <cperciva@tarsnap.com> | 2021-08-07 14:34:21 -0600 |
---|---|---|
committer | Warner Losh <imp@bsdimp.com> | 2021-09-10 14:13:06 -0600 |
commit | b8012648b38274aa996f1477c422a79e2d44110b (patch) | |
tree | a02def877fc4d15d5afef2b194b9f02a5474c6a3 /bsd-user/main.c | |
parent | 63cca1067ac70df2d71c0064f7bf53e19334223c (diff) | |
download | qemu-b8012648b38274aa996f1477c422a79e2d44110b.zip qemu-b8012648b38274aa996f1477c422a79e2d44110b.tar.gz qemu-b8012648b38274aa996f1477c422a79e2d44110b.tar.bz2 |
bsd-user: Add '-0 argv0' option to bsd-user/main.c
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>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'bsd-user/main.c')
-rw-r--r-- | bsd-user/main.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/bsd-user/main.c b/bsd-user/main.c index 659dd2b..6df4f4f 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -243,6 +243,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(); @@ -367,6 +368,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(); } @@ -390,6 +393,9 @@ int main(int argc, char **argv) usage(); } filename = argv[optind]; + if (argv0) { + argv[optind] = argv0; + } if (!trace_init_backends()) { exit(1); |