From patchwork Fri Jun 1 07:30:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 137479 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp615574lji; Fri, 1 Jun 2018 00:47:30 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKCyw0b/nxoOmw2si0b+lU5H1eDhGvWdvvE5RLN8dOHMjl1wYRs+oi0kwz3O0ACEr2ZQ+lr X-Received: by 2002:ac8:30b1:: with SMTP id v46-v6mr10099218qta.353.1527839249955; Fri, 01 Jun 2018 00:47:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527839249; cv=none; d=google.com; s=arc-20160816; b=SEI8PdknF7IEK/eP9thaNhHG4M/wSmYn56rb52aARhfrlAOi+b+OoDUfyAOXSvDos0 XcBKXeAYgzUj6r//xWowhpx8ejnbLe4STrKCYPwSJEcP2vclp+/yUFWCa9kUDeYHiZP5 zTGVePojV8BxI1hrQPSCD/j2p85RLlKspm+NomSTp5vIdq+9yzsuhGHMHmRw7D2rJljP lLtiIuWA1K52YbxVkly+0VqvPdUTHtS/04aR1lyjMWOqQ3qpewPV/kIuZ0fqqvv684Dv xbTPrn9cbQjYJvTZ9flEJIDBzVn8yWi+slOM23zheQbtguBEscghW7X7oWcN0E1kBSrM Qc3A== 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=DJHyjL+tq2NbJ5wT/xWlzt5ykrkXQ2pykteKcZn2KLM=; b=EiaehIxgQtAQgJGjtntlzm2A/QCy47R9ffIeIu2v5raHXn/ykFrF2h1nmV+u+jpjU3 uUL/Eg5XFJSgmT3TisRNxBtI1+7hRRJ2Klr/RjYkFTzs8JQtsdwSRIwNiJSmPofQdP5e 9rWR92aLYT1Z9pNZUiMJ7Cts3F7NjUdX+We/x5Nv3dhgDWh6ppjEwSEpQQolQQHaHfL9 xy4AiXXopufNWzcL2+EUBfvFB8tcXSYcQlyYVh4CwoEliF6vuv78uPCQI4aJToOqBduh 7Zauv01zC1EA4Egk4laSPVsCLsitLDlBiyiw61RNpeEh1z0GafsOHFa+FNWeJ6d/51OP m2SQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=exp9jqN6; 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 n64-v6si5505953qkf.210.2018.06.01.00.47.29 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:47:29 -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=exp9jqN6; 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]:47898 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOemX-0001VG-EB for patch@linaro.org; Fri, 01 Jun 2018 03:47:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57528) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeWu-0005bg-07 for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeWt-0000Xv-37 for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:19 -0400 Received: from mail-pf0-x22f.google.com ([2607:f8b0:400e:c00::22f]:36696) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeWs-0000X1-TL for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:19 -0400 Received: by mail-pf0-x22f.google.com with SMTP id w129-v6so12092166pfd.3 for ; Fri, 01 Jun 2018 00:31:18 -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=DJHyjL+tq2NbJ5wT/xWlzt5ykrkXQ2pykteKcZn2KLM=; b=exp9jqN6xtuE2CnKloiKnxz05GgmCjjvgnZAi78f9/GHYwAmDu9abrvH7dhPMWIObg vykkttvqsmr3IYEbfFZ1uY1aZmleHy5KIJQQgsLklGwIcPan83EKKh7AFxdiCXQ4XpEn qAczLEN4zN5yoyfqe4c3qpLfnSu2aQXzlzSEw= 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=DJHyjL+tq2NbJ5wT/xWlzt5ykrkXQ2pykteKcZn2KLM=; b=gvIONJ8mTZS6NqIx9nn2+c3rfBiz9xpGang60DZ06679uSYt1iKB0ofoApXC0u74Pn ZoyQ11RHCfm4cWUWyRTpXdkUoizWFQKwZbwFOMCVZpTjbzFAmzOtumgl9izqDrqA3VJZ qbZ+uxCN/ZWZsPDvAMLINPr5Zx1kLY9ojrW03/WA6xA9rRWnK6UPe7jTbMvNzq7i28gO JFHUDLuE+HchM5cT8/3PXyf3UCQYrIx/8/eDgkORQWuzLdLCf6mJFGbsEMRwy+Zpp5dW Ii+CNO/GsHLTJRyyOTYpIAddQPoiumTU7+5Rh8vtYnUvrakvbWugq8nOAx9sy7EMCQyy qHlQ== X-Gm-Message-State: ALKqPwe5DGv0oZ1240tk9TjEkcf/XgaKby27z5LyS4+wL/fKQKzsGM/6 oNIWbsjZvi42pC7qkcPN+6c3ITmaR+s= X-Received: by 2002:a65:6354:: with SMTP id p20-v6mr8085837pgv.437.1527838277660; Fri, 01 Jun 2018 00:31:17 -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.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:31:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:34 -0700 Message-Id: <20180601073050.8054-18-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::22f Subject: [Qemu-devel] [PATCH 17/33] linux-user: Split out unlink, unlinkat 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 | 59 ++++++++++++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 19 deletions(-) -- 2.17.0 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index b5736436f8..bbe9d6d9fb 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8276,6 +8276,40 @@ IMPL(read) return ret; } +#ifdef TARGET_NR_unlink +IMPL(unlink) +{ + char *p = lock_user_string(arg1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(unlink(p)); + unlock_user(p, arg1, 0); + return ret; +} +#endif + +#ifdef TARGET_NR_unlinkat +IMPL(unlinkat) +{ + char *p; + abi_long ret; + + if (is_hostfd(arg1)) { + return -TARGET_EBADF; + } + p = lock_user_string(arg2); + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(unlinkat(arg1, p, arg3)); + unlock_user(p, arg2, 0); + return ret; +} +#endif + #ifdef TARGET_NR_waitid IMPL(waitid) { @@ -8352,25 +8386,6 @@ IMPL(everything_else) char *fn; switch(num) { -#ifdef TARGET_NR_unlink - case TARGET_NR_unlink: - if (!(p = lock_user_string(arg1))) - return -TARGET_EFAULT; - ret = get_errno(unlink(p)); - unlock_user(p, arg1, 0); - return ret; -#endif -#if defined(TARGET_NR_unlinkat) - case TARGET_NR_unlinkat: - if (is_hostfd(arg1)) { - return -TARGET_EBADF; - } - if (!(p = lock_user_string(arg2))) - return -TARGET_EFAULT; - ret = get_errno(unlinkat(arg1, p, arg3)); - unlock_user(p, arg2, 0); - return ret; -#endif case TARGET_NR_chdir: if (!(p = lock_user_string(arg1))) return -TARGET_EFAULT; @@ -12978,6 +12993,12 @@ static impl_fn * const syscall_table[] = { [TARGET_NR_open_by_handle_at] = impl_open_by_handle_at, #endif [TARGET_NR_read] = impl_read, +#ifdef TARGET_NR_unlink + [TARGET_NR_unlink] = impl_unlink, +#endif +#if TARGET_NR_unlinkat + [TARGET_NR_unlinkat] = impl_unlinkat, +#endif #ifdef TARGET_NR_waitid [TARGET_NR_waitid] = impl_waitid, #endif