[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 07/11] linux-user: simplify is_proc_myself
From: |
YAMAMOTO Takashi |
Subject: |
[PATCH v2 07/11] linux-user: simplify is_proc_myself |
Date: |
Mon, 31 May 2021 14:50:14 +0900 |
Signed-off-by: YAMAMOTO Takashi <yamamoto@midokura.com>
---
linux-user/syscall.c | 23 +++--------------------
1 file changed, 3 insertions(+), 20 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 999760448d..86b12cc8b4 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -8027,26 +8027,9 @@ static int is_proc_file(const char *filename, int *pidp,
const char *entry)
static int is_proc_myself(const char *filename, const char *entry)
{
- if (!strncmp(filename, "/proc/", strlen("/proc/"))) {
- filename += strlen("/proc/");
- if (!strncmp(filename, "self/", strlen("self/"))) {
- filename += strlen("self/");
- } else if (*filename >= '1' && *filename <= '9') {
- char myself[80];
- snprintf(myself, sizeof(myself), "%d/", getpid());
- if (!strncmp(filename, myself, strlen(myself))) {
- filename += strlen(myself);
- } else {
- return 0;
- }
- } else {
- return 0;
- }
- if (!strcmp(filename, entry)) {
- return 1;
- }
- }
- return 0;
+ int pid;
+
+ return is_proc_file(filename, &pid, entry) && pid == getpid();
}
#if defined(HOST_WORDS_BIGENDIAN) != defined(TARGET_WORDS_BIGENDIAN) || \
--
2.21.1 (Apple Git-122.3)
- [PATCH v2 00/11] linux-user changes to run docker, YAMAMOTO Takashi, 2021/05/31
- [PATCH v2 01/11] linux-user: handle /proc/self/exe for execve, YAMAMOTO Takashi, 2021/05/31
- [PATCH v2 02/11] linux-user: Fix the execfd case of /proc/self/exe open, YAMAMOTO Takashi, 2021/05/31
- [PATCH v2 03/11] linux-user: dup the execfd on start up, YAMAMOTO Takashi, 2021/05/31
- [PATCH v2 04/11] linux-user: make exec_path realpath, YAMAMOTO Takashi, 2021/05/31
- [PATCH v2 05/11] linux-user: Implement pivot_root, YAMAMOTO Takashi, 2021/05/31
- [PATCH v2 06/11] linux-user: add get_exe_path, YAMAMOTO Takashi, 2021/05/31
- [PATCH v2 07/11] linux-user: simplify is_proc_myself,
YAMAMOTO Takashi <=
- [PATCH v2 08/11] linux-user: Implement exec of /proc/$pid/exe of qemu process, YAMAMOTO Takashi, 2021/05/31
- [PATCH v2 09/11] linux-user: Make the qemu detection for /proc/$pid/exe a bit conservative, YAMAMOTO Takashi, 2021/05/31
- [PATCH v2 10/11] linux-user: a crude hack for libcontainer (CLONE_PARENT) [!MERGE], YAMAMOTO Takashi, 2021/05/31
- [PATCH v2 11/11] linux-user: always assume preserve_argv0 for now [!MERGE], YAMAMOTO Takashi, 2021/05/31
- Re: [PATCH v2 00/11] linux-user changes to run docker, no-reply, 2021/05/31