From patchwork Sun Jun 10 03:02:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138169 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2612312lji; Sat, 9 Jun 2018 21:11:35 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJw7LGsb/nnEZPNJX6H9E0Yf1qe4hgxwD0tNG49cpYxqUaZHLzPxzTC/HrKwM2/KDQanhBa X-Received: by 2002:a37:9d13:: with SMTP id g19-v6mr10354385qke.217.1528603895881; Sat, 09 Jun 2018 21:11:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528603895; cv=none; d=google.com; s=arc-20160816; b=L/pYaFToUJTiMeEkEpoirNLJeFmZMbBZoyx3PWQFKZFO7l39Wv5eIyIqiY9Ypl7/Pl dhowMZQBdudvONCD4EmWmhgeRzVfvTjUzDqPEHktQYSt1nCE1tqtqcJH+3+cSFGTkdQf sLVj6hEpKBAHpY3rYJdTFrC6MNNIhCb9JQnqQuqYMRRuR7s0LItJzg/nXusCakqDhuoi 8gKLfc+4C2lqr4b6GKQXCa3Bxjr4pkcF8CiIdYxCRHYk50TOwaIVE+KoMVlyXc9ElvUE bejXjiL0VGEBkbPE9pIxgu+J7Ui8faqbOSUfSWq9IFKCFVy6HHdLE9U4iztv68btx5g+ /g+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=BHOdXervprw5sz9D/vM6jCzatyaAU1e4HSS2ZXnR4XQ=; b=gsOmFQp/9R1jpxYqPkgC0eCORsvzA0CgpR+xC9l3i4vsc4UPsnl2S6FqLh8kkCMnB7 iW1Q8NFfFG8IDvSRs/0fKjdEgqcEXMisudMMTKQlMfnlUMtl0mu8yFv7XZBmlOLeV9di +csZ882hXH+yKjv71H0lgPQ6u5a/+tETdfn31Og0CfCqUx/re3G0NxFAdybKaJgN3Yma M+ET35d7t/2UWsl9wFbSU8I/RGBJ5VeQqrPWuzQMyaekZ6kgTniSP6DWCtC9IpbGiezE WuirbLEQN9illROK8nhjl1x9G3Ny5nQd8ckuhekaWRE0yR5FgQ5/J2/i/VAxQdSX0oKr xWVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Lrl4Z6rL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 29-v6si13788397qto.253.2018.06.09.21.11.35 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 21:11:35 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Lrl4Z6rL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:42563 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrhX-0005nV-9M for patch@linaro.org; Sun, 10 Jun 2018 00:11:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41416) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqfm-0004R1-Hz for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqfl-0004gv-22 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:42 -0400 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]:47037) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqfk-0004gp-QF for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:40 -0400 Received: by mail-pg0-x243.google.com with SMTP id d2-v6so8130646pga.13 for ; Sat, 09 Jun 2018 20:05:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=BHOdXervprw5sz9D/vM6jCzatyaAU1e4HSS2ZXnR4XQ=; b=Lrl4Z6rL/lprdYgZrZHDirA6BUcdcFYu0qkwYVftci9bsb7Ki37pEEfr8u+HvDf4kT ouM4OVm0hNg7P9KY89Eb1JH9YGoZcczVzj/9jGJTHvLmVZjCTYlySAR8MRbPEq5EC5UA Qp+r88Y024QlEk4PU3zFhGWkLPwv7T9h3s+mQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=BHOdXervprw5sz9D/vM6jCzatyaAU1e4HSS2ZXnR4XQ=; b=VuMTEdp0Qz/NAhSKjf39Ud+bMkd+wwZCJfUnCJQ/LwZrFKAgdAS9iVX+S9oJitWE0q WA8WocYPep1hULnea2kjqKfISYdQpnmpN8gCqy8UV48qn5YgWRK9UoxE8phsTSjpXQ4w Nqxy/l6EKgRumlDmasjDSc+C0OANdKwwEzqs+WGhdHWIYNGTROIDY+E4CshAOSrP9iWU 2CgDYESUVekYageXjn1a9QS050NSgzgMzwPdIialBhtdRZhSe97QbIQQItMTQ3NNsnbO 9DL1jBYCkFAF9V8dtGRInxGbNAZt4It+K4GVKlzJqS8yKs94mybbD+QPW63wbgSAydqW 5r+w== X-Gm-Message-State: APt69E0xbVJzazUvbkKbjvzH2sClV7yTaef+FGswYTvBrDxZFZX9hT1X WQY28Zxov7HJoGlHoSJ1IloVtUwIjMk= X-Received: by 2002:a62:2281:: with SMTP id p1-v6mr12186141pfj.53.1528599939642; Sat, 09 Jun 2018 20:05:39 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.05.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:05:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:02:06 -1000 Message-Id: <20180610030220.3777-95-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::243 Subject: [Qemu-devel] [PATCH v2 094/108] linux-user: Split out inotify syscalls X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This includes inotify_add_watch, inotify_init, inotify_init1, and inotify_rm_watch. At the same time, merge in the useless wrappers around the libc functions. If host inotify_init1 is not available, use inotify_init if flags == 0. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 139 ++++++++++++++++++++----------------------- 1 file changed, 65 insertions(+), 74 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 95b30adea2..a540c1455b 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -74,6 +74,9 @@ #ifdef CONFIG_SENDFILE #include #endif +#ifdef CONFIG_INOTIFY +#include +#endif #define termios host_termios #define winsize host_winsize @@ -235,9 +238,6 @@ static type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, \ #define __NR_sys_rt_sigqueueinfo __NR_rt_sigqueueinfo #define __NR_sys_rt_tgsigqueueinfo __NR_rt_tgsigqueueinfo #define __NR_sys_syslog __NR_syslog -#define __NR_sys_inotify_init __NR_inotify_init -#define __NR_sys_inotify_add_watch __NR_inotify_add_watch -#define __NR_sys_inotify_rm_watch __NR_inotify_rm_watch /* These definitions produce an ENOSYS from the host kernel. * Performing a bogus syscall is lazier than boilerplating @@ -626,43 +626,6 @@ static int sys_renameat2(int oldfd, const char *old, } #endif -#ifdef CONFIG_INOTIFY -#include - -#if defined(TARGET_NR_inotify_init) && defined(__NR_inotify_init) -static int sys_inotify_init(void) -{ - return (inotify_init()); -} -#endif -#if defined(TARGET_NR_inotify_add_watch) && defined(__NR_inotify_add_watch) -static int sys_inotify_add_watch(int fd,const char *pathname, int32_t mask) -{ - return (inotify_add_watch(fd, pathname, mask)); -} -#endif -#if defined(TARGET_NR_inotify_rm_watch) && defined(__NR_inotify_rm_watch) -static int sys_inotify_rm_watch(int fd, int32_t wd) -{ - return (inotify_rm_watch(fd, wd)); -} -#endif -#ifdef CONFIG_INOTIFY1 -#if defined(TARGET_NR_inotify_init1) && defined(__NR_inotify_init1) -static int sys_inotify_init1(int flags) -{ - return (inotify_init1(flags)); -} -#endif -#endif -#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 # define __NR_prlimit64 -1 @@ -7421,9 +7384,7 @@ static TargetFdTrans target_eventfd_trans = { .target_to_host_data = swap_data_eventfd, }; -#if (defined(TARGET_NR_inotify_init) && defined(__NR_inotify_init)) || \ - (defined(CONFIG_INOTIFY1) && defined(TARGET_NR_inotify_init1) && \ - defined(__NR_inotify_init1)) +#ifdef CONFIG_INOTIFY static abi_long host_to_target_data_inotify(void *buf, size_t len) { struct inotify_event *ev; @@ -9177,6 +9138,59 @@ IMPL(getxuid) } #endif +#ifdef CONFIG_INOTIFY +IMPL(inotify_add_watch) +{ + char *p; + abi_long ret; + + p = lock_user_string(arg2); + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(inotify_add_watch(arg1, path(p), arg3)); + unlock_user(p, arg2, 0); + return ret; +} + +# ifdef TARGET_NR_inotify_init +IMPL(inotify_init) +{ + abi_long ret = get_errno(inotify_init()); + if (!is_error(ret)) { + fd_trans_register(ret, &target_inotify_trans); + } + return ret; +} +# endif + +IMPL(inotify_init1) +{ + int flags = target_to_host_bitmask(arg1, fcntl_flags_tbl); + abi_long ret; + +# ifdef CONFIG_INOTIFY1 + ret = inotify_init1(flags); +# else + if (arg1 == 0) { + ret = inotify_init(); + } else { + return -TARGET_ENOSYS; + } +# endif + ret = get_errno(ret); + if (!is_error(ret)) { + fd_trans_register(ret, &target_inotify_trans); + } + return ret; +} + +IMPL(inotify_rm_watch) +{ + return get_errno(inotify_rm_watch(arg1, arg2)); +} +#endif /* CONFIG_INOTIFY */ + /* ??? Implement proper locking for ioctls. */ IMPL(ioctl) { @@ -12598,37 +12612,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#if defined(TARGET_NR_inotify_init) && defined(__NR_inotify_init) - case TARGET_NR_inotify_init: - ret = get_errno(sys_inotify_init()); - if (ret >= 0) { - fd_trans_register(ret, &target_inotify_trans); - } - return ret; -#endif -#ifdef CONFIG_INOTIFY1 -#if defined(TARGET_NR_inotify_init1) && defined(__NR_inotify_init1) - case TARGET_NR_inotify_init1: - ret = get_errno(sys_inotify_init1(target_to_host_bitmask(arg1, - fcntl_flags_tbl))); - if (ret >= 0) { - fd_trans_register(ret, &target_inotify_trans); - } - return ret; -#endif -#endif -#if defined(TARGET_NR_inotify_add_watch) && defined(__NR_inotify_add_watch) - case TARGET_NR_inotify_add_watch: - p = lock_user_string(arg2); - ret = get_errno(sys_inotify_add_watch(arg1, path(p), arg3)); - unlock_user(p, arg2, 0); - return ret; -#endif -#if defined(TARGET_NR_inotify_rm_watch) && defined(__NR_inotify_rm_watch) - case TARGET_NR_inotify_rm_watch: - return get_errno(sys_inotify_rm_watch(arg1, arg2)); -#endif - #if defined(TARGET_NR_mq_open) && defined(__NR_mq_open) case TARGET_NR_mq_open: { @@ -13481,6 +13464,14 @@ static impl_fn *syscall_table(unsigned num) #endif #if defined(TARGET_NR_getxuid) && defined(TARGET_ALPHA) SYSCALL(getxuid); +#endif +#ifdef CONFIG_INOTIFY + SYSCALL(inotify_add_watch); +# ifdef TARGET_NR_inotify_init + SYSCALL(inotify_init); +# endif + SYSCALL(inotify_init1); + SYSCALL(inotify_rm_watch); #endif SYSCALL(ioctl); #ifdef TARGET_NR_ipc