From: aladjev.andrew@gmail.com
To: qemu-devel@nongnu.org
Cc: Andrew Aladjev <aladjev.andrew@gmail.com>
Subject: [PATCH 2/4] linux user: moved is proc functions to separate file
Date: Thu, 25 Feb 2021 23:54:46 +0300 [thread overview]
Message-ID: <20210225205448.10624-2-aladjev.andrew@gmail.com> (raw)
In-Reply-To: <20210225205448.10624-1-aladjev.andrew@gmail.com>
From: Andrew Aladjev <aladjev.andrew@gmail.com>
---
linux-user/meson.build | 1 +
linux-user/syscall.c | 33 +--------------------------------
linux-user/syscall_proc.c | 32 ++++++++++++++++++++++++++++++++
linux-user/syscall_proc.h | 7 +++++++
4 files changed, 41 insertions(+), 32 deletions(-)
create mode 100644 linux-user/syscall_proc.c
create mode 100644 linux-user/syscall_proc.h
diff --git a/linux-user/meson.build b/linux-user/meson.build
index 7fe28d6..b6a204d 100644
--- a/linux-user/meson.build
+++ b/linux-user/meson.build
@@ -9,6 +9,7 @@ linux_user_ss.add(files(
'signal.c',
'strace.c',
'syscall.c',
+ 'syscall_proc.c',
'uaccess.c',
'uname.c',
))
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index c171dea..0ead34b 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -133,6 +133,7 @@
#include "qapi/error.h"
#include "fd-trans.h"
#include "tcg/tcg.h"
+#include "syscall_proc.h"
#ifndef CLONE_IO
#define CLONE_IO 0x80000000 /* Clone io context */
@@ -7979,38 +7980,6 @@ static int open_self_auxv(void *cpu_env, int fd)
return 0;
}
-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;
-}
-
-#if defined(HOST_WORDS_BIGENDIAN) != defined(TARGET_WORDS_BIGENDIAN) || \
- defined(TARGET_SPARC) || defined(TARGET_M68K) || defined(TARGET_HPPA)
-static int is_proc(const char *filename, const char *entry)
-{
- return strcmp(filename, entry) == 0;
-}
-#endif
-
#if defined(HOST_WORDS_BIGENDIAN) != defined(TARGET_WORDS_BIGENDIAN)
static int open_net_route(void *cpu_env, int fd)
{
diff --git a/linux-user/syscall_proc.c b/linux-user/syscall_proc.c
new file mode 100644
index 0000000..34051a8
--- /dev/null
+++ b/linux-user/syscall_proc.c
@@ -0,0 +1,32 @@
+#include "qemu/osdep.h"
+
+#include "syscall_proc.h"
+
+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 is_proc(const char *filename, const char *entry)
+{
+ return strcmp(filename, entry) == 0;
+}
diff --git a/linux-user/syscall_proc.h b/linux-user/syscall_proc.h
new file mode 100644
index 0000000..3098af9
--- /dev/null
+++ b/linux-user/syscall_proc.h
@@ -0,0 +1,7 @@
+#ifndef SYSCALL_PROC_H
+#define SYSCALL_PROC_H
+
+int is_proc(const char *filename, const char *entry);
+int is_proc_myself(const char *filename, const char *entry);
+
+#endif
--
2.26.2
next prev parent reply other threads:[~2021-02-25 20:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-25 20:54 [PATCH 1/4] linux user: make execfd global (like exec path) and keep it open aladjev.andrew
2021-02-25 20:54 ` aladjev.andrew [this message]
2021-02-25 20:54 ` [PATCH 3/4] linux user: refactored is proc myself, added support for fd/<execfd> aladjev.andrew
2021-02-25 20:54 ` [PATCH 4/4] linux user: added tests for proc myself aladjev.andrew
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210225205448.10624-2-aladjev.andrew@gmail.com \
--to=aladjev.andrew@gmail.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).