[PATCH trivial 3/7] linux-user: assume inotify sycalls are always present

Michael Tokarev posted 7 patches 3 weeks, 6 days ago
Maintainers: Laurent Vivier <laurent@vivier.eu>, Paolo Bonzini <pbonzini@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Stefan Hajnoczi <stefanha@redhat.com>, Fam Zheng <fam@euphon.net>
There is a newer version of this series
[PATCH trivial 3/7] linux-user: assume inotify sycalls are always present
Posted by Michael Tokarev 3 weeks, 6 days ago
inotify_init() and other syscalls appeared in linux 2.6.13,
inotify_init1() - in linux 2.6.27.

There's no need to check their presence on linux anymore.

Keep condition on TARGET_NR_inotify_init because modern
architectures have only more generic inotify_init1().

Other, not linux-specific, places of the code checks for
inotify_init1() syscall only.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 linux-user/fd-trans.c |  5 -----
 linux-user/fd-trans.h |  4 ----
 linux-user/syscall.c  | 19 ++-----------------
 3 files changed, 2 insertions(+), 26 deletions(-)

diff --git a/linux-user/fd-trans.c b/linux-user/fd-trans.c
index f83d1f79d5..64dd0745d2 100644
--- a/linux-user/fd-trans.c
+++ b/linux-user/fd-trans.c
@@ -18,9 +18,7 @@
 #include <sys/signalfd.h>
 #include <linux/unistd.h>
 #include <linux/audit.h>
-#ifdef CONFIG_INOTIFY
 #include <sys/inotify.h>
-#endif
 #include <linux/netlink.h>
 #ifdef CONFIG_RTNETLINK
 #include <linux/rtnetlink.h>
@@ -1861,8 +1859,6 @@ TargetFdTrans target_timerfd_trans = {
     .host_to_target_data = swap_data_u64,
 };
 
-#if defined(CONFIG_INOTIFY) && (defined(TARGET_NR_inotify_init) || \
-        defined(TARGET_NR_inotify_init1))
 static abi_long host_to_target_data_inotify(void *buf, size_t len)
 {
     struct inotify_event *ev;
@@ -1885,4 +1881,3 @@ static abi_long host_to_target_data_inotify(void *buf, size_t len)
 TargetFdTrans target_inotify_trans = {
     .host_to_target_data = host_to_target_data_inotify,
 };
-#endif
diff --git a/linux-user/fd-trans.h b/linux-user/fd-trans.h
index e14f96059c..3bbc15fa1f 100644
--- a/linux-user/fd-trans.h
+++ b/linux-user/fd-trans.h
@@ -141,9 +141,5 @@ extern TargetFdTrans target_netlink_audit_trans;
 extern TargetFdTrans target_signalfd_trans;
 extern TargetFdTrans target_eventfd_trans;
 extern TargetFdTrans target_timerfd_trans;
-#if (defined(TARGET_NR_inotify_init) && defined(__NR_inotify_init)) || \
-    (defined(CONFIG_INOTIFY1) && defined(TARGET_NR_inotify_init1) && \
-     defined(__NR_inotify_init1))
 extern TargetFdTrans target_inotify_trans;
 #endif
-#endif
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 9cc9ed2fbc..fad2bf3632 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -497,15 +497,7 @@ static int sys_renameat2(int oldfd, const char *old,
 #endif
 #endif /* TARGET_NR_renameat2 */
 
-#ifdef CONFIG_INOTIFY
 #include <sys/inotify.h>
-#else
-/* Userspace can usually survive runtime without inotify */
-#undef TARGET_NR_inotify_init
-#undef TARGET_NR_inotify_init1
-#undef TARGET_NR_inotify_add_watch
-#undef TARGET_NR_inotify_rm_watch
-#endif /* CONFIG_INOTIFY  */
 
 #if defined(TARGET_NR_prlimit64)
 #ifndef __NR_prlimit64
@@ -13267,8 +13259,8 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
     case TARGET_NR_futex_time64:
         return do_futex(cpu, true, arg1, arg2, arg3, arg4, arg5, arg6);
 #endif
-#ifdef CONFIG_INOTIFY
-#if defined(TARGET_NR_inotify_init)
+
+#ifdef TARGET_NR_inotify_init
     case TARGET_NR_inotify_init:
         ret = get_errno(inotify_init());
         if (ret >= 0) {
@@ -13276,7 +13268,6 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
         }
         return ret;
 #endif
-#if defined(TARGET_NR_inotify_init1) && defined(CONFIG_INOTIFY1)
     case TARGET_NR_inotify_init1:
         ret = get_errno(inotify_init1(target_to_host_bitmask(arg1,
                                           fcntl_flags_tbl)));
@@ -13284,19 +13275,13 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
             fd_trans_register(ret, &target_inotify_trans);
         }
         return ret;
-#endif
-#if defined(TARGET_NR_inotify_add_watch)
     case TARGET_NR_inotify_add_watch:
         p = lock_user_string(arg2);
         ret = get_errno(inotify_add_watch(arg1, path(p), arg3));
         unlock_user(p, arg2, 0);
         return ret;
-#endif
-#if defined(TARGET_NR_inotify_rm_watch)
     case TARGET_NR_inotify_rm_watch:
         return get_errno(inotify_rm_watch(arg1, arg2));
-#endif
-#endif
 
 #if defined(TARGET_NR_mq_open) && defined(__NR_mq_open)
     case TARGET_NR_mq_open:
-- 
2.47.3
Re: [PATCH trivial 3/7] linux-user: assume inotify sycalls are always present
Posted by Richard Henderson 3 weeks, 1 day ago
On 1/14/26 00:00, Michael Tokarev wrote:
> inotify_init() and other syscalls appeared in linux 2.6.13,
> inotify_init1() - in linux 2.6.27.
> 
> There's no need to check their presence on linux anymore.
> 
> Keep condition on TARGET_NR_inotify_init because modern
> architectures have only more generic inotify_init1().
> 
> Other, not linux-specific, places of the code checks for
> inotify_init1() syscall only.
> 
> Signed-off-by: Michael Tokarev<mjt@tls.msk.ru>
> ---
>   linux-user/fd-trans.c |  5 -----
>   linux-user/fd-trans.h |  4 ----
>   linux-user/syscall.c  | 19 ++-----------------
>   3 files changed, 2 insertions(+), 26 deletions(-)

As Peter mentioned vs patch 1, the relevant version is glibc 2.4.
But again, well within the minimum supported version.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~