From patchwork Fri Jun 1 07:30:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 137470 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp610390lji; Fri, 1 Jun 2018 00:40:35 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKrrb84aWOUzpB0WWCgCfuCrZmlLXSvoatDMYwxNJQmyZkerssmqgfO1wXn3fvfC0GD+QBs X-Received: by 2002:a37:b0c5:: with SMTP id z188-v6mr9539868qke.133.1527838835646; Fri, 01 Jun 2018 00:40:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527838835; cv=none; d=google.com; s=arc-20160816; b=AFI/Is+4TgrhH6zzJyyaYXfCotCA6H5xvhb374O+J20OAuERkqz8Gk1ze13MT7V3pG nPikKU3Dte5VOLaVws1ZZ26z0TuMCze5yDudxHhRwRaYniAFqrYSALc+yTIAn1UuOVAQ WB3IzADeAxakMLq12FxZq1c9LBAMOAhFIlpMnkKC/aLCSpIgnuNMwRyCnAw/pbKakydh 2RwD9LS+Ty2ojo5kRZfIsqc09jshqPO7aEFCbrogqblhD/1iINy9wL/KNQCoqXmZOQCq Xni2xdDvKXfCjf/0ihBKBjTw4HBcmWJuwFCN0pWxTVzKIo58a/gu471ZH7pisFsPbbnx rNdQ== 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=OBnyU53YCatMcb4pWKJZWeViNHMHWGdsDbXD+xY0RYk=; b=udc26Sb/nKO41+FE7416psy2GyvqDaN72s0ZAUW08TRWolXJwiwzKQSRRAOeOp4pZN DBqCkZg3B17Cuh/0USIk023IaKb+rV2XdNjhcq8RIAkYZpHJNsuTYLKPfBfoxQPE1epm HpR/md5KKVXsST1ppw3v4S62grqN1U1l5qmBsM07A3kAPQE/rklAmT5z2oaEJk65GRbD 52OpHH91EWNaFWU/ej5Mitz47f2at3O9+/TqC9FDHadwX1ddmo7HI9UByTJVlCPJnx3R 2ARmr0dIoA2Xh/Fo6pR3VezNJi86e2x6JX90YoGzNT0S256PJrjZcrr1UBKr8zd3APCK cQcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=NivypzK9; 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 g9-v6si5053525qtb.376.2018.06.01.00.40.35 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:40:35 -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=NivypzK9; 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]:47848 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOefr-000303-29 for patch@linaro.org; Fri, 01 Jun 2018 03:40:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57459) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeWn-0005WM-0n for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeWm-0000RT-2w for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:13 -0400 Received: from mail-pg0-x22b.google.com ([2607:f8b0:400e:c05::22b]:45842) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeWl-0000Qs-Te for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:12 -0400 Received: by mail-pg0-x22b.google.com with SMTP id z1-v6so3946144pgv.12 for ; Fri, 01 Jun 2018 00:31:11 -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=OBnyU53YCatMcb4pWKJZWeViNHMHWGdsDbXD+xY0RYk=; b=NivypzK9VQ/AkFkKjARzuXENVGVDc+mW8TScorclWc/8UlW/VCikgrw8frXXI0lazf gL4eGgNYRs0swFbF5l7gKlyu0TO5MlvgwMtlJS8TF1Twq8ZG8hQd3XWDi1TENwIpGDxG vGaXgRGIVC28RyTIWkNEUVrr/JNw8yuFN45FM= 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=OBnyU53YCatMcb4pWKJZWeViNHMHWGdsDbXD+xY0RYk=; b=F29EhLooSB/QVGrRu4EGzRP32dbZaB0uHRau+ZP8U/GkMIqySI0hIuZG1RWa29IjRO JMUfI4Vk21FDoqXeffqMm7wdRSyAW89jkdHm/n/JjTGPi1xxx9qnMt61j2gGrfqXMgCs YsY+Yr4U6oopiBPrWRgax0DFnZ9mXEXASLPFOSpiAkiESJTh0O8Mm2i33pLMj+E1hxNP eGV2Toy+SmBX46REg2lvENaI88T5Z31zCmP/s0oH0ocxoM1+Lod7P3ApGlTEobuLAj2o +OqycICH3MAGYAccx0ugwyHL1I5XOAaN+Tty5MG0FZ+Mf2NH/8wteFFDCqlUWFxnNWea WuPg== X-Gm-Message-State: ALKqPwcL3nr54wyVwU7zO4R2So2Z3m8gNw/gk6t+BN+149kxl5GmuKB3 Ky5v/J6ApGWA9JiUIbs3/IxWEeE1wcU= X-Received: by 2002:a63:648:: with SMTP id 69-v6mr8002948pgg.205.1527838270588; Fri, 01 Jun 2018 00:31:10 -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.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:31:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:29 -0700 Message-Id: <20180601073050.8054-13-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:c05::22b Subject: [Qemu-devel] [PATCH 12/33] 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 | 65 ++++++++++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 23 deletions(-) -- 2.17.0 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index a9b59a8658..fb1a8a4e7e 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8145,6 +8145,44 @@ IMPL(exit) g_assert_not_reached(); } +#ifdef TARGET_NR_open +IMPL(open) +{ + char *fn = lock_user_string(arg1); + abi_long ret; + + if (!fn) { + return -TARGET_EFAULT; + } + ret = get_errno(do_openat(cpu_env, AT_FDCWD, fn, + target_to_host_bitmask(arg2, fcntl_flags_tbl), + arg3)); + fd_trans_unregister(ret); + unlock_user(fn, arg1, 0); + return ret; +} +#endif + +IMPL(openat) +{ + char *fn; + abi_long ret; + + if (is_hostfd(arg1)) { + return -TARGET_EBADF; + } + fn = lock_user_string(arg2); + if (!fn) { + return -TARGET_EFAULT; + } + ret = get_errno(do_openat(cpu_env, arg1, fn, + target_to_host_bitmask(arg3, fcntl_flags_tbl), + arg4)); + fd_trans_unregister(ret); + unlock_user(fn, arg2, 0); + return ret; +} + IMPL(read) { abi_long ret; @@ -8210,29 +8248,6 @@ IMPL(everything_else) char *fn; 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 (is_hostfd(arg1)) { - return -TARGET_EBADF; - } - 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: if (is_hostfd(arg1)) { @@ -12926,6 +12941,10 @@ static impl_fn * const syscall_table[] = { [TARGET_NR_close] = impl_close, [TARGET_NR_execve] = impl_execve, [TARGET_NR_exit] = impl_exit, +#ifdef TARGET_NR_open + [TARGET_NR_open] = impl_open, +#endif + [TARGET_NR_openat] = impl_openat, [TARGET_NR_read] = impl_read, [TARGET_NR_write] = impl_write, };