[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 2/3] linux user: moving is proc functions to separate file
From: |
Laurent Vivier |
Subject: |
Re: [PATCH 2/3] linux user: moving is proc functions to separate file |
Date: |
Tue, 18 Aug 2020 17:56:15 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 |
Le 18/08/2020 à 01:57, Andrew Aladjev a écrit :
> Signed-off-by: Andrew Aladjev <aladjev.andrew@gmail.com>
> ---
> linux-user/Makefile.objs | 5 +++--
> linux-user/syscall.c | 33 +--------------------------------
> linux-user/syscall_proc.c | 32 ++++++++++++++++++++++++++++++++
> linux-user/syscall_proc.h | 7 +++++++
> 4 files changed, 43 insertions(+), 34 deletions(-)
> create mode 100644 linux-user/syscall_proc.c
> create mode 100644 linux-user/syscall_proc.h
>
> diff --git a/linux-user/Makefile.objs b/linux-user/Makefile.objs
> index 1940910a73..20f8828b86 100644
> --- a/linux-user/Makefile.objs
> +++ b/linux-user/Makefile.objs
> @@ -1,7 +1,8 @@
> obj-y = main.o syscall.o strace.o mmap.o signal.o \
> elfload.o linuxload.o uaccess.o uname.o \
> - safe-syscall.o $(TARGET_ABI_DIR)/signal.o \
> - $(TARGET_ABI_DIR)/cpu_loop.o exit.o fd-trans.o
> + safe-syscall.o syscall_proc.o \
> + $(TARGET_ABI_DIR)/cpu_loop.o $(TARGET_ABI_DIR)/signal.o \
> + exit.o fd-trans.o
>
I think this will collide with Paolo's meson pull request.
> obj-$(TARGET_HAS_BFLT) += flatload.o
> obj-$(TARGET_I386) += vm86.o
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 5741c72733..01edc9b68d 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -125,6 +125,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 */
> @@ -7482,38 +7483,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 0000000000..34051a8e6b
> --- /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 0000000000..3098af931f
> --- /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
>
Please add a "SPDX-License-Identifier: GPL-2.0-or-later" header in the
new files.
Thanks,
Laurent