Drop -0 argument for linux-user (schwab) OBS-URL: https://build.opensuse.org/request/show/430644 OBS-URL: https://build.opensuse.org/package/show/Virtualization/qemu?expand=0&rev=316
66 lines
2.2 KiB
Diff
66 lines
2.2 KiB
Diff
From c591019f7c3d6d1ca45a8773313aeb5ffac686c2 Mon Sep 17 00:00:00 2001
|
|
From: Andreas Schwab <schwab@suse.de>
|
|
Date: Mon, 26 Sep 2016 10:08:59 +0200
|
|
Subject: [PATCH] linux-user: skip -0 flag from /proc/self/cmdline
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
This removes the "-0 argv0" flag from /proc/self/cmdline that was passed in
|
|
by the qemu-ARCH-binfmt wrapper.
|
|
|
|
Signed-off-by: Andreas Schwab <schwab@suse.de>
|
|
Signed-off-by: Andreas Färber <afaerber@suse.de>
|
|
---
|
|
linux-user/syscall.c | 22 ++++++++++++++++------
|
|
1 file changed, 16 insertions(+), 6 deletions(-)
|
|
|
|
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
|
|
index 856e75d..9be99d6 100644
|
|
--- a/linux-user/syscall.c
|
|
+++ b/linux-user/syscall.c
|
|
@@ -7014,7 +7014,7 @@ int host_to_target_waitstatus(int status)
|
|
static int open_self_cmdline(void *cpu_env, int fd)
|
|
{
|
|
int fd_orig = -1;
|
|
- bool word_skipped = false;
|
|
+ int skip_words = 3;
|
|
|
|
fd_orig = open("/proc/self/cmdline", O_RDONLY);
|
|
if (fd_orig < 0) {
|
|
@@ -7036,19 +7036,29 @@ static int open_self_cmdline(void *cpu_env, int fd)
|
|
break;
|
|
}
|
|
|
|
- if (!word_skipped) {
|
|
+ while (skip_words) {
|
|
/* Skip the first string, which is the path to qemu-*-static
|
|
instead of the actual command. */
|
|
- cp_buf = memchr(buf, 0, nb_read);
|
|
+ char *p = cp_buf;
|
|
+ cp_buf = memchr(p, 0, nb_read);
|
|
if (cp_buf) {
|
|
/* Null byte found, skip one string */
|
|
cp_buf++;
|
|
- nb_read -= cp_buf - buf;
|
|
- word_skipped = true;
|
|
+ nb_read -= cp_buf - p;
|
|
+ skip_words--;
|
|
+ if (skip_words == 2) {
|
|
+ /* Check for presence of -0 flag. */
|
|
+ if (nb_read > 0 && cp_buf[0] != '-' ||
|
|
+ nb_read > 1 && cp_buf[1] != '0') {
|
|
+ skip_words = 0;
|
|
+ }
|
|
+ }
|
|
+ } else {
|
|
+ break;
|
|
}
|
|
}
|
|
|
|
- if (word_skipped) {
|
|
+ if (skip_words == 0) {
|
|
if (write(fd, cp_buf, nb_read) != nb_read) {
|
|
int e = errno;
|
|
close(fd_orig);
|