From patchwork Fri Jun 1 07:30:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 137472 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp610748lji; Fri, 1 Jun 2018 00:41:05 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL253wQ+OW7tbmvFQu6lcNzBokzVWoWC6+YWrfz5gB2Gc/6qx/SNPL5tpTv8fBMHkRhs9UR X-Received: by 2002:ac8:3415:: with SMTP id u21-v6mr10096584qtb.356.1527838865254; Fri, 01 Jun 2018 00:41:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527838865; cv=none; d=google.com; s=arc-20160816; b=WbiROcvtA2cduueG+wfqryJS/e15UEDJ0lTAhiuBRtX/1R/PIj55bSTd3Ss/6v/TP6 9pXLVeIBa7+7847fT6q7OptDTMAq9WlW1/JoAjxlgfxlY0YF0FlkW/kVgpeL8XWC2FRo LSg61fnKg+R1V5umLSWdxAy2aWrIExsorec+WQT9WPE79fOcpaWxcwdYfQJVmHWyF8GU hxZIoyqkvNQ3nKRNAT2LaJuFrFIrU1Hi05xN/v1h1p2FFi1EtnKVOovQYxJWJsKMyomk 6TXYz3o5M6p50+lr6PyHHdC9XWMYIHvlEDQdPOgRgwBOaN6T5Ul0BFnri+Pk1rStiGGj okzg== 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=wRUrfTonuJ/mCXPMxPqhtS3ySI2PW3F2ScDJa0nWJZ8=; b=smMgxw4JbU4FItWg+bw0q9PMeAnZeLdbVzCO5WpdkhFyqHt2ku+Gg7AFYeHwRDcrQU kJYWCUpImbcWUaVtSEGghb5h3L/Gh2PXqyu3UhSI4YKlH1yt0hEsXUmmPloADJe0vwDq +U9GWG2tGlAU8gGSY9Bu8Dwqy4T/dQDwQQXGZ3dj3Z+9HAbe2DDs3TgiF/2fjXlfBZSa p8RsRyWCg2dtKptyVRECZXub30HV4MwWa/ii/xjA/LYfKVYApcrmcNl9XyK2Vljz/UsY WUBMYF7F4qIqRQoUfr7yjdrLSosB/KQ8rK4XRbFtcMeALmx9cmjTmFmHBHbumeD1cNMv zn4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=SPjjsOPc; 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 o63-v6si252809qtd.270.2018.06.01.00.41.05 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:41:05 -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=SPjjsOPc; 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]:47858 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOegK-0004K7-JT for patch@linaro.org; Fri, 01 Jun 2018 03:41:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57508) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeWs-0005a9-Ob for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeWr-0000Wb-SB for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:18 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:35083) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeWr-0000Vo-MH for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:17 -0400 Received: by mail-pf0-x242.google.com with SMTP id x9-v6so12086132pfm.2 for ; Fri, 01 Jun 2018 00:31:17 -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=wRUrfTonuJ/mCXPMxPqhtS3ySI2PW3F2ScDJa0nWJZ8=; b=SPjjsOPc7b8qlFc/fVVXJqXw1+fzWboMP1QJDxRyfq2HK6QNN0iJVsuAomGry2r+2o udqE3dR/1Xaoeni3ml8FQWVLLCkhlamAQMslKP9Lo6e1aqaco+Cpca4k2kvZ/ZNh/91s g6APtJkMkTH+5wZed0KzyJD+B+AF3YAaikjvs= 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=wRUrfTonuJ/mCXPMxPqhtS3ySI2PW3F2ScDJa0nWJZ8=; b=YUs2fQI9BJRc0kPMHi3C10IOU3nmaO4gV09Kbp6P+ym2Vk6R2xFuoYi9M9bIptHZpA IGnFK7yMcVjKE8N+IKKxfysWXqykKwgXM0WTxKp+dQVvrFQgTzKlE1GZ7FDTi4xsDKQn DlQdNy5wugIVp0S/N0UH/IPNNAb3x9804HAQ/9QLA04+2BwZTwlJffjW5eGKIrFipKde dV8b0tl+wK/nmgVfTbnoSggu+oF/KoCo+YC9fUW9QvFAr/fAAA6dUBCFEqQXb/bZweHG Qa3CT6nxCbTnrIDp8+JIGguiINRR4llBOTQgW7TxD4kAY0BpAfTwgPxOio2DjHl1zCeH op3Q== X-Gm-Message-State: ALKqPwdGwv8zjnp0MqnUIFkWNH5QVD2+KDVL2uPAIll7Gijdtc+InuDu GeXGpM0EPqcZ/7b/6OuHZQBs2iyMlPM= X-Received: by 2002:a65:498e:: with SMTP id r14-v6mr7781893pgs.78.1527838276415; Fri, 01 Jun 2018 00:31:16 -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.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:31:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:33 -0700 Message-Id: <20180601073050.8054-17-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::242 Subject: [Qemu-devel] [PATCH 16/33] linux-user: Split out link, linkat 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 | 77 +++++++++++++++++++++++++------------------- 1 file changed, 43 insertions(+), 34 deletions(-) -- 2.17.0 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index e208f8647a..b5736436f8 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8078,6 +8078,43 @@ IMPL(fork) } #endif +#ifdef TARGET_NR_link +IMPL(link) +{ + char *p1 = lock_user_string(arg1); + char *p2 = lock_user_string(arg2); + abi_long ret = -TARGET_EFAULT; + + if (p1 && p2) { + ret = get_errno(link(p1, p2)); + } + unlock_user(p1, arg1, 0); + unlock_user(p2, arg2, 0); + return ret; +} +#endif + +#if defined(TARGET_NR_linkat) +IMPL(linkat) +{ + char *p1, *p2; + abi_long ret; + + if (is_hostfd(arg1)) { + return -TARGET_EBADF; + } + p1 = lock_user_string(arg2); + p2 = lock_user_string(arg4); + ret = -TARGET_EFAULT; + if (p1 && p2) { + ret = get_errno(linkat(arg1, p1, arg3, p2, arg5)); + } + unlock_user(p1, arg2, 0); + unlock_user(p2, arg4, 0); + return ret; +} +#endif + #if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE) IMPL(name_to_handle_at) { @@ -8315,40 +8352,6 @@ IMPL(everything_else) char *fn; switch(num) { -#ifdef TARGET_NR_link - case TARGET_NR_link: - { - void * p2; - p = lock_user_string(arg1); - p2 = lock_user_string(arg2); - if (!p || !p2) - ret = -TARGET_EFAULT; - else - ret = get_errno(link(p, p2)); - unlock_user(p2, arg2, 0); - unlock_user(p, arg1, 0); - } - return ret; -#endif -#if defined(TARGET_NR_linkat) - case TARGET_NR_linkat: - if (is_hostfd(arg1)) { - return -TARGET_EBADF; - } else { - void * p2 = NULL; - if (!arg2 || !arg4) - return -TARGET_EFAULT; - p = lock_user_string(arg2); - p2 = lock_user_string(arg4); - if (!p || !p2) - ret = -TARGET_EFAULT; - else - ret = get_errno(linkat(arg1, p, arg3, p2, arg5)); - unlock_user(p, arg2, 0); - unlock_user(p2, arg4, 0); - } - return ret; -#endif #ifdef TARGET_NR_unlink case TARGET_NR_unlink: if (!(p = lock_user_string(arg1))) @@ -12958,6 +12961,12 @@ static impl_fn * const syscall_table[] = { #ifdef TARGET_NR_fork [TARGET_NR_fork] = impl_fork, #endif +#ifdef TARGET_NR_link + [TARGET_NR_link] = impl_link, +#endif +#if defined(TARGET_NR_linkat) + [TARGET_NR_linkat] = impl_linkat, +#endif #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