From patchwork Sun Jun 10 03:00:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138094 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2580961lji; Sat, 9 Jun 2018 20:15:36 -0700 (PDT) X-Google-Smtp-Source: ADUXVKImMudQP3qI5kRg8hI87dWHAfGTKgZsOXxoZ9JYWqF1iRMWTwRAoJSH8p+GciKiw2bfwDu9 X-Received: by 2002:ac8:3854:: with SMTP id r20-v6mr11439911qtb.190.1528600536239; Sat, 09 Jun 2018 20:15:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528600536; cv=none; d=google.com; s=arc-20160816; b=nIM8e1SSfT0Jw/VcQz/mECuNorPveghAaUjJfVQXfLnERF1EAGy/n1Cw+uT99Fk7nD HBnZlgiJjAJwSrgkbFqiwWPOGRtx6HznLpkZgVLoRc/24nWL0BYYd1rav6LwHm0kCsBw L+36R5Zqr3F0myCl3WPM9+SgAo7MGLmrEH7VxE7hg7jG5m7U5DLyBdHzjiQoihZGf4Ax 72UoVfYymLkOaLoiZ9MYCw0HftCFLm9gDtrWRw5oioDCzlwpQ5U9WMK/d3VmThIfBuf6 4AaDwj0KZ2Yc3tlj4owYaDZH26fAeDsKqRIvmH9VroaKd5Xa7Np/dy3qkEQ8Motx3Se4 obpA== 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=j/sd47lthgp6bpUhdcpmpr619JLrsbdMYb5HPGVrIjU=; b=dLHgp397TBnME4dBdNHzJEutTbxZNcFa6UKQo9RCH5Q+gOolsKPgvLTEMwiXsq111M lpHadkIr6GWgdJqe31AODiCWe8blvhxBNQOvD35zOhCWPYtb2tl0/Dnkd+2MIj1JAbQD d0eInb8EvqW1kNDKFVw0JBhKnJrFJ0+V9am8zjpHFwNlJ9ZVN5v/bsCY25d15UmfDYEQ gW79e4f8WuLFgCtkPnMQZUdiqPBNLxA360S9F1Xy7bJhzZeTzuI5lTXSGtwDj44rNK3j t5UEi164kZv2J7j3rpNPintMkMtsEM+TAaF4yYbGEYT9X230Czij0rgDFclo260hTD7o As6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Ij9rjx3E; 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 h7-v6si4812145qvj.54.2018.06.09.20.15.36 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:15:36 -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=Ij9rjx3E; 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]:42243 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqpL-0004ZM-Ma for patch@linaro.org; Sat, 09 Jun 2018 23:15:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40186) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqd4-0001oB-LL for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqd3-0003EO-Ey for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:54 -0400 Received: from mail-pg0-x22c.google.com ([2607:f8b0:400e:c05::22c]:34313) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqd3-0003E8-90 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:53 -0400 Received: by mail-pg0-x22c.google.com with SMTP id q4-v6so7074086pgr.1 for ; Sat, 09 Jun 2018 20:02:53 -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=j/sd47lthgp6bpUhdcpmpr619JLrsbdMYb5HPGVrIjU=; b=Ij9rjx3EMdPL8I7NLZrA0eCT+6PWsiokcxMgQlfVUe2WCpP8Fu0QotR/lmig5M8uM3 wHshI7zGF4ei4++exIVllicMqjdw4hc//5UmXk1izK6hpTme8JxkO/pLEwVK4T8xVZi4 yurSFWZo5ba/uUmeJSuQpkMOetWLVst68nQrU= 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=j/sd47lthgp6bpUhdcpmpr619JLrsbdMYb5HPGVrIjU=; b=KgyjKjV8D2vIo9H+j0dX+o31aU/c/XiIRuBvYw4of8GyEeGEr2DlB8M8ilcpOsD1U8 Fp9TO+jUwZK51qPmybMnLeE19SOz3dMztFJZqqoE8wuzjvZy3VB9mjfNoGe39NeWQyPK 52nLsk9a25HW6o0iCCYflGYGC1/Jlp5sY6FZ13boxCq+4UQOvBerTIPLVXg0ptMWkVGz hK5P03WOtycJX015FWc85K5PORQhIW5/UqvhTG9OQ8Jo8MoWSyIb0CmSSbLQ7hKBOxdt s32JhJ1mGXn/ruDL8IUNvZofgNsjhuqvqK7UqYcyA1NuwUvhe38c88nRs4iv4p3IZw7i 15/Q== X-Gm-Message-State: APt69E2xQrx3cJE5xk/c/uQ6qc4XVH4Jvtoof1OinhYXx87Cn7ws1Nsg L3tRT1JW8ja3+b19Vq2jr5Q2QPTm5CM= X-Received: by 2002:a63:7a4a:: with SMTP id j10-v6mr10442040pgn.421.1528599772043; Sat, 09 Jun 2018 20:02:52 -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.02.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:02:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:00:44 -1000 Message-Id: <20180610030220.3777-13-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::22c Subject: [Qemu-devel] [PATCH v2 012/108] linux-user: Split out open, openat 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 | 58 +++++++++++++++++++++++++++++--------------- 1 file changed, 38 insertions(+), 20 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index aa6c4e1577..a4d0f2720f 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8116,6 +8116,40 @@ IMPL(exit) g_assert_not_reached(); } +#ifdef TARGET_NR_open +IMPL(open) +{ + char *p = lock_user_string(arg1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(do_openat(cpu_env, AT_FDCWD, p, + target_to_host_bitmask(arg2, fcntl_flags_tbl), + arg3)); + unlock_user(p, arg1, 0); + fd_trans_unregister(ret); + return ret; +} +#endif + +IMPL(openat) +{ + char *p = lock_user_string(arg2); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(do_openat(cpu_env, arg1, p, + target_to_host_bitmask(arg3, fcntl_flags_tbl), + arg4)); + unlock_user(p, arg2, 0); + fd_trans_unregister(ret); + return ret; +} + IMPL(read) { abi_long ret; @@ -8177,26 +8211,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_open - case TARGET_NR_open: - if (!(p = lock_user_string(arg1))) - return -TARGET_EFAULT; - ret = get_errno(do_openat(cpu_env, AT_FDCWD, p, - target_to_host_bitmask(arg2, fcntl_flags_tbl), - arg3)); - fd_trans_unregister(ret); - unlock_user(p, arg1, 0); - return ret; -#endif - case TARGET_NR_openat: - if (!(p = lock_user_string(arg2))) - return -TARGET_EFAULT; - ret = get_errno(do_openat(cpu_env, arg1, p, - target_to_host_bitmask(arg3, fcntl_flags_tbl), - arg4)); - fd_trans_unregister(ret); - unlock_user(p, arg2, 0); - return ret; #if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE) case TARGET_NR_name_to_handle_at: ret = do_name_to_handle_at(arg1, arg2, arg3, arg4, arg5); @@ -12477,6 +12491,10 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(close); SYSCALL(execve); SYSCALL(exit); +#ifdef TARGET_NR_open + SYSCALL(open); +#endif + SYSCALL(openat); SYSCALL(read); SYSCALL(write); }