From nobody Tue Feb 10 07:57:40 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1527838792860393.5848091619796; Fri, 1 Jun 2018 00:39:52 -0700 (PDT) Received: from localhost ([::1]:47848 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOef4-000303-7s for importer@patchew.org; Fri, 01 Jun 2018 03:39:46 -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) 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) 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-Google-Smtp-Source: ADUXVKLlDUivLx2N70MZ8gGsgFhOVcd6cUzmimaId7oIOyud9y3c11uV6GLYtuuVcJrFEyE0NBv6dw== X-Received: by 2002:a63:648:: with SMTP id 69-v6mr8002948pgg.205.1527838270588; Fri, 01 Jun 2018 00:31:10 -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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson --- linux-user/syscall.c | 65 ++++++++++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 23 deletions(-) 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(); } =20 +#ifdef TARGET_NR_open +IMPL(open) +{ + char *fn =3D lock_user_string(arg1); + abi_long ret; + + if (!fn) { + return -TARGET_EFAULT; + } + ret =3D 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 =3D lock_user_string(arg2); + if (!fn) { + return -TARGET_EFAULT; + } + ret =3D 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; =20 switch(num) { -#ifdef TARGET_NR_open - case TARGET_NR_open: - if (!(p =3D lock_user_string(arg1))) - return -TARGET_EFAULT; - ret =3D 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 =3D lock_user_string(arg2))) - return -TARGET_EFAULT; - ret =3D 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[] =3D { [TARGET_NR_close] =3D impl_close, [TARGET_NR_execve] =3D impl_execve, [TARGET_NR_exit] =3D impl_exit, +#ifdef TARGET_NR_open + [TARGET_NR_open] =3D impl_open, +#endif + [TARGET_NR_openat] =3D impl_openat, [TARGET_NR_read] =3D impl_read, [TARGET_NR_write] =3D impl_write, }; --=20 2.17.0