From patchwork Fri Jun 1 07:30:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 137483 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp618708lji; Fri, 1 Jun 2018 00:51:59 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJbD03qGT1DElNt1wM2PZlSyaBYVCE7tSmy7G8YxcgLnpe4APIMUqz4PBRXcLpsM9/r3l7r X-Received: by 2002:aed:2459:: with SMTP id s25-v6mr9742617qtc.289.1527839519701; Fri, 01 Jun 2018 00:51:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527839519; cv=none; d=google.com; s=arc-20160816; b=H8ACRN3XhPY/zKlSdIWYdivDeRsRGZc32TLXJ/bZ8fCDZLX2IHpeLWGtcXrzHbyWyF mJiT5c554coiINXrh8ZarWz057xNz1LY9v/tRZSKEZWEa3OVUd+Bt3dVc6lfpcf3+wYI xcIsWVbtGH31KVyN5VIjeQdI//2g4l92FJdiP35hYl6U8UoCKEdoz+b1ejuEEJTe7aQW sZd/cmSaNXYc6jK89jk5V0xefrLfsW0Qc79/m9TDcaMkIyfQwoxAIHrPRjNHyhmm6TqM gGjpOWoYYuXwugnMkpafh2kSYp9DgKCFmCBXxB6R9P6DPh87oLhZdmogT/hOGd+IE9eq F/Qg== 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=GPs5t0l66EvKVvNNQI5eEapWRXFmwLFqtIpi2Zi6vkg=; b=aSC7UUi5z/ydI88yOhnQdkNYbs5engwlv04pLfiHsAtEzTlHoimf1ielGR1ks+Q/Y+ RsmQ+GoiiWMHzKuWowz6iIUzHuJLkykgONKKjIFjmLu1iroztL2Xt7MY5QdNDOuVTrCT rKTR730+HH3HcF4Ca8z5CO0bmWwxmPj1n8aJlCS7p3kr7W9GnNJL6ZlH8tIxqcT/JCQ2 GXroiZ/mi+x0u4FVAjIzhPdOobkuJ7z0UGs7ltFg1M/QbUvNro8lgid6MkIQIZxRmPho wPfr4JPxGmE+vHG+zd2Lz1+uMuSjYRcevrPg778hqwldK+Dzz1ks4RQ05K2dVr861iJB ENeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=GzVaoyL7; 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 s13-v6si3997447qve.15.2018.06.01.00.51.59 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:51:59 -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=GzVaoyL7; 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]:47921 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeqt-0004rV-5Y for patch@linaro.org; Fri, 01 Jun 2018 03:51:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57618) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeX3-0005mz-5m for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeX1-0000hS-QX for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:29 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:35085) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeX1-0000gr-Iu for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:27 -0400 Received: by mail-pf0-x244.google.com with SMTP id x9-v6so12086382pfm.2 for ; Fri, 01 Jun 2018 00:31:27 -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=GPs5t0l66EvKVvNNQI5eEapWRXFmwLFqtIpi2Zi6vkg=; b=GzVaoyL7HWnaDxm7ukRwHElh580PUKoDU+y7T2edPq6ElyJ38vTquHkdBmjyOfNkJn A2IriDHbo9U2Sa6UPrWXvKkyZzaeMsReuUExEmkm95CpJmGifU2alHTv4AJVuzWktvtM avaNkcXphhJbKw23P8KsjRi+7H5bJvx9j/FdI= 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=GPs5t0l66EvKVvNNQI5eEapWRXFmwLFqtIpi2Zi6vkg=; b=Pgc7O0wmOqk8ZPklfcs3zYmyayLF8rXgX2YMITTvDrPYoGsbNbWMfuh9H4apk+Hxxa oL4cvLQzZdIfrBEBJX7W9KjPrYbae8XebMfsBbKiFOSWNUuBSPquwbzQJ8NuWyOPieBd Ff72Xc0HpM4XPpSk/El1ICRTqVQum8C4Mf0MOvKMv5ZriqKLtF9NaZvXX5jpFFaHcCQY vzDr76L8UqB0tg+WS04r3WF+NzfB+kXQost/vq1HxTgeDAfXYP78Ea5cWTusJ6vJt6S/ I1vF9ItiOXhyJrg8MWlEkZ1b3pKyQdaYTfUW80JCjCQDaQGdHv2dzMJ5lq1xsluHjdE2 Qw0A== X-Gm-Message-State: ALKqPwe+rgn9ThBVjy+e/lFyV67AzfMQk9Jhe2j+Ut+9/UKnLjRpmpLo VUXsz6DwsrEXbOt9tiubhxDuBfsDnUE= X-Received: by 2002:a62:808f:: with SMTP id j137-v6mr1568708pfd.91.1527838286242; Fri, 01 Jun 2018 00:31:26 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id c4-v6sm4431782pgv.86.2018.06.01.00.31.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:31:25 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:40 -0700 Message-Id: <20180601073050.8054-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601073050.8054-1-richard.henderson@linaro.org> References: <20180601073050.8054-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:c00::244 Subject: [Qemu-devel] [PATCH 23/33] linux-user: Split out access, faccessat, futimesat, kill, nice, sync, syncfs 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" Signed-off-by: Richard Henderson --- linux-user/syscall.c | 179 +++++++++++++++++++++++++++---------------- 1 file changed, 113 insertions(+), 66 deletions(-) -- 2.17.0 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index b3838c5161..2a172e24eb 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7894,6 +7894,24 @@ IMPL(enosys) return do_unimplemented(num); } +#ifdef TARGET_NR_access +IMPL(access) +{ + char *fn = lock_user_string(arg1); + abi_long ret; + + if (!fn) { + return -TARGET_EFAULT; + } + TRY_INTERP_FD(ret, fn, + faccessat(interp_dirfd, fn + 1, arg2, 0), + access(fn, arg2)); + ret = get_errno(ret); + unlock_user(fn, arg1, 0); + return ret; +} +#endif + #ifdef TARGET_NR_alarm IMPL(alarm) { @@ -8106,6 +8124,28 @@ IMPL(exit) g_assert_not_reached(); } +#ifdef TARGET_NR_faccessat +IMPL(faccessat) +{ + char *fn; + abi_long ret; + + if (is_hostfd(arg1)) { + return -TARGET_EBADF; + } + fn = lock_user_string(arg2); + if (!fn) { + return -TARGET_EFAULT; + } + TRY_INTERP_FD(ret, fn, + faccessat(interp_dirfd, fn + 1, arg3, 0), + faccessat(arg1, fn, arg3, 0)); + ret = get_errno(ret); + unlock_user(fn, arg2, 0); + return ret; +} +#endif + #ifdef TARGET_NR_fork IMPL(fork) { @@ -8113,6 +8153,37 @@ IMPL(fork) } #endif +#ifdef TARGET_NR_futimesat +IMPL(futimesat) +{ + struct timeval tv[2], *tvp = NULL; + char *fn; + abi_long ret; + + if (is_hostfd(arg1)) { + return -TARGET_EBADF; + } + if (arg3) { + if (copy_from_user_timeval(&tv[0], arg3) || + copy_from_user_timeval(&tv[1], + arg3 + sizeof(struct target_timeval))) { + return -TARGET_EFAULT; + } + tvp = tv; + } + fn = lock_user_string(arg2); + if (!fn) { + return -TARGET_EFAULT; + } + TRY_INTERP_FD(ret, fn, + futimesat(interp_dirfd, fn + 1, tvp), + futimesat(arg1, fn, tvp)); + ret = get_errno(ret); + unlock_user(fn, arg2, 0); + return ret; +} +#endif + #ifdef TARGET_NR_getpid IMPL(getpid) { @@ -8128,6 +8199,11 @@ IMPL(getxpid) } #endif +IMPL(kill) +{ + return get_errno(safe_kill(arg1, target_to_host_signal(arg2))); +} + #ifdef TARGET_NR_link IMPL(link) { @@ -8309,6 +8385,13 @@ IMPL(name_to_handle_at) } #endif +#ifdef TARGET_NR_nice +IMPL(nice) +{ + return get_errno(nice(arg1)); +} +#endif + #ifdef TARGET_NR_open IMPL(open) { @@ -8432,6 +8515,19 @@ IMPL(stime) } #endif +IMPL(sync) +{ + sync(); + return 0; +} + +#if defined(TARGET_NR_syncfs) && defined(CONFIG_SYNCFS) +IMPL(syncfs) +{ + return get_errno(syncfs(arg1)); +} +#endif + #ifdef TARGET_NR_time IMPL(time) { @@ -8618,72 +8714,6 @@ IMPL(everything_else) char *fn; switch(num) { -#if defined(TARGET_NR_futimesat) - case TARGET_NR_futimesat: - if (is_hostfd(arg1)) { - return -TARGET_EBADF; - } else { - struct timeval *tvp, tv[2]; - if (arg3) { - if (copy_from_user_timeval(&tv[0], arg3) - || copy_from_user_timeval(&tv[1], - arg3 + sizeof(struct target_timeval))) - return -TARGET_EFAULT; - tvp = tv; - } else { - tvp = NULL; - } - if (!(fn = lock_user_string(arg2))) { - return -TARGET_EFAULT; - } - TRY_INTERP_FD(ret, fn, - futimesat(interp_dirfd, fn + 1, tvp), - futimesat(arg1, fn, tvp)); - ret = get_errno(ret); - unlock_user(fn, arg2, 0); - } - return ret; -#endif -#ifdef TARGET_NR_access - case TARGET_NR_access: - if (!(fn = lock_user_string(arg1))) { - return -TARGET_EFAULT; - } - TRY_INTERP_FD(ret, fn, - faccessat(interp_dirfd, fn + 1, arg2, 0), - access(fn, arg2)); - ret = get_errno(ret); - unlock_user(fn, arg1, 0); - return ret; -#endif -#if defined(TARGET_NR_faccessat) && defined(__NR_faccessat) - case TARGET_NR_faccessat: - if (is_hostfd(arg1)) { - return -TARGET_EBADF; - } - if (!(fn = lock_user_string(arg2))) { - return -TARGET_EFAULT; - } - TRY_INTERP_FD(ret, fn, - faccessat(interp_dirfd, fn + 1, arg3, 0), - faccessat(arg1, fn, arg3, 0)); - ret = get_errno(ret); - unlock_user(fn, arg2, 0); - return ret; -#endif -#ifdef TARGET_NR_nice /* not on alpha */ - case TARGET_NR_nice: - return get_errno(nice(arg1)); -#endif - case TARGET_NR_sync: - sync(); - return 0; -#if defined(TARGET_NR_syncfs) && defined(CONFIG_SYNCFS) - case TARGET_NR_syncfs: - return get_errno(syncfs(arg1)); -#endif - case TARGET_NR_kill: - return get_errno(safe_kill(arg1, target_to_host_signal(arg2))); #ifdef TARGET_NR_rename case TARGET_NR_rename: { @@ -12873,6 +12903,9 @@ IMPL(everything_else) } static impl_fn * const syscall_table[] = { +#ifdef TARGET_NR_access + [TARGET_NR_access] = impl_access, +#endif #ifdef TARGET_NR_alarm [TARGET_NR_alarm] = impl_alarm, #endif @@ -12887,15 +12920,22 @@ static impl_fn * const syscall_table[] = { #endif [TARGET_NR_execve] = impl_execve, [TARGET_NR_exit] = impl_exit, +#ifdef TARGET_NR_faccessat + [TARGET_NR_faccessat] = impl_faccessat, +#endif #ifdef TARGET_NR_fork [TARGET_NR_fork] = impl_fork, #endif +#ifdef TARGET_NR_futimesat + [TARGET_NR_futimesat] = impl_futimesat, +#endif #ifdef TARGET_NR_getpid [TARGET_NR_getpid] = impl_getpid, #endif #if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA) [TARGET_NR_getxpid] = impl_getxpid, #endif + [TARGET_NR_kill] = impl_kill, #ifdef TARGET_NR_link [TARGET_NR_link] = impl_link, #endif @@ -12913,6 +12953,9 @@ static impl_fn * const syscall_table[] = { #if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE) [TARGET_NR_name_to_handle_at] = impl_name_to_handle_at, #endif +#ifdef TARGET_NR_nice + [TARGET_NR_nice] = impl_nice, +#endif #ifdef TARGET_NR_open [TARGET_NR_open] = impl_open, #endif @@ -12926,6 +12969,10 @@ static impl_fn * const syscall_table[] = { [TARGET_NR_read] = impl_read, #ifdef TARGET_NR_stime [TARGET_NR_stime] = impl_stime, +#endif + [TARGET_NR_sync] = impl_sync, +#if defined(TARGET_NR_syncfs) && defined(CONFIG_SYNCFS) + [TARGET_NR_syncfs] = impl_syncfs, #endif #ifdef TARGET_NR_time [TARGET_NR_time] = impl_time,