From patchwork Sun Jun 10 03:00:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138093 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2580750lji; Sat, 9 Jun 2018 20:15:12 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKxR+rR+PmAroU8BbCsHNgrCZ7tL9b3XBik35bCudWxCVLrJbydqS/2HrYy6qL3yp/fch0D X-Received: by 2002:ac8:2be1:: with SMTP id n30-v6mr11044119qtn.18.1528600511963; Sat, 09 Jun 2018 20:15:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528600511; cv=none; d=google.com; s=arc-20160816; b=So6chm0wIkWAt39m69RAOnJdYqTXgGY00axh0M3sF+kwkhIz7UHrRVujH6c4yHQPXs r3g/6Gq/OxlSFJ6ttXFoCGKDxsu96mLNt9966hxTdWWudE1wWANs5ZKq5/GEM/my9Kgu DZbO3Pyjh5f6V1xGMCQpAGvi0nkCotmNh6Jus9gquEKAhh/RTq+GE2hT7LaFfgQSewSP 4Do0udwfoHDnSVOSj4wRySBNXV35gbVhz1DeP9U1JY1Uxe7kdyT7dTcX62cIFpnkS7kH jOWiRqPQCCcZ6UqwLC2SZjKDB3BxLzSValD+/HgbThg115AojyRKErmZWmY6lFRl+rs/ zKNA== 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=TlwGDowEzig9O8tykcxop59hqYNHijUGPvLIhQuLKuw=; b=P3vUgKu+oBfJbIsl5G+XQqMGZ6rfAdaCMFAWCCss613gQKpmairMoePg5C3FXw9npd suH4Z+XoqCge8D9sagvBHmH1vi71VS8xPtt3pvyw2YWg60+WFanhboxluunlSDNY/NYM UnwByGHq676rp9nZ9GWzEkPSDCFP/wQXM1bDCRnH08xBDh2Yn6AazwjjssOBOy7Lwrhw iKflgRSErnANG/1IE2fqasqQKXiobxhnBuL43u3+DdVaWfR1okUjx77a9mrk7VfqhP0R Xuzu8Is2C9c0U8UAlc1VqDAesO4hWjci15HzitgS7JCitdWmkNqqGwP8UBvrgDciH8db XNZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=aJGP0RRg; 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 m42-v6si7758563qvm.136.2018.06.09.20.15.11 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:15:11 -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=aJGP0RRg; 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]:42237 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqox-0004Bb-AS for patch@linaro.org; Sat, 09 Jun 2018 23:15:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40326) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqdR-00027h-66 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqdO-0003M5-2i for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:17 -0400 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]:44108) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqdN-0003Lk-QL for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:13 -0400 Received: by mail-pl0-x241.google.com with SMTP id z9-v6so10386379plk.11 for ; Sat, 09 Jun 2018 20:03:13 -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=TlwGDowEzig9O8tykcxop59hqYNHijUGPvLIhQuLKuw=; b=aJGP0RRgXQ2It8CUO7tRrMIgxHcu/H07Mkjam1Ea87mb8L9maIUgGcHHCuRZ4i2Dw4 UP7OA98+NJtRoq5ZApkHZrmdoR4Ha0DnX57l56RLLXHWKp6ARhxLlFjLguuMJQajc7Hg U+NIBxMOlBjzz4j7tti2hc5OC2wBEVs5RFYlc= 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=TlwGDowEzig9O8tykcxop59hqYNHijUGPvLIhQuLKuw=; b=p7iUQjmIAqEXmhq+owHPv8Mu/2Xn47naGlZ7KlGRCGS230O8/afHsJJH8tZaNkUkJS gGmMXWrURYzG6cItKHxm+kevjbN6bCeikc1++l06Zyu4dmSkOxqIqPIWS+B2EAt5e+p9 h431HN+5An7KR/LQb2C3yP6+MTGv9pdKxaCkwI3ClvBzPusnuSnci7gQ35d8hl54Ua6Z +Fd5FmUju8Gpkb59oWduPgLgQmMmq3IvCDjfIfgMChL+I3W1rqMgvyat9PfJ3LWMK3sR NYhPOB1m1mi1/HlTLosgMUpLnd2qDYgkivbRdY1XQ49otawdUqn/fpZXDJDUHkVCvhcP /N2Q== X-Gm-Message-State: APt69E2h5gq2bSMcr6o6iY/lpJsxUUarAhix+LvVCWIZCPOOab1I6nlb lIxH/dyMMoVEowCSwqUOkirOdfg1bYE= X-Received: by 2002:a17:902:1004:: with SMTP id b4-v6mr12927890pla.82.1528599792434; Sat, 09 Jun 2018 20:03:12 -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.03.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:03:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:00:54 -1000 Message-Id: <20180610030220.3777-23-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:c01::241 Subject: [Qemu-devel] [PATCH v2 022/108] 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" All targets define faccessat and syncfs; remove the ifdefs. Fix the missing flags parameter to faccessat. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 143 +++++++++++++++++++++++++++---------------- 1 file changed, 91 insertions(+), 52 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index d5f7519e62..6729a960ea 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7871,6 +7871,21 @@ static abi_long impl_##NAME(void *cpu_env, unsigned num, abi_long arg1, \ abi_long arg5, abi_long arg6, abi_long arg7, \ abi_long arg8) +#ifdef TARGET_NR_access +IMPL(access) +{ + char *p = lock_user_string(arg1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(access(path(p), arg2)); + unlock_user(p, arg1, 0); + return ret; +} +#endif + #ifdef TARGET_NR_alarm IMPL(alarm) { @@ -8080,6 +8095,19 @@ IMPL(exit) g_assert_not_reached(); } +IMPL(faccessat) +{ + char *p = lock_user_string(arg2); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(faccessat(arg1, p, arg3, arg4)); + unlock_user(p, arg2, 0); + return ret; +} + #ifdef TARGET_NR_fork IMPL(fork) { @@ -8087,6 +8115,29 @@ IMPL(fork) } #endif +#ifdef TARGET_NR_futimesat +IMPL(futimesat) +{ + struct timeval tv[2]; + char *p; + abi_long ret; + + if (arg3 && + (copy_from_user_timeval(&tv[0], arg3) || + copy_from_user_timeval(&tv[1], + arg3 + sizeof(struct target_timeval)))) { + return -TARGET_EFAULT; + } + p = lock_user_string(arg2); + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(futimesat(arg1, path(p), arg3 ? tv : NULL)); + unlock_user(p, arg2, 0); + return ret; +} +#endif + #ifdef TARGET_NR_getpid IMPL(getpid) { @@ -8102,6 +8153,11 @@ IMPL(getxpid) } #endif +IMPL(kill) +{ + return get_errno(safe_kill(arg1, target_to_host_signal(arg2))); +} + #ifdef TARGET_NR_link IMPL(link) { @@ -8256,6 +8312,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) { @@ -8368,6 +8431,19 @@ IMPL(stime) } #endif +IMPL(sync) +{ + sync(); + return 0; +} + +#ifdef CONFIG_SYNCFS +IMPL(syncfs) +{ + return get_errno(syncfs(arg1)); +} +#endif + #ifdef TARGET_NR_time IMPL(time) { @@ -8545,58 +8621,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#if defined(TARGET_NR_futimesat) - case TARGET_NR_futimesat: - { - 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 (!(p = lock_user_string(arg2))) { - return -TARGET_EFAULT; - } - ret = get_errno(futimesat(arg1, path(p), tvp)); - unlock_user(p, arg2, 0); - } - return ret; -#endif -#ifdef TARGET_NR_access - case TARGET_NR_access: - if (!(p = lock_user_string(arg1))) { - return -TARGET_EFAULT; - } - ret = get_errno(access(path(p), arg2)); - unlock_user(p, arg1, 0); - return ret; -#endif -#if defined(TARGET_NR_faccessat) && defined(__NR_faccessat) - case TARGET_NR_faccessat: - if (!(p = lock_user_string(arg2))) { - return -TARGET_EFAULT; - } - ret = get_errno(faccessat(arg1, p, arg3, 0)); - unlock_user(p, 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: { @@ -12544,6 +12568,9 @@ static impl_fn *syscall_table(unsigned num) /* * Other syscalls listed in collation order, with '_' ignored. */ +#ifdef TARGET_NR_access + SYSCALL(access); +#endif #ifdef TARGET_NR_alarm SYSCALL(alarm); #endif @@ -12558,15 +12585,20 @@ static impl_fn *syscall_table(unsigned num) #endif SYSCALL(execve); SYSCALL(exit); + SYSCALL(faccessat); #ifdef TARGET_NR_fork SYSCALL(fork); #endif +#ifdef TARGET_NR_futimesat + SYSCALL(futimesat); +#endif #ifdef TARGET_NR_getpid SYSCALL(getpid); #endif #if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA) SYSCALL(getxpid); #endif + SYSCALL(kill); #ifdef TARGET_NR_link SYSCALL(link); #endif @@ -12580,6 +12612,9 @@ static impl_fn *syscall_table(unsigned num) #ifdef CONFIG_OPEN_BY_HANDLE SYSCALL(name_to_handle_at); #endif +#ifdef TARGET_NR_nice + SYSCALL(nice); +#endif #ifdef TARGET_NR_open SYSCALL(open); #endif @@ -12593,6 +12628,10 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(read); #ifdef TARGET_NR_stime SYSCALL(stime); +#endif + SYSCALL(sync); +#ifdef CONFIG_SYNCFS + SYSCALL(syncfs); #endif #ifdef TARGET_NR_time SYSCALL(time);